From 0ac2d4112295d2d4ef9ca7502af509c2b165f337 Mon Sep 17 00:00:00 2001 From: 海波 张 <2956280567@qq.com> Date: 星期一, 23 六月 2025 17:31:15 +0800 Subject: [PATCH] 金坛修改 --- wms/TaskHelper.cs | 366 +++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 265 insertions(+), 101 deletions(-) diff --git a/wms/TaskHelper.cs b/wms/TaskHelper.cs index 57a8127..05a3184 100644 --- a/wms/TaskHelper.cs +++ b/wms/TaskHelper.cs @@ -58,6 +58,13 @@ } + internal static WmsWork GetWmsWork(string no) { + var db = new SqlHelper<WmsWork>().GetInstance(); + return db.Queryable<WmsWork>().Where(it => it.S_CODE == no).First(); + } + + + internal static WMSTask GetTaskByCntrCode(string cntrCode) { var db = new SqlHelper<WMSTask>().GetInstance(); @@ -212,6 +219,7 @@ CreateOneTask(operation); break; case 7: + //鍑哄簱涓ゆ浠诲姟 CreateOutTowTask(operation); break; case 9: @@ -430,107 +438,115 @@ var ConnectionLoc = LocationHelper.GetLocOne(operation.CONNECTION); - - // 浠诲姟1 - var task1 = new WMSTask() + var count = LocationHelper.GetConnectionTaskCount(operation.CONNECTION); + LogHelper.Info($"CreateOneTask 浣滀笟:{operation.S_CODE},鎺ラ┏浣�{operation.CONNECTION}锛屼换鍔℃暟閲忥細{count}", "浠诲姟"); + if (count<4) { - // 浣滀笟缂栫爜 - S_OP_CODE = operation.S_CODE, - // 浠诲姟鍙�- S_CODE = operation.S_CODE + "_1", - // 浠诲姟绫诲瀷 - N_TYPE = operation.N_TYPE, - // 浠诲姟绫诲瀷 - S_TYPE = operation.S_TYPE, - // 璧风偣璐т綅 - S_START_LOC = operation.S_START_LOC, - // 璧风偣搴撳尯 - S_START_AREA = operation.S_START_AREA, - // 缁堢偣璐т綅 - S_END_LOC = operation.CONNECTION, - // 缁堢偣搴撳尯 - S_END_AREA = ConnectionLoc.S_AREA_CODE, - // 璁惧绫诲瀷 - N_SCHEDULE_TYPE = 2, - // 璁惧绫诲瀷 - S_SCHEDULE_TYPE = "wcs", - // 瀹瑰櫒缂栫爜 - S_CNTR_CODE = operation.S_CNTR_CODE, - //浠诲姟鐘舵� - S_B_STATE = "鏈墽琛�, - // 浼樺厛绾�- N_PRIORITY = operation.N_PRIORITY, - //宸ヨ绫诲瀷 - TOOLSTYPE = operation.TOOLSTYPE, - //璧风偣搴撳尯鍚嶇О - S_START_AREA_NAME = operation.S_START_AREA_NAME, - //缁堢偣搴撳尯鍚嶇О - S_END_AREA_NAME = operation.CONNECTION_AREA, - }; - // 浠诲姟2 - var task2 = new WMSTask() - { - // 浣滀笟缂栫爜 - S_OP_CODE = operation.S_CODE, - // 浠诲姟鍙�- S_CODE = operation.S_CODE + "_2", - // 浠诲姟绫诲瀷 - N_TYPE = operation.N_TYPE, - // 浠诲姟绫诲瀷 - S_TYPE = operation.S_TYPE, - // 璧风偣璐т綅 - S_START_LOC = operation.CONNECTION, - // 璧风偣搴撳尯 - S_START_AREA = ConnectionLoc.S_AREA_CODE, - // 缁堢偣璐т綅 - S_END_LOC = operation.S_END_LOC, - // 缁堢偣搴撳尯 - S_END_AREA = operation.S_END_AREA, - // 璁惧绫诲瀷 - N_SCHEDULE_TYPE = 3, - // 璁惧绫诲瀷 - S_SCHEDULE_TYPE = "agv", - // 瀹瑰櫒缂栫爜 - S_CNTR_CODE = operation.S_CNTR_CODE, - //浠诲姟鐘舵� - S_B_STATE = "鏈墽琛�, - // 浼樺厛绾�- N_PRIORITY = operation.N_PRIORITY, - //宸ヨ绫诲瀷 - TOOLSTYPE = operation.TOOLSTYPE, - //璧风偣搴撳尯鍚嶇О - S_START_AREA_NAME = operation.CONNECTION_AREA, - //缁堢偣搴撳尯鍚嶇О - S_END_AREA_NAME = operation.S_END_AREA_NAME, - }; - - try - { - // 淇敼浣滀笟鐘舵�涓烘墽琛屼腑 - operation.N_B_STATE = 1; - operation.S_B_STATE = "鎵ц"; - - if (CreateTask(task1) && CreateTask(task2)) + // 浠诲姟1 + var task1 = new WMSTask() { - LocationHelper.LockLoc(operation.S_START_LOC, "鍑哄簱閿�, 2); - LocationHelper.LockLoc(operation.S_END_LOC, "鍏ュ簱閿�, 1); - LocationHelper.LockLoc(operation.CONNECTION, "鍏ュ簱閿�, 1); - LogHelper.Info($"浠诲姟{task1.S_CODE},{task2.S_CODE}鍒涘缓鎴愬姛", "浠诲姟"); - var db = new SqlHelper<object>().GetInstance(); - db.Updateable(operation).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand(); - } - else - { - LogHelper.Info($"浠诲姟{task1.S_CODE},{task2.S_CODE}鍒涘缓澶辫触", "浠诲姟"); - } + // 浣滀笟缂栫爜 + S_OP_CODE = operation.S_CODE, + // 浠诲姟鍙�+ S_CODE = operation.S_CODE + "_1", + // 浠诲姟绫诲瀷 + N_TYPE = operation.N_TYPE, + // 浠诲姟绫诲瀷 + S_TYPE = operation.S_TYPE, + // 璧风偣璐т綅 + S_START_LOC = operation.S_START_LOC, + // 璧风偣搴撳尯 + S_START_AREA = operation.S_START_AREA, + // 缁堢偣璐т綅 + S_END_LOC = operation.CONNECTION, + // 缁堢偣搴撳尯 + S_END_AREA = ConnectionLoc.S_AREA_CODE, + // 璁惧绫诲瀷 + N_SCHEDULE_TYPE = 2, + // 璁惧绫诲瀷 + S_SCHEDULE_TYPE = "wcs", + // 瀹瑰櫒缂栫爜 + S_CNTR_CODE = operation.S_CNTR_CODE, + //浠诲姟鐘舵� + S_B_STATE = "鏈墽琛�, + // 浼樺厛绾�+ N_PRIORITY = operation.N_PRIORITY, + //宸ヨ绫诲瀷 + TOOLSTYPE = operation.TOOLSTYPE, + //璧风偣搴撳尯鍚嶇О + S_START_AREA_NAME = operation.S_START_AREA_NAME, + //缁堢偣搴撳尯鍚嶇О + S_END_AREA_NAME = operation.CONNECTION_AREA, + }; + // 浠诲姟2 + var task2 = new WMSTask() + { + // 浣滀笟缂栫爜 + S_OP_CODE = operation.S_CODE, + // 浠诲姟鍙�+ S_CODE = operation.S_CODE + "_2", + // 浠诲姟绫诲瀷 + N_TYPE = operation.N_TYPE, + // 浠诲姟绫诲瀷 + S_TYPE = operation.S_TYPE, + // 璧风偣璐т綅 + S_START_LOC = operation.CONNECTION, + // 璧风偣搴撳尯 + S_START_AREA = ConnectionLoc.S_AREA_CODE, + // 缁堢偣璐т綅 + S_END_LOC = operation.S_END_LOC, + // 缁堢偣搴撳尯 + S_END_AREA = operation.S_END_AREA, + // 璁惧绫诲瀷 + N_SCHEDULE_TYPE = 3, + // 璁惧绫诲瀷 + S_SCHEDULE_TYPE = "agv", + // 瀹瑰櫒缂栫爜 + S_CNTR_CODE = operation.S_CNTR_CODE, + //浠诲姟鐘舵� + S_B_STATE = "鏈墽琛�, + // 浼樺厛绾�+ N_PRIORITY = operation.N_PRIORITY, + //宸ヨ绫诲瀷 + TOOLSTYPE = operation.TOOLSTYPE, + //璧风偣搴撳尯鍚嶇О + S_START_AREA_NAME = operation.CONNECTION_AREA, + //缁堢偣搴撳尯鍚嶇О + S_END_AREA_NAME = operation.S_END_AREA_NAME, + }; + + try + { + // 淇敼浣滀笟鐘舵�涓烘墽琛屼腑 + operation.N_B_STATE = 1; + operation.S_B_STATE = "鎵ц"; + + if (CreateTask(task1) && CreateTask(task2)) + { + LocationHelper.LockLoc(operation.S_START_LOC, "鍑哄簱閿�, 2); + LocationHelper.LockLoc(operation.S_END_LOC, "鍏ュ簱閿�, 1); + LocationHelper.LockLoc(operation.CONNECTION, "鍏ュ簱閿�, 1); + LogHelper.Info($"浠诲姟{task1.S_CODE},{task2.S_CODE}鍒涘缓鎴愬姛", "浠诲姟"); + var db = new SqlHelper<object>().GetInstance(); + db.Updateable(operation).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand(); + } + else + { + LogHelper.Info($"浠诲姟{task1.S_CODE},{task2.S_CODE}鍒涘缓澶辫触", "浠诲姟"); + } + + } + catch (Exception e) + { + LogHelper.Info("CreateOneTask寮傚父淇℃伅" + e.Message, "浠诲姟"); + throw; + } } - catch (Exception e) - { - LogHelper.Info("CreateOneTask寮傚父淇℃伅" + e.Message, "浠诲姟"); - throw; - } + + + } @@ -552,6 +568,7 @@ var db = new SqlHelper<WmsTaskAction>().GetInstance(); var action = new WmsTaskAction() { S_ACTION = state.ToString(), + N_ACTION_CODE = state, S_TASK_CODE = no, S_EQ_CODE = forkliftNo, S_EQ_TYPE = "agv", @@ -596,6 +613,7 @@ var action = new WmsTaskAction() { S_ACTION = state.ToString(), + N_ACTION_CODE = int.Parse(state), S_TASK_CODE = no, S_EQ_CODE = forkliftNo, S_EQ_TYPE = "wcs", @@ -713,12 +731,12 @@ if (task.S_TYPE.Contains("鍑哄簱") && task.S_SCHEDULE_TYPE.Contains("wcs")) { LocationHelper.LockLoc(task.S_END_LOC, "鍑哄簱閿�, 2); } - - if (task.S_TYPE.Contains("鍑哄簱")&&task.S_SCHEDULE_TYPE.Contains("agv") ) + + if (task.S_TYPE.Contains("鍑哄簱") && task.S_SCHEDULE_TYPE.Contains("agv")) { var location = db.Queryable<Location>().Where(a => a.S_CODE == task.S_END_LOC).First(); location.N_CURRENT_NUM = 0; - db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM}).ExecuteCommand(); + db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM }).ExecuteCommand(); db.Deleteable<Container>().Where(it => it.S_CODE == task.S_CNTR_CODE).ExecuteCommand(); db.Deleteable<LocCntrRel>().Where(it => it.S_CNTR_CODE == task.S_CNTR_CODE).ExecuteCommand(); db.Deleteable<CntrItemRel>().Where(it => it.S_CNTR_CODE == task.S_CNTR_CODE).ExecuteCommand(); @@ -853,6 +871,79 @@ } + /// <summary> + /// 鏍规嵁浠诲姟鐘舵�鍜岃捣鐐瑰拰绫诲瀷鏌ユ壘浠诲姟 + /// </summary> + /// <param name="state"></param> + /// <returns></returns> + internal static WMSTask GetTaskByType(string start,string type,string state) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + return db.Queryable<WMSTask>().Where(a => a.S_B_STATE.Trim() == state && a.S_TYPE.Contains(type) && a.S_START_LOC.Contains(start)).First(); + } + catch (Exception ex) + { + LogHelper.Error(ex.Message, ex); + return new WMSTask(); + } + + } + + + + /// <summary> + /// 鏍规嵁浣滀笟缂栫爜鍜岃澶囩被鍨嬭幏鍙栧崟涓换鍔�+ /// </summary> + /// <param name="state"></param> + /// <returns></returns> + internal static WMSTask GetTaskByWork(string eq, string opCode) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + return db.Queryable<WMSTask>().Where(a => a.S_SCHEDULE_TYPE.Contains(eq) && a.S_OP_CODE.Contains(opCode)).First(); + } + catch (Exception ex) + { + LogHelper.Error(ex.Message, ex); + return new WMSTask(); + } + + } + + /// <summary> + /// 杩斿洖褰撳墠鎺ラ┏浣嶆墽琛屼腑浠诲姟鏁伴噺 + /// </summary> + internal static int GetConnectionTask(string Connection) + { + var db = new SqlHelper<object>().GetInstance(); + + + var ConnectionList = 0; + ConnectionList = db.Queryable<WMSTask>().Where(a => a.S_END_LOC.Contains(Connection) && a.S_TYPE.Contains("鍑哄簱") && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷" && a.S_B_STATE != "鏈墽琛�).ToList().Count(); + + return ConnectionList; + } + + + //internal static bool CreateAgvState(AgvState agvState) + //{ + // try + // { + // var db = new SqlHelper<object>().GetInstance(); + + // return db.Insertable<AgvState>(agvState).ExecuteCommand() > 0; + // } + // catch (Exception ex) + // { + // LogHelper.Info($"娣诲姞Agv鍔ㄤ綔缂撳瓨寮傚父" + ex.Message, "NDC"); + // throw; + // } + //} + + internal static bool CreateMesKtTask(MesKtTask cntr) { try @@ -863,12 +954,85 @@ } catch (Exception ex) { - Console.WriteLine(ex.Message); LogHelper.Info($"娣诲姞Mes绌烘墭缂撳瓨寮傚父" + ex.Message, "Mes浠诲姟涓嬪彂"); throw; } } - + internal static MesKtTask GetMesKtTask(string end) + { + + var db = new SqlHelper<object>().GetInstance(); + + return db.Queryable<MesKtTask>().Where(a => a.Location_To==end && a.Status=="N").First(); + } + + internal static bool ChangeMesKtTask(MesKtTask kt) + { + + var db = new SqlHelper<object>().GetInstance(); + kt.Status = "Y"; + return db.Updateable(kt).UpdateColumns(it => new { + it.Status + }).ExecuteCommand()>0; + + + } + + internal static List<UnlimitedLoc> GetMesKtLoc() + { + + var db = new SqlHelper<object>().GetInstance(); + + return db.Queryable<UnlimitedLoc>().Where(a=>a.Enable=="Y").ToList(); + } + + + /// <summary> + /// 鑾峰彇鍏ュ簱浼樺厛绾ц〃 + /// </summary> + /// <returns></returns> + internal static List<InPri> GetInPri() + { + + var db = new SqlHelper<object>().GetInstance(); + + return db.Queryable<InPri>().Where(a=>a.Enable=="Y") .ToList(); + } + + + /// <summary> + /// 娣诲姞agv鍔ㄤ綔缂撳瓨 + /// </summary> + /// <param name="agv"></param> + /// <returns></returns> + internal static bool CreateAgvActionState(AgvActionState agv) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + return db.Insertable<AgvActionState>(agv).ExecuteCommand() > 0; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + throw; + } + } + + + /// <summary> + /// 鑾峰彇agv鍔ㄤ綔 + /// </summary> + /// <returns></returns> + internal static List<AgvActionState> GetAgvActionState( string taskNo) + { + + var db = new SqlHelper<object>().GetInstance(); + + return db.Queryable<AgvActionState>().Where(a => a.task_no==taskNo).ToList(); + } + + } } -- Gitblit v1.9.1