生产管理模块代码调整

This commit is contained in:
DEVICE8\12494
2023-05-15 14:47:14 +08:00
parent c3809e2f45
commit a3ec329dc7
3 changed files with 367 additions and 333 deletions

View File

@@ -11,7 +11,8 @@ namespace Tnb.ProductionMgr.Entities
[SugarTable("prd_mo")] [SugarTable("prd_mo")]
public partial class PrdMo public partial class PrdMo
{ {
public PrdMo(){ public PrdMo()
{
} }
@@ -302,6 +303,10 @@ namespace Tnb.ProductionMgr.Entities
/// Nullable:True /// Nullable:True
/// </summary> /// </summary>
public string material_id { get; set; } public string material_id { get; set; }
/// <summary>
/// 已排产数量
/// </summary>
public int scheduled_qty { get; set; }
} }
} }

View File

@@ -11,7 +11,8 @@ namespace Tnb.ProductionMgr.Entities
[SugarTable("prd_mo_task_log")] [SugarTable("prd_mo_task_log")]
public partial class PrdTaskLog public partial class PrdTaskLog
{ {
public PrdTaskLog(){ public PrdTaskLog()
{
} }
@@ -103,6 +104,10 @@ namespace Tnb.ProductionMgr.Entities
/// 生产任务ID /// 生产任务ID
/// </summary> /// </summary>
public string mo_task_id { get; set; } public string mo_task_id { get; set; }
/// <summary>
/// 任务单编号
/// </summary>
public string mo_task_code { get; set; }
} }
} }

View File

@@ -438,13 +438,37 @@ namespace Tnb.ProductionMgr
//根据工单号获取当前工单包含的已排产数 //根据工单号获取当前工单包含的已排产数
var schedQty = db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty); var schedQty = db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产
if (mo != null && schedQty.HasValue && schedQty.Value >= mo.plan_qty) if (mo != null)
{//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产
if (schedQty.HasValue && schedQty.Value >= mo.plan_qty)
{ {
mo.mo_status = DictConst.AlreadyId; mo.mo_status = DictConst.AlreadyId;
row = await db.Updateable(mo).ExecuteCommandAsync(); row = await db.Updateable(mo).ExecuteCommandAsync();
} }
else
{
if (schedQty.HasValue)
mo.scheduled_qty = schedQty.Value;
}
}
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id); var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id))?.mo_code;
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id))?.code;
taskLog.mold_code = (await db.Queryable<Molds>().FirstAsync(it => it.id == input.mold_id))?.mold_code;
taskLog.item_code = material?.code;
taskLog.item_standard = material?.material_standard;
taskLog.status = DictConst.ToBeScheduledEncode;
taskLog.operator_name = _userManager.RealName;
taskLog.create_id = _userManager.UserId;
taskLog.create_time = DateTime.Now;
taskLog.mo_task_id = moTask.id;
taskLog.mo_task_code = moTask.mo_task_code;
await db.Insertable(taskLog).ExecuteCommandAsync();
//将生产任务插入到自检报废记录表 //将生产任务插入到自检报废记录表
var sacipRecord = new PrdMoTaskDefectRecord(); var sacipRecord = new PrdMoTaskDefectRecord();
sacipRecord.id = SnowflakeIdHelper.NextId(); sacipRecord.id = SnowflakeIdHelper.NextId();