Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -76,6 +76,21 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? mbom_id { get; set; }
|
public string? mbom_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? last_process_no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? next_process_no { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:工序id
|
/// Desc:工序id
|
||||||
/// Default:
|
/// Default:
|
||||||
|
|||||||
@@ -83,6 +83,21 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? process_id { get; set; }
|
public string? process_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? last_process_no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? next_process_no { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:准备时间
|
/// Desc:准备时间
|
||||||
/// Default:
|
/// Default:
|
||||||
|
|||||||
@@ -64,4 +64,20 @@ public partial class BasMbomProcess : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int ordinal { get; set; }
|
public int ordinal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? last_process_no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? next_process_no { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,4 +114,19 @@ public partial class BasRouteD : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? output_ratio { get; set; }
|
public decimal? output_ratio { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? last_process_no { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下道工序编号
|
||||||
|
/// </summary>
|
||||||
|
public string? next_process_no { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ namespace Tnb.BasicData
|
|||||||
production_method = process.production_method,
|
production_method = process.production_method,
|
||||||
inputs = inputs.Where(x => x.process_id == process.process_id).ToList(),
|
inputs = inputs.Where(x => x.process_id == process.process_id).ToList(),
|
||||||
outputs = outputs.Where(x => x.process_id == process.process_id).ToList(),
|
outputs = outputs.Where(x => x.process_id == process.process_id).ToList(),
|
||||||
|
no = process.no,
|
||||||
|
last_process_no = process.last_process_no,
|
||||||
|
next_process_no = process.next_process_no
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -508,6 +511,284 @@ namespace Tnb.BasicData
|
|||||||
}
|
}
|
||||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存生产bom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mbomSaveDataInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<string> SaveDataNew(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,
|
||||||
|
production_method = process.production_method,
|
||||||
|
route_detail_id = process.route_detail_id,
|
||||||
|
ordinal = ++index,
|
||||||
|
is_last = index==mbomSaveDataInput.processes.Count ? 1 : 0,
|
||||||
|
no = process.no,
|
||||||
|
last_process_no = process.last_process_no,
|
||||||
|
next_process_no = process.next_process_no,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user