| | |
| | | RouteData rotData = new RouteData(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(routerId)) |
| | | { |
| | | res.IsSuccessed = false; |
| | | res.LocaleMsg = new($"传入的工艺路线ID为空,不能查找工艺路线!"); |
| | | 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; |
| | | //节点 |
| | |
| | | }; |
| | | } |
| | | 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>() |
| | |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.Message = $"保存边数据异常"; |
| | | result.LocaleMsg = new($"保存边数据异常"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.Message = $"保存节点数据异常"; |
| | | result.LocaleMsg = new($"保存节点数据异常"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.Message = $"保存行为数据异常"; |
| | | result.LocaleMsg = new($"保存行为数据异常"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | /// <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(); |
| | |
| | | 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) |