Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料型号
|
/// 物料型号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string material_category_code { get; set; }
|
public string material_standard { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///输出数量
|
///输出数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -44,6 +44,10 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string bom_id { get; set; }
|
public string bom_id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 工艺路线id
|
||||||
|
/// </summary>
|
||||||
|
public string route_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// 工序id
|
/// 工序id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string process_id { get; set; }
|
public string process_id { get; set; }
|
||||||
@@ -56,5 +60,9 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// 工艺路线名称
|
/// 工艺路线名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string route_name { get; set; }
|
public string route_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工序排序序号
|
||||||
|
/// </summary>
|
||||||
|
public long? ordinal { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,26 +155,51 @@ namespace Tnb.BasicData
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||||
|
|
||||||
var result = await _db.Queryable<BasMbom>()
|
var result = await _db.Queryable<BasMbom>()
|
||||||
.LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||||
.LeftJoin<BasRouteD>((a, b, c) => b.id == c.route_id)
|
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => c.process_id == d.process_id)
|
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
|
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||||
.Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
|
.Where((a, b, c, d, e) => a.id == bomId)
|
||||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||||
{
|
{
|
||||||
version = a.version,
|
version = a.version,
|
||||||
unit_id = a.unit_id,
|
unit_id = a.unit_id,
|
||||||
route_name = b.name,
|
route_name = c.name,
|
||||||
process_id = c.process_id,
|
process_id = b.process_id,
|
||||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||||
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||||
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||||
material_category_code = "",
|
material_standard = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.material_standard),
|
||||||
num = e.num,
|
num = e.num,
|
||||||
})
|
ordinal = d.ordinal,
|
||||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
})
|
||||||
.ToListAsync();
|
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||||
|
.ToListAsync();
|
||||||
|
#region 注释代码
|
||||||
|
//var result = await _db.Queryable<BasMbom>()
|
||||||
|
// .LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
||||||
|
// .LeftJoin<BasRouteD>((a, b, c) => b.id == c.route_id)
|
||||||
|
// .LeftJoin<BasMbomProcess>((a, b, c, d) => c.process_id == d.process_id)
|
||||||
|
// .LeftJoin<BasMbomOutput>((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
|
||||||
|
// .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
|
||||||
|
|
||||||
|
// .Select((a, b, c, d, e) => new SubBomListOutput
|
||||||
|
// {
|
||||||
|
// version = a.version,
|
||||||
|
// unit_id = a.unit_id,
|
||||||
|
// route_name = b.name,
|
||||||
|
// process_id = c.process_id,
|
||||||
|
// material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||||
|
// material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||||
|
// material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||||
|
// material_standard = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.material_standard),
|
||||||
|
// num = e.num,
|
||||||
|
// })
|
||||||
|
// .Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||||
|
// .ToListAsync();
|
||||||
|
#endregion
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +223,6 @@ namespace Tnb.BasicData
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<dynamic> GetMBomListByMaterialId([FromRoute] string materialId)
|
public async Task<dynamic> GetMBomListByMaterialId([FromRoute] string materialId)
|
||||||
{
|
{
|
||||||
|
|
||||||
return await _db.Queryable<BasMbom>()
|
return await _db.Queryable<BasMbom>()
|
||||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排产数量
|
/// 排产数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string scheduled_qty { get; set; }
|
public int scheduled_qty { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:预计开始时间
|
/// Desc:预计开始时间
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string mo_task_code { get; set; }
|
public string mo_task_code { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string material_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// 物料编号
|
/// 物料编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string material_code { get; set; }
|
public string material_code { get; set; }
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ namespace Tnb.ProductionMgr
|
|||||||
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||||
.Where((a, b, c, d) => a.mo_id == moId)
|
.Where((a, b, c, d) => a.mo_id == moId && string.IsNullOrEmpty(a.parent_id))
|
||||||
.Select((a, b, c, d) => new PrdMoTaskOutput
|
.Select((a, b, c, d) => new PrdMoTaskOutput
|
||||||
{
|
{
|
||||||
mo_task_code = a.mo_task_code,
|
mo_task_code = a.mo_task_code,
|
||||||
@@ -414,28 +414,29 @@ namespace Tnb.ProductionMgr
|
|||||||
public async Task<dynamic> GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input)
|
public async Task<dynamic> GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input)
|
||||||
{
|
{
|
||||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||||
var result = await _db.Queryable<PrdMoTask>().Where(it => it.schedule_type == 2)
|
var result = await _db.Queryable<PrdMoTask>()
|
||||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
.LeftJoin<OrganizeEntity>((a, b) => a.workline_id == b.Id)
|
||||||
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||||
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
|
.LeftJoin<BasMbom>((a, b, c, d) => a.bom_id == d.id)
|
||||||
.LeftJoin<BasMbom>((a, b, c, d, e) => a.bom_id == e.id)
|
.WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d) => a.mo_task_code.Contains(input.mo_task_code))
|
||||||
.WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d, e) => a.mo_task_code.Contains(input.mo_task_code))
|
.Where((a, b, c, d) => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id))
|
||||||
.Select((a, b, c, d, e) => new PackSechelToBeIssueListOutput
|
.Select((a, b, c, d) => new PackSechelToBeIssueListOutput
|
||||||
{
|
{
|
||||||
mo_task_id = a.id,
|
mo_task_id = a.id,
|
||||||
mo_task_code = a.mo_task_code,
|
mo_task_code = a.mo_task_code,
|
||||||
material_code = b.code,
|
material_id = a.material_id,
|
||||||
material_name = b.name,
|
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == a.material_id).Select(it => it.code),
|
||||||
|
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == a.material_id).Select(it => it.name),
|
||||||
workline_id = a.workline_id,
|
workline_id = a.workline_id,
|
||||||
workline_code = c.EnCode,
|
workline_code = b.EnCode,
|
||||||
workline_name = c.FullName,
|
workline_name = b.FullName,
|
||||||
mo_task_status = a.mo_task_status,
|
mo_task_status = a.mo_task_status,
|
||||||
scheduled_qty = a.scheduled_qty,
|
scheduled_qty = SqlFunc.Subqueryable<PrdMoTask>().Where(it => it.mo_id == a.mo_id).Sum(it => it.scheduled_qty),
|
||||||
plan_qty = d.plan_qty,
|
plan_qty = SqlFunc.Subqueryable<PrdMo>().Where(it => it.id == a.mo_id).Select(it => it.plan_qty),
|
||||||
estimated_start_date = a.estimated_start_date,
|
estimated_start_date = a.estimated_start_date,
|
||||||
estimated_end_date = a.estimated_end_date,
|
estimated_end_date = a.estimated_end_date,
|
||||||
bom_id = e.id,
|
bom_id = d.id,
|
||||||
bom_version = e.version
|
bom_version = d.version
|
||||||
})
|
})
|
||||||
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
|
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@@ -467,8 +468,10 @@ namespace Tnb.ProductionMgr
|
|||||||
scheduled_qty = a.scheduled_qty,
|
scheduled_qty = a.scheduled_qty,
|
||||||
plan_qty = d.plan_qty,
|
plan_qty = d.plan_qty,
|
||||||
process_task_qty = a.process_task_qty,
|
process_task_qty = a.process_task_qty,
|
||||||
|
bom_version = SqlFunc.Subqueryable<BasMbom>().Where(it => it.material_id == a.material_id).Select(it => it.version)
|
||||||
})
|
})
|
||||||
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
|
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
|
||||||
|
.OrderBy(a => a.mo_task_code, OrderByType.Asc)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -692,18 +695,21 @@ namespace Tnb.ProductionMgr
|
|||||||
var moTask = input.Adapt<PrdMoTask>();
|
var moTask = input.Adapt<PrdMoTask>();
|
||||||
moTask.id = SnowflakeIdHelper.NextId();
|
moTask.id = SnowflakeIdHelper.NextId();
|
||||||
moTask.create_id = _userManager.UserId;
|
moTask.create_id = _userManager.UserId;
|
||||||
|
moTask.bom_id = input.bom_id;
|
||||||
|
moTask.workline_id = input.workline_id;
|
||||||
moTask.create_time = DateTime.Now;
|
moTask.create_time = DateTime.Now;
|
||||||
moTask.schedule_type = 2;
|
moTask.schedule_type = 2;
|
||||||
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
moTask.estimated_start_date = input.estimated_start_date;
|
moTask.estimated_start_date = input.estimated_start_date;
|
||||||
moTask.estimated_end_date = input.estimated_end_date;
|
moTask.estimated_end_date = input.estimated_end_date;
|
||||||
|
moTask.scheduled_qty = input.scheduled_qty;
|
||||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||||
var moCode = mo?.mo_code;
|
var moCode = mo?.mo_code;
|
||||||
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
|
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
|
||||||
.OrderByDescending(it => it.mo_task_code)
|
.OrderByDescending(it => it.mo_task_code)
|
||||||
.Select(it => it.mo_task_code)
|
.Select(it => it.mo_task_code)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
if (taskCode!.IsNullOrEmpty())
|
if (taskCode is null || taskCode.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
moTask.mo_task_code = $"{moCode}-01";
|
moTask.mo_task_code = $"{moCode}-01";
|
||||||
}
|
}
|
||||||
@@ -771,51 +777,98 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
//根据生产bomId 拆解生产子任务
|
//根据生产bomId 拆解生产子任务
|
||||||
var outputList = new List<PackingSchedulingListOutput>();
|
var outputList = new List<PackingSchedulingListOutput>();
|
||||||
var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
var subTaskList = await _db.Queryable<BasMbom>()
|
||||||
if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||||
|
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||||
|
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||||
|
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||||
|
.Where((a, b, c, d, e) => a.id == input.bom_id && d.ordinal < SqlFunc.Subqueryable<BasRouteD>().Where(it => it.route_id == a.route_id).OrderByDesc(it => it.ordinal).Select(it => it.ordinal))
|
||||||
|
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||||
|
{
|
||||||
|
version = a.version,
|
||||||
|
unit_id = a.unit_id,
|
||||||
|
route_id = c.id,
|
||||||
|
route_name = c.name,
|
||||||
|
process_id = b.process_id,
|
||||||
|
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||||
|
num = e.num,
|
||||||
|
ordinal = d.ordinal,
|
||||||
|
})
|
||||||
|
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (subTaskList?.Count > 0)
|
||||||
{
|
{
|
||||||
var routes = await _db.Queryable<BasRouteD>().Where(it => it.route_id == bom.route_id).ToListAsync();
|
List<PrdMoTask> subMoTasks = new();
|
||||||
if (routes?.Count > 0)
|
foreach (var item in subTaskList)
|
||||||
{
|
{
|
||||||
var processIds = routes.Select(x => x.process_id).ToList();
|
PrdMoTask subMoTask = new();
|
||||||
if (processIds?.Count > 0)
|
subMoTask.schedule_type = 2;
|
||||||
|
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
|
subMoTask.parent_id = moTask.id;
|
||||||
|
subMoTask.mo_id = input.mo_id;
|
||||||
|
//subMoTask.bom_id = input.bom_id;
|
||||||
|
subMoTask.workline_id = input.workline_id;
|
||||||
|
subMoTask.material_id = item.material_id;
|
||||||
|
subMoTask.workroute_id = item.route_id;
|
||||||
|
subMoTask.scheduled_qty = item.output_qty * moTask.scheduled_qty;
|
||||||
|
subMoTask.process_task_qty = item.output_qty * moTask.scheduled_qty;
|
||||||
|
subMoTask.estimated_start_date = input.estimated_start_date;
|
||||||
|
subMoTask.estimated_end_date = input.estimated_end_date;
|
||||||
|
subMoTask.create_id = _userManager.UserId;
|
||||||
|
subMoTask.create_time = DateTime.Now;
|
||||||
|
subMoTasks.Add(subMoTask);
|
||||||
|
}
|
||||||
|
//根据生产任务编号生成子任务编号
|
||||||
|
if (moTask.mo_task_code!.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= subMoTasks.Count; i++)
|
||||||
{
|
{
|
||||||
var bomOutputs = await _db.Queryable<BasMbomOutput>().Where(it => processIds.Contains(it.process_id)).ToListAsync();
|
string n = i.ToString();
|
||||||
if (bomOutputs?.Count > 0)
|
subMoTasks[i - 1].mo_task_code = $"{moTask.mo_task_code}-{n.PadLeft(2, '0')}";
|
||||||
{
|
|
||||||
List<PrdMoTask> subMoTasks = new();
|
|
||||||
foreach (var item in bomOutputs)
|
|
||||||
{
|
|
||||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
|
||||||
PrdMoTask subMoTask = new();
|
|
||||||
subMoTask.id = SnowflakeIdHelper.NextId();
|
|
||||||
subMoTask.schedule_type = 2;
|
|
||||||
subMoTask.parent_id = moTask.id;
|
|
||||||
subMoTask.bom_id = input.bom_id;
|
|
||||||
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
|
||||||
subMoTask.workline_id = input.workline_id;
|
|
||||||
subMoTask.material_id = item.material_id;
|
|
||||||
subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
|
|
||||||
subMoTask.estimated_start_date = input.estimated_start_date;
|
|
||||||
subMoTask.estimated_end_date = input.estimated_end_date;
|
|
||||||
subMoTask.create_id = _userManager.UserId;
|
|
||||||
subMoTask.create_time = DateTime.Now;
|
|
||||||
subMoTasks.Add(subMoTask);
|
|
||||||
}
|
|
||||||
//根据生产任务编号生成子任务编号
|
|
||||||
if (moTask.mo_task_code!.IsNotEmptyOrNull())
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= subMoTasks.Count; i++)
|
|
||||||
{
|
|
||||||
string n = i.ToString();
|
|
||||||
subMoTasks[i - 1].mo_task_code = $"{moTask.mo_task_code}-{n.PadLeft(2, '0')}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
#region 注释代码
|
||||||
|
//var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
||||||
|
//if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
||||||
|
//{
|
||||||
|
// var mbomProcesses = await _db.Queryable<BasMbomProcess>().Where(it => it.mbom_id == bom.id).ToListAsync();
|
||||||
|
// var routes = await _db.Queryable<BasRouteD>().Where(it => it.route_id == bom.route_id).ToListAsync();
|
||||||
|
// if (routes?.Count > 0)
|
||||||
|
// {
|
||||||
|
// var processIds = routes.Select(x => x.process_id).ToList();
|
||||||
|
// if (processIds?.Count > 0)
|
||||||
|
// {
|
||||||
|
// var bomOutputs = await _db.Queryable<BasMbomOutput>().Where(it => processIds.Contains(it.process_id)).ToListAsync();
|
||||||
|
// if (bomOutputs?.Count > 0)
|
||||||
|
// {
|
||||||
|
// List<PrdMoTask> subMoTasks = new();
|
||||||
|
// foreach (var item in bomOutputs)
|
||||||
|
// {
|
||||||
|
// var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
||||||
|
// PrdMoTask subMoTask = new();
|
||||||
|
// subMoTask.id = SnowflakeIdHelper.NextId();
|
||||||
|
// subMoTask.schedule_type = 2;
|
||||||
|
// subMoTask.parent_id = moTask.id;
|
||||||
|
// subMoTask.bom_id = input.bom_id;
|
||||||
|
// subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
|
// subMoTask.workline_id = input.workline_id;
|
||||||
|
// subMoTask.material_id = item.material_id;
|
||||||
|
// subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
|
||||||
|
// subMoTask.estimated_start_date = input.estimated_start_date;
|
||||||
|
// subMoTask.estimated_end_date = input.estimated_end_date;
|
||||||
|
// subMoTask.create_id = _userManager.UserId;
|
||||||
|
// subMoTask.create_time = DateTime.Now;
|
||||||
|
// subMoTasks.Add(subMoTask);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1142,7 +1195,7 @@ namespace Tnb.ProductionMgr
|
|||||||
.Where((a, b, c) => a.id == input.bom_id && input.ids.Contains(b.process_id))
|
.Where((a, b, c) => a.id == input.bom_id && input.ids.Contains(b.process_id))
|
||||||
.Select((a, b, c) => new
|
.Select((a, b, c) => new
|
||||||
{
|
{
|
||||||
material_id = a.material_id,
|
material_id = c.material_id,
|
||||||
num = c.num,
|
num = c.num,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@@ -1151,35 +1204,37 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
var mids = await _db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
|
var mids = await _db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
|
||||||
var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
|
var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
|
||||||
var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
if (ids?.Count > 0)
|
||||||
List<PrdMo> subMoList = new();
|
|
||||||
var outputMaterials = await _db.Queryable<BasMaterial>().Where(it => ids.Contains(it.id)).ToListAsync();
|
|
||||||
foreach (var om in outputMaterials)
|
|
||||||
{
|
{
|
||||||
PrdMo subMo = new();
|
var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
||||||
subMo.material_id = om.id;
|
List<PrdMo> subMoList = new();
|
||||||
subMo.material_code = om.code;
|
var outputMaterials = await _db.Queryable<BasMaterial>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||||
subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
|
foreach (var om in outputMaterials)
|
||||||
subMo.mo_type = curMo.mo_type;
|
{
|
||||||
subMo.parent_id = curMo.id;
|
PrdMo subMo = new();
|
||||||
subMo.plan_start_date = curMo.plan_start_date;
|
subMo.material_id = om.id;
|
||||||
subMo.plan_end_date = curMo.plan_end_date;
|
subMo.material_code = om.code;
|
||||||
subMo.create_id = _userManager.UserId;
|
subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
|
||||||
subMo.create_time = DateTime.Now;
|
subMo.mo_type = curMo.mo_type;
|
||||||
subMo.mo_status = DictConst.WaitProductId;
|
subMo.parent_id = curMo.id;
|
||||||
subMoList.Add(subMo);
|
subMo.plan_start_date = curMo.plan_start_date;
|
||||||
|
subMo.plan_end_date = curMo.plan_end_date;
|
||||||
|
subMo.create_id = _userManager.UserId;
|
||||||
|
subMo.create_time = DateTime.Now;
|
||||||
|
subMo.mo_status = DictConst.WaitProductId;
|
||||||
|
subMoList.Add(subMo);
|
||||||
|
}
|
||||||
|
//生成子工单编码
|
||||||
|
for (int i = 0; i < subMoList.Count; i++)
|
||||||
|
{
|
||||||
|
var num = (i + 1).ToString().PadLeft(2, '0');
|
||||||
|
subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
|
||||||
|
}
|
||||||
|
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||||
}
|
}
|
||||||
//生成子工单编码
|
|
||||||
for (int i = 0; i < subMoList.Count; i++)
|
|
||||||
{
|
|
||||||
var num = (i + 1).ToString().PadLeft(2, '0');
|
|
||||||
subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
|
|
||||||
}
|
|
||||||
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1208,7 +1263,6 @@ namespace Tnb.ProductionMgr
|
|||||||
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
||||||
dicProperties[name] = properies;
|
dicProperties[name] = properies;
|
||||||
}
|
}
|
||||||
//var properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
|
||||||
foreach (var pn in properies)
|
foreach (var pn in properies)
|
||||||
{
|
{
|
||||||
if (dictionary.ContainsKey(pn))
|
if (dictionary.ContainsKey(pn))
|
||||||
@@ -1218,10 +1272,6 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user