From 1b6bf29ff7daa1987de65940af52f452cabd6881 Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期二, 15 七月 2025 17:27:50 +0800 Subject: [PATCH] 优化AGV任务部分日志、货位绑定内部方法 --- wms/LocationHelper.cs | 135 ++------------------------------------------- 1 files changed, 6 insertions(+), 129 deletions(-) diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs index 67fcff2..c31f32c 100644 --- a/wms/LocationHelper.cs +++ b/wms/LocationHelper.cs @@ -98,22 +98,6 @@ { site = Location.S_AGV_SITE; } - //if (Location.N_CURRENT_NUM == 1) - //{ - // site = Location.S_AGV_SITE2; - //} - //if (Location.N_CURRENT_NUM == 2) - //{ - // site = Location.S_AGV_SITE3; - //} - //if (Location.N_CURRENT_NUM == 3) - //{ - // site = Location.S_AGV_SITE4; - //} - //if (Location.N_CURRENT_NUM == 4) - //{ - // site = Location.S_AGV_SITE5; - //} } } } @@ -124,83 +108,6 @@ { var db = new SqlHelper<object>().GetInstance(); return db.Queryable<TN_Location>().Where(a => a.S_CODE.Trim() == code).First(); - } - - /// <summary> - /// 璧风偣鍑哄簱閿侊紙鍙兘瀵规棤閿佽揣浣嶄笂閿侊級 - /// </summary> - /// <param name="loc"></param> - /// <param name="lockSource"></param> - /// <returns></returns> - public static bool LockStartLoc(ref TN_Location loc, string lockSource = "") { - if (loc == null) { - LogHelper.Info($"璧风偣鍑哄簱閿侊細浼犲叆鐨勮揣浣嶅弬鏁颁负null"); - return false; - } - - if (loc.N_LOCK_STATE != 0 || loc.S_LOCK_STATE != "鏃�) { - LogHelper.Info($"璧风偣鍑哄簱閿侊細璐т綅褰撳墠宸叉湁閿�{loc.N_LOCK_STATE},{loc.S_LOCK_STATE})"); - return false; - } - - if (loc != null && loc.N_LOCK_STATE == 0) { - loc.N_LOCK_STATE = 2; // 璧风偣鍑哄簱閿�- loc.S_LOCK_STATE = TN_Location.GetLockStateStr(2); // 璧风偣鍑哄簱閿�- loc.S_LOCK_OP = lockSource; - loc.T_MODIFY = System.DateTime.Now; - } - - return true; - } - - /// <summary> - /// 缁堢偣鍏ュ簱閿侊紙鍙兘瀵规棤閿佽揣浣嶄笂閿侊級 - /// </summary> - /// <param name="loc"></param> - /// <param name="lockSource"></param> - /// <returns></returns> - public static bool LockEndLoc(ref TN_Location loc, string lockSource = "") { - if (loc == null) { - LogHelper.Info($"缁堢偣鍏ュ簱閿侊細浼犲叆鐨勮揣浣嶅弬鏁颁负null"); - return false; - } - - if (loc.N_LOCK_STATE != 0 || loc.S_LOCK_STATE != "鏃�) { - LogHelper.Info($"缁堢偣鍏ュ簱閿侊細璐т綅褰撳墠宸叉湁閿�{loc.N_LOCK_STATE},{loc.S_LOCK_STATE})"); - return false; - } - - if (loc != null && loc.N_LOCK_STATE == 0) { - loc.N_LOCK_STATE = 1; // 缁堢偣鍑哄簱閿�- loc.S_LOCK_STATE = TN_Location.GetLockStateStr(1); // 缁堢偣鍑哄簱閿�- loc.S_LOCK_OP = lockSource; - loc.T_MODIFY = System.DateTime.Now; - } - - return true; - } - - /// <summary> - /// 鏋勫缓璐т綅鏌ヨ琛ㄨ揪寮忥細褰撳墠鏁伴噺銆佽揣鍖恒�鍚嶇О - /// </summary> - /// <param name="db"></param> - /// <param name="nCurrentNum"></param> - /// <param name="areas"></param> - /// <param name="name"></param> - /// <returns></returns> - public static ISugarQueryable<TN_Location> GetLocQuery(SqlSugarClient db, int nCurrentNum = 0, List<string> areas = null, string name = null) { - var query = db.Queryable<TN_Location>() - .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "鏃� && l.C_ENABLE == "Y" && l.N_CURRENT_NUM == nCurrentNum); - - if (areas != null && !areas.Any()) { - query = query.Where(l => areas.Contains(l.S_AREA_CODE)); - } - - if (!string.IsNullOrEmpty(name)) { - query = query.Where(l => l.S_CODE == name); - } - - return query; } /// <summary> @@ -257,30 +164,8 @@ location.S_LOCK_STATE = "鏃�; location.N_LOCK_STATE = 0; - //var containerList = new List<TN_Container>(); - //foreach (var item in lcrList) { - // // 閽堝瀹瑰櫒绫诲瀷娣诲姞鐨勬柊閫昏緫 - // var cntr = db.Queryable<TN_Container>() - // .Where(c => c.S_CODE == item.S_CNTR_CODE).First(); - // if (cntr == null) { - // LogHelper.Info($"璐т綅瑙g粦鏃讹紝瀹瑰櫒{item.S_CNTR_CODE}娌℃湁鍦ㄥ鍣ㄤ俊鎭〃涓煡鍒帮紝杩欓噷鏍规嵁璐т綅瀹瑰櫒鍏崇郴娣诲姞"); - // containerList.Add(new TN_Container { - // S_CODE = item.S_CNTR_CODE, - // S_TYPE = item.S_CNTR_TYPE, - // }); - // } - //} - using (var tran = db.Ado.UseTran()) { - //if (containerList.Count > 0) { - // if (db.Insertable<TN_Container>(containerList).ExecuteCommand() <= 0) { - // LogHelper.Info($"鎻掑叆瀹瑰櫒淇℃伅琛ㄥけ璐� + JsonConvert.SerializeObject(containerList)); - // tran.RollbackTran(); - // return "璐т綅瑙g粦瀹瑰櫒澶辫触锛� + logs; - // } - //} - if (db.Deleteable<TN_Loc_Container>().Where(it => cntrs.Contains(it.S_CNTR_CODE) && it.S_LOC_CODE == loc).ExecuteCommand() > 0) { LogHelper.Info($"鍒犻櫎璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}"); @@ -336,20 +221,16 @@ var logs = $"璐т綅锛歿loc}锛屽鍣細{JsonConvert.SerializeObject(cntrs)}"; try { + // 鍒犻櫎宸茬粡缁戝畾杩囩殑瀹瑰櫒璁板綍 var lcrList = db.Queryable<TN_Loc_Container>().Where(a => cntrs.Contains(a.S_CNTR_CODE) && a.S_LOC_CODE == loc).ToList(); - - if (lcrList.Count > 0) - { + if (lcrList.Count > 0) { cntrs = cntrs.Except(lcrList.Select(a => a.S_CNTR_CODE).ToList()).ToList(); } var bindLocCntList = new List<TN_Loc_Container>(); - foreach (var item in cntrs) - { + foreach (var item in cntrs) { // 閽堝瀹瑰櫒绫诲瀷娣诲姞鐨勬柊閫昏緫 - var cntr = db.Queryable<TN_Container>() - .Where(c => c.S_CODE == item) - .First(); + var cntr = db.Queryable<TN_Container>().Where(c => c.S_CODE == item).First(); if (cntr == null) { LogHelper.Info($"璐т綅瑙g粦鏃讹紝瀹瑰櫒{item}娌℃湁鍦ㄥ鍣ㄤ俊鎭〃涓煡鍒帮紝涓嶈褰曞鍣ㄧ被鍨�); @@ -364,16 +245,12 @@ using (var tran = db.Ado.UseTran()) { - if (db.Insertable<TN_Loc_Container>(bindLocCntList).ExecuteCommand() > 0) - { - LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}"); - } - else - { + if (db.Insertable<TN_Loc_Container>(bindLocCntList).ExecuteCommand() <= 0) { db.RollbackTran(); LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄥけ璐ワ紝{log}"); return "璐т綅缁戝畾瀹瑰櫒澶辫触锛� + logs; } + LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}"); var location = db.Queryable<TN_Location>().First(a => a.S_CODE == loc); if (location != null) -- Gitblit v1.9.1