1
This commit is contained in:
@@ -804,8 +804,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
|
||||
}
|
||||
var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
|
||||
if (taskList?.Count > 0)
|
||||
//var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
|
||||
//if (taskList?.Count > 0)
|
||||
{
|
||||
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
|
||||
{
|
||||
@@ -912,7 +912,10 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
if (taskLogEntities?.Count > 0)
|
||||
{
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
List<PrdReportRecord> prdReportLogs = new();
|
||||
List<PrdMoTaskDefectRecord> prdTaskDefectLogs = new();
|
||||
@@ -924,6 +927,7 @@ namespace Tnb.ProductionMgr
|
||||
var material = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskInfo.material_id));
|
||||
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskInfo.mo_id);
|
||||
var record = taskInfo.Adapt<PrdReportRecord>();
|
||||
record.id = SnowflakeIdHelper.NextId();
|
||||
record.masterial_code = material?.code;
|
||||
record.masterial_name = material?.name;
|
||||
record.plan_start_date = taskInfo.estimated_start_date;
|
||||
@@ -938,6 +942,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
//组装自检报废对象
|
||||
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 == taskInfo.eqp_id))?.code!;
|
||||
@@ -956,12 +961,28 @@ namespace Tnb.ProductionMgr
|
||||
prdTaskDefectLogs.Add(sacipRecord);
|
||||
}
|
||||
}
|
||||
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
|
||||
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
|
||||
var reportTaskIds = prdReportLogs.Select(it => it.mo_task_id).ToList();
|
||||
if (reportTaskIds?.Count > 0)
|
||||
{
|
||||
var items = await db.Queryable<PrdReportRecord>().Where(it => reportTaskIds.Contains(it.mo_task_id)).ToListAsync();
|
||||
if (items == null || items.Count < 1)
|
||||
{
|
||||
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
var defectTaskIds = prdTaskDefectLogs.Select(it => it.mo_task_id).ToList();
|
||||
if (defectTaskIds?.Count > 0)
|
||||
{
|
||||
var items = await db.Queryable<PrdMoTaskDefectRecord>().Where(it => defectTaskIds.Contains(it.mo_task_id)).ToListAsync();
|
||||
if (items == null || items.Count < 1)
|
||||
{
|
||||
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
|
||||
//else
|
||||
// throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user