任务单调整 更换设备模具产线 任务单操作记录

This commit is contained in:
2023-08-10 11:58:41 +08:00
parent 1bbb30f135
commit 4a81df87b0
11 changed files with 222 additions and 1 deletions

View File

@@ -1820,20 +1820,25 @@ namespace Tnb.ProductionMgr
(a, b, c, d) => a.workline_id == eqpId || a.eqp_id == eqpId)
.WhereIF(worklineIds.Count > 0, (a, b, c, d) => worklineIds.Contains(a.workline_id))
.WhereIF(equipIds.Count > 0, (a, b, c, d) => equipIds.Contains(a.eqp_id))
.Where((a)=>a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_code==DictConst.ToBeScheduledEncode || a.mo_task_code==DictConst.MoStatusPauseCode)
.Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput
{
id = a.id,
mo_task_code = a.mo_task_code,
material_id = b.code+"/"+b.name,
material_id_id = a.material_id,
mold_id = e.mold_code+"/"+e.mold_name,
mold_id_id = a.mold_id,
mo_task_status = d.FullName,
plan_qty = f.plan_qty,
complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0),
scheduled_qty = a.scheduled_qty,
workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName,
workline_id_id = a.workline_id,
estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"),
estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"),
eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name,
eqp_id_id = a.eqp_id,
create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss")
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
@@ -1924,5 +1929,145 @@ namespace Tnb.ProductionMgr
.Where(x => x.workline_id == id && x.mo_task_status == DictConst.InProgressEnCode).FirstAsync();
}
/// <summary>
/// 更换机台
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeEquip(ChangeEquipInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.eqp_id == input.equip_id)
{
throw new Exception("与原机台相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.eqp_id == input.equip_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!;
taskLog.mold_code = "";
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换机台";
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;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
/// <summary>
/// 更换模具
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeMold(ChangeMoldInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.mold_id == input.mold_id)
{
throw new Exception("与原模具相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.mold_id == input.mold_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var mold = await db.Queryable<ToolMolds>().SingleAsync(x => x.id == input.mold_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = "";
taskLog.mold_code = mold?.mold_code;
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换模具";
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;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
/// <summary>
/// 更换产线
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeWorkline(ChangeWorklineInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.workline_id == input.workline_id)
{
throw new Exception("与原产线相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.workline_id == input.workline_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = "";
taskLog.mold_code = "";
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换产线";
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;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
}
}