From 0aa0370049c5499367394f494e8c804941cedcbc Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 22 八月 2024 14:20:39 +0800 Subject: [PATCH] 工单管理更新 --- Tiger.Api/Controllers/MES/MESController.BIZ_MES_WO.cs | 21 ++++++++++ Tiger.IBusiness/MES/BIZ/IMES_WO.cs | 1 Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | 54 ++++++++++++++++++++++++++ Tiger.Model.Net/Entitys/MES/ParameterEntity/BizMesWoParameter.cs | 1 4 files changed, 76 insertions(+), 1 deletions(-) diff --git a/Tiger.Api/Controllers/MES/MESController.BIZ_MES_WO.cs b/Tiger.Api/Controllers/MES/MESController.BIZ_MES_WO.cs index cef776e..ab34030 100644 --- a/Tiger.Api/Controllers/MES/MESController.BIZ_MES_WO.cs +++ b/Tiger.Api/Controllers/MES/MESController.BIZ_MES_WO.cs @@ -94,5 +94,26 @@ } return Ok(response); } + + /// <summary> + /// 鏇存柊宸ュ崟鎵规鐘舵�� + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> UpdateWoBatchStatus([FromBody] ApiAction<BizMesWoInput> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IBIZ_MES_WO>().UpdateWoBatchStatus(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } } } diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs index 59cd2ad..e4039bb 100644 --- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs @@ -103,7 +103,6 @@ var result = new ApiAction(); try { - WoContext.RemoveBatch(input.WoBatch.BATCH_NO); //淇濆瓨鍓嶇殑鍒ゆ柇,骞剁敓鎴愭壒娆″彿 var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).FirstAsync(); //if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Init) @@ -125,6 +124,14 @@ result.LocaleMsg = new($"宸ュ崟涓嬪彂鐨勬暟閲忚秴杩囧伐鍗曡鍒掓暟閲忥紝涓嶈兘涓嬪彂锛�"); return result; } + if (!Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS==(int)BIZ_MES_WO_BATCH.STATUSs.Closed)) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟鍦ㄧ嚎浣揫{input.WoBatch.ACT_LINE}]鏈夋病瀹屽伐鐨勫伐鍗曟壒娆★紝涓嶈兘涓嬪彂锛�"); + return result; + } + WoContext.RemoveBatch(input.WoBatch.BATCH_NO); + var _batchWos = await Biz.Db.Queryable<V_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WoBatch.ORDER_NO).ToListAsync(); if (_batchWos.Count > 0) { @@ -201,5 +208,50 @@ } return result; } + + /// <summary> + /// 鏇存柊宸ュ崟鎵规鐘舵�� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + /// <exception cref="NotImplementedException"></exception> + public async Task<ApiAction> UpdateWoBatchStatus(BizMesWoInput input) + { + var result = new ApiAction(); + try + { + //淇濆瓨鍓嶇殑鍒ゆ柇,骞剁敓鎴愭壒娆″彿 + var _wo = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.BATCH_NO == input.WoBatch).FirstAsync(); + if (_wo != null) + { + _wo.STATUS = input.Status < 0 ? _wo.STATUS : input.Status; + if (input.Status == (int) BIZ_MES_WO_BATCH.STATUSs.Paused) { + WoContext.RemoveBatch(input.WoBatch); + } + } + else + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟鎵规[{input.WoBatch}]涓嶅瓨鍦�"); + return result; + } + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + db.Updateable(_wo, input.UserId).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"鏇存柊宸ュ崟鎵规鐘舵�佸紓甯�"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "鏇存柊宸ュ崟鎵规鐘舵�佸紓甯�"); + } + return result; + } } } diff --git a/Tiger.IBusiness/MES/BIZ/IMES_WO.cs b/Tiger.IBusiness/MES/BIZ/IMES_WO.cs index cd69ea6..2fad67a 100644 --- a/Tiger.IBusiness/MES/BIZ/IMES_WO.cs +++ b/Tiger.IBusiness/MES/BIZ/IMES_WO.cs @@ -17,5 +17,6 @@ public Task<ApiAction> DeleteMesWo(string woId); public Task<ApiAction> SaveMesBatchWo(SaveWoBatchInput input); public Task<ApiAction> UpdateWoStatus(BizMesWoInput input); + public Task<ApiAction> UpdateWoBatchStatus(BizMesWoInput input); } } diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizMesWoParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizMesWoParameter.cs index aac7b6f..053cf7d 100644 --- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizMesWoParameter.cs +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizMesWoParameter.cs @@ -9,6 +9,7 @@ public class BizMesWoInput { public string WorkOrder { get; set; } + public string WoBatch { get; set; } public string UserId { get; set; } public int Status { get; set; } public int RouteStatus { get; set; } -- Gitblit v1.9.3