From 6abc355aeb4e6f7960c11795dbbcc26396b0c888 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期五, 16 五月 2025 17:20:45 +0800
Subject: [PATCH] 博实物料下发同步接口开发,满箱入库、出库逻辑测试与优化

---
 Dtos/Response/MoboxResponse.cs                                                      |   28 ++
 Models/TN_Outbound_Order.cs                                                         |   10 
 Program.cs                                                                          |    2 
 Models/TN_Task.cs                                                                   |    3 
 Controllers/DebugController.cs                                                      |   45 ---
 config/config.json                                                                  |   10 
 .vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/7b1f7e4e-45eb-4263-a455-827cb67bccfe.vsidx |    0 
 HH.WCS.Mobox3.DSZSH.csproj                                                          |   12 
 .vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/5c57b4d0-dbd7-49e3-9f10-3d5a4d6dc3f3.vsidx |    0 
 Dtos/Request/DebugRequest.cs                                                        |    4 
 .vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/ab784fdf-fa93-4eaa-9449-8122428bc0ae.vsidx |    0 
 Controllers/MesController.cs                                                        |   18 +
 Dtos/Response/WmsResponse.cs                                                        |   45 +++
 Dtos/Request/WmsRequest.cs                                                          |   52 +++
 Controllers/MoboxController.cs                                                      |   36 -
 Controllers/WmsController.cs                                                        |   19 +
 ServiceCore/DebugCore.cs                                                            |   11 
 Services/WmsService.cs                                                              |   67 ++++
 /dev/null                                                                           |   36 --
 Models/TN_Outbound_Detail.cs                                                        |    2 
 Models/DebugModel.cs                                                                |   12 
 Dtos/Request/AgvRequest.cs                                                          |   13 
 Services/DebugService.cs                                                            |   56 ---
 Helpers/TaskHelper.cs                                                               |    3 
 Services/MoboxService.cs                                                            |  273 ++++++++++---------
 Models/TN_CG_Detail.cs                                                              |   33 ++
 Dtos/Request/MoboxRequest.cs                                                        |   25 -
 Models/TN_Shift_Detail.cs                                                           |    3 
 28 files changed, 484 insertions(+), 334 deletions(-)

diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/5c57b4d0-dbd7-49e3-9f10-3d5a4d6dc3f3.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/5c57b4d0-dbd7-49e3-9f10-3d5a4d6dc3f3.vsidx
new file mode 100644
index 0000000..e5b9ec0
--- /dev/null
+++ b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/5c57b4d0-dbd7-49e3-9f10-3d5a4d6dc3f3.vsidx
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/7b1f7e4e-45eb-4263-a455-827cb67bccfe.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/7b1f7e4e-45eb-4263-a455-827cb67bccfe.vsidx
new file mode 100644
index 0000000..771f809
--- /dev/null
+++ b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/7b1f7e4e-45eb-4263-a455-827cb67bccfe.vsidx
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/ab784fdf-fa93-4eaa-9449-8122428bc0ae.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/ab784fdf-fa93-4eaa-9449-8122428bc0ae.vsidx
new file mode 100644
index 0000000..99f862c
--- /dev/null
+++ b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/ab784fdf-fa93-4eaa-9449-8122428bc0ae.vsidx
Binary files differ
diff --git a/Controllers/DebugController.cs b/Controllers/DebugController.cs
index f40ffe1..edb5232 100644
--- a/Controllers/DebugController.cs
+++ b/Controllers/DebugController.cs
@@ -29,37 +29,15 @@
         {
             return DebugService.AgvSeriesReports(model);
         }
-            
+        
         /// <summary>
         /// 鍒濆鍖栨暟鎹簱
         /// </summary>
         /// <returns></returns>
         [HttpPost]
         [Route("CreateDatabase")]
-        public string CreateDatabase() {
-            return DebugService.CreateDatabase();
-        }
-
-        [HttpPost]
-        [Route("InsertLocation")]
-        public string InsertLocation(InsertLocationInfo model) {
-            try {
-                var db = DbHelper.GetDbClient();
-                
-                var locList = new List<TN_Location>();
-                locList.Add(new TN_Location { S_AREA_CODE = model.AreaCode, S_CODE = model.Code});
-
-                if (db.Insertable<TN_Location>(locList).ExecuteCommand() <= 0) {
-                    return "澶辫触";
-                }
-
-            }
-            catch (Exception ex) {
-                LogHelper.Info($"鍙戠敓浜嗗紓甯�);
-                return "娣诲姞璐т綅閿欒" + ex.Message;
-            }
-            //return res ? "鎴愬姛" : "澶辫触";
-            return "鎴愬姛";
+        public string CreateDatabase(CoverInfo model) {
+            return DebugService.CreateDatabase(model.IsCover);
         }
 
         /// <summary>
@@ -71,22 +49,5 @@
         public string InsertLocCntrCg() {
             return DebugService.InsertLocCntrCg();
         }
-
-    }
-
-    public class CgInfo {
-        public string ItemCode { get; set; }
-        public string CntId { get; set; }
-        public string LocId { get; set; }
-    }
-
-    public class InsertLocationInfo {
-        public string Code { set; get; } 
-        public string AreaCode { set; get; }
-    }
-
-    public class UpdateTaskWeightInfo {
-        public string TaskID { set; get; }
-        public float Weight { set; get; }
     }
 }
diff --git a/Controllers/MesController.cs b/Controllers/MesController.cs
new file mode 100644
index 0000000..372a63b
--- /dev/null
+++ b/Controllers/MesController.cs
@@ -0,0 +1,18 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web.Http;
+
+using HH.WCS.Mobox3.DSZSH.Services;
+
+namespace HH.WCS.Mobox3.DSZSH.Controllers {
+    /// <summary>
+    /// MES 璋冪敤鐨勬帴鍙�+    /// </summary>
+    [RoutePrefix("api")]
+    public class MesController : ApiController {
+
+    }
+}
diff --git a/Controllers/MoboxController.cs b/Controllers/MoboxController.cs
index 4bb42eb..e50687c 100644
--- a/Controllers/MoboxController.cs
+++ b/Controllers/MoboxController.cs
@@ -9,7 +9,6 @@
 
 using static HH.WCS.Mobox3.DSZSH.Dtos.Request.MoboxRequest;
 using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
-using static HH.WCS.Mobox3.DSZSH.Helpers.ResultHelper;
 
 namespace HH.WCS.Mobox3.DSZSH.Controllers {
     /// <summary>
@@ -62,30 +61,14 @@
         public SimpleResult EmptyInbound(EmptyInboundInfo model) {
             LogHelper.InfoApi("绌烘墭/绌虹鍏ュ簱", model);
 
-            var db = DbHelper.GetDbClient();
-            var locCntrRel = db.Queryable<TN_Loc_Container>()
-                .Where(lc => lc.S_CNTR_CODE == model.CntrCode).First();
-
-            if (locCntrRel == null) {
-                return BuildSimpleResult(-1, $"涓嶅瓨鍦ㄥ凡缁戝畾瀹瑰櫒鐨勮揣浣嶅彿锛�{model.CnteType}'");
+            if (model.CntrType == "鎵樼洏") {
+                return MoboxService.EmptyInboundPallet(model);
             }
-
-            if (locCntrRel.S_CNTR_TYPE == "鎵樼洏") {
-
-                return MoboxService.EmptyInboundPallet(new EmptyInboundDetailInfo {
-                    StartLoc = locCntrRel.S_LOC_CODE,
-                    CntId = locCntrRel.S_CNTR_TYPE
-                });
-            }
-            else if (locCntrRel.S_CNTR_TYPE == "濂借繍绠�) {
-
-                return MoboxService.EmptyInboundGoodpack(new EmptyInboundDetailInfo {
-                    StartLoc = locCntrRel.S_LOC_CODE,
-                    CntId = locCntrRel.S_CNTR_TYPE
-                });
+            else if (model.CntrType == "濂借繍绠�) {
+                return MoboxService.EmptyInboundGoodpack(model);
             }
             else {
-                return BuildSimpleResult(-2, $"涓嶅悎娉曠殑瀹瑰櫒绫诲瀷锛�{locCntrRel.S_CNTR_CODE}'");
+                return BuildSimpleResult(-1, $"瀹瑰櫒绫诲瀷 '{model.CntrType}' 涓嶅悎娉曪細搴斾负 '鎵樼洏' 鎴�'濂借繍绠�");
             }
         }
 
@@ -191,9 +174,7 @@
         public SimpleResult RestBack(RestBackInfo model) {
             return MoboxService.RestBack(model);
         }
-        #endregion
 
-        #region Mobox 鎺ュ彛
         /// <summary>
         /// 鎴愬搧鑳跺嚭搴�PDA)
         /// </summary>
@@ -203,12 +184,17 @@
         [Route("finished-outbound")]
         public SimpleResult FinishedOutbound(FinishedOutboundInfo model) {
             LogHelper.InfoApi("鎴愬搧鑳跺嚭搴�PDA)", model);
+
             if (model.ForcedOut) {
                 return MoboxService.FinishedOutboundForce(model);
             }
-            return MoboxService.FinishedOutbound(model);
+            else {
+                return MoboxService.FinishedOutbound(model);
+            }
         }
+        #endregion
 
+        #region Mobox 鎺ュ彛
         /// <summary>
         /// 鎶芥-鍒涘缓鎶芥鍗�WMS)
         /// </summary>
diff --git a/Controllers/WmsController.cs b/Controllers/WmsController.cs
index 075593b..5ecedca 100644
--- a/Controllers/WmsController.cs
+++ b/Controllers/WmsController.cs
@@ -1,7 +1,12 @@
 锘縰sing HH.WCS.Mobox3.DSZSH.AppStart;
+using HH.WCS.Mobox3.DSZSH.Services;
+
 using Newtonsoft.Json;
 using System.Collections.Generic;
 using System.Web.Http;
+using static HH.WCS.Mobox3.DSZSH.Dtos.Request.WmsRequest;
+
+using static HH.WCS.Mobox3.DSZSH.Dtos.Response.WmsResponse;
 
 namespace HH.WCS.Mobox3.DSZSH.Controllers
 {
@@ -9,8 +14,16 @@
     /// 绗笁鏂硅皟鐢ㄧ殑鎺ュ彛
     /// </summary>
     [RoutePrefix("api")]
-    public class WmsController : ApiController
-    {
-        
+    public class WMSController : ApiController {
+        /// <summary>
+        /// 鍗氬疄鐗╂枡淇℃伅涓嬪彂鍚屾(MES)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        //[Route("WMS/CgInfoSync")]
+        public WmsResult CgInfoSync(CgInfoSyncInfo model) {
+            return WmsService.CgInfoSync(model);
+        }
     }
 }
diff --git a/Dtos/Request/AgvRequest.cs b/Dtos/Request/AgvRequest.cs
index a63eb24..a8d6063 100644
--- a/Dtos/Request/AgvRequest.cs
+++ b/Dtos/Request/AgvRequest.cs
@@ -10,14 +10,25 @@
         /// HostToAGV 涓婃姤浠诲姟鐘舵�
         /// </summary>
         public class AgvTaskState {
+            /// <summary>
+            /// AGV 鍥炴姤鐘舵�鍙�+            /// </summary>
             public int state { get; set; }
+            /// <summary>
+            /// 浠诲姟鍙�+            /// </summary>
             public string task_no { get; set; }
+            /// <summary>
+            /// AGV 杞﹀彿
+            /// </summary>
             public string forklift_no { get; set; }
-
             /// <summary>
             /// 瀹夊叏闂ㄧ紪鍙�             /// </summary>
             public string lock_no { get; set; }
+            /// <summary>
+            /// 闄勫姞淇℃伅
+            /// </summary>
             public string ext_data { get; set; }
         }
 
diff --git a/Dtos/Request/DebugRequest.cs b/Dtos/Request/DebugRequest.cs
index 76822a7..a111853 100644
--- a/Dtos/Request/DebugRequest.cs
+++ b/Dtos/Request/DebugRequest.cs
@@ -25,5 +25,9 @@
             /// </summary>
             public int NextState { set; get; }
         }
+
+        public class CoverInfo {
+            public bool IsCover { set; get; } = true;
+        }
     }
 }
diff --git a/Dtos/Request/MoboxRequest.cs b/Dtos/Request/MoboxRequest.cs
index 8417ed7..5f240a5 100644
--- a/Dtos/Request/MoboxRequest.cs
+++ b/Dtos/Request/MoboxRequest.cs
@@ -13,20 +13,17 @@
             /// <summary>
             /// 鐗╂枡缂栫爜
             /// </summary>
-            
             [JsonProperty("s_item_code")]
             public string ItemCode { get; set; }
             ///// <summary>
             ///// 鐗╂枡鍚嶇О
             ///// </summary>
-            //
             //[JsonProperty("item_name")]
             //public string ItemName { get; set; }
             /// <summary>
             /// 鎵规鍙�             /// </summary>
-            
-            [JsonProperty("s_batch_no")]
+            [JsonProperty("s_batch")]
             public string BatchNo { get; set; }
             /// <summary>
             /// 鐗╂枡瑙勬牸
@@ -39,7 +36,7 @@
             [JsonProperty("n_num")]
             public int Qty { get; set; }
             /// <summary>
-            /// 璐т綅淇℃伅
+            /// 璧风偣璐т綅淇℃伅
             /// </summary>
             [JsonProperty("s_start_loc")]
             public string StartLoc { get; set; }
@@ -117,12 +114,17 @@
             /// 瀹瑰櫒绫诲瀷
             /// </summary>
             [JsonProperty("cntr_type")]
-            public string CnteType { get; set; }
+            public string CntrType { get; set; }
             /// <summary>
             /// 缁堢偣搴撳尯缂栫爜
             /// </summary>
             [JsonProperty("end_area")]
             public string EndArea { get; set; }
+            /// <summary>
+            /// 璧风偣璐т綅
+            /// </summary>
+            [JsonProperty("start_loc")]
+            public string StartLoc { get; set; }
         }
 
         public class EmptyInboundDetailInfo : StartCntInfo { }
@@ -220,7 +222,9 @@
             [JsonProperty("end_area")]
             public string EndArea { get; set; }
         }
-
+        /// <summary>
+        /// 鎶芥-鍚堟牸鍥炲簱(PDA) 鏁版嵁绫�+        /// </summary>
         public class QualifiedBackInfo {
             /// <summary>
             /// 鐗╂枡缂栫爜
@@ -256,13 +260,11 @@
             /// <summary>
             /// 鐗╂枡缂栫爜
             /// </summary>
-            
             [JsonProperty("item_code")]
             public string ItemCode { get; set; }
             ///// <summary>
             ///// 鐗╂枡鍚嶇О
             ///// </summary>
-            //
             //[JsonProperty("item_name")]
             //public string ItemName { get; set; }
             /// <summary>
@@ -273,7 +275,6 @@
             /// <summary>
             /// 鎵规鍙�             /// </summary>
-            
             [JsonProperty("batch_no")]
             public string BatchNo { get; set; }
             /// <summary>
@@ -284,20 +285,16 @@
             /// <summary>
             /// 瀹瑰櫒绫诲瀷
             /// </summary>
-            
             [JsonProperty("cntr_type")]
             public string CntrType { get; set; }
-            
             /// <summary>
             /// 鍑哄簱缁堢偣璐у尯
             /// </summary>
-            
             [JsonProperty("end_area")]
             public string EndArea { get; set; }
             /// <summary>
             /// 鏄惁寮哄埗鍑哄簱
             /// </summary>
-            
             [JsonProperty("force_out")]
             public bool ForcedOut { get; set; }
         }
diff --git a/Dtos/Request/WmsRequest.cs b/Dtos/Request/WmsRequest.cs
new file mode 100644
index 0000000..92e3e85
--- /dev/null
+++ b/Dtos/Request/WmsRequest.cs
@@ -0,0 +1,52 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Newtonsoft.Json;
+
+namespace HH.WCS.Mobox3.DSZSH.Dtos.Request {
+    public class WmsRequest {
+        /// <summary>
+        /// 鐗╂枡淇℃伅涓嬪彂鍚屾 鏁版嵁绫�+        /// </summary>
+        public class CgInfoSyncInfo {
+            /// <summary>
+            /// 鐗╂枡鍚嶇О
+            /// </summary>
+            [JsonProperty("itemName")]
+            public string ItemName { get; set; }
+
+            /// <summary>
+            /// 浜у搧鐗屽彿
+            /// </summary>
+            [JsonProperty("itemCode")]
+            public string ItemCode { get; set; }
+
+            /// <summary>
+            /// 鎵规鍙�+            /// </summary>
+            [JsonProperty("batchNo")]
+            public string BatchNo { get; set; }
+
+            /// <summary>
+            /// 鎵ц鏍囧噯
+            /// </summary>
+            [JsonProperty("standard")]
+            public string Standard { get; set; }
+
+            /// <summary>
+            /// 鍑�惈閲�+            /// </summary>
+            [JsonProperty("netWeight")]
+            public string NetWeight { get; set; }
+
+            /// <summary>
+            /// 璐ㄩ噺绛夌骇
+            /// </summary>
+            [JsonProperty("qualityGrade")]
+            public string QualityGrade { get; set; }
+        }
+    }
+}
diff --git a/Dtos/Response/MoboxResponse.cs b/Dtos/Response/MoboxResponse.cs
index f404c20..a5068c7 100644
--- a/Dtos/Response/MoboxResponse.cs
+++ b/Dtos/Response/MoboxResponse.cs
@@ -24,6 +24,34 @@
         }
 
         /// <summary>
+        /// 鏋勫缓 <see cref="SimpleResult"/> 杩斿洖鍊硷紝閫夋嫨鎵撳嵃鏃ュ織淇℃伅锛堥粯璁ゆ墦鍗帮級
+        /// </summary>
+        /// <param name="code"></param>
+        /// <param name="message"></param>
+        /// <param name="pringLog"></param>
+        /// <returns></returns>
+        public static SimpleResult BuildSimpleResult(int code, string message, bool pringLog = true) {
+            if (pringLog) {
+                LogHelper.Info(message);
+            }
+            return new SimpleResult { Code = code, Message = message };
+        }
+
+        /// <summary>
+        /// 鏋勫缓 <see cref="SimpleResult"/> 寮傚父杩斿洖鍊硷紝閫夋嫨鎵撳嵃寮傚父鏃ュ織淇℃伅锛堥粯璁ゆ墦鍗帮級
+        /// </summary>
+        /// <param name="ex"></param>
+        /// <param name="exCode"></param>
+        /// <param name="pringLog"></param>
+        /// <returns></returns>
+        public static SimpleResult BuildSimpleEx(Exception ex, int exCode = 1, bool pringLog = true) {
+            if (pringLog) {
+                LogHelper.InfoEx(ex);
+            }
+            return new SimpleResult { Code = exCode, Message = ex.Message };
+        }
+
+        /// <summary>
         /// mobox 鍙栨秷浠诲姟銆佹爣璁板畬鎴愪换鍔�         /// </summary>
         public class MoboxTaskBase {
diff --git a/Dtos/Response/WmsResponse.cs b/Dtos/Response/WmsResponse.cs
new file mode 100644
index 0000000..92d1bb6
--- /dev/null
+++ b/Dtos/Response/WmsResponse.cs
@@ -0,0 +1,45 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Newtonsoft.Json;
+
+namespace HH.WCS.Mobox3.DSZSH.Dtos.Response {
+    public class WmsResponse {
+        /// <summary>
+        /// MES API 鍝嶅簲缁撴灉绫�+        /// </summary>
+        public class WmsResult {
+            /// <summary>
+            /// 鎺ュ彛璋冪敤缁撴灉  1-鎴愬姛  0-澶辫触
+            /// </summary>
+            [JsonProperty("result")]
+            public int Result { get; set; }
+
+            /// <summary>
+            /// 鏄惁鎴愬姛 True-鎴愬姛锛孎alse锛氬け璐�+            /// </summary>
+            [JsonProperty("success")]
+            public bool Success { get; set; }
+
+            /// <summary>
+            /// 杩欓噷鏄痵tring绫诲瀷锛屽缁撴灉鐨勬弿杩�+            /// </summary>
+            [JsonProperty("data")]
+            public string Data { get; set; }
+        }
+
+        public static WmsResult MesResultBuilder(int code, string message = "", bool printLog = true) {
+            if (printLog && string.IsNullOrEmpty(message)) {
+                LogHelper.Info(message);
+            }
+            return new WmsResult {
+                Result = code,
+                Success = code == 0, // 浠呭綋code=0鏃讹紝success=true
+                Data = message,
+            };
+        }
+    }
+}
diff --git a/HH.WCS.Mobox3.DSZSH.csproj b/HH.WCS.Mobox3.DSZSH.csproj
index 40f6db6..35d7c1e 100644
--- a/HH.WCS.Mobox3.DSZSH.csproj
+++ b/HH.WCS.Mobox3.DSZSH.csproj
@@ -235,16 +235,18 @@
     <Compile Include="Consts\TaskName.cs" />
     <Compile Include="Controllers\DebugController.cs" />
     <Compile Include="Controllers\ErpController.cs" />
+    <Compile Include="Controllers\MesController.cs" />
     <Compile Include="Controllers\MoboxController.cs" />
     <Compile Include="Controllers\AgvController.cs" />
     <Compile Include="App_Start\SwaggerControllerDescProvider.cs" />
+    <Compile Include="Dtos\Request\WmsRequest.cs" />
+    <Compile Include="Dtos\Response\WmsResponse.cs" />
     <Compile Include="Models\DebugModel.cs" />
     <Compile Include="Dtos\Request\DebugRequest.cs" />
     <Compile Include="Dtos\Response\DebugResponse.cs" />
     <Compile Include="Helpers\AgvHelper.cs" />
     <Compile Include="Helpers\ExprHelper.cs" />
     <Compile Include="Helpers\PathHelper.cs" />
-    <Compile Include="Helpers\ResultHelper.cs" />
     <Compile Include="Helpers\DbHelper.cs" />
     <Compile Include="Models\TN_CNTR_ITEM.cs" />
     <Compile Include="Models\TN_Check_Detail.cs" />
@@ -256,6 +258,7 @@
     <Compile Include="Models\TN_Shift_Detail.cs" />
     <Compile Include="Models\TN_Shift_Order.cs" />
     <Compile Include="ServiceCore\CheckCore.cs" />
+    <Compile Include="ServiceCore\DebugCore.cs" />
     <Compile Include="ServiceCore\OutboundCore.cs" />
     <Compile Include="ServiceCore\ShiftCore.cs" />
     <Compile Include="Services\DebugService.cs" />
@@ -286,10 +289,11 @@
     <Compile Include="Models\TN_Task_Action.cs" />
     <Compile Include="Helpers\DeviceProcess.cs" />
     <Compile Include="ServiceCore\TaskCore.cs" />
-    <Compile Include="Controllers\WmsController.cs" />
+    <Compile Include="Controllers\WMSController.cs" />
     <Compile Include="Dispatch\HostToAGV.cs" />
     <Compile Include="Helpers\TaskHelper.cs" />
     <Compile Include="Services\AgvService.cs" />
+    <Compile Include="Services\WmsService.cs" />
     <Compile Include="Services\MoboxService.cs" />
     <Compile Include="Helpers\LogHelper.cs" />
     <Compile Include="Helpers\ContainerHelper.cs" />
@@ -331,8 +335,6 @@
       <Install>false</Install>
     </BootstrapperPackage>
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Dtos\Internal\" />
-  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
diff --git a/Helpers/ResultHelper.cs b/Helpers/ResultHelper.cs
deleted file mode 100644
index 3eaab40..0000000
--- a/Helpers/ResultHelper.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-锘縰sing System;
-
-using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
-
-namespace HH.WCS.Mobox3.DSZSH.Helpers {
-    public class ResultHelper {
-
-        /// <summary>
-        /// 鏋勫缓 <see cref="SimpleResult"/> 杩斿洖鍊硷紝閫夋嫨鎵撳嵃鏃ュ織淇℃伅锛堥粯璁ゆ墦鍗帮級
-        /// </summary>
-        /// <param name="code"></param>
-        /// <param name="message"></param>
-        /// <param name="pringLog"></param>
-        /// <returns></returns>
-        public static SimpleResult BuildSimpleResult(int code, string message, bool pringLog = true) {
-            if (pringLog) {
-                LogHelper.Info(message);
-            }
-            return new SimpleResult { Code = code, Message = message };
-        }
-
-        /// <summary>
-        /// 鏋勫缓 <see cref="SimpleResult"/> 寮傚父杩斿洖鍊硷紝閫夋嫨鎵撳嵃寮傚父鏃ュ織淇℃伅锛堥粯璁ゆ墦鍗帮級
-        /// </summary>
-        /// <param name="ex"></param>
-        /// <param name="exCode"></param>
-        /// <param name="pringLog"></param>
-        /// <returns></returns>
-        public static SimpleResult BuildSimpleEx(Exception ex, int exCode = 1, bool pringLog = true) {
-            if (pringLog) {
-                LogHelper.InfoEx(ex);
-            }
-            return new SimpleResult { Code = exCode, Message = ex.Message };
-        }
-    }
-}
diff --git a/Helpers/TaskHelper.cs b/Helpers/TaskHelper.cs
index 3b78306..bbfca8e 100644
--- a/Helpers/TaskHelper.cs
+++ b/Helpers/TaskHelper.cs
@@ -12,7 +12,6 @@
 using SqlSugar;
 
 using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
-using static HH.WCS.Mobox3.DSZSH.Helpers.ResultHelper;
 
 namespace HH.WCS.Mobox3.DSZSH.Helpers {
     /// <summary>
@@ -57,6 +56,8 @@
                 N_B_STATE = 0,
                 S_CNTR_CODE = cnt,
                 T_START_TIME = DateTime.Now,
+                //T_END_TIME = null,
+                
             };
 
             var db = DbHelper.GetDbClient();
diff --git a/Models/DebugModel.cs b/Models/DebugModel.cs
index b0b7174..165388b 100644
--- a/Models/DebugModel.cs
+++ b/Models/DebugModel.cs
@@ -7,20 +7,14 @@
 namespace HH.WCS.Mobox3.DSZSH.Models {
     public class DebugModel {
         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 CgId { get; set; }
+            public string ItemCode { get; set; }
             public string BatchNo { get; set; }
-        }
-
-        public class OutboundOrder {
-            public string No { get; set; }
-            public string CgId { get; set; }
-            public string BatchNo { get; set; }
-            public string EndArea { get; set; }
-            public int Qty { get; set; }
         }
     }
 }
diff --git a/Models/TN_CG_Detail.cs b/Models/TN_CG_Detail.cs
index 23e6b65..11893d2 100644
--- a/Models/TN_CG_Detail.cs
+++ b/Models/TN_CG_Detail.cs
@@ -9,7 +9,7 @@
         /// <summary>
         /// 鏂欑鍟嗗搧鏍囪瘑
         /// </summary>
-        public string S_CG_ID { get; set; } = "";
+        public string S_CG_ID { get; set; } = string.Empty; // 鏆傛椂鐢ㄤ笉鍒帮紝榛樿涓虹┖
 
         /// <summary>
         /// 鐗╂枡缂栫爜
@@ -17,9 +17,9 @@
         public string S_ITEM_CODE { get; set; }
 
         /// <summary>
-        /// 鐗╂枡瑙勬牸
+        /// 鐗╂枡鍚嶇О
         /// </summary>
-        public string S_SPE { get; set; }
+        public string S_ITEM_NAME { get; set; } = string.Empty; 
 
         /// <summary>
         /// 瀹瑰櫒缂栫爜
@@ -44,6 +44,31 @@
         /// <summary>
         /// 璐у搧鏁伴噺
         /// </summary>
-        public int N_QTY { get; set; }
+        public int N_QTY { get; set; } = 0;
+
+        /// <summary>
+        /// 鐗╂枡瑙勬牸
+        /// </summary>
+        public string S_SPE { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 鎵ц鏍囧噯
+        /// </summary>
+        public string S_STANDARD { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 鍑�惈閲�+        /// </summary>
+        public string S_NET_WEIGHT { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 璐ㄩ噺绛夌骇
+        /// </summary>
+        public string S_QUALITY_GRADE { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 浜х嚎鍙�+        /// </summary>
+        public int N_PRODUCT_LINE { get; set; } = 0; // NOTE 鍚庣画MES鍙兘浼氭彁渚涳紝鍏堝垱寤�     }
 }
diff --git a/Models/TN_Outbound_Detail.cs b/Models/TN_Outbound_Detail.cs
index f219dca..94ee21a 100644
--- a/Models/TN_Outbound_Detail.cs
+++ b/Models/TN_Outbound_Detail.cs
@@ -31,7 +31,7 @@
         /// <summary>
         /// 鍑哄簱璐у搧鏁伴噺锛堟暣鏁帮紝鐢ㄤ簬鐢熸垚浠诲姟鏁帮級
         /// </summary>
-        public int N_QTY { get; set; }
+        public int N_COUNT { get; set; }
 
         /// <summary>
         /// 缁堢偣搴撳尯锛堢敱WMS涓嬪彂浠诲姟鏃舵寚瀹氾級
diff --git a/Models/TN_Outbound_Order.cs b/Models/TN_Outbound_Order.cs
index 99fb355..c3493cf 100644
--- a/Models/TN_Outbound_Order.cs
+++ b/Models/TN_Outbound_Order.cs
@@ -26,11 +26,13 @@
         /// <summary>
         /// 鎵规鍙�         /// </summary>
-        public string S_BATCH_NO { get; set; }
+        public string S_BATCH { get; set; }
+        /// <summary>
+        /// 鍑哄簱鏁伴噺
+        /// </summary>
+        public int N_END_NUM { get; set; }
 
-        public float F_QTY { get; set; }
-
-        public float F_OUT_QTY { get; set; }
+        //public float F_OUT_QTY { get; set; }
 
         /// <summary>
         /// 缁堢偣搴撳尯锛堢敱WMS涓嬪彂浠诲姟鏃舵寚瀹氾級
diff --git a/Models/TN_Shift_Detail.cs b/Models/TN_Shift_Detail.cs
index b343e3e..ada808f 100644
--- a/Models/TN_Shift_Detail.cs
+++ b/Models/TN_Shift_Detail.cs
@@ -6,6 +6,9 @@
 using System.Threading.Tasks;
 
 namespace HH.WCS.Mobox3.DSZSH.Models {
+    /// <summary>
+    /// 绉诲簱鍗曟槑缁�+    /// </summary>
     internal class TN_Shift_Detail : BaseModel {
         public string S_NO { get; set; }
         public string S_ITEM_CODE { get; set; }
diff --git a/Models/TN_Task.cs b/Models/TN_Task.cs
index 28515a3..c94cb52 100644
--- a/Models/TN_Task.cs
+++ b/Models/TN_Task.cs
@@ -46,10 +46,11 @@
         /// <summary>
         /// 瀹屾垚鏃堕棿
         /// </summary>
+        [SugarColumn(IsNullable = true)]
         public DateTime? T_END_TIME { get; set; }
 
         /// <summary>
-        /// AGV 杞﹀彿
+        /// AGV 杞﹀彿  
         /// </summary>
         public string S_EQ_NO { get; set; }
 
diff --git a/Program.cs b/Program.cs
index 5f198b3..e77e060 100644
--- a/Program.cs
+++ b/Program.cs
@@ -129,7 +129,7 @@
 
                 //tasks.Add(GetTask(CheckCore.CheckOrderState));
 
-                //tasks.Add(GetTask(OutboundCore.CheckOrderState));
+                tasks.Add(GetTask(OutboundCore.CheckOrderState));
 
 
                 // 娣诲姞浠诲姟鎺ㄩ�绾跨▼
diff --git a/ServiceCore/DebugCore.cs b/ServiceCore/DebugCore.cs
new file mode 100644
index 0000000..4d44786
--- /dev/null
+++ b/ServiceCore/DebugCore.cs
@@ -0,0 +1,11 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.WCS.Mobox3.DSZSH.ServiceCore {
+    public class DebugCore {
+
+    }
+}
diff --git a/Services/DebugService.cs b/Services/DebugService.cs
index bc72257..cbc8c2a 100644
--- a/Services/DebugService.cs
+++ b/Services/DebugService.cs
@@ -76,7 +76,6 @@
             return returnResults;
         }
 
-
         /// <summary>
         /// 鍒濆鏁版嵁搴撳缓绔�         /// </summary>
@@ -175,16 +174,6 @@
                             loc = newLoc;
                         }
 
-                        //if (loc.N_CURRENT_NUM == 0) {
-                        //    loc.N_CURRENT_NUM = 1;
-                        //    if (db.Updateable<TN_Location>(loc).UpdateColumns(
-                        //        it => new { it.N_CURRENT_NUM, it.T_MODIFY }).ExecuteCommand() <= 0) {
-                        //        tran.RollbackTran();
-                        //        LogHelper.Info($"淇敼浣嶇疆{locCntrCg.LocCode}澶辫触");
-                        //        continue;
-                        //    }
-                        //}
-
                         if (string.IsNullOrEmpty(locCntrCg.CntrCode)) {
                             LogHelper.Info("瀹瑰櫒鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
                             continue;
@@ -210,23 +199,23 @@
                             }
                         }
 
-                        if (string.IsNullOrEmpty(locCntrCg.CgId)) {
+                        if (string.IsNullOrEmpty(locCntrCg.ItemCode)) {
                             LogHelper.Info("鐗╂枡鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
                             continue;
                         }
 
                         var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrCg.CntrCode
-                            && a.S_ITEM_CODE == locCntrCg.CgId);
+                            && a.S_ITEM_CODE == locCntrCg.ItemCode);
                         if (cgDetail == null) {
                             var locList = new List<TN_CG_Detail>();
-                            locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_ITEM_CODE = locCntrCg.CgId, S_BATCH_NO = locCntrCg.BatchNo ?? "" });
+                            locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_ITEM_CODE = locCntrCg.ItemCode, S_BATCH_NO = locCntrCg.BatchNo ?? "" });
                             if (db.Insertable<TN_CG_Detail>(locList).ExecuteCommand() <= 0) {
                                 tran.RollbackTran();
                                 LogHelper.Info($"鎻掑叆鎵樼洏鐗╂枡鍏崇郴{locCntrCg.CntrCode}-{locCntrCg}澶辫触");
                                 return "鎻掑叆澶辫触";
                             }
                         }
-                    } 
+                    }
                     tran.CommitTran();
                 }
 
@@ -240,42 +229,5 @@
                 return $"Error reading CSV file: {ex.Message}";
             }
         }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <returns></returns>
-        //public string InsertOutboundOrder() {
-        //    string filePath = PathHelper.GetProjDir("./debug/outbound_order.csv");
-        //    var db = DbHelper.GetDbClient();
-
-        //    try {
-        //        var configuration = new CsvConfiguration(CultureInfo.InvariantCulture) {
-        //            // 閰嶇疆閫夐」
-        //            Delimiter = ",",               // 鍒嗛殧绗�-        //            HasHeaderRecord = true,        // 鏈夋爣棰樿
-        //            MissingFieldFound = null,      // 蹇界暐缂哄け瀛楁
-        //            HeaderValidated = null,        // 璺宠繃鏍囬楠岃瘉
-        //            BadDataFound = context => { }  // 澶勭悊閿欒鏁版嵁
-        //        };
-
-        //        var locCntrCgList = new List<DebugModel.OutboundOrder>();
-
-        //        using (var reader = new StreamReader(filePath))
-        //        using (var csv = new CsvReader(reader, configuration)) {
-        //            // 璇诲彇璁板綍
-        //            locCntrCgList = csv.GetRecords<DebugModel.OutboundOrder>().ToList();
-        //        }
-
-        //        using (var tran = db.Ado.UseTran()) {
-                    
-        //        }
-
-        //    }
-        //    catch (Exception) {
-
-        //        throw;
-        //    }
-        //}
     }
 }
diff --git a/Services/MoboxService.cs b/Services/MoboxService.cs
index 4ff7773..680d804 100644
--- a/Services/MoboxService.cs
+++ b/Services/MoboxService.cs
@@ -13,7 +13,6 @@
 
 using static HH.WCS.Mobox3.DSZSH.Dtos.Request.MoboxRequest;
 using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
-using static HH.WCS.Mobox3.DSZSH.Helpers.ResultHelper;
 
 namespace HH.WCS.Mobox3.DSZSH.Services {
     public class MoboxService {
@@ -30,169 +29,185 @@
             var db = DbHelper.GetDbClient();
 
             try {
-                // TODO 灏哖DA鎻愪緵鐨勭墿鏂欑紪鐮佷笌璐存爣鏈虹殑淇℃伅姣斿
+                // 灏哖DA鎻愪緵鐨勭墿鏂欑紪鐮佷笌璐存爣鏈虹殑淇℃伅姣斿
+                var cgDetail = db.Queryable<TN_CG_Detail>()
+                    .Where(d => d.S_ITEM_CODE == model.ItemCode && d.S_BATCH_NO == model.BatchNo) // 鎸囧畾锛氱墿鏂欑紪鐮併�鎵规鍙�+                    .Where(d => d.N_ITEM_STATE == 1 && d.S_ITEM_STATE == "寰呮") // NOTE 鍐椾綑妫�煡锛氱墿鏂欑姸鎬佸簲璇ヤ负 1寰呮
+                    .First();
 
-                var startLoc = db.Queryable<TN_Location>()
-                    .Where(ExprHelper.LocCode(model.StartLoc))
-                    .Where(ExprHelper.LocIsFree)
-                    .Where(ExprHelper.LocIsEmpty.Negate()).First();
-
-                if (startLoc == null) {
-                    return BuildSimpleResult(2, $"璧风偣浣嶇疆 '{model.StartLoc}' 涓嶅瓨鍦ㄦ垨涓嶅叿澶囧彇璐ц姹�);
+                if (cgDetail == null) {
+                    return BuildSimpleResult(2, $"PDA鎵爜鐗╂枡淇℃伅涓庤创鏍囨満浼犻�鐨勪俊鎭笉涓�嚧锛� + JsonConvert.SerializeObject(model));
                 }
 
-                // 鏌ョ湅瀹瑰櫒涓庤捣鐐硅揣浣嶆槸鍚︾粦瀹�-                var locCntrRel = db.Queryable<TN_Loc_Container>().First(
-                    a => a.S_LOC_CODE == startLoc.S_CODE);
-                if (locCntrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 鏃犲彲鍑哄簱鐨勭墿鏂�);
+                var startLoc = db.Queryable<TN_Location>()
+                    .Where(ExprHelper.LocCode(model.StartLoc)) // 鎸囧畾锛氳捣鐐硅揣浣�+                    .Where(ExprHelper.LocIsFree)
+                    //.Where(ExprHelper.LocIsEmpty)
+                    .First();
+
+                if (startLoc == null) {
+                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 涓嶅瓨鍦ㄦ垨涓嶅叿澶囧彇璐ц姹�);
+                }
+
+                // 缁戝畾璐т綅鍜屽鍣ㄥ彿
+                var locCntrRel = new TN_Loc_Container {
+                    S_LOC_CODE = model.StartLoc,
+                    S_CNTR_CODE = cgDetail.S_CNTR_CODE,
+                    S_CNTR_TYPE = "濂借繍绠�,
+                };
+
+                if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) {
+                    return BuildSimpleResult(4, $"鎻掑叆璐т綅瀹瑰櫒鍏崇郴澶辫触锛� + JsonConvert.SerializeObject(locCntrRel));
                 }
 
                 // TODO 婊$鍏ュ簱绠楁硶寰呬紭鍖�                 var endLoc = db.Queryable<TN_Location>()
                     .Where(ExprHelper.LocBelongsToArea(AreaName.婊$瀛樻斁鍖�)
                     .Where(ExprHelper.LocIsFree)
-                    .Where(ExprHelper.LocIsFree)
+                    .Where(ExprHelper.LocIsEmpty)
                     .OrderBy(l => l.N_LAYER)
                     .OrderBy(l => l.S_AREA_CODE).First();
 
                 if (endLoc == null) {
-                    return BuildSimpleResult(4, "婊$鍏ュ簱鏆傛椂娌℃湁鍚堥�鐨勮揣浣嶅彲浠ュ叆搴�);
+                    return BuildSimpleResult(5, "婊$鍏ュ簱鏆傛椂娌℃湁鍚堥�鐨勮揣浣嶅彲浠ュ叆搴�);
                 }
 
-                return TaskHelper.SimpleCreateTask(startLoc.S_CODE, locCntrRel.S_CNTR_CODE, endLoc.S_CODE, taskName);
+                return TaskHelper.SimpleCreateTask(startLoc.S_CODE, locCntrRel.S_CNTR_CODE, endLoc.S_CODE, taskName, failCode: 6);
             }
             catch (Exception ex) {
                 return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
             }
         }
 
-        /// <summary>
-        /// 绌烘墭鐩樼粦瀹�PDA)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        public static SimpleResult EmptyBindPallet(EmptyBindInfo model) {
-            var db = DbHelper.GetDbClient();
+        ///// <summary>
+        ///// 绌烘墭鐩樼粦瀹�PDA)
+        ///// </summary>
+        ///// <param name="model"></param>
+        ///// <returns></returns>
+        //public static SimpleResult EmptyBindPallet(EmptyBindInfo model) {
+        //    var db = DbHelper.GetDbClient();
 
-            try {
-                var loc = db.Queryable<TN_Location>()
-                    .Where(ExprHelper.LocCode(model.LocCode))
-                    .Where(ExprHelper.LocBelongsToArea(AreaName.绌烘墭鐩樻帴椹冲尯))
-                    .Where(ExprHelper.LocIsFree)
-                    .Where(ExprHelper.LocIsEmpty).First();
+        //    try {
+        //        var loc = db.Queryable<TN_Location>()
+        //            .Where(ExprHelper.LocCode(model.LocCode))
+        //            .Where(ExprHelper.LocBelongsToArea(AreaName.绌烘墭鐩樻帴椹冲尯))
+        //            .Where(ExprHelper.LocIsFree)
+        //            .Where(ExprHelper.LocIsEmpty).First();
 
-                if (loc == null) {
-                    return BuildSimpleResult(2, $"褰撳墠璐т綅 '{model.LocCode}' 鏃犳硶鍐嶇粦瀹氬鍣�);
-                }
+        //        if (loc == null) {
+        //            return BuildSimpleResult(2, $"褰撳墠璐т綅 '{model.LocCode}' 鏃犳硶鍐嶇粦瀹氬鍣�);
+        //        }
 
-                var locCntrRel = db.Queryable<TN_Loc_Container>()
-                    .Where(lc => lc.S_CNTR_CODE == model.LocCode).First();
+        //        var locCntrRel = db.Queryable<TN_Loc_Container>()
+        //            .Where(lc => lc.S_CNTR_CODE == model.LocCode).First();
 
-                if (locCntrRel != null) {
-                    return BuildSimpleResult(3, $"褰撳墠瀹瑰櫒 '{model.CntrCode}' 宸茬粡涓�'{locCntrRel.S_LOC_CODE}' 缁戝畾");
-                }
+        //        if (locCntrRel != null) {
+        //            return BuildSimpleResult(3, $"褰撳墠瀹瑰櫒 '{model.CntrCode}' 宸茬粡涓�'{locCntrRel.S_LOC_CODE}' 缁戝畾");
+        //        }
 
-                //loc.N_CURRENT_NUM = model.PalletCount;
+        //        //loc.N_CURRENT_NUM = model.PalletCount;
 
-                locCntrRel = new TN_Loc_Container {
-                    S_LOC_CODE = model.LocCode,
-                    S_CNTR_CODE = model.CntrCode
-                };
+        //        locCntrRel = new TN_Loc_Container {
+        //            S_LOC_CODE = model.LocCode,
+        //            S_CNTR_CODE = model.CntrCode
+        //        };
 
-                using (var tran = db.Ado.UseTran()) {
-                    if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0
-                        && db.Updateable<TN_Location>(loc).UpdateColumns(it => it.N_CURRENT_NUM).ExecuteCommand() > 0) {
-                        tran.CommitTran();
-                        return BuildSimpleResult(0, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 鎴愬姛");
-                    }
-                    else {
-                        tran.RollbackTran();
-                        return BuildSimpleResult(4, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 澶辫触");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleEx(ex);
-            }
-        }
+        //        using (var tran = db.Ado.UseTran()) {
+        //            if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0
+        //                && db.Updateable<TN_Location>(loc).UpdateColumns(it => it.N_CURRENT_NUM).ExecuteCommand() > 0) {
+        //                tran.CommitTran();
+        //                return BuildSimpleResult(0, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 鎴愬姛");
+        //            }
+        //            else {
+        //                tran.RollbackTran();
+        //                return BuildSimpleResult(4, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 澶辫触");
+        //            }
+        //        }
+        //    }
+        //    catch (Exception ex) {
+        //        return BuildSimpleEx(ex);
+        //    }
+        //}
 
-        /// <summary>
-        /// 绌虹缁戝畾(PDA)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        public static SimpleResult EmptyBindGoodpack(EmptyBindInfo model) {
-            var db = DbHelper.GetDbClient();
+        ///// <summary>
+        ///// 绌虹缁戝畾(PDA)
+        ///// </summary>
+        ///// <param name="model"></param>
+        ///// <returns></returns>
+        //public static SimpleResult EmptyBindGoodpack(EmptyBindInfo model) {
+        //    var db = DbHelper.GetDbClient();
 
-            try {
-                var loc = db.Queryable<TN_Location>()
-                    .Where(ExprHelper.LocCode(model.LocCode))
-                    .Where(ExprHelper.LocBelongsToArea(AreaName.绌虹鎺ラ┏鍖�)
-                    .Where(ExprHelper.LocIsFree)
-                    .Where(ExprHelper.LocIsEmpty).First();
+        //    try {
+        //        var loc = db.Queryable<TN_Location>()
+        //            .Where(ExprHelper.LocCode(model.LocCode))
+        //            .Where(ExprHelper.LocBelongsToArea(AreaName.绌虹鎺ラ┏鍖�)
+        //            .Where(ExprHelper.LocIsFree)
+        //            .Where(ExprHelper.LocIsEmpty).First();
 
-                if (loc == null) {
-                    return BuildSimpleResult(2, $"褰撳墠璐т綅 '{model.LocCode}' 鏃犳硶鍐嶇粦瀹氬鍣�);
-                }
+        //        if (loc == null) {
+        //            return BuildSimpleResult(2, $"褰撳墠璐т綅 '{model.LocCode}' 鏃犳硶鍐嶇粦瀹氬鍣�);
+        //        }
 
-                var locCntrRel = db.Queryable<TN_Loc_Container>()
-                    .Where(lc => lc.S_CNTR_CODE == model.LocCode).First();
+        //        var locCntrRel = db.Queryable<TN_Loc_Container>()
+        //            .Where(lc => lc.S_CNTR_CODE == model.LocCode).First();
 
-                if (locCntrRel != null) {
-                    return BuildSimpleResult(3, $"褰撳墠瀹瑰櫒 '{model.CntrCode}' 宸茬粡涓�'{locCntrRel.S_LOC_CODE}' 缁戝畾");
-                }
+        //        if (locCntrRel != null) {
+        //            return BuildSimpleResult(3, $"褰撳墠瀹瑰櫒 '{model.CntrCode}' 宸茬粡涓�'{locCntrRel.S_LOC_CODE}' 缁戝畾");
+        //        }
 
-                loc.N_CURRENT_NUM = 1; // 绌虹缁戝畾鏃跺鍣ㄦ暟蹇呯劧涓�1
+        //        loc.N_CURRENT_NUM = 1; // 绌虹缁戝畾鏃跺鍣ㄦ暟蹇呯劧涓�1
 
-                locCntrRel = new TN_Loc_Container {
-                    S_LOC_CODE = model.LocCode,
-                    S_CNTR_CODE = model.CntrCode
-                };
+        //        locCntrRel = new TN_Loc_Container {
+        //            S_LOC_CODE = model.LocCode,
+        //            S_CNTR_CODE = model.CntrCode
+        //        };
 
-                using (var tran = db.Ado.UseTran()) {
-                    if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0
-                        && db.Updateable<TN_Location>(loc).UpdateColumns(it => it.N_CURRENT_NUM).ExecuteCommand() > 0) {
-                        tran.CommitTran();
-                        return BuildSimpleResult(0, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 鎴愬姛");
-                    }
-                    else {
-                        tran.RollbackTran();
-                        return BuildSimpleResult(4, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 澶辫触");
-                    }
-                }
-
-            }
-            catch (Exception ex) {
-                return BuildSimpleEx(ex);
-            }
-        }
+        //        using (var tran = db.Ado.UseTran()) {
+        //            if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0
+        //                && db.Updateable<TN_Location>(loc).UpdateColumns(it => it.N_CURRENT_NUM).ExecuteCommand() > 0) {
+        //                tran.CommitTran();
+        //                return BuildSimpleResult(0, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 鎴愬姛");
+        //            }
+        //            else {
+        //                tran.RollbackTran();
+        //                return BuildSimpleResult(4, $"缁戝畾瀹瑰櫒 '{model.CntrCode}' 涓庤揣浣�'{model.LocCode}' 澶辫触");
+        //            }
+        //        }
+        //    }
+        //    catch (Exception ex) {
+        //        return BuildSimpleEx(ex);
+        //    }
+        //}
 
         /// <summary>
         /// 鎵樼洏-绌烘墭鍏ュ簱(PDA)
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        public static SimpleResult EmptyInboundPallet(EmptyInboundDetailInfo model) {
+        public static SimpleResult EmptyInboundPallet(EmptyInboundInfo model) {
             var taskName = TaskName.鎵樼洏_绌烘墭鍏ュ簱;
             var db = DbHelper.GetDbClient();
 
             try {
+
+
                 var startLoc = db.Queryable<TN_Location>()
                     .Where(ExprHelper.LocCode(model.StartLoc))
                     .Where(ExprHelper.LocIsFree)
-                    .Where(ExprHelper.LocIsEmpty.Negate()).First();
+                    .Where(ExprHelper.LocIsEmpty.Negate())
+                    .First();
 
                 if (startLoc == null) {
                     return BuildSimpleResult(2, $"璧风偣浣嶇疆 '{model.StartLoc}' 涓嶅瓨鍦ㄦ垨涓嶅叿澶囧彇璐ц姹�);
                 }
 
                 // 鏌ョ湅瀹瑰櫒涓庤捣鐐硅揣浣嶆槸鍚︾粦瀹�-                var locCntrRel = db.Queryable<TN_Loc_Container>().First(
-                    a => a.S_LOC_CODE == model.StartLoc
-                    && a.S_CNTR_CODE == model.CntId);
+                var locCntrRel = db.Queryable<TN_Loc_Container>()
+                    .Where(c => c.S_LOC_CODE == model.StartLoc && c.S_CNTR_CODE == model.CntrCode)
+                    .First();
+
                 if (locCntrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 娌℃湁缁戝畾瀹瑰櫒 '{model.CntId}'");
+                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 娌℃湁缁戝畾瀹瑰櫒 '{model.CntrCode}'");
                 }
 
                 // TODO 鏆傚畾閫夋嫨鏈�綆灞傛寜鍖轰綅椤哄簭鍏ュ簱锛屽悗闈㈠緟淇敼
@@ -216,7 +231,7 @@
         /// 濂借繍绠�绌虹鍏ュ簱(PDA)
         /// </summary>
         /// <returns></returns>
-        public static SimpleResult EmptyInboundGoodpack(EmptyInboundDetailInfo model) {
+        public static SimpleResult EmptyInboundGoodpack(EmptyInboundInfo model) {
             var taskName = TaskName.濂借繍绠盻绌虹鍏ュ簱;
             var db = DbHelper.GetDbClient();
 
@@ -231,11 +246,12 @@
                 }
 
                 // 鏌ョ湅瀹瑰櫒涓庤捣鐐硅揣浣嶆槸鍚︾粦瀹�-                var locCntrRel = db.Queryable<TN_Loc_Container>().First(
-                    a => a.S_LOC_CODE == model.StartLoc
-                    && a.S_CNTR_CODE == model.CntId);
+                var locCntrRel = db.Queryable<TN_Loc_Container>()
+                    .Where(c => c.S_LOC_CODE == model.StartLoc && c.S_CNTR_CODE == model.CntrCode)
+                    .First();
+
                 if (locCntrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 娌℃湁缁戝畾瀹瑰櫒 '{model.CntId}'");
+                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 '{model.StartLoc}' 娌℃湁缁戝畾瀹瑰櫒 '{model.CntrCode}'");
                 }
 
                 // TODO 鏆傚畾閫夋嫨鏈�綆灞傛寜鍖轰綅椤哄簭鍏ュ簱锛屽悗闈㈠緟淇敼
@@ -394,28 +410,31 @@
                 return BuildSimpleEx(ex);
             }
         }
-
+        /// <summary>
+        /// 鎶芥-鍚堟牸鍥炲簱(PDA)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
         public static SimpleResult QualifiedBack(QualifiedBackInfo model) {
             var db = DbHelper.GetDbClient();
 
             try {
-
                 var cgDetail = db.Queryable<TN_CG_Detail>()
                     .Where(d => d.S_ITEM_CODE == model.ItemCode && d.S_CNTR_CODE == model.CntrCode)
                     .First();
                 
                 if (cgDetail == null) {
-                    return BuildSimpleResult(2, "娌℃湁鎵惧埌寰呭洖搴撶殑鎶芥鐗╂枡");
+                    return BuildSimpleResult(2, "娌℃湁鎵惧埌寰呭洖搴撶殑鎶芥鐗╂枡锛� + JsonConvert.SerializeObject(model));
                 }
 
                 cgDetail.N_ITEM_STATE = 0;
                 cgDetail.S_ITEM_STATE = "鍚堟牸";
 
-                // TODO 涓嶉渶瑕佽仈绔嬩笁涓〃
                 var startLocCntrRel = db.Queryable<TN_Location, TN_Loc_Container>
                     ((l, c) => l.S_CODE == c.S_LOC_CODE)
-                    .Where(ExprHelper.LocIsFree)
-                    .Select((l, c) => c)
+                    .Where((l, c) => c.S_CNTR_CODE == cgDetail.S_CNTR_CODE) // 鎸囧畾瀹瑰櫒鍙�+                    .Where(ExprHelper.LocIsFree) // NOTE 妫�煡
+                    .Select((l, c) => c) // 绛涢� Loc_Container
                     .First();
 
                 if (startLocCntrRel == null) {
@@ -468,7 +487,6 @@
                 cgDetail.N_ITEM_STATE = 2;
                 cgDetail.S_ITEM_STATE = "涓嶅悎鏍�;
 
-                // TODO 涓嶉渶瑕佽仈绔嬩笁涓〃
                 var startLocCntrRel = db.Queryable<TN_Location, TN_Loc_Container>
                     ((l, c) => l.S_CODE == c.S_LOC_CODE)
                     .Where(ExprHelper.LocIsFree)
@@ -573,6 +591,7 @@
                             S_ITEM_CODE = cgDetail.S_ITEM_CODE,
                             S_BATCH_NO = cgDetail.S_BATCH_NO,
                             S_CNTR_CODE = cgDetail.S_CNTR_CODE,
+                            N_COUNT = cgDetail.N_QTY,
                             S_END_AREA = model.EndArea
                         };
 
@@ -585,9 +604,9 @@
                     var order = new TN_Outbound_Order {
                         S_NO = orderNo,
                         S_ITEM_CODE = model.ItemCode,
-                        S_BATCH_NO = model.BatchNo,
-                        F_QTY = model.Qty,
-                        F_OUT_QTY = cgDetailList.Sum(a => a.N_QTY),
+                        S_BATCH = model.BatchNo,
+                        N_END_NUM = model.Qty,                        
+                        //F_OUT_QTY = cgDetailList.Sum(a => a.N_QTY),
                         S_END_AREA = model.EndArea
                     };
 
@@ -646,9 +665,9 @@
                     var order = new TN_Outbound_Order {
                         S_NO = orderNo,
                         S_ITEM_CODE = model.ItemCode,
-                        S_BATCH_NO = model.BatchNo,
-                        F_QTY = model.Qty,
-                        F_OUT_QTY = cgDetailList.Sum(a => a.N_QTY),
+                        S_BATCH = model.BatchNo,
+                        N_END_NUM = model.Qty,
+                        //F_OUT_QTY = cgDetailList.Sum(a => a.N_QTY),
                         S_END_AREA = model.EndArea
                     };
 
@@ -692,7 +711,7 @@
                     .OrderBy(d => d.N_QTY, OrderByType.Desc)
                     .OrderBy(d => d.N_ITEM_STATE, OrderByType.Asc).ToList();
 
-                if (sortedMaterials.Count == 0)//娌℃湁婊¤冻鏉′欢鐨�+                if (sortedMaterials.Count == 0) //娌℃湁婊¤冻鏉′欢鐨�                 {
                     return result;
                 }
diff --git a/Services/WmsService.cs b/Services/WmsService.cs
new file mode 100644
index 0000000..2d58939
--- /dev/null
+++ b/Services/WmsService.cs
@@ -0,0 +1,67 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using HH.WCS.Mobox3.DSZSH.AppStart;
+using HH.WCS.Mobox3.DSZSH.Helpers;
+using HH.WCS.Mobox3.DSZSH.Models;
+
+using Newtonsoft.Json;
+
+using static HH.WCS.Mobox3.DSZSH.Dtos.Request.WmsRequest;
+using static HH.WCS.Mobox3.DSZSH.Dtos.Response.WmsResponse;
+
+namespace HH.WCS.Mobox3.DSZSH.Services {
+    public class WmsService {
+        /// <summary>
+        /// 鍗氬疄鐗╂枡淇℃伅涓嬪彂鍚屾
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public static WmsResult CgInfoSync(CgInfoSyncInfo model) {
+            var db = DbHelper.GetDbClient();
+            var random = new Random();
+
+			try {
+                var detail = new TN_CG_Detail {
+                    S_ITEM_CODE = model.ItemCode,
+                    S_ITEM_NAME = model.ItemName,
+                    S_CNTR_CODE = Guid.NewGuid().ToString("D"), // NOTE 瀹瑰櫒鍙凤細鐩墠闅忔満锛堝悗鏈熷彲鑳戒細鎸囧畾锛屾垨鑰匬DA缁戝畾鏃跺啀濉叆锛�+                    S_BATCH_NO = model.BatchNo,
+                    S_STANDARD = model.Standard,
+                    S_NET_WEIGHT = model.NetWeight,
+                    S_QUALITY_GRADE = model.QualityGrade,
+                    N_PRODUCT_LINE = random.Next(0, 3), // NOTE 浜х嚎鍙凤細鐩墠闅忔満锛堝悗鏈熷彲鑳戒細鎸囧畾锛屾垨鑰匬DA缁戝畾鏃跺啀濉叆锛�+                };
+
+                // 璐т綅瀹瑰櫒缁戝畾鐨勯�杈戯紝鍦ㄥソ杩愮涓嬬嚎PDA鐨勬祦绋嬩腑鎿嶄綔
+
+                //var locCntrRel = new TN_Loc_Container {
+                //    //S_LOC_CODE = Settings.Config.ProductionLines[detail.N_PRODUCT_LINE].OffLoc[0], // 濂借繍绠辩殑浣嶇疆鏄搷浣滃尯锛屼笉鏄骇绾�+                //    S_CNTR_CODE = detail.S_CNTR_CODE,
+                //    S_CNTR_TYPE = "濂借繍绠�, // 璐存爣鏈哄彧閽堝濂借繍绠�+                //};
+
+                //using (var tran = db.Ado.UseTran()) {
+                //    if (db.Insertable<TN_CG_Detail>(detail).ExecuteCommand() <= 0
+                //        && db.Insertable<TN_Loc_Container>(detail).ExecuteCommand() <= 0) {
+                //        tran.RollbackTran();
+                //        return MesResultBuilder(2, "鎻掑叆鐗╂枡淇℃伅澶辫触锛� + JsonConvert.SerializeObject(detail));
+                //    }
+                //    tran.CommitTran();
+                //}
+
+                if (db.Insertable<TN_CG_Detail>(detail).ExecuteCommand() <= 0) {
+                    return MesResultBuilder(2, "鎻掑叆鐗╂枡淇℃伅澶辫触锛� + JsonConvert.SerializeObject(detail));
+                }
+
+                return MesResultBuilder(0, "鎻掑叆鐗╂枡淇℃伅鎴愬姛");
+			}
+			catch (Exception ex) {
+                return MesResultBuilder(1, ex.Message);
+			}
+        }
+    }
+}
diff --git a/config/config.json b/config/config.json
index bca70e9..3aa016c 100644
--- a/config/config.json
+++ b/config/config.json
@@ -1,7 +1,7 @@
 {
-    "WebApiUrl": "http://192.168.1.141:8901/",
+    "WebApiUrl": "http://192.168.1.141:8901",
     "NdcApiUrl": "http://127.0.0.1:5201/api/order/",
-    "SqlServer": "Data Source=(local);Initial Catalog=DSZSHTest;User ID=sa;Password=123456;",
+    "SqlServer": "Data Source=192.168.1.87;Initial Catalog=AMS_OIMobox;User ID=sa;Password=123456;",
     "TcpServerIp": "127.0.0.1",
     "TcpServerPort": 8085,
     "Areas": [
@@ -108,12 +108,6 @@
         },
         {
             "Name": "鎴愬搧鑳跺嚭搴�
-        },
-        {
-            "Name": "鎵樼洏-绌烘墭缁戝畾"
-        },
-        {
-            "Name": "濂借繍绠�绌虹缁戝畾"
         }
     ],
     "ProductionLines": [

--
Gitblit v1.9.1