From 666a8c8ed399c6e74b2f307bf6649b32a0fdb3e1 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 23 十月 2024 21:32:31 +0800 Subject: [PATCH] 添加工单工艺路线优化 --- Tiger.Business/MES/Biz.Route.cs | 48 ++++++++++++++++++++++++ Tiger.Controllers.MES/Controllers/MESController.Route.cs | 12 +---- Tiger.IBusiness/MES/IRoute.cs | 1 Tiger.Model.Net/Entitys/MES/ParameterEntity/RouteInput.cs | 7 +++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs index ec90c54..f1f4a08 100644 --- a/Tiger.Business/MES/Biz.Route.cs +++ b/Tiger.Business/MES/Biz.Route.cs @@ -14,6 +14,7 @@ using Tiger.Model.Entitys.WMS.DTOS; using static Tiger.Model.BIZ_MES_WO; using Tiger.Model.Entitys.MES.Position; +using System.Security.Cryptography; namespace Tiger.Business { @@ -990,6 +991,53 @@ } return result; } + + /// <summary> + /// 娣诲姞宸ュ崟宸ヨ壓璺嚎 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction> ProdRouteToWo(WoRotInput input) + { + var result = new ApiAction(); + try + { + //淇濆瓨鍓嶅垽鏂� + if (Db.Queryable<BIZ_MES_WO>().Any(x => x.ORDER_NO == input.wo && x.STATUS > STATUSs.Init.GetValue() && x.STATUS < STATUSs.Closed.GetValue())) { + + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟[{input.wo}]鐘舵�佷笉鏄垵濮嬪寲鎴栬�呭畬鎴愶紝涓嶅彲浠ヤ慨鏀瑰伐鑹鸿矾绾匡紒"); + return result; + } + + var wo = await Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.wo).FirstAsync(); + wo.ROUTE_STATUS = ROUTE_STATUSs.Finish.GetValue(); + + SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { ROT_ID = input.rotId, WO = input.wo, ERR_CODE = 0, ERR_MSG = "" }); + pars[2].Direction = System.Data.ParameterDirection.Output; + pars[3].Direction = System.Data.ParameterDirection.Output; + Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_PROD2WO", pars); + result.Data = pars[2].Value; + result.IsSuccessed = pars[2].Value.ToInt32() == 0 ? true : false; + result.LocaleMsg = new(pars[3].Value.ToString()); + + var db = Db; + var dbTran = db.UseTran(() => + { + db.Updateable(wo, input.userId).UpdateColumns(x => new { x.ROUTE_STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"娣诲姞宸ュ崟宸ヨ壓璺嚎寮傚父"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "娣诲姞宸ュ崟宸ヨ壓璺嚎寮傚父"); + } + return result; + } } //endClass Route } //endClass Biz } diff --git a/Tiger.Controllers.MES/Controllers/MESController.Route.cs b/Tiger.Controllers.MES/Controllers/MESController.Route.cs index e274299..9539fcc 100644 --- a/Tiger.Controllers.MES/Controllers/MESController.Route.cs +++ b/Tiger.Controllers.MES/Controllers/MESController.Route.cs @@ -350,20 +350,14 @@ /// <param name="rotId"></param> /// <param name="wo"></param> /// <returns></returns> - [HttpGet] + [HttpPost] [Route("api/[controller]/[action]")] - public async Task<IActionResult> SP_MES_PROD2WO(string? rotId, string? wo) + public async Task<IActionResult> ProdRouteToWo([FromBody] ApiAction<WoRotInput> action) { ApiAction response = new(); try { - SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { ROT_ID = rotId, WO = wo, ERR_CODE = 0, ERR_MSG = "" }); - pars[2].Direction = System.Data.ParameterDirection.Output; - pars[3].Direction = System.Data.ParameterDirection.Output; - Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_PROD2WO", pars); - response.Data = pars[2].Value; - response.IsSuccessed = pars[2].Value.ToInt32() == 0 ? true : false; - response.LocaleMsg = new(pars[3].Value.ToString()); + response = response.GetResponse(await DI.Resolve<IRoute>().ProdRouteToWo(action.Data)); } catch (System.Exception ex) { diff --git a/Tiger.IBusiness/MES/IRoute.cs b/Tiger.IBusiness/MES/IRoute.cs index e3388dc..69e3927 100644 --- a/Tiger.IBusiness/MES/IRoute.cs +++ b/Tiger.IBusiness/MES/IRoute.cs @@ -27,5 +27,6 @@ public Task<ApiAction> SaveWoRouteData(WoRouteData routeData); public Task<ApiAction> SetDefaultRoute(ProdRotInput input); public Task<List<V_MES_ROUTE_PTREE>> GetRoutePTree(string? prodCode, string? orgCode); + public Task<ApiAction> ProdRouteToWo(WoRotInput input); } } diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/RouteInput.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/RouteInput.cs index f7616b0..fef657b 100644 --- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/RouteInput.cs +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/RouteInput.cs @@ -10,6 +10,7 @@ { public string rotId { get; set; } public string rotCode { get; set; } + public string userId { get; set; } public AuthOption options { get; set; } } @@ -24,7 +25,11 @@ public bool isDefault { get; set; } } - public class DelWoRotInput : RouteInput + public class DelWoRotInput : WoRotInput + { + } + + public class WoRotInput : RouteInput { public string wo { get; set; } } -- Gitblit v1.9.3