From 3ce6c91e5325d0067596b5a571a4faa74d067289 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期一, 07 七月 2025 16:48:07 +0800
Subject: [PATCH] 修复满箱下线入库相关问题,优化日志和测试接口

---
 api/DebugController.cs |   62 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/api/DebugController.cs b/api/DebugController.cs
index e6b697f..e725102 100644
--- a/api/DebugController.cs
+++ b/api/DebugController.cs
@@ -15,6 +15,7 @@
 
 using static HH.WCS.Mobox3.DSZSH.api.ApiModel;
 using static HH.WCS.Mobox3.DSZSH.api.OtherModel;
+using static HH.WCS.Mobox3.DSZSH.Config;
 using static HH.WCS.Mobox3.DSZSH.core.Monitor;
 
 namespace HH.WCS.Mobox3.DSZSH.api {
@@ -226,7 +227,60 @@
         }
 
         /// <summary>
-        /// 妯℃嫙Erp涓嬪彂鍑哄簱璁″垝鍗�+        /// DEBUG锛氭ā鎷熶汉宸ュ皢鏂欑鎼繍鍒颁骇绾夸笂绾垮彛锛堢洿鎺ヤ慨鏀规暟鎹簱锛�+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("GoodpackToProdLine")]
+        public string GoodpackToProdLine(GoodpackToProdLineInfo model) {
+
+            var db = new SqlHelper<object>().GetInstance();
+            try {
+                // 鏌ヨ璧风偣璐т綅锛氭暟閲�0
+                var startLoc = db.Queryable<TN_Location>().LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE)
+                    .Where((l,c) => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "鏃� && l.C_ENABLE == "Y" && l.S_CODE == model.StartLoc && l.N_CURRENT_NUM == 1 && c.S_CNTR_CODE == model.CntrCode).First();
+                if (startLoc == null) {
+                    return $"娌℃湁鎵惧埌璧风偣璐т綅'{model.StartLoc}'锛佽姹傦細閿佺姸鎬�'鏃�锛屽綋鍓嶅鍣ㄦ暟閲�1";
+                }
+
+                // 鏌ヨ缁堢偣璐т綅
+                // Order锛氭寜璐т綅灞傛暟锛屼粠灏忓埌澶ф帓鍒�+                var endLoc = db.Queryable<TN_Location>().Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "鏃� && l.C_ENABLE == "Y" && l.N_CURRENT_NUM == 0).First();
+                if (endLoc == null) {
+                    return $"娌℃湁鎵惧埌鍚堥�鐨勭粓鐐硅揣浣嶏紒瑕佹眰锛氶攣鐘舵�='鏃�锛屽綋鍓嶅鍣ㄦ暟閲�0";
+                }
+
+                var locCntrRel = db.Queryable<TN_Loc_Container>().Where(c => c.S_CNTR_CODE == model.CntrCode).First() ;
+                if (locCntrRel == null) {
+                    return $"璇ュ鍣ㄤ笉瀛樺湪缁戝畾鐨勮揣浣嶏紒";
+                }
+
+                locCntrRel.S_LOC_CODE = model.StartLoc;
+                startLoc.N_CURRENT_NUM = 0;
+                endLoc.N_CURRENT_NUM = 1;
+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Location>(startLoc).ExecuteCommand() <= 0 &&
+                        db.Updateable<TN_Location>(endLoc).ExecuteCommand() <= 0 &&
+                        db.Updateable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) {
+                        
+                        tran.RollbackTran();
+                        return "鏁版嵁搴撴搷浣滃け璐ワ紒";
+                    }
+
+                    tran.CommitTran() ;
+                    return "鏁版嵁搴撴搷浣滄垚鍔�;
+                }
+            }
+            catch (Exception ex) {
+
+                return ex.Message;
+            }
+        }
+
+        /// <summary>
+        /// DEBUG锛氭ā鎷烢rp涓嬪彂鍑哄簱璁″垝鍗�         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
@@ -289,6 +343,12 @@
         }
     }
 
+    public class GoodpackToProdLineInfo {
+        public string CntrCode { get; set; }
+        public string StartLoc { get; set; }
+        public string EndLoc { get; set; }
+    }
+
     public class TestErpSendOutboundPlanInfo {
         /// <summary>
         /// 鍑哄簱璁″垝鍗曞彿锛堣鍒掑崟鍙�jhdh锛�
--
Gitblit v1.9.1