From 25f8eb843fd2046d8b94b410185e4ecdd3c07f57 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期日, 04 八月 2024 18:44:28 +0800 Subject: [PATCH] 工单工艺路线编辑 --- Tiger.Business/MES/Biz.Route.cs | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 229 insertions(+), 10 deletions(-) diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs index 56fe66c..cd069f1 100644 --- a/Tiger.Business/MES/Biz.Route.cs +++ b/Tiger.Business/MES/Biz.Route.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http; using Tiger.Model.Entitys.WMS.DTOS; using static Tiger.Model.BIZ_MES_WO; +using Tiger.Model.Entitys.MES.Position; namespace Tiger.Business { @@ -271,11 +272,11 @@ var result = new ApiAction(); try { - var _route = Db.Queryable<MES_ROUTE>().Where(x=>x.ROT_CODE == route.ROT_CODE).First(); - if (_route!=null && Db.Queryable<MES_ROUTE_NODE>().Where(x=>x.ROT_ID == _route.ID).Any()) + var _route = Db.Queryable<MES_ROUTE>().Where(x => x.ROT_CODE == route.ROT_CODE).First(); + if (_route != null && Db.Queryable<MES_ROUTE_NODE>().Where(x => x.ROT_ID == _route.ID).Any()) { result.IsSuccessed = false; - result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夎璁¤褰曪紝涓嶈兘淇濆瓨锛�"); + result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夎璁¤褰曪紝涓嶈兘淇濆瓨锛�"); return result; } var db = Db; @@ -323,7 +324,7 @@ } db.Deleteable<MES_ROUTE_NODE>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand(); db.Deleteable<MES_ROUTE_EDGE>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand(); - db.Deleteable<MES_ROUTE_NODE_ACT>(false).Where(x=>x.ROT_ID == routeData.route.ID).ExecuteCommand(); + db.Deleteable<MES_ROUTE_NODE_ACT>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand(); if (routeData.nodes != null) { db.Insertable(routeData.nodes).ExecuteCommand(); @@ -355,7 +356,8 @@ /// </summary> /// <param name="routeId"></param> /// <returns></returns> - public async Task<ApiAction> DeleteRoute(string routeId) { + public async Task<ApiAction> DeleteRoute(string routeId) + { var result = new ApiAction(); try { @@ -387,7 +389,8 @@ /// </summary> /// <param name="nodePost"></param> /// <returns></returns> - public async Task<ApiAction> SaveRouteNodePost(List<MES_ROUTE_NODE_POST> nodePost) { + public async Task<ApiAction> SaveRouteNodePost(List<MES_ROUTE_NODE_POST> nodePost) + { var result = new ApiAction(); try { @@ -476,7 +479,7 @@ var result = new ApiAction(); try { - var bizMesWo = await Db.Queryable<BIZ_MES_WO>().Where(x=> x.ORDER_NO == input.wo).FirstAsync(); + var bizMesWo = await Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.wo).FirstAsync(); if (bizMesWo != null && bizMesWo.STATUS > (int)STATUSs.Imported && bizMesWo.STATUS < (int)STATUSs.Closed) { result.IsSuccessed = false; @@ -511,7 +514,8 @@ } } //濡傛灉闄や簡鍒犻櫎鐨勫綋鍓嶅伐鑹鸿矾绾夸笉瀛樺湪鍏朵粬缁戝畾鐨勫伐鑹鸿矾绾匡紝鍒欐洿鏂扮姸鎬� - if (bizMesWo != null && !Db.Queryable<MES_WO_NODE>().Where(x => x.WORK_ORDER == input.wo && x.ROT_ID != _rotId).Any()) { + if (bizMesWo != null && !Db.Queryable<MES_WO_NODE>().Where(x => x.WORK_ORDER == input.wo && x.ROT_ID != _rotId).Any()) + { bizMesWo.ROUTE_STATUS = (int)ROUTE_STATUSs.WaitSet; bizMesWo.STATUS = (int)STATUSs.Init; bizMesWo.ROUTE_CODE = ""; @@ -551,6 +555,221 @@ } return result; } - } - } + + #region 宸ュ崟宸ヨ壓璺嚎鐩稿叧 + + + /// <summary> + /// 鑾峰彇宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁 + /// </summary> + /// <param name="workorder"></param> + /// <returns></returns> + public async Task<ApiAction<WoRouteData>> GetWoRouteData(string workorder) + { + var res = new ApiAction<WoRouteData>(); + WoRouteData rotData = new WoRouteData(); + try + { + if (string.IsNullOrEmpty(workorder)) + { + res.IsSuccessed = false; + res.LocaleMsg = new($"浼犲叆鐨勫伐鑹鸿矾绾縄D涓虹┖锛屼笉鑳芥煡鎵惧伐鑹鸿矾绾匡紒"); + return res; + } + //宸ヨ壓璺嚎 + var route = await Db.Queryable<BIZ_MES_WO, MES_ROUTE>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ROUTE_CODE == s.ROT_CODE)) + .Where((q, s) => q.ID.Equals(workorder) || q.ORDER_NO == workorder).Select((q, s) => new MES_ROUTE + { + ID = s.ID, + ROT_CODE = s.ROT_CODE, + ROT_NAME = s.ROT_NAME, + ROT_TYPE = s.ROT_TYPE, + ROT_VER = s.ROT_VER, + IS_ACTIVE = s.IS_ACTIVE, + REMARK = s.REMARK, + WORK_ORDER = q.ORDER_NO, + PROD_CODE = q.ITEM_CODE, + CUST_CODE = q.CUST_CODE, + }).FirstAsync(); + rotData.route = route; + if (route == null) + { + res.IsSuccessed = false; + res.LocaleMsg = new($"涓嶈兘鏌ユ壘鍒板伐鍗曞伐鑹鸿矾绾匡紒"); + return res; + } + //鑺傜偣 + var nodes = await Db.Queryable<MES_WO_NODE>() + .WhereIF(!string.IsNullOrEmpty(route.ID), x => x.WORK_ORDER.Equals(route.WORK_ORDER)) + .ToListAsync(); + foreach (var node in nodes) + { + node.node = new() + { + id = node.ID, + type = node.GPH_TYPE, + x = node.GPH_X, + y = node.GPH_Y, + properties = node.GPH_PROP, + text = new() + { + x = node.GPH_X, + y = node.GPH_Y, + value = node.GPH_TEXT + } + }; + } + rotData.nodes = nodes; + + var acts = await Db.Queryable<MES_WO_NODE_ACT>() + .WhereIF(!string.IsNullOrEmpty(route.ID), x => x.WORK_ORDER.Equals(route.WORK_ORDER)) + .ToListAsync(); + foreach (var act in acts) + { + act.node = new() + { + id = act.ID, + type = act.GPH_TYPE, + x = act.GPH_X, + y = act.GPH_Y, + properties = act.GPH_PROP, + text = new() + { + x = act.GPH_X, + y = act.GPH_Y, + value = act.GPH_TEXT + } + }; + } + rotData.acts = acts; + + //杈� + var edges = await Db.Queryable<MES_WO_EDGE>() + .WhereIF(!string.IsNullOrEmpty(route.ID), x => x.WORK_ORDER.Equals(route.WORK_ORDER)) + .ToListAsync(); + foreach (var edge in edges) + { + edge.edge = new() + { + id = edge.ID, + type = edge.GPH_TYPE, + sourceNodeId = edge.SRC_NODE, + targetNodeId = edge.TGT_NODE, + properties = edge.GPH_PROP, + startPoint = new() + { + x = edge.GPH_SRC_X, + y = edge.GPH_SRC_Y, + }, + endPoint = new() + { + x = edge.GPH_TGT_X, + y = edge.GPH_TGT_Y, + }, + pointsList = new() + { + new(){ + x = edge.GPH_SRC_X, + y = edge.GPH_SRC_Y, + }, + new(){ + x = edge.GPH_TGT_X, + y = edge.GPH_TGT_Y, + } + } + }; + } + rotData.edges = edges; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); + } + res.Data = rotData; + return res; + } + + /// <summary> + /// 淇濆瓨宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁 + /// </summary> + /// <param name="routeData"></param> + /// <returns></returns> + public async Task<ApiAction> SaveWoRouteData(WoRouteData routeData) + { + var result = new ApiAction(); + try + { + var db = Db; + var dbTran = db.UseTran(() => + { + //if (routeData.route != null) + //{ + // var y = db.Storageable(routeData.route) + // .WhereColumns(t => new { t.ROT_CODE, t.GHOST_ROW }) + // .ToStorage(); + // y.AsInsertable.ExecuteCommand(); + // y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); + //} + db.Deleteable<MES_WO_NODE>(false).Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER).ExecuteCommand(); + db.Deleteable<MES_WO_EDGE>(false).Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER).ExecuteCommand(); + db.Deleteable<MES_WO_NODE_ACT>(false).Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER).ExecuteCommand(); + if (routeData.nodes != null) + { + db.Insertable(routeData.nodes).ExecuteCommand(); + } + if (routeData.edges != null) + { + db.Insertable(routeData.edges).ExecuteCommand(); + } + if (routeData.acts != null) + { + db.Insertable(routeData.acts).ExecuteCommand(); + } + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"淇濆瓨宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁寮傚父"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁寮傚父"); + } + return await Task.FromResult(result); + } + + /// <summary> + /// 淇濆瓨宸ュ崟宸ヨ壓鑺傜偣宀椾綅璧勬簮 + /// </summary> + /// <param name="nodePost"></param> + /// <returns></returns> + public async Task<ApiAction> SaveWoRouteNodePost(List<MES_WO_NODE_POST> nodePost) + { + var result = new ApiAction(); + try + { + var db = Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(nodePost) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"淇濆瓨宸ュ崟宸ヨ壓鑺傜偣宀椾綅璧勬簮鏁版嵁寮傚父"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨宸ュ崟宸ヨ壓鑺傜偣宀椾綅璧勬簮鏁版嵁寮傚父"); + } + return await Task.FromResult(result); + } + #endregion + } //endClass Route + } //endClass Biz } -- Gitblit v1.9.3