From 22a576c63f15913e60999bf594fe0bc544577ac3 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 11 Jul 2024 16:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=91=98=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/ChangeWorkerInput.cs | 8 +++ .../WorkOrderAdjustmentListOutput.cs | 1 + .../Tnb.ProductionMgr/PrdMoTaskService.cs | 51 ++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs new file mode 100644 index 00000000..63039a1f --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs @@ -0,0 +1,8 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class ChangeWorkerInput + { + public string mo_task_id { get; set; } + public string worker_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs index fb6e5593..ff06053e 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs @@ -16,6 +16,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public int? complete_qty { get; set; } public int? scheduled_qty { get; set; } public string workline_id { get; set; } + public string worker_id { get; set; } public string workline_id_id { get; set; } public string estimated_start_date { get; set; } public string estimated_end_date { get; set; } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index ce318912..d74ca75b 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2568,13 +2568,14 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d, e, f) => a.mo_id == f.id) .LeftJoin((a, b, c, d, e, f, g) => a.workline_id == g.Id) .LeftJoin((a, b, c, d, e, f, g, h) => a.eqp_id == h.id) + .LeftJoin((a, b, c, d, e, f, g, h,i)=>a.worker_id==i.Id) .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) .WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count <= 0 && worklineIds.Count <= 0, (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 + .Select((a, b, c, d, e, f, g, h,i) => new WorkOrderAdjustmentListOutput { id = a.id, mo_task_code = a.mo_task_code, @@ -2594,6 +2595,7 @@ namespace Tnb.ProductionMgr eqp_id_id = a.eqp_id, create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), schedule_type = a.schedule_type, + worker_id = i.RealName }).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } @@ -2844,6 +2846,53 @@ namespace Tnb.ProductionMgr return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage); } + + /// + /// 更换员工 + /// + /// + [HttpPost] + public async Task ChangeWorker(ChangeWorkerInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + PrdMoTask moTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + if (moTask.worker_id == input.worker_id) + { + throw new Exception("与原员工相同"); + } + + + _ = await db.Updateable().SetColumns(x => x.worker_id == input.worker_id) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + + PrdMo mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id); + BasMaterial? material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id); + BasMaterial process = await db.Queryable().SingleAsync(x => x.id == moTask.process_id); + PrdTaskLog taskLog = new() + { + id = SnowflakeIdHelper.NextId(), + mo_code = mo?.mo_code!, + eqp_code = "", + mold_code = "", + item_code = material?.code!, + item_standard = material?.material_specification!, + status = "更换员工", + operator_name = _userManager.RealName, + create_id = _userManager.UserId, + create_time = DateTime.Now, + mo_task_id = moTask.id, + mo_task_code = moTask.mo_task_code, + station_code = "", + process_code = process?.code + }; + + _ = await db.Insertable(taskLog).ExecuteCommandAsync(); + }); + + return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage); + } /// /// 根据id获取任务单相关信息