From 1b6bf29ff7daa1987de65940af52f452cabd6881 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期二, 15 七月 2025 17:27:50 +0800
Subject: [PATCH] 优化AGV任务部分日志、货位绑定内部方法

---
 api/DebugController.cs         |   23 -----
 wms/LocationHelper.cs          |   58 +-------------
 device/ProductionLineDevice.cs |   27 ------
 /dev/null                      |    0 
 .gitignore                     |    3 
 util/LogHelper.cs              |    2 
 api/ApiModel.cs                |    3 
 process/TaskProcess.cs         |   12 +-
 core/WCSCore.cs                |   75 +++++-------------
 HH.WCS.Mobox3.DSZSH.csproj     |    1 
 10 files changed, 41 insertions(+), 163 deletions(-)

diff --git a/.gitignore b/.gitignore
index b1f62fa..6c8d198 100644
--- a/.gitignore
+++ b/.gitignore
@@ -185,3 +185,6 @@
 
 # Microsoft Fakes
 FakesAssemblies/
+/.vs/HH.WCS.Mobox3.DSZSH/CopilotIndices/17.14.794.21998/
+/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/
+/.vs/HH.WCS.Mobox3.DSZSH/v17/
\ No newline at end of file
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/8f40c4eb-5494-4624-8837-7798ba225e13.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/8f40c4eb-5494-4624-8837-7798ba225e13.vsidx
deleted file mode 100644
index 5577c20..0000000
--- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/8f40c4eb-5494-4624-8837-7798ba225e13.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/a42b25e2-c082-4566-872c-fb64d2329cec.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/a42b25e2-c082-4566-872c-fb64d2329cec.vsidx
deleted file mode 100644
index 3e65c15..0000000
--- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/a42b25e2-c082-4566-872c-fb64d2329cec.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/b33d2c5b-1765-4994-b034-1c71a27c4905.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/b33d2c5b-1765-4994-b034-1c71a27c4905.vsidx
deleted file mode 100644
index b597e92..0000000
--- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/b33d2c5b-1765-4994-b034-1c71a27c4905.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/de1cdb9f-9ed9-418c-ad35-f953526016d4.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/de1cdb9f-9ed9-418c-ad35-f953526016d4.vsidx
deleted file mode 100644
index 92a596f..0000000
--- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/de1cdb9f-9ed9-418c-ad35-f953526016d4.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/read.lock b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/read.lock
deleted file mode 100644
index e69de29..0000000
--- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/read.lock
+++ /dev/null
diff --git a/HH.WCS.Mobox3.DSZSH.csproj b/HH.WCS.Mobox3.DSZSH.csproj
index 35781fe..570c813 100644
--- a/HH.WCS.Mobox3.DSZSH.csproj
+++ b/HH.WCS.Mobox3.DSZSH.csproj
@@ -293,6 +293,7 @@
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include=".gitignore" />
     <Content Include="readme.md" />
     <EmbeddedResource Include="swagger.js">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
diff --git a/api/ApiModel.cs b/api/ApiModel.cs
index 45ab71c..4a0cb39 100644
--- a/api/ApiModel.cs
+++ b/api/ApiModel.cs
@@ -79,7 +79,8 @@
             public string ResultMsg { get; set; }
         }
 
-        public static ReturnResult NewReturnResult(int code, string message) {
+        public static ReturnResult NewReturnResult(int code, string message, bool log = true) {
+            if (log) { LogHelper.Info(message); }
             return new ReturnResult { ResultCode = code, ResultMsg = message };
         }
 
diff --git a/api/DebugController.cs b/api/DebugController.cs
index e725102..dd1d711 100644
--- a/api/DebugController.cs
+++ b/api/DebugController.cs
@@ -400,10 +400,6 @@
         /// AGV 灏忚溅鍙�         /// </summary>
         public string ForkliftNo { set; get; }
-        ///// <summary>
-        ///// AGV 涓嬩竴涓姸鎬�-        ///// </summary>
-        //public int NextState { set; get; }
     }
 
     public class AgvReportsInfo {
@@ -421,15 +417,6 @@
         public int NextState { set; get; } = 0;
     }
 
-    public class FalseOk {
-        public bool JumpOut { set; get; } = true;
-    }
-
-    public class InsertCntrItemInfo {
-        public string Cntr { set; get; }
-        public string Item { set; get; }
-    }
-
     /// <summary>
     /// 
     /// </summary>
@@ -437,14 +424,4 @@
         public List<ReturnResult> ResultList { set; get; }
     }
 
-    public class LocCntrCg {
-        public string Note { get; set; } // 浠呯敤浜庡娉�-
-        public string LocCode { get; set; }
-        public string LocArea { get; set; }
-        public string CntrCode { get; set; }
-        public string CntrType { get; set; }
-        public string ItemCode { get; set; }
-        public string BatchNo { get; set; }
-    }
 }
diff --git a/core/WCSCore.cs b/core/WCSCore.cs
index b6b994e..a683ebd 100644
--- a/core/WCSCore.cs
+++ b/core/WCSCore.cs
@@ -22,29 +22,20 @@
 namespace HH.WCS.Mobox3.DSZSH.core {
     public class WCSCore {
         public static ReturnResult OperateAgvTaskStatus(AgvTaskState model) {
-            var result = new ReturnResult();
+            const string preLog = "AGV锛氫换鍔$姸鎬佸洖鎶ワ細";
             try {
                 if (model.state > 0) {
                     // AGV 鎵ц浠诲姟鐨勯�杈戝鐞�                     if (!AgvTaskProcessOk(model)) {
                         // 鎵ц涓峅K锛岃鏄庢病鏈夋壘鍒颁换鍔�-                        result.ResultCode = 1;
-                        result.ResultMsg = $"鏍规嵁Model.No鏈壘鍒板搴旂殑浠诲姟锛寋model.task_no}";
-                        LogHelper.Info(result.ResultMsg, "API");
-                        return result;
+                        return NewReturnResult(1, preLog + $"鏍规嵁浠诲姟鍙�{model.task_no}'鏈壘鍒板搴旂殑浠诲姟锛�);
                     }
                 }
 
-                result.ResultCode = 0;
-                result.ResultMsg = "success";
-                LogHelper.Info(result.ResultMsg, "API");
-                return result;
+                return NewReturnResult(0, "success"); // 涓嶈繑鍥炶缁嗘垚鍔熸棩蹇楋紝閬垮厤NDC浠sg=success浣滀负鎴愬姛鍒ゅ畾锛堝弬鑰冨浗鑷級
             }
             catch (Exception ex) {
-                result.ResultCode = -1;
-                result.ResultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}";
-                LogHelper.Info(result.ResultMsg, "Error");
-                return result;
+                return NewReturnResult(-1, $"鍙戠敓浜嗗紓甯革細{ex.Message}\n{ex.StackTrace}");
             }
 
         }
@@ -147,7 +138,7 @@
 
                 var isInbound = false; // 鍏ュ簱绫诲瀷鐨勪换鍔★紙鍖呮嫭绉诲簱绫讳换鍔★級
                 var inboundTasks = new List<string> {
-                    ETask.M婊℃墭涓嬬嚎鍏ュ簱.Name(), ETask.K绌虹鍏ュ簱.Name(), ETask.M婊℃墭涓嬬嚎鍏ュ簱.Name(), ETask.K绌烘墭鍏ュ簱.Name(),
+                    ETask.M婊℃墭涓嬬嚎鍏ュ簱.Name(), ETask.M婊$涓嬬嚎鍏ュ簱.Name(), ETask.K绌烘墭鍏ュ簱.Name(), ETask.K绌虹鍏ュ簱.Name(),
                     ETask.C鎶芥鍚堟牸鍥炲簱.Name(), ETask.C鎶芥涓嶅悎鏍肩Щ搴�Name(), ETask.Y绉诲簱.Name()
                 };
                 if (inboundTasks.Contains(task.S_TYPE)) {
@@ -204,7 +195,7 @@
         /// <returns></returns>
         public static ReturnResult SafetyInteraction(SafetyInteractionInfo model) {
             var db = new SqlHelper<object>().GetInstance();
-            var info = "";
+            const string preLog = "AGV锛氫骇绾垮畨鍏ㄤ氦浜掞細";
 
             try {
                 ModbusHelper.Relink();
@@ -214,24 +205,18 @@
                     .Where(l => BZQ.Contains(l.S_AREA_CODE) && l.S_AGV_SITE == model.station_name).First();
 
                 if (loc == null) {
-                    info = $"AGV 绔欑偣{model.station_name}涓嶆槸鍚堟硶鐨勪骇绾挎帴椹充綅绔欑偣";
-                    LogHelper.Info(info);
-                    return NewReturnResult(1, info);
+                    return NewReturnResult(1, preLog + $"AGV 绔欑偣{model.station_name}涓嶆槸鍚堟硶鐨勪骇绾挎帴椹充綅绔欑偣");
                 }
 
                 if (!Settings.LocProdIdMap.TryGetValue(loc.S_CODE, out var prodIndex)) {
-                    info = $"AGV 绔欑偣{model.station_name}涓嶆槸鍚堟硶鐨勪骇绾挎帴椹充綅绔欑偣";
-                    LogHelper.Info(info);
-                    return NewReturnResult(1, info);
+                    return NewReturnResult(1, preLog + $"AGV 绔欑偣{model.station_name}涓嶆槸鍚堟硶鐨勪骇绾挎帴椹充綅绔欑偣");
                 }
 
                 var prodLineInfo = Settings.ProductionLines[prodIndex];
 
                 var prodLineDevice = new ProductionLineDevice(prodLineInfo);
                 if (!prodLineDevice.LoadDeviceStateOk()) {
-                    info = "涓庝骇绾胯澶囬�璁け璐�;
-                    LogHelper.Info(info);
-                    return NewReturnResult(2, info);
+                    return NewReturnResult(2, preLog + "涓庝骇绾胯澶囬�璁け璐�);
                 }
 
                 //var tn_task = db.Queryable<TN_Task>().First(a => a.S_CODE == model.task_no);
@@ -248,56 +233,40 @@
                 //}
 
                 if (prodLineDevice.SystemState != 1) {
-                    info = $"褰撳墠浜х嚎鏃犳硶涓嶢GV鑱斿姩锛氱姸鎬亄prodLineDevice.SystemState}";
-                    LogHelper.Info(info);
-                    return NewReturnResult(3, info);
+                    return NewReturnResult(3, preLog + $"褰撳墠浜х嚎鏃犳硶涓嶢GV鑱斿姩锛氱姸鎬亄prodLineDevice.SystemState}");
                 }
 
-                if (model.apply_code == "5") { // 璇锋眰鍙栬揣
+                // 璇锋眰鍙栬揣
+                if (model.apply_code == "5") {
                     if (prodLineDevice.FullOffline != 1) {
-                        info = $"褰撳墠杈撻�绾挎弧鏂欎笅绾夸俊鍙蜂笉涓�锛屾棤娉曞彇璐�;
-                        LogHelper.Info(info);
-                        return NewReturnResult(4, info);
+                        return NewReturnResult(4, preLog + $"褰撳墠杈撻�绾挎弧鏂欎笅绾夸俊鍙蜂笉涓�锛屾棤娉曞彇璐�);
                     }
                     
                     if (!prodLineDevice.SetAgvPicking(1)) {
-                        info = $"鍚戣緭閫佺嚎鍐欏叆鍏佽鍙栬揣淇″彿澶辫触";
-                        LogHelper.Info(info);
-                        return NewReturnResult(5, info);
+                        return NewReturnResult(5, preLog + $"鍚戣緭閫佺嚎鍐欏叆鍏佽鍙栬揣淇″彿澶辫触");
                     }
                     
-                    info = $"鍚戣緭閫佺嚎鍐欏叆鍏佽鍙栬揣淇″彿鎴愬姛";
-                    LogHelper.Info(info);
-                    return NewReturnResult(0, info);
+                    return NewReturnResult(0, preLog + $"鍚戣緭閫佺嚎鍐欏叆鍏佽鍙栬揣淇″彿鎴愬姛");
                 }
-                else if (model.apply_code == "1") { // 璇锋眰鍗歌揣
+                // 璇锋眰鍗歌揣
+                else if (model.apply_code == "1") {
                     if (prodLineDevice.AllowAgvPlacePallet != 1) {
-                        info = $"褰撳墠杈撻�绾垮厑璁告斁鎵樼洏淇″彿涓嶄负1锛屾棤娉曟斁璐�;
-                        LogHelper.Info(info);
-                        return NewReturnResult(6, info);
+                        return NewReturnResult(6, preLog + $"褰撳墠杈撻�绾垮厑璁告斁鎵樼洏淇″彿涓嶄负1锛屾棤娉曟斁璐�);
                     }
 
                     if (!prodLineDevice.SetAgvPlacingPallet(1)) {
-                        info = $"鍚戣緭閫佺嚎鍐欏叆鍏佽鏀捐揣淇″彿澶辫触";
-                        LogHelper.Info(info);
-                        return NewReturnResult(7, info);
+                        return NewReturnResult(7, preLog + $"鍚戣緭閫佺嚎鍐欏叆鍏佽鏀捐揣淇″彿澶辫触");
                     }
 
-                    info = $"鍚戣緭閫佺嚎鍐欏叆鍏佽鏀捐揣淇″彿鎴愬姛";
-                    LogHelper.Info(info);
-                    return NewReturnResult(0, info);
+                    return NewReturnResult(0, preLog + $"鍚戣緭閫佺嚎鍐欏叆鍏佽鏀捐揣淇″彿鎴愬姛");
                 }
                 else {
-                    info = $"褰撳墠AGV璇锋眰鐮佷笉涓�5鍙栬揣 鎴�1鍗歌揣";
-                    LogHelper.Info(info);
-                    return NewReturnResult(8, info);
+                    return NewReturnResult(8, preLog + $"褰撳墠AGV璇锋眰鐮佷笉涓�5鍙栬揣 鎴�1鍗歌揣");
                 }
 
             }
             catch (Exception ex) {
-                info = $"鍙戠敓浜嗗紓甯革細{ex.Message}";
-                LogHelper.InfoEx(ex);
-                return NewReturnResult(1, info);
+                return NewReturnResult(1, preLog + $"鍙戠敓浜嗗紓甯革細{ex.Message}\n{ex.StackTrace}");
             }
         }
 
diff --git a/device/ProductionLineDevice.cs b/device/ProductionLineDevice.cs
index c22a7d7..406c492 100644
--- a/device/ProductionLineDevice.cs
+++ b/device/ProductionLineDevice.cs
@@ -51,20 +51,6 @@
         /// </summary>
         public int AllowAgvPlacePallet { get; set; }
 
-        //private int _agvPicking;
-        //private int _agvPlacingPallet;
-
-        ///// <summary>
-        ///// AGV 姝e湪鍙栬揣锛氫笅绾緼GV鍐欏叆1锛屽彇璐у畬鎴愬悗鎭㈠0
-        ///// </summary>
-        //public int AgvPicking {
-        //    get => _agvPicking;
-        //    set {
-        //        var isOk = ModbusHelper.WriteSingleRegister(10, value, Ip, Port);
-        //        _agvPicking = isOk ? value : throw new Exception($"淇敼 [AGV 姝e湪鍙栬揣] 涓�'{value}' 澶辫触");
-        //    }
-        //}
-
         /// <summary>
         /// AGV 姝e湪鍙栬揣锛氫笅绾緼GV鍐欏叆1锛屽彇璐у畬鎴愬悗鎭㈠0
         /// </summary>
@@ -83,17 +69,6 @@
             AgvPicking = value;
             return true;
         }
-
-        ///// <summary>
-        ///// AGV 姝e湪鏀炬墭鐩樺灈锛氫笂绾緼GV鍐欏叆1锛屾斁鎵樺畬鎴愬悗鎭㈠0
-        ///// </summary>
-        //public int AgvPlacingPallet {
-        //    get => _agvPlacingPallet;
-        //    set {
-        //        var isOk = ModbusHelper.WriteSingleRegister(11, value, Ip, Port);
-        //        _agvPlacingPallet = isOk ? value : throw new Exception($"淇敼 [AGV 姝e湪鏀炬墭鐩樺灈] 涓�'{value}' 澶辫触");
-        //    }
-        //}
 
         /// <summary>
         /// AGV 姝e湪鏀炬墭鐩樺灈锛氫笂绾緼GV鍐欏叆1锛屾斁鎵樺畬鎴愬悗鎭㈠0
@@ -124,8 +99,6 @@
             CallPallet = readArray[2];
             AllowAgvPlacePallet = readArray[3];
             // 鍙啓鍦板潃鏁版嵁
-            //_agvPicking = readArray[10];
-            //_agvPlacingPallet = readArray[11];
             AgvPicking = readArray[10];
             AgvPlacingPallet = readArray[11];
 
diff --git a/process/TaskProcess.cs b/process/TaskProcess.cs
index 19c469f..c3a3343 100644
--- a/process/TaskProcess.cs
+++ b/process/TaskProcess.cs
@@ -18,7 +18,7 @@
         /// </summary>
         /// <param name="mst"></param>
         /// <param name="load"></param>
-        internal static void CacheBitUpdate(TN_Task mst, bool load) {
+        internal static void BufferLocUpdate(TN_Task mst, bool load) {
             //var trayCarryCount = mst.N_CNTR_COUNT > 0 ? mst.N_CNTR_COUNT : 1;
             if (load) {
                 Console.WriteLine($"浠诲姟{mst.S_CODE} 璐т綅{mst.S_START_LOC}鍙栬揣瀹屾垚锛岃捣鐐硅В缁戝鍣▄mst.S_CNTR_CODE}");
@@ -37,12 +37,12 @@
         /// 浠诲姟鍙栨秷锛岀紦瀛樹綅鐘舵�鏇存柊
         /// </summary>
         /// <param name="mst"></param>
-        internal static void CacheBitCancelUpdate(TN_Task mst) {
+        internal static void BufferLocCancelUpdate(TN_Task mst) {
             //浠诲姟鍙栨秷锛屽彇璐у畬鎴愬墠鐨勶紝璧风偣鐨刲oadingCount鍜岀粓鐐箄nLoadingCount閮芥竻闄わ紝鍙栬揣瀹屾垚鐨勫彧澶勭悊缁堢偣
             if (WCSHelper.CheckActionRecordExist(mst.S_CODE, 4)) {
                 //鏍规嵁瀹㈡埛鐜板満瑕佹眰锛屽鏋滃彇璐у畬鎴愪换鍔″け璐ヤ汉宸ユ媺鍒扮粓鐐癸紝鎴戜滑灏卞綋鍗歌揣瀹屾垚澶勭悊锛涘鏋滄槸浜哄伐鎷夎蛋鍒板叾瀹冨尯鍩燂紝鎴戜滑灏辫В閿佺粓鐐癸紝鍒犻櫎鎵樼洏銆�                 //缁堢偣缁戝畾
-                CacheBitUpdate(mst, false);
+                BufferLocUpdate(mst, false);
                 LocationHelper.UnLockLoc(mst.S_END_LOC);
             }
             else {
@@ -62,14 +62,14 @@
         /// <param name="state"></param>
         internal static void OperateStatus(TN_Task mst, int state) {
             if (state == 4) {
-                CacheBitUpdate(mst, true);
+                BufferLocUpdate(mst, true);
             }
             if (state == 6)//鍗歌揣瀹屾垚
             {
-                CacheBitUpdate(mst, false);
+                BufferLocUpdate(mst, false);
             }
             if (state == 7) {
-                CacheBitCancelUpdate(mst);
+                BufferLocCancelUpdate(mst);
             }
         }
 
diff --git a/util/LogHelper.cs b/util/LogHelper.cs
index 94fd38f..bb0e16d 100644
--- a/util/LogHelper.cs
+++ b/util/LogHelper.cs
@@ -80,7 +80,7 @@
         }
 
         public static void InfoHostToAGV(string taskName, object model) {
-            Info($"AGV浠诲姟锛� + JsonConvert.SerializeObject(model), "HosttoagvTask");
+            Info($"AGV浠诲姟锛歿taskName}" + JsonConvert.SerializeObject(model), "HosttoagvTask");
         }
         #endregion
 
diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs
index ad88264..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;
-                        //}
                     }
                 }
             }
@@ -180,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}");
@@ -259,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}娌℃湁鍦ㄥ鍣ㄤ俊鎭〃涓煡鍒帮紝涓嶈褰曞鍣ㄧ被鍨�);
@@ -287,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