From ce391a05c48f91ed1f43faabb93eb472395af9d7 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 01 五月 2024 14:24:26 +0800 Subject: [PATCH] 工艺路线更新 --- Tiger.Business/MES/Biz.Route.cs | 72 ++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 23 deletions(-) diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs index 77ab922..b397e91 100644 --- a/Tiger.Business/MES/Biz.Route.cs +++ b/Tiger.Business/MES/Biz.Route.cs @@ -56,9 +56,15 @@ RouteData rotData = new RouteData(); try { + if (string.IsNullOrEmpty(routerId)) + { + res.IsSuccessed = false; + res.LocaleMsg = new($"浼犲叆鐨勫伐鑹鸿矾绾縄D涓虹┖锛屼笉鑳芥煡鎵惧伐鑹鸿矾绾匡紒"); + return res; + } //宸ヨ壓璺嚎 var route = await Db.Queryable<MES_ROUTE>() - .WhereIF(!string.IsNullOrEmpty(routerId), x => x.ROT_CODE.Equals(routerId)) + .WhereIF(!string.IsNullOrEmpty(routerId), x => x.ID.Equals(routerId)) .OrderBy(x => x.CREATE_TIME).FirstAsync(); rotData.route = route; //鑺傜偣 @@ -83,6 +89,28 @@ }; } rotData.nodes = nodes; + + var acts = await Db.Queryable<MES_ROUTE_NODE_ACT>() + .WhereIF(!string.IsNullOrEmpty(routerId), x => x.ROT_ID.Equals(routerId)) + .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_ROUTE_EDGE>() @@ -152,7 +180,7 @@ if (!dbTran.IsSuccess) { result.IsSuccessed = false; - result.Message = $"淇濆瓨杈规暟鎹紓甯�"; + result.LocaleMsg = new($"淇濆瓨杈规暟鎹紓甯�"); } } catch (Exception ex) @@ -184,7 +212,7 @@ if (!dbTran.IsSuccess) { result.IsSuccessed = false; - result.Message = $"淇濆瓨鑺傜偣鏁版嵁寮傚父"; + result.LocaleMsg = new($"淇濆瓨鑺傜偣鏁版嵁寮傚父"); } } catch (Exception ex) @@ -216,7 +244,7 @@ if (!dbTran.IsSuccess) { result.IsSuccessed = false; - result.Message = $"淇濆瓨琛屼负鏁版嵁寮傚父"; + result.LocaleMsg = new($"淇濆瓨琛屼负鏁版嵁寮傚父"); } } catch (Exception ex) @@ -229,17 +257,24 @@ /// <summary> /// 淇濆瓨 /// </summary> - /// <param name="router"></param> + /// <param name="route"></param> /// <returns></returns> - public async Task<ApiAction> SaveRoute(MES_ROUTE router) + public async Task<ApiAction> SaveRoute(MES_ROUTE route) { 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()) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夎璁¤褰曪紝涓嶈兘淇濆瓨锛�"); + return result; + } var db = Db; var dbTran = db.UseTran(() => { - var y = db.Storageable(router) + var y = db.Storageable(route) .WhereColumns(t => new { t.ROT_CODE, t.GHOST_ROW }) .ToStorage(); y.AsInsertable.ExecuteCommand(); @@ -279,35 +314,26 @@ y.AsInsertable.ExecuteCommand(); y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); } + 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(); if (routeData.nodes != null) { - var y = db.Storageable(routeData.nodes) - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); + db.Insertable(routeData.nodes).ExecuteCommand(); } if (routeData.edges != null) { - var y = db.Storageable(routeData.edges) - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); + db.Insertable(routeData.edges).ExecuteCommand(); } if (routeData.acts != null) { - var y = db.Storageable(routeData.acts) - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); + db.Insertable(routeData.acts).ExecuteCommand(); } }); if (!dbTran.IsSuccess) { result.IsSuccessed = false; - result.Message = $"淇濆瓨宸ヨ壓璺嚎鍥惧舰鏁版嵁寮傚父"; + result.LocaleMsg = new($"淇濆瓨宸ヨ壓璺嚎鍥惧舰鏁版嵁寮傚父"); } } catch (Exception ex) -- Gitblit v1.9.3