Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -19,5 +19,10 @@ namespace Tnb.BasicData
|
||||
/// 生产任务单号单据模板编码
|
||||
/// </summary>
|
||||
public const string PRDMOTASK_CODE = "ProductionPlanAndSchedule";
|
||||
|
||||
/// <summary>
|
||||
/// 备件领用
|
||||
/// </summary>
|
||||
public const string SPAREPARTSREQUISITION_CODE = "SparePartsRequisition";
|
||||
}
|
||||
}
|
||||
@@ -237,280 +237,281 @@ namespace Tnb.BasicData
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存生产bom
|
||||
/// </summary>
|
||||
/// <param name="mbomSaveDataInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<string> SaveData(MbomSaveDataInput mbomSaveDataInput)
|
||||
{
|
||||
ErrorCode errorCode = ErrorCode.COM1008;
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
//新增
|
||||
if (string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
{
|
||||
string mbomId = SnowflakeIdHelper.NextId();
|
||||
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
BasMbom mbom = new BasMbom()
|
||||
{
|
||||
id = mbomId,
|
||||
org_id = orgId,
|
||||
material_id = mbomSaveDataInput.material_id,
|
||||
num = mbomSaveDataInput.num,
|
||||
unit_id = mbomSaveDataInput.unit_id,
|
||||
version = mbomSaveDataInput.version,
|
||||
start_time = mbomSaveDataInput.start_time,
|
||||
end_time = mbomSaveDataInput.end_time,
|
||||
ebom_id = mbomSaveDataInput.ebom_id,
|
||||
route_id = mbomSaveDataInput.route_id,
|
||||
is_first = mbomSaveDataInput.is_first,
|
||||
remark = mbomSaveDataInput.remark,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
|
||||
};
|
||||
|
||||
if (await _repository.IsAnyAsync(x =>
|
||||
x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version))
|
||||
{
|
||||
errorCode = ErrorCode.COM1004;
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
}
|
||||
await _repository.InsertAsync(mbom);
|
||||
List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
|
||||
if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var process in mbomSaveDataInput.processes)
|
||||
{
|
||||
string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
processes.Add(new BasMbomProcess()
|
||||
{
|
||||
id = mbomProcessId,
|
||||
org_id = orgId,
|
||||
mbom_id = mbomId,
|
||||
process_id = process?.process_id ?? "",
|
||||
preparation_time = process?.preparation_time ?? 0,
|
||||
station = process?.station ?? "",
|
||||
byproduct_status = process?.byproduct_status ?? 0,
|
||||
production_method = process?.production_method,
|
||||
route_detail_id = process?.route_detail_id ?? "",
|
||||
ordinal = ++index,
|
||||
is_last = index==mbomSaveDataInput.processes.Count ? 1 : 0,
|
||||
|
||||
});
|
||||
|
||||
if (process!.inputs != null)
|
||||
{
|
||||
foreach (var input in process.inputs)
|
||||
{
|
||||
string inputId = SnowflakeIdHelper.NextId();
|
||||
inputs.Add(new BasMbomInput()
|
||||
{
|
||||
id = inputId,
|
||||
mbom_id = mbomId,
|
||||
mbom_process_id = mbomProcessId,
|
||||
process_id = process?.process_id ?? "",
|
||||
material_id = input.material_id,
|
||||
num = input.num,
|
||||
org_id = orgId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (process.outputs != null)
|
||||
{
|
||||
foreach (var output in process.outputs)
|
||||
{
|
||||
string outputId = SnowflakeIdHelper.NextId();
|
||||
outputs.Add(new BasMbomOutput()
|
||||
{
|
||||
id = outputId,
|
||||
mbom_id = mbomId,
|
||||
mbom_process_id = mbomProcessId,
|
||||
process_id = process?.process_id ?? "",
|
||||
material_id = output.material_id,
|
||||
num = output.num,
|
||||
org_id = orgId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (processes.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (inputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (outputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else//修改
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x =>
|
||||
x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version && x.id != mbomSaveDataInput.id))
|
||||
{
|
||||
errorCode = ErrorCode.COM1004;
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
}
|
||||
|
||||
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
if (mbomSaveDataInput != null)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new BasMbom()
|
||||
{
|
||||
// org_id = orgId,
|
||||
material_id = mbomSaveDataInput.material_id,
|
||||
num = mbomSaveDataInput.num,
|
||||
unit_id = mbomSaveDataInput.unit_id,
|
||||
version = mbomSaveDataInput.version,
|
||||
start_time = mbomSaveDataInput.start_time,
|
||||
end_time = mbomSaveDataInput.end_time,
|
||||
ebom_id = mbomSaveDataInput.ebom_id,
|
||||
route_id = mbomSaveDataInput.route_id,
|
||||
is_first = mbomSaveDataInput.is_first,
|
||||
remark = mbomSaveDataInput.remark,
|
||||
modify_id = _userManager.UserId,
|
||||
modify_time = DateTime.Now,
|
||||
|
||||
}, x => x.id == mbomSaveDataInput.id);
|
||||
}
|
||||
// List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
|
||||
if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
{
|
||||
foreach (var process in mbomSaveDataInput.processes)
|
||||
{
|
||||
string mbomProcessId = process.id;
|
||||
// string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
// processes.Add(new BasMbomProcess()
|
||||
// {
|
||||
// id = mbomProcessId,
|
||||
// org_id = orgId ?? "",
|
||||
// mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
// process_id = process?.process_id ?? "",
|
||||
// preparation_time = process?.preparation_time ?? 0,
|
||||
// station = process.station,
|
||||
// byproduct_status = process.byproduct_status,
|
||||
// production_method = process.production_method,
|
||||
// route_detail_id = process.route_detail_id,
|
||||
//
|
||||
// });
|
||||
|
||||
decimal preparation_time = process?.preparation_time ?? 0;
|
||||
await _repository.AsSugarClient().Updateable<BasMbomProcess>()
|
||||
.SetColumns(x => x.preparation_time == preparation_time)
|
||||
.SetColumns(x => x.station == process!.station)
|
||||
.SetColumns(x => x.byproduct_status == process!.byproduct_status)
|
||||
.SetColumns(x => x.production_method == process!.production_method)
|
||||
.Where(x => x.id == process!.id).ExecuteCommandAsync();
|
||||
|
||||
if (process!.inputs != null)
|
||||
{
|
||||
foreach (var input in process.inputs)
|
||||
{
|
||||
string inputId = SnowflakeIdHelper.NextId();
|
||||
inputs.Add(new BasMbomInput()
|
||||
{
|
||||
id = inputId,
|
||||
mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
mbom_process_id = mbomProcessId,
|
||||
process_id = process?.process_id ?? "",
|
||||
material_id = input.material_id,
|
||||
num = input.num,
|
||||
org_id = orgId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (process.outputs != null)
|
||||
{
|
||||
foreach (var output in process.outputs)
|
||||
{
|
||||
string outputId = SnowflakeIdHelper.NextId();
|
||||
outputs.Add(new BasMbomOutput()
|
||||
{
|
||||
id = outputId,
|
||||
mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
mbom_process_id = mbomProcessId,
|
||||
process_id = process?.process_id ?? "",
|
||||
material_id = output.material_id,
|
||||
num = output.num,
|
||||
org_id = orgId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (mbomSaveDataInput != null && !string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
{
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
}
|
||||
// if (processes.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
// }
|
||||
|
||||
if (inputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (outputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
{
|
||||
if (errorCode != ErrorCode.COM1004)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Oh(errorCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errorCode != ErrorCode.COM1004)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Oh(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 保存生产bom
|
||||
// /// </summary>
|
||||
// /// <param name="mbomSaveDataInput"></param>
|
||||
// /// <returns></returns>
|
||||
// [HttpPost]
|
||||
// public async Task<string> SaveData(MbomSaveDataInput mbomSaveDataInput)
|
||||
// {
|
||||
// ErrorCode errorCode = ErrorCode.COM1008;
|
||||
// DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
// {
|
||||
// //新增
|
||||
// if (string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
// {
|
||||
// string mbomId = SnowflakeIdHelper.NextId();
|
||||
// string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
// BasMbom mbom = new BasMbom()
|
||||
// {
|
||||
// id = mbomId,
|
||||
// org_id = orgId,
|
||||
// material_id = mbomSaveDataInput.material_id,
|
||||
// num = mbomSaveDataInput.num,
|
||||
// unit_id = mbomSaveDataInput.unit_id,
|
||||
// version = mbomSaveDataInput.version,
|
||||
// start_time = mbomSaveDataInput.start_time,
|
||||
// end_time = mbomSaveDataInput.end_time,
|
||||
// ebom_id = mbomSaveDataInput.ebom_id,
|
||||
// route_id = mbomSaveDataInput.route_id,
|
||||
// is_first = mbomSaveDataInput.is_first,
|
||||
// remark = mbomSaveDataInput.remark,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now,
|
||||
//
|
||||
// };
|
||||
//
|
||||
// if (await _repository.IsAnyAsync(x =>
|
||||
// x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version))
|
||||
// {
|
||||
// errorCode = ErrorCode.COM1004;
|
||||
// throw Oops.Oh(ErrorCode.COM1004);
|
||||
// }
|
||||
// await _repository.InsertAsync(mbom);
|
||||
// List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
// List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
// List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
//
|
||||
// if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
// {
|
||||
// int index = 0;
|
||||
// foreach (var process in mbomSaveDataInput.processes)
|
||||
// {
|
||||
// string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
// processes.Add(new BasMbomProcess()
|
||||
// {
|
||||
// id = mbomProcessId,
|
||||
// org_id = orgId,
|
||||
// mbom_id = mbomId,
|
||||
// process_id = process?.process_id ?? "",
|
||||
// preparation_time = process?.preparation_time ?? 0,
|
||||
// station = process?.station ?? "",
|
||||
// byproduct_status = process?.byproduct_status ?? 0,
|
||||
// production_method = process?.production_method,
|
||||
// route_detail_id = process?.route_detail_id ?? "",
|
||||
// ordinal = ++index,
|
||||
// is_last = index==mbomSaveDataInput.processes.Count ? 1 : 0,
|
||||
//
|
||||
// });
|
||||
//
|
||||
// if (process!.inputs != null)
|
||||
// {
|
||||
// foreach (var input in process.inputs)
|
||||
// {
|
||||
// string inputId = SnowflakeIdHelper.NextId();
|
||||
// inputs.Add(new BasMbomInput()
|
||||
// {
|
||||
// id = inputId,
|
||||
// mbom_id = mbomId,
|
||||
// mbom_process_id = mbomProcessId,
|
||||
// process_id = process?.process_id ?? "",
|
||||
// material_id = input.material_id,
|
||||
// num = input.num,
|
||||
// org_id = orgId,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (process.outputs != null)
|
||||
// {
|
||||
// foreach (var output in process.outputs)
|
||||
// {
|
||||
// string outputId = SnowflakeIdHelper.NextId();
|
||||
// outputs.Add(new BasMbomOutput()
|
||||
// {
|
||||
// id = outputId,
|
||||
// mbom_id = mbomId,
|
||||
// mbom_process_id = mbomProcessId,
|
||||
// process_id = process?.process_id ?? "",
|
||||
// material_id = output.material_id,
|
||||
// num = output.num,
|
||||
// org_id = orgId,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (processes.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
// }
|
||||
//
|
||||
// if (inputs.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
// }
|
||||
//
|
||||
// if (outputs.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
// }
|
||||
// }
|
||||
// else//修改
|
||||
// {
|
||||
// if (await _repository.IsAnyAsync(x =>
|
||||
// x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version && x.id != mbomSaveDataInput.id))
|
||||
// {
|
||||
// errorCode = ErrorCode.COM1004;
|
||||
// throw Oops.Oh(ErrorCode.COM1004);
|
||||
// }
|
||||
//
|
||||
// string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
// if (mbomSaveDataInput != null)
|
||||
// {
|
||||
// await _repository.UpdateAsync(x => new BasMbom()
|
||||
// {
|
||||
// // org_id = orgId,
|
||||
// material_id = mbomSaveDataInput.material_id,
|
||||
// num = mbomSaveDataInput.num,
|
||||
// unit_id = mbomSaveDataInput.unit_id,
|
||||
// version = mbomSaveDataInput.version,
|
||||
// start_time = mbomSaveDataInput.start_time,
|
||||
// end_time = mbomSaveDataInput.end_time,
|
||||
// ebom_id = mbomSaveDataInput.ebom_id,
|
||||
// route_id = mbomSaveDataInput.route_id,
|
||||
// is_first = mbomSaveDataInput.is_first,
|
||||
// remark = mbomSaveDataInput.remark,
|
||||
// modify_id = _userManager.UserId,
|
||||
// modify_time = DateTime.Now,
|
||||
//
|
||||
// }, x => x.id == mbomSaveDataInput.id);
|
||||
// }
|
||||
// // List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
// List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
// List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
//
|
||||
// if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
// {
|
||||
// foreach (var process in mbomSaveDataInput.processes)
|
||||
// {
|
||||
// string mbomProcessId = process.id;
|
||||
// // string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
// // processes.Add(new BasMbomProcess()
|
||||
// // {
|
||||
// // id = mbomProcessId,
|
||||
// // org_id = orgId ?? "",
|
||||
// // mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
// // process_id = process?.process_id ?? "",
|
||||
// // preparation_time = process?.preparation_time ?? 0,
|
||||
// // station = process.station,
|
||||
// // byproduct_status = process.byproduct_status,
|
||||
// // production_method = process.production_method,
|
||||
// // route_detail_id = process.route_detail_id,
|
||||
// //
|
||||
// // });
|
||||
//
|
||||
// decimal preparation_time = process?.preparation_time ?? 0;
|
||||
// await _repository.AsSugarClient().Updateable<BasMbomProcess>()
|
||||
// .SetColumns(x => x.preparation_time == preparation_time)
|
||||
// .SetColumns(x => x.station == process!.station)
|
||||
// .SetColumns(x => x.byproduct_status == process!.byproduct_status)
|
||||
// .SetColumns(x => x.production_method == process!.production_method)
|
||||
// .Where(x => x.id == process!.id).ExecuteCommandAsync();
|
||||
//
|
||||
// if (process!.inputs != null)
|
||||
// {
|
||||
// foreach (var input in process.inputs)
|
||||
// {
|
||||
// string inputId = SnowflakeIdHelper.NextId();
|
||||
// inputs.Add(new BasMbomInput()
|
||||
// {
|
||||
// id = inputId,
|
||||
// mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
// mbom_process_id = mbomProcessId,
|
||||
// process_id = process?.process_id ?? "",
|
||||
// material_id = input.material_id,
|
||||
// num = input.num,
|
||||
// org_id = orgId,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (process.outputs != null)
|
||||
// {
|
||||
// foreach (var output in process.outputs)
|
||||
// {
|
||||
// string outputId = SnowflakeIdHelper.NextId();
|
||||
// outputs.Add(new BasMbomOutput()
|
||||
// {
|
||||
// id = outputId,
|
||||
// mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
// mbom_process_id = mbomProcessId,
|
||||
// process_id = process?.process_id ?? "",
|
||||
// material_id = output.material_id,
|
||||
// num = output.num,
|
||||
// org_id = orgId,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (mbomSaveDataInput != null && !string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
// {
|
||||
// // await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
// }
|
||||
// // if (processes.Count > 0)
|
||||
// // {
|
||||
// // await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
// // }
|
||||
//
|
||||
// if (inputs.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
// }
|
||||
//
|
||||
// if (outputs.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// if (!result.IsSuccess)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
// {
|
||||
// if (errorCode != ErrorCode.COM1004)
|
||||
// {
|
||||
// throw Oops.Oh(ErrorCode.COM1001);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw Oops.Oh(errorCode);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (errorCode != ErrorCode.COM1004)
|
||||
// {
|
||||
// throw Oops.Oh(ErrorCode.COM1000);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw Oops.Oh(errorCode);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 保存生产bom
|
||||
@@ -573,13 +574,13 @@ namespace Tnb.BasicData
|
||||
preparation_time = process?.preparation_time ?? 0,
|
||||
station = process?.station ?? "",
|
||||
byproduct_status = process!.byproduct_status,
|
||||
production_method = process!.production_method,
|
||||
route_detail_id = process!.route_detail_id,
|
||||
production_method = process.production_method,
|
||||
route_detail_id = process.route_detail_id,
|
||||
ordinal = ++index,
|
||||
is_last = index==mbomSaveDataInput.processes.Count ? 1 : 0,
|
||||
is_last = string.IsNullOrEmpty(process.next_process_no) ? 1 : 0,
|
||||
no = process!.no,
|
||||
last_process_no = process!.last_process_no,
|
||||
next_process_no = process!.next_process_no,
|
||||
last_process_no = process.last_process_no,
|
||||
next_process_no = process.next_process_no,
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 备件入库子表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_spare_parts_instock_d")]
|
||||
public partial class EqpSparePartsInstockD : BaseEntity<string>
|
||||
{
|
||||
public EqpSparePartsInstockD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 备件入库单id
|
||||
/// </summary>
|
||||
public string? instock_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备件id
|
||||
/// </summary>
|
||||
public string? spare_parts_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库数量
|
||||
/// </summary>
|
||||
public int quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位id
|
||||
/// </summary>
|
||||
public string? location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 质保开始时间
|
||||
/// </summary>
|
||||
public DateTime? warranty_start_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 质保结束时间
|
||||
/// </summary>
|
||||
public DateTime? warranty_end_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已领数量
|
||||
/// </summary>
|
||||
public int use_quantity { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 备件入库
|
||||
/// </summary>
|
||||
[SugarTable("eqp_spare_parts_instock_h")]
|
||||
public partial class EqpSparePartsInstockH : BaseEntity<string>
|
||||
{
|
||||
public EqpSparePartsInstockH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 入库单编号
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库时间
|
||||
/// </summary>
|
||||
public string? instock_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库人员
|
||||
/// </summary>
|
||||
public string? instock_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位号
|
||||
/// </summary>
|
||||
public string? location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备件id
|
||||
/// </summary>
|
||||
public string? spare_parts_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string? descrip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 备件领用子表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_spare_parts_requisition_d")]
|
||||
public partial class EqpSparePartsRequisitionD : BaseEntity<string>
|
||||
{
|
||||
public EqpSparePartsRequisitionD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 备件id
|
||||
/// </summary>
|
||||
public string spare_parts_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 批号
|
||||
/// </summary>
|
||||
public string? batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public int quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备件领用主表id
|
||||
/// </summary>
|
||||
public string spare_parts_requisition_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备件入库id
|
||||
/// </summary>
|
||||
public string? instock_detail_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 备件领用主表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_spare_parts_requisition_h")]
|
||||
public partial class EqpSparePartsRequisitionH : BaseEntity<string>
|
||||
{
|
||||
public EqpSparePartsRequisitionH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 领用单编号
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作用设备id
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用部门
|
||||
/// </summary>
|
||||
public string? department { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 领用目的
|
||||
/// </summary>
|
||||
public string? requisition_purpose { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位号
|
||||
/// </summary>
|
||||
public string? location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备件id
|
||||
/// </summary>
|
||||
public string? spare_parts_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 领用人
|
||||
/// </summary>
|
||||
public string? recipient_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 备品备件领用服务
|
||||
/// </summary>
|
||||
public interface IEqpSparePartsRequisitionHService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
134
EquipMgr/Tnb.EquipMgr/EqpSparePartsRequisitionHService.cs
Normal file
134
EquipMgr/Tnb.EquipMgr/EqpSparePartsRequisitionHService.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.ClearScript.Util.Web;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 备品备件领用服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class EqpSparePartsRequisitionHService : IEqpSparePartsRequisitionHService, IOverideVisualDevService,IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "27338205223957";
|
||||
private readonly ISqlSugarRepository<EqpSparePartsRequisitionH> _repository;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRuleService;
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
public EqpSparePartsRequisitionHService(ISqlSugarRepository<EqpSparePartsRequisitionH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IBillRullService billRuleService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
_billRuleService = billRuleService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
// VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
// await _runService.Create(templateEntity, input);
|
||||
var code = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.SPAREPARTSREQUISITION_CODE);
|
||||
EqpSparePartsRequisitionH eqpSparePartsRequisitionH = new EqpSparePartsRequisitionH()
|
||||
{
|
||||
code = code,
|
||||
equip_id = input.data.ContainsKey("equip_id") ? input.data["equip_id"].ToString() : "",
|
||||
department = input.data.ContainsKey("department") ? input.data["department"].ToString() : "",
|
||||
recipient_id = input.data.ContainsKey("recipient_id") ? input.data["recipient_id"].ToString() : "",
|
||||
requisition_purpose = input.data.ContainsKey("requisition_purpose") ? input.data["requisition_purpose"].ToString() : "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
|
||||
await db.Insertable<EqpSparePartsRequisitionH>(eqpSparePartsRequisitionH).ExecuteCommandAsync();
|
||||
|
||||
if (input.data.TryGetValue("tablefield120", out var value))
|
||||
{
|
||||
var details = value.ToObject<List<Dictionary<string,string>>>();
|
||||
List<EqpEquipSpareParts> eqpSparePartsList = new List<EqpEquipSpareParts>();
|
||||
List<EqpSparePartsRequisitionD> eqpSparePartsRequisitionDs = new List<EqpSparePartsRequisitionD>(){};
|
||||
foreach (var detail in details)
|
||||
{
|
||||
string instockDetailId = detail.ContainsKey("instock_detail_id") ? detail["instock_detail_id"] : "";
|
||||
string sparePartsId = detail.ContainsKey("spare_parts_id") ? detail["spare_parts_id"] : "";
|
||||
int quantity = Convert.ToInt32(detail.ContainsKey("quantity") ? detail["quantity"] : "");
|
||||
|
||||
eqpSparePartsRequisitionDs.Add(new EqpSparePartsRequisitionD
|
||||
{
|
||||
instock_detail_id = instockDetailId,
|
||||
spare_parts_id = sparePartsId,
|
||||
quantity = quantity,
|
||||
equip_id = eqpSparePartsRequisitionH.equip_id,
|
||||
spare_parts_requisition_id = eqpSparePartsRequisitionH.id,
|
||||
});
|
||||
|
||||
if (await db.Queryable<EqpSparePartsInstockD>()
|
||||
.AnyAsync(x => x.id == instockDetailId && (x.quantity - x.use_quantity - quantity) >= 0))
|
||||
{
|
||||
eqpSparePartsList.Add(new EqpEquipSpareParts
|
||||
{
|
||||
equip_id = input.data["equip_id"]?.ToString() ?? "",
|
||||
spare_parts_id = sparePartsId,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
});
|
||||
|
||||
await db.Updateable<EqpSparePartsInstockD>()
|
||||
.SetColumns(x => x.use_quantity == x.use_quantity + quantity)
|
||||
.Where(x => x.id == instockDetailId).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("库存不够");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (eqpSparePartsRequisitionDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<EqpSparePartsRequisitionD>(eqpSparePartsRequisitionDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (eqpSparePartsList.Count > 0)
|
||||
{
|
||||
await db.Insertable<EqpEquipSpareParts>(eqpSparePartsList).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1278,20 +1278,24 @@ namespace Tnb.ProductionMgr
|
||||
.SetColumns(x => x.reported_work_qty == x.reported_work_qty + input.reported_qty)
|
||||
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
var mbomProcess = await db.Queryable<BasMbomProcess>().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
|
||||
if (mbomProcess.is_last==1 && prdMoTask != null && !string.IsNullOrEmpty(prdMoTask.parent_id))
|
||||
|
||||
if (prdMoTask.schedule_type == 2 && !string.IsNullOrEmpty(prdMoTask.mbom_process_id))
|
||||
{
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == prdMoTask.parent_id);
|
||||
if (parentMoTask?.last_process_complete_qty == null)
|
||||
var mbomProcess = await db.Queryable<BasMbomProcess>().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
|
||||
if (mbomProcess.is_last==1 && prdMoTask != null && !string.IsNullOrEmpty(prdMoTask.parent_id))
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(x => x.last_process_complete_qty == input.reported_qty)
|
||||
.Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync();
|
||||
}else if (parentMoTask?.last_process_complete_qty != null)
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(x => x.last_process_complete_qty == x.last_process_complete_qty + input.reported_qty)
|
||||
.Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync();
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == prdMoTask.parent_id);
|
||||
if (parentMoTask?.last_process_complete_qty == null)
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(x => x.last_process_complete_qty == input.reported_qty)
|
||||
.Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync();
|
||||
}else if (parentMoTask?.last_process_complete_qty != null)
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(x => x.last_process_complete_qty == x.last_process_complete_qty + input.reported_qty)
|
||||
.Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user