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 ++++++++++++++++++++++++++++- Tiger.IBusiness/MES/IRoute.cs | 3 Tiger.Model.Net/Entitys/MES/V_MES_WO_NODE_POST.cs | 71 ++++++++ Tiger.Model.Net/Entitys/MES/MES_WO_EDGE.cs | 31 ++- Tiger.Api/Controllers/MES/MESController.Route.cs | 63 +++++++ Tiger.Model.Net/Entitys/MES/MES_WO_NODE.cs | 5 Tiger.Model.Net/Entitys/MES/MES_ROUTE.cs | 38 +++- Tiger.Model.Net/Entitys/MES/MES_WO_NODE_ACT.cs | 5 Tiger.Model.Net/Tiger.Model.Net.csproj | 1 9 files changed, 424 insertions(+), 32 deletions(-) diff --git a/Tiger.Api/Controllers/MES/MESController.Route.cs b/Tiger.Api/Controllers/MES/MESController.Route.cs index 55edb33..f1030aa 100644 --- a/Tiger.Api/Controllers/MES/MESController.Route.cs +++ b/Tiger.Api/Controllers/MES/MESController.Route.cs @@ -160,6 +160,69 @@ } /// <summary> + /// 淇濆瓨宸ュ崟宸ヨ壓鑺傜偣宀椾綅璧勬簮 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> SaveWoRouteNodePost([FromBody] ApiAction<List<MES_WO_NODE_POST>> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IRoute>().SaveWoRouteNodePost(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + + /// <summary> + /// 淇濆瓨宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> SaveWoRouteData([FromBody] ApiAction<WoRouteData> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IRoute>().SaveWoRouteData(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + + /// <summary> + /// 鑾峰彇宸ュ崟宸ヨ壓璺嚎鍥惧舰鏁版嵁 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> GetWoRouteData([FromBody] ApiAction action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IRoute>().GetWoRouteData(action.Data?.ToString())); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + + /// <summary> /// 鍒犻櫎宸ュ崟缁戝畾鐨勫伐鑹鸿矾绾� /// </summary> /// <param name="action"></param> 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 } diff --git a/Tiger.IBusiness/MES/IRoute.cs b/Tiger.IBusiness/MES/IRoute.cs index cc95ac5..718c9c0 100644 --- a/Tiger.IBusiness/MES/IRoute.cs +++ b/Tiger.IBusiness/MES/IRoute.cs @@ -22,5 +22,8 @@ public Task<ApiAction> SaveRouteNodePost(List<MES_ROUTE_NODE_POST> nodePost); public Task<ApiAction> DeleteProdRoute(DelProdRotInput input); public Task<ApiAction> DeleteWoRoute(DelWoRotInput input); + public Task<ApiAction<WoRouteData>> GetWoRouteData(string workorder); + public Task<ApiAction> SaveWoRouteNodePost(List<MES_WO_NODE_POST> nodePost); + public Task<ApiAction> SaveWoRouteData(WoRouteData routeData); } } diff --git a/Tiger.Model.Net/Entitys/MES/MES_ROUTE.cs b/Tiger.Model.Net/Entitys/MES/MES_ROUTE.cs index 4031f2b..b268176 100644 --- a/Tiger.Model.Net/Entitys/MES/MES_ROUTE.cs +++ b/Tiger.Model.Net/Entitys/MES/MES_ROUTE.cs @@ -46,17 +46,23 @@ /// 备注 /// </summary> public string REMARK { get; set; } - #endregion + #endregion - #region 虚拟属性 - /*例子 + #region 虚拟属性 + /*例子 [SugarColumn(IsIgnore = true)] public string FieldName { get; set; } */ - #endregion + [SugarColumn(IsIgnore = true)] + public string WORK_ORDER { get; set; } + [SugarColumn(IsIgnore = true)] + public string PROD_CODE { get; set; } + [SugarColumn(IsIgnore = true)] + public string CUST_CODE { get; set; } + #endregion - #region 外键属性 - /*例子 + #region 外键属性 + /*例子 //一对一外键导航 [Navigate(NavigateType.OneToOne, nameof(ClassAId))]//一对一 ClassAId是MES_ROUTE类里面的外键ID字段 public ClassA ClassA { get; set; } //注意禁止手动赋值,只能是null @@ -67,10 +73,10 @@ [Navigate(typeof(MappingClass), nameof(MappingClass.MES_ROUTEId), nameof(MappingClass.ClassAId))]//注意顺序 public List<ClassA> ClassAList { get; set; } //注意禁止手动赋值,只能是null */ - #endregion + #endregion - #region 枚举变量 - /*例子 + #region 枚举变量 + /*例子 public enum FieldNames { [Description("枚举描述0")] @@ -94,6 +100,9 @@ }//endClass + /// <summary> + /// 标准工艺路线图实体 + /// </summary> public class RouteData { public MES_ROUTE route { get; set; } @@ -101,4 +110,15 @@ public List<MES_ROUTE_EDGE> edges { get; set; } public List<MES_ROUTE_NODE_ACT> acts { get; set; } } + + /// <summary> + /// 工单工艺路线图实体 + /// </summary> + public class WoRouteData + { + public MES_ROUTE route { get; set; } + public List<MES_WO_NODE> nodes { get; set; } + public List<MES_WO_EDGE> edges { get; set; } + public List<MES_WO_NODE_ACT> acts { get; set; } + } } \ No newline at end of file diff --git a/Tiger.Model.Net/Entitys/MES/MES_WO_EDGE.cs b/Tiger.Model.Net/Entitys/MES/MES_WO_EDGE.cs index 371a625..a1e1db1 100644 --- a/Tiger.Model.Net/Entitys/MES/MES_WO_EDGE.cs +++ b/Tiger.Model.Net/Entitys/MES/MES_WO_EDGE.cs @@ -123,17 +123,22 @@ /// </summary> [DisplayName("备注")] public string REMARK { get; set; } - #endregion + #endregion - #region 虚拟属性 - /*例子 + #region 虚拟属性 + /*例子 [SugarColumn(IsIgnore = true)] public string FieldName { get; set; } */ - #endregion + /// <summary> + /// 边 + /// </summary> + [SugarColumn(IsIgnore = true)] + public edge edge { get; set; } + #endregion - #region 外键属性 - /*例子 + #region 外键属性 + /*例子 //一对一外键导航 [Navigate(NavigateType.OneToOne, nameof(ClassAId))]//一对一 ClassAId是MES_WO_EDGE类里面的外键ID字段 public ClassA ClassA { get; set; } //注意禁止手动赋值,只能是null @@ -144,10 +149,10 @@ [Navigate(typeof(MappingClass), nameof(MappingClass.MES_WO_EDGEId), nameof(MappingClass.ClassAId))]//注意顺序 public List<ClassA> ClassAList { get; set; } //注意禁止手动赋值,只能是null */ - #endregion + #endregion - #region 枚举变量 - /*例子 + #region 枚举变量 + /*例子 public enum FieldNames { [Description("枚举描述0")] @@ -156,11 +161,11 @@ Enum1, } */ - #endregion + #endregion - #region 公共方法 + #region 公共方法 - #endregion + #endregion - }//endClass + }//endClass } \ No newline at end of file diff --git a/Tiger.Model.Net/Entitys/MES/MES_WO_NODE.cs b/Tiger.Model.Net/Entitys/MES/MES_WO_NODE.cs index 1f7afce..b5295c6 100644 --- a/Tiger.Model.Net/Entitys/MES/MES_WO_NODE.cs +++ b/Tiger.Model.Net/Entitys/MES/MES_WO_NODE.cs @@ -154,6 +154,11 @@ public int Sequence { get; set; } [SugarColumn(IsIgnore = true)] public List<string> PrepNodeIDs { get; set; } = new List<string>(); + /// <summary> + /// 鑺傜偣 + /// </summary> + [SugarColumn(IsIgnore = true)] + public node node { get; set; } #endregion #region 澶栭敭灞炴�� diff --git a/Tiger.Model.Net/Entitys/MES/MES_WO_NODE_ACT.cs b/Tiger.Model.Net/Entitys/MES/MES_WO_NODE_ACT.cs index 3c82390..8f7b557 100644 --- a/Tiger.Model.Net/Entitys/MES/MES_WO_NODE_ACT.cs +++ b/Tiger.Model.Net/Entitys/MES/MES_WO_NODE_ACT.cs @@ -140,6 +140,11 @@ [SugarColumn(IsIgnore = true)] public string FieldName { get; set; } */ + /// <summary> + /// 鑺傜偣 + /// </summary> + [SugarColumn(IsIgnore = true)] + public node node { get; set; } #endregion #region 澶栭敭灞炴�� diff --git a/Tiger.Model.Net/Entitys/MES/V_MES_WO_NODE_POST.cs b/Tiger.Model.Net/Entitys/MES/V_MES_WO_NODE_POST.cs new file mode 100644 index 0000000..88f1785 --- /dev/null +++ b/Tiger.Model.Net/Entitys/MES/V_MES_WO_NODE_POST.cs @@ -0,0 +1,71 @@ +using System; +using SqlSugar; +using System.Linq; +using System.ComponentModel; +using System.Collections.Generic; +using Tiger.Model; + +namespace Tiger.Model +{ + /// <summary> + /// 实体:V_MES_WO_NODE_POST + /// </summary> + [Serializable] + [SugarTable("V_MES_WO_NODE_POST")] + public class V_MES_WO_NODE_POST : iViewEntity + { + #region 构造函数 + /// <summary> + /// 实体:V_MES_WO_NODE_POST + /// </summary> + public V_MES_WO_NODE_POST() {} + #endregion + + #region 公共属性 + /// <summary> + /// + /// </summary> + public string NODE_ID { get; set; } + /// <summary> + /// + /// </summary> + public string POST_CODE { get; set; } + /// <summary> + /// + /// </summary> + public string POST_NAME { get; set; } + /// <summary> + /// + /// </summary> + public string LINE_CODE { get; set; } + /// <summary> + /// + /// </summary> + public string OPER_CODE { get; set; } + #endregion + + #region 虚拟属性 + /*例子 + [SugarColumn(IsIgnore = true)] + public string FieldName { get; set; } + */ + #endregion + + #region 枚举变量 + /*例子 + public enum FieldNames + { + [Description("枚举描述0")] + Enum0, + [Description("枚举描述1")] + Enum1, + } + */ + #endregion + + #region 公共方法 + + #endregion + + }//endClass +} \ No newline at end of file diff --git a/Tiger.Model.Net/Tiger.Model.Net.csproj b/Tiger.Model.Net/Tiger.Model.Net.csproj index ec6ce45..069431d 100644 --- a/Tiger.Model.Net/Tiger.Model.Net.csproj +++ b/Tiger.Model.Net/Tiger.Model.Net.csproj @@ -179,6 +179,7 @@ <Compile Include="Entitys\MES\V_MES_ROUTE_NOE_POST.cs" /> <Compile Include="Entitys\MES\V_MES_ROUTE_PTREE.cs" /> <Compile Include="Entitys\MES\V_MES_WO_BATCH.cs" /> + <Compile Include="Entitys\MES\V_MES_WO_NODE_POST.cs" /> <Compile Include="Entitys\MES\V_MES_WO_PTREE.cs" /> <Compile Include="Entitys\MES\V_SMT_TOOL.cs" /> <Compile Include="Entitys\MES\SMT_TOOL.cs" /> -- Gitblit v1.9.3