From 74ca5a83f24c53c48ad7e6f5b7739649fb411546 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期四, 17 七月 2025 17:19:53 +0800
Subject: [PATCH] 优化部分日志和未使用代码

---
 wms/LocationHelper.cs |  188 ++--------------------------------------------
 1 files changed, 10 insertions(+), 178 deletions(-)

diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs
index 714a1bc..3ab86d1 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,125 +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 = 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 = GetLockStateStr(1); // 缁堢偣鍑哄簱閿�-                loc.S_LOCK_OP = lockSource;
-                loc.T_MODIFY = System.DateTime.Now;
-            }
-
-            return true;
-        }
-
-        private static string GetLockStateStr(int lockState) {
-            var str = "";
-            switch (lockState) {
-                case 0: str = "鏃�; break;
-                case 1: str = "鍏ュ簱閿�; break;
-                case 2: str = "鍑哄簱閿�; break;
-                case 3: str = "鍏跺畠閿�; break;
-            }
-            return str;
-        }
-
-        /// <summary>
-        /// 鏋勫缓璐т綅鏌ヨ琛ㄨ揪寮忥細褰撳墠閿佺姸鎬併�鏁伴噺銆佽揣鍖恒�鍚嶇О锛堥粯璁ょ瓫閫夊凡鍚敤璐т綅锛�-        /// </summary>
-        /// <param name="db">璋冪敤鍖哄煙鐨勬暟鎹簱Client</param>
-        /// <param name="lockState">閿佺姸鎬侊紝榛樿涓�锛屽皬浜�鏃朵笉绛涢�</param>
-        /// <param name="curNum">褰撳墠鏁伴噺锛岄粯璁や负-1锛屽皬浜�鏃朵笉绛涢�</param>
-        /// <param name="areas">鎵�湪搴撳尯鍒楄〃锛岄粯璁や负null锛屼负null鎴栦负绌烘椂涓嶇瓫閫�/param>
-        /// <param name="name">璐т綅鍚嶇О锛岄粯璁や负null锛屼负null鎴栦负绌烘椂涓嶇瓫閫�/param>
-        /// <returns></returns>
-        public static ISugarQueryable<TN_Location> Query(SqlSugarClient db, int lockState = 0, int curNum = -1, List<string> areas = null, string name = null) {
-            var query = db.Queryable<TN_Location>().Where(l => l.C_ENABLE == "Y"); // 宸插惎鐢�-
-            if (lockState >= 0) {
-                query = query.Where(l => l.N_LOCK_STATE == lockState && l.S_LOCK_STATE == GetLockStateStr(lockState));
-            }
-            if (curNum >= 0) {
-                query = query.Where(l => l.N_CURRENT_NUM == curNum);
-            }
-            if (areas != null && areas.Count == 0) {
-                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>
-        /// 鏋勫缓璐т綅鏌ヨ鐨勮姹備俊鎭�-        /// </summary>
-        /// <param name="lockState"></param>
-        /// <param name="curNum"></param>
-        /// <param name="areas"></param>
-        /// <returns></returns>
-        public static string Require(int lockState = 0, int curNum = -1, List<string> areas = null) {
-            var res = "璐т綅瑕佹眰锛�;
-            var index = 1;
-            if (lockState >= 0) {
-                res += $"({index})閿佺姸鎬�'{GetLockStateStr(lockState)}';";
-                index++;
-            }
-            if (curNum >= 0) {
-                res += $"({index})褰撳墠瀹瑰櫒鏁伴噺={curNum};";
-                index++;
-            }
-            if (areas != null && areas.Count != 0) {
-                res += $"({index})鎵�湪搴撳尯=['{string.Join("','", areas)}'];";
-                index++;
-            }
-
-            return res;
         }
 
         /// <summary>
@@ -278,15 +143,14 @@
         /// <param name="loc"></param>
         /// <param name="cntrs"></param>
         /// <returns></returns>
-        public static string UnBindingLoc(string loc, List<string> cntrs)
+        public static string UnbindLocCntr(string loc, List<string> cntrs)
         {
             var db = new SqlHelper<object>().GetInstance();
             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) {
                     LogHelper.Info($"璐т綅鏃犻渶瑙g粦瀹瑰櫒锛屽湪鏁版嵁搴撲腑鏈壘鍒皗JsonConvert.SerializeObject(cntrs)}鐩稿叧鐨勮揣浣嶅鍣ㄥ叧绯昏〃淇℃伅");
                 }
                 cntrs = lcrList.Select(a => a.S_CNTR_CODE).ToList();
@@ -299,30 +163,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}");
@@ -337,14 +179,12 @@
                         }
 
                         log = JsonConvert.SerializeObject(location);
-                        if (db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand() > 0)
-                        {
+                        if (db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand() > 0) {
                             tran.CommitTran();
 
                             LogHelper.Info($"鏇存柊璐т綅琛ㄦ垚鍔燂紝{log}");
                         }
-                        else
-                        {
+                        else {
                             tran.RollbackTran();
 
                             LogHelper.Info($"鏇存柊璐т綅琛ㄥけ璐ワ紝{log}");
@@ -378,20 +218,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}娌℃湁鍦ㄥ鍣ㄤ俊鎭〃涓煡鍒帮紝涓嶈褰曞鍣ㄧ被鍨�);
@@ -406,16 +242,12 @@
 
                 using (var tran = db.Ado.UseTran())
                 {
-                    if (db.Insertable<TN_Loc_Container>(bindLocCntList).ExecuteCommand() > 0)
-                    {
-                        LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}");
-                    }
-                    else
-                    {
+                    if (db.Insertable(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