组装包装,生产排产代码调整
This commit is contained in:
@@ -466,6 +466,35 @@ namespace Tnb.ProductionMgr
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组装、包装 待排产工单树形列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnSchedulingList()
|
||||
{
|
||||
List<PrdMotreeOutput> trees = new();
|
||||
var list = await _db.Queryable<PrdMo>().Where(it => string.IsNullOrEmpty(it.parent_id) && it.mo_status == DictConst.ScheduledId).ToListAsync();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var node = item.Adapt<PrdMotreeOutput>();
|
||||
node.mo_id = item.id;
|
||||
node.id = SnowflakeIdHelper.NextId();
|
||||
node.parentId = "0";
|
||||
var items = await _db.Queryable<PrdMo>().Where(it => it.parent_id == item.id).ToListAsync();
|
||||
if (items?.Count() > 0)
|
||||
{
|
||||
var childNodes = items.Adapt<List<PrdMotreeOutput>>();
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
childNodes[i].mo_id = items[i].id;
|
||||
}
|
||||
trees.AddRange(childNodes);
|
||||
}
|
||||
trees.Add(node);
|
||||
}
|
||||
return trees.ToTree();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -653,6 +682,24 @@ namespace Tnb.ProductionMgr
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code!;
|
||||
row = await _db.Insertable(taskLog).ExecuteCommandAsync();
|
||||
//将生产任务插入到自检报废记录表
|
||||
//var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
//sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||
//sacipRecord.material_code = material?.code!;
|
||||
//sacipRecord.material_name = material?.name!;
|
||||
//sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
|
||||
//sacipRecord.mold_name = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mold_id))?.mold_name!;
|
||||
//sacipRecord.estimated_start_date = moTask.plan_start_date;
|
||||
//sacipRecord.estimated_end_date = moTask.plan_end_date;
|
||||
//sacipRecord.plan_qty = moTask.plan_qty;
|
||||
//sacipRecord.scrap_qty = moTask.scrap_qty;
|
||||
//sacipRecord.status = moTask.mo_task_status;
|
||||
//sacipRecord.create_id = _userManager.UserId;
|
||||
//sacipRecord.create_time = DateTime.Now;
|
||||
//sacipRecord.mo_task_id = moTask.id;
|
||||
//sacipRecord.mo_task_code = moTask.mo_task_code;
|
||||
//await db.Insertable(sacipRecord).ExecuteCommandAsync();
|
||||
|
||||
//根据工单号获取当前工单包含的已排产数
|
||||
var schedQty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
||||
if (mo != null)
|
||||
@@ -1026,6 +1073,54 @@ namespace Tnb.ProductionMgr
|
||||
return row > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成子工单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task GenSubMo(GenSubMoCrInput input)
|
||||
{
|
||||
if (input is null) throw new ArgumentNullException("input");
|
||||
if (input.ids is null || input.ids.Count == 0) throw new ArgumentException($"{nameof(input.ids)} not be null or count zero");
|
||||
var curMo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
if (curMo == null) throw new ArgumentNullException("创建子工单时的父工单不能为null");
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().LeftJoin<BasMbomOutput>((a, b) => a.id == b.material_id)
|
||||
.Where((a, b) => input.ids.Contains(a.id))
|
||||
.Select((a, b) => new
|
||||
{
|
||||
material_id = a.id,
|
||||
material_code = a.code,
|
||||
num = b.num,
|
||||
})
|
||||
.ToListAsync();
|
||||
foreach (var om in outputMaterials)
|
||||
{
|
||||
PrdMo subMo = new();
|
||||
subMo.material_id = om.material_id;
|
||||
subMo.material_code = om.material_code;
|
||||
subMo.plan_qty = om.num.ParseToInt() * curMo.plan_qty;
|
||||
subMo.mo_type = curMo.mo_type;
|
||||
subMo.parent_id = curMo.id;
|
||||
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 = $"{subMoList[i].mo_code}-{num}";
|
||||
}
|
||||
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user