From 99004292e20a9e1efa4e3b11b8c319bfd796912c Mon Sep 17 00:00:00 2001 From: cjs <2216046164@qq.com> Date: 星期一, 14 七月 2025 17:24:30 +0800 Subject: [PATCH] 111 --- HH.WCS.Mobox3.NongFuLinZhi/core/Monitor.cs | 142 +++++++++++++++++++++++++++++++---------------- 1 files changed, 94 insertions(+), 48 deletions(-) diff --git a/HH.WCS.Mobox3.NongFuLinZhi/core/Monitor.cs b/HH.WCS.Mobox3.NongFuLinZhi/core/Monitor.cs index 45008d6..76b0b40 100644 --- a/HH.WCS.Mobox3.NongFuLinZhi/core/Monitor.cs +++ b/HH.WCS.Mobox3.NongFuLinZhi/core/Monitor.cs @@ -2,6 +2,7 @@ using HH.WCS.Mobox3.NFLZ.process; using HH.WCS.Mobox3.NFLZ.util; using HH.WCS.Mobox3.NFLZ.wms; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Configuration; @@ -53,34 +54,8 @@ internal static void BottleBlankTransportation() { var db = new SqlHelper<object>().GetInstance(); - #region 鐡剁洊婊℃墭鍏ュ簱 - var areaInfo = Settings.areaInfos.Where(a => a.areaName == "鐡剁洊鍏ュ簱鎺ラ┏" && a.enable == 1).FirstOrDefault(); - if (areaInfo != null) - { - var locInfo = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM > 0 && a.S_LOCK_STATE == "鏃�).Includes(a => a.LocCntrRel).First(); - if (locInfo != null) - { - LogHelper.Info($"銆愮摱鐩栨弧鎵樿浆杩愩�鐡跺澂鎺ラ┏浣嶆煡璇㈠埌闇�叆搴撶殑鐡跺澂锛岃揣浣嶇紪鐮侊細{locInfo.S_CODE}"); - string cntrCode = getCntrCode(db, locInfo); - if (string.IsNullOrEmpty(cntrCode)) - { - //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(locInfo.S_CODE, "", "鍏ュ簱", "鎺ラ┏浣嶅叆搴�, cntrCode, "鐡剁洊"); - } - else - { - LogHelper.Info($"銆愮摱鐩栨弧鎵樿浆杩愩�褰撳墠璐т綅鏈粦瀹氭墭鐩樼爜锛岃揣浣嶇紪鐮侊細{locInfo.S_CODE}"); - } - } - } - else - { - LogHelper.Info("銆愮摱鐩栨弧鎵樿浆杩愩�鐡剁洊鍏ュ簱鎺ラ┏ 鏈厤缃�); - } - #endregion - #region 鐡剁洊绌烘墭鍏ュ簱 - areaInfo = Settings.areaInfos.Where(a => a.areaName == "鐡剁洊闈炲嵆浜х┖妗� && a.enable == 1).FirstOrDefault(); + var areaInfo = Settings.areaInfos.Where(a => a.areaName == "鐡剁洊闈炲嵆浜х┖妗� && a.enable == 1).FirstOrDefault(); if(areaInfo != null) { var locInfo = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM == a.N_CAPACITY && a.S_LOCK_STATE == "鏃�).First(); @@ -115,7 +90,7 @@ if (!string.IsNullOrEmpty(cntrCode)) { //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(locInfo.S_CODE, "", "鍏ュ簱", "鎺ラ┏浣嶅叆搴�, cntrCode, "鐡跺澂"); + WMSHelper.CreateOpTask(locInfo.S_CODE, "", "鍏ュ簱", "鐡跺澂鎺ラ┏浣嶅叆搴�, cntrCode, "鐡跺澂"); } else { @@ -231,7 +206,7 @@ { string cntrCode = getCntrCode(db, location); //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃", cntrCode, "鐡剁洊"); + WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃澶у寘瑁�, cntrCode, "鐡剁洊"); } } if (itemCount.Count == 2) @@ -277,7 +252,7 @@ { string cntrCode = getCntrCode(db, location); //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃", cntrCode, "鐡剁洊"); + WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃澶у寘瑁�, cntrCode, "鐡剁洊"); } } } @@ -288,7 +263,7 @@ { string cntrCode = getCntrCode(db, location); //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃", cntrCode, "鐡剁洊"); + WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡剁洊闈炴�浜цˉ婊℃澶у寘瑁�, cntrCode, "鐡剁洊"); } } } @@ -315,31 +290,40 @@ var areaInfo = Settings.areaInfos.Where(a => a.areaName == "鐡跺澂闈炲嵆浜х┖妗� && a.enable == 1).FirstOrDefault(); if (areaInfo != null) { - var LocList = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM == a.N_CAPACITY).ToList(); + var LocList = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM > 0).ToList(); if(LocList.Count <= 1) { - //闇�浠庡簱鍖鸿ˉ鍏呯┖鎵�- Location location = TaskProcess.FJCKTLoc(); - var locInfo = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM < a.N_CAPACITY && a.S_LOCK_STATE == "鏃�).First(); - if(location != null && locInfo != null) + var taskInfo = db.Queryable<WCSTask>().Where(a => a.S_TYPE == "鐡跺澂闈炴�浜цˉ绌烘" && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷").First(); + if(taskInfo == null) { - string cntrCode = getCntrCode(db, location); - //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡跺澂闈炴�浜цˉ绌烘", cntrCode, "鐡跺澂"); + //闇�浠庡簱鍖鸿ˉ鍏呯┖鎵�+ Location location = TaskProcess.FJCKTLoc(); + var locInfo = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM < a.N_CAPACITY && a.S_LOCK_STATE == "鏃�).OrderBy(a => a.N_ROW).First(); + if (location != null && locInfo != null) + { + string cntrCode = getCntrCode(db, location); + //鍒涘缓浣滀笟 + WMSHelper.CreateOpTask(location.S_CODE, locInfo.S_CODE, "鍏ュ簱", "鐡跺澂闈炴�浜цˉ绌烘", cntrCode, "鐡跺澂"); + } } } - if (LocList.Count >= 2) + LocList = db.Queryable<Location>().Where(a => a.S_AREA_CODE == areaInfo.areaCode && a.N_CURRENT_NUM == a.N_CAPACITY).ToList(); + if (LocList.Count > 2) { - //闇�灏嗙┖鎵樿浆杩愬埌搴撳尯 - foreach (var a in LocList) + var taskInfo = db.Queryable<WCSTask>().Where(a => a.S_TYPE == "鐡跺澂闈炴�浜х┖妗嗗叆搴� && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷" && a.S_B_STATE != "鍗歌揣瀹屾垚" && a.S_B_STATE != "寮�鍗歌揣" && a.S_B_STATE != "鍙栬揣瀹屾垚").First(); + if(taskInfo == null) { - if(a.S_LOCK_STATE == "鏃�) + //闇�灏嗙┖鎵樿浆杩愬埌搴撳尯 + foreach (var a in LocList) { - //鐢熸垚浠诲姟 - string cntrCode = getCntrCode(db, a); - //鍒涘缓浣滀笟 - WMSHelper.CreateOpTask(a.S_CODE, "", "鍏ュ簱", "鐡跺澂闈炴�浜х┖妗嗗叆搴�, cntrCode, "鐡跺澂"); - break; + if (a.S_LOCK_STATE == "鏃�) + { + //鐢熸垚浠诲姟 + string cntrCode = getCntrCode(db, a); + //鍒涘缓浣滀笟 + WMSHelper.CreateOpTask(a.S_CODE, "", "鍏ュ簱", "鐡跺澂闈炴�浜х┖妗嗗叆搴�, cntrCode, "鐡跺澂"); + break; + } } } } @@ -415,5 +399,67 @@ } } } + + /// <summary> + /// 鐡剁洊灏忓寘瑁呯洊杞繍 + /// </summary> + /// <exception cref="NotImplementedException"></exception> + internal static void PGXBZZY() + { + var db = new SqlHelper<object>().GetInstance(); + Location endLoca = null; + var workInfo = db.Queryable<LinZhiBCPWorkOrder>().Where(a => a.S_PLineNo.Contains("鐡剁洊") && a.S_ITEM_TYPE == "灏忓寘瑁呯洊" && a.S_WorkState == "鎵ц涓�).ToList(); + if(workInfo.Count > 0) + { + foreach(var it in workInfo) + { + LogHelper.Info($"鐡剁洊灏忓寘瑁呯洊杞繍锛�鏌ヨ浜х嚎鍙凤細{it.S_PLineNo},鐗╂枡缂栫爜锛歿it.S_ItemCode}"); + //鏌ヨ缁堢偣璐т綅 + string endAreaName = it.S_PLineNo.Split('-')[1].Substring(0, 1) + "鍙风摱鐩栫炕鏂楁満灏忓寘瑁�; + var areaInfo = Settings.areaInfos.Where(b => b.areaName == endAreaName && b.enable == 1).FirstOrDefault(); + if(areaInfo != null) + { + var taskInfo = db.Queryable<WCSTask>().Where(a => a.S_END_AREA == areaInfo.areaCode && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷").First(); + if(taskInfo != null) + { + //鎺у埗涓�釜搴撳尯鍙兘涓�涓�潯浠诲姟 + return; + } + + var locInfo = db.Queryable<Location>().Where(b => b.S_AREA_CODE == areaInfo.areaCode && b.N_CURRENT_NUM == 0).OrderBy(b => b.N_ROW).OrderBy(b => b.N_COL).Take(1).PartitionBy(b => b.N_ROW).ToList(); + if(locInfo.Count > 0) + { + foreach(var endloc in locInfo) + { + var rowInfo = db.Queryable<RowLock>().Where(a => a.S_AREA_CODE == endloc.S_AREA_CODE && a.S_ROW == endloc.S_ROW).First(); + LogHelper.Info($"鐡剁洊灏忓寘瑁呯洊杞繍锛氭煡璇㈤攣淇℃伅锛岃揣浣嶉攣锛歿endloc.S_LOCK_STATE},鎺掗攣锛歿JsonConvert.SerializeObject(rowInfo)}"); + if(rowInfo!=null && rowInfo.S_LOCK_STATE == "鏃� && endloc.S_LOCK_STATE == "鏃�) + { + endLoca = endloc; + break; + } + + } + } + } + else + { + LogHelper.Info($"{endAreaName} 鏈厤缃�); + } + + //鏌ヨ璧风偣璐т綅 + LogHelper.Info($"鐡剁洊灏忓寘瑁呯洊杞繍锛氳幏鍙栧埌缁堢偣璐т綅淇℃伅锛歿JsonConvert.SerializeObject(endLoca)}"); + if (endLoca != null) + { + Location startLoca = TaskProcess.BCPInOrOut(db,true,"鐡剁洊搴撳尯",it.S_ItemCode + it.S_ITEM_TYPE); + if (startLoca != null) + { + string cntrCode = getCntrCode(db, startLoca); + WMSHelper.CreateOpTask(startLoca.S_CODE, endLoca.S_CODE, "鍑哄簱", "鐡剁洊闈炴�浜цˉ婊℃灏忓寘瑁�, cntrCode, ""); + } + } + } + } + } } } -- Gitblit v1.9.1