From a8627a98b82d2364cbe849ca746e72fbab9916e5 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期三, 21 五月 2025 17:31:14 +0800
Subject: [PATCH] 重构代码修复事务问题,测试完善后台盘点功能

---
 device/S7Helper.cs                                                                   |    4 
 Models/TN_Container.cs                                                               |    2 
 Dispatch/NDCHelper.cs                                                                |    2 
 wms/WMSHelper.cs                                                                     |   15 
 api/ApiModel.cs                                                                      |  481 +++++++++
 Dispatch/NDC.cs                                                                      |    2 
 device/OpcUaHelper.cs                                                                |    2 
 api/AgvController.cs                                                                 |   18 
 Models/TN_Location.cs                                                                |    2 
 wms/ContainerHelper.cs                                                               |   12 
 process/TaskProcess.cs                                                               |   79 -
 App_Start/Startup.cs                                                                 |    0 
 wms/SYSHelper.cs                                                                     |    8 
 models/TN_Count_Diff.cs                                                              |   21 
 process/DeviceProcess.cs                                                             |    5 
 api/ErpController.cs                                                                 |   11 
 models/TN_Count_CG_Detail.cs                                                         |   22 
 Dispatch/GZRobot.cs                                                                  |   27 
 util/LogHelper.cs                                                                    |   11 
 HH.WCS.Mobox3.AnGang.csproj                                                          |  120 +-
 device/SnapDevice.cs                                                                 |   10 
 util/Settings.cs                                                                     |  113 ++
 App_Start/SwaggerControllerDescProvider.cs                                           |    0 
 api/ApiHelper.cs                                                                     |  612 ++++++++++++
 models/TN_Count_Plan.cs                                                              |   38 
 Models/TN_CAR_IN.cs                                                                  |    2 
 Models/TN_Outbound_Order.cs                                                          |    2 
 Program.cs                                                                           |   16 
 Models/BaseModel.cs                                                                  |    2 
 core/Monitor.cs                                                                      |  159 +++
 Models/TN_Task.cs                                                                    |    2 
 Models/TN_Task_Action.cs                                                             |    2 
 config/config.json                                                                   |    4 
 App_Start/SwaggerConfig.cs                                                           |    0 
 wms/WCSHelper.cs                                                                     |   70 +
 device/TcpClient.cs                                                                  |    4 
 device/TcpServer.cs                                                                  |    4 
 .vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c94de693-d780-402e-840f-826433af2f96.vsidx |    0 
 models/TN_Count_Order.cs                                                             |   24 
 Models/TN_Inbound_Order.cs                                                           |    2 
 Dispatch/NDCApi.cs                                                                   |    5 
 core/WMSCore.cs                                                                      |    4 
 Models/TN_Loc_Container.cs                                                           |    2 
 device/SnapManager.cs                                                                |    6 
 device/ModbusHelper.cs                                                               |    2 
 wms/LocationHelper.cs                                                                |   44 
 /dev/null                                                                            |  363 -------
 device/PlcHelper.cs                                                                  |    2 
 Models/TN_WorkOrder.cs                                                               |    2 
 core/WCSCore.cs                                                                      |  160 +-
 api/WmsController.cs                                                                 |    4 
 util/SqlHelper.cs                                                                    |   70 +
 api/DebugController.cs                                                               |  320 ++++++
 util/HttpHelper.cs                                                                   |    0 
 Models/TN_CG_Detail.cs                                                               |    3 
 Dispatch/HanAo.cs                                                                    |    2 
 .vs/HH.WCS.Mobox3.AnGang/FileContentIndex/1a441e71-f454-4033-af8e-db39c2339a05.vsidx |    0 
 api/MoboxController.cs                                                               |  115 ++
 58 files changed, 2,307 insertions(+), 707 deletions(-)

diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/05336dc4-4629-4a97-bb9a-4516a380cd0d.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/05336dc4-4629-4a97-bb9a-4516a380cd0d.vsidx
deleted file mode 100644
index ab70759..0000000
--- a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/05336dc4-4629-4a97-bb9a-4516a380cd0d.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/1a441e71-f454-4033-af8e-db39c2339a05.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/1a441e71-f454-4033-af8e-db39c2339a05.vsidx
new file mode 100644
index 0000000..da03df8
--- /dev/null
+++ b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/1a441e71-f454-4033-af8e-db39c2339a05.vsidx
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/bd85daa8-32a5-4c87-9f8f-b1ed513fa1f8.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/bd85daa8-32a5-4c87-9f8f-b1ed513fa1f8.vsidx
deleted file mode 100644
index ddb7fec..0000000
--- a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/bd85daa8-32a5-4c87-9f8f-b1ed513fa1f8.vsidx
+++ /dev/null
Binary files differ
diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c94de693-d780-402e-840f-826433af2f96.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c94de693-d780-402e-840f-826433af2f96.vsidx
new file mode 100644
index 0000000..2ccb1c0
--- /dev/null
+++ b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c94de693-d780-402e-840f-826433af2f96.vsidx
Binary files differ
diff --git a/AppStart/Config.cs b/AppStart/Config.cs
deleted file mode 100644
index cea2e11..0000000
--- a/AppStart/Config.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-锘縰sing System.Collections.Generic;
-
-// 鏍规嵁 JSON 鏂囦欢 鐢熸垚瀵瑰簲鐨�C# 瀵硅薄锛涚綉鍧�細https://json2csharp.com/
-// 1. 灏�config.json 鏂囦欢澶嶅埗鍒扮綉鍧�腑
-// 2. 灏嗗緱鍒扮殑鍐呭澶嶅埗鍒�namespace HH.WCS.Mobox3.{椤圭洰浠e彿}.AppStart { } 澶ф嫭鍙峰唴閮紙C# 10 鎵嶆敮鎸�鏂囦欢鑼冨洿鍐呯殑鍛藉悕绌洪棿锛�-// 3. 灏�Root 鏇村悕涓�Config
-// 琛ュ厖锛氳繖绉嶆柟寮忔病娉曚繚鐣欐敞閲婏紝闇�鐔熸倝 Config 鏂囦欢鐨勫瓧娈靛惈涔夛紙鏆備笉鑰冭檻浠g爜鐢熸垚 Json 鏂囦欢锛�-
-namespace HH.WCS.Mobox3.AnGang.AppStart {
-    // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
-    public class Area {
-        public string Name { get; set; }
-        public List<string> Codes { get; set; }
-    }
-
-    public class Config {
-        public string WebApiUrl { get; set; }
-        public string RCSApiUrl { get; set; }
-        public string NDCApiUrl { get; set; }
-        public string SqlServer { get; set; }
-        public string TCPServerIP { get; set; }
-        public int TCPServerPort { get; set; }
-        public List<Area> Areas { get; set; }
-        public List<Snap> Snap { get; set; }
-        public string CaptureUrl { get; set; }
-    }
-
-    public class Snap {
-        public string Ip { get; set; }
-        public int Port { get; set; }
-        public string Name { get; set; }
-        public string Pwd { get; set; }
-    }
-
-
-}
diff --git a/AppStart/Settings.cs b/AppStart/Settings.cs
deleted file mode 100644
index 9f0a7ad..0000000
--- a/AppStart/Settings.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.IO;
-
-using HH.WCS.Mobox3.AnGang;
-
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-
-namespace HH.WCS.Mobox3.AnGang.AppStart {
-    public class Settings {
-        /// <summary>
-        /// 閰嶇疆鏂囦欢
-        /// </summary>
-        public static Config Config { get; set; }
-
-        /// <summary>
-        /// 搴撳尯瀛楀吀锛堝姞杞藉悗灏变笉鍙橈級
-        /// </summary>
-        public static Dictionary<string, List<string>> AreaMap { get; set; } = new Dictionary<string, List<string>>();
-
-        //public static Snap Snap { get; set; }
-        public static string CaptureUrl { get; set; }
-
-        public static void Init() {
-            // 鍔犺浇閰嶇疆鏂囦欢
-            LoadJson();
-
-            // 閽堝 Areas 杩涜杞崲锛氬皢 Config 鐨�List 鍔犺浇鍒�Dict 涓�-            LoadAreas();
-
-            //Snap = Config.Snap[0]; // 鐩墠鏈」鐩彧鏈変竴涓浉鏈�-            CaptureUrl = Config.CaptureUrl; // 淇濆瓨鍥剧墖鐨勬牴鐩綍
-        }
-
-        private static void LoadJson() {
-            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 寮�");
-            // JSON 鏂囦欢璺緞
-            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./config/config.json");
-
-            try {
-                // 璇诲彇 JSON 鏂囦欢鍐呭
-                string jsonContent = File.ReadAllText(filePath);
-
-                // 鍙嶅簭鍒楀寲涓�Config 瀵硅薄
-                Config = JsonConvert.DeserializeObject<Config>(jsonContent);
-            }
-            catch (FileNotFoundException) {
-                LogHelper.Info("JSON 鏂囦欢鏈壘鍒�);
-            }
-            catch (JsonException ex) {
-                LogHelper.Info($"JSON 瑙f瀽閿欒: {ex.Message}");
-            }
-            catch (Exception ex) {
-                LogHelper.Info($"鍙戠敓閿欒: {ex.Message}");
-            }
-            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚");
-        }
-
-        private static void LoadAreas() {
-            foreach (var area in Config.Areas) {
-                AreaMap.Add(area.Name, area.Codes);
-            }
-        }
-    }
-}
diff --git a/AppStart/Startup.cs b/App_Start/Startup.cs
similarity index 100%
rename from AppStart/Startup.cs
rename to App_Start/Startup.cs
diff --git a/AppStart/SwaggerConfig.cs b/App_Start/SwaggerConfig.cs
similarity index 100%
rename from AppStart/SwaggerConfig.cs
rename to App_Start/SwaggerConfig.cs
diff --git a/AppStart/SwaggerControllerDescProvider.cs b/App_Start/SwaggerControllerDescProvider.cs
similarity index 100%
rename from AppStart/SwaggerControllerDescProvider.cs
rename to App_Start/SwaggerControllerDescProvider.cs
diff --git a/Consts/AgvStateCode.cs b/Consts/AgvStateCode.cs
deleted file mode 100644
index 32d2048..0000000
--- a/Consts/AgvStateCode.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    public class AgvStateCode {
-        public const int 鎵ц = 1;
-        public const int 瀹屾垚 = 2;
-        public const int 寮�鍙栬揣 = 3;
-        public const int 鍙栬揣瀹屾垚 = 4;
-        public const int 寮�鍗歌揣 = 5;
-        public const int 鍗歌揣瀹屾垚 = 6;
-        public const int 寮傚父 = 7;
-    }
-}
diff --git a/Consts/AgvStateName.cs b/Consts/AgvStateName.cs
deleted file mode 100644
index 6e7f817..0000000
--- a/Consts/AgvStateName.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    public class AgvStateName {
-        public const string 鎵ц = "鎵ц";
-        public const string 瀹屾垚 = "瀹屾垚";
-        public const string 寮�鍙栬揣 = "寮�鍙栬揣";
-        public const string 鍙栬揣瀹屾垚 = "鍙栬揣瀹屾垚";
-        public const string 寮�鍗歌揣 = "寮�鍗歌揣";
-        public const string 鍗歌揣瀹屾垚 = "鍗歌揣瀹屾垚";
-        public const string 寮傚父 = "寮傚父";
-    }
-}
diff --git a/Consts/AreaCode.cs b/Consts/AreaCode.cs
deleted file mode 100644
index 952b457..0000000
--- a/Consts/AreaCode.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    public class AreaCode {
-        public const string 鏀跺彂鍖�= "SFQ";
-        public const string 璐ф灦鍖�= "HJQ";
-    }
-}
diff --git a/Consts/LockStateCode.cs b/Consts/LockStateCode.cs
deleted file mode 100644
index f61e5be..0000000
--- a/Consts/LockStateCode.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    public class LockStateCode {
-        public const int 鏃�= 0;
-        public const int 鍏ュ簱閿�= 1;
-        public const int 鍑哄簱閿�= 2;
-        public const int 鍏朵粬閿�= 3;
-    }
-}
diff --git a/Consts/LockStateName.cs b/Consts/LockStateName.cs
deleted file mode 100644
index 8fad39f..0000000
--- a/Consts/LockStateName.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    /// <summary>
-    /// [鍘熷垯涓婁笉淇敼] 浣嶇疆閿佸悕绉�瀛楃涓插父閲�-    /// </summary>
-    public class LockStateName {
-        public const string 鏃�= "鏃�;
-        public const string 鍏ュ簱閿�= "鍏ュ簱閿�;
-        public const string 鍑哄簱閿�= "鍑哄簱閿�;
-        public const string 鍏朵粬閿�= "鍏朵粬閿�;
-    }
-}
diff --git a/Consts/TaskName.cs b/Consts/TaskName.cs
deleted file mode 100644
index 071eb9e..0000000
--- a/Consts/TaskName.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Consts {
-    public class TaskName {
-        public const string 浜у搧鍏ュ簱 = "浜у搧鍏ュ簱";
-        public const string 浜у搧閮ㄥ垎鍑哄簱 = "浜у搧閮ㄥ垎鍑哄簱";
-        public const string 浜у搧閮ㄥ垎鍥炲簱 = "浜у搧閮ㄥ垎鍥炲簱";
-        public const string 鐩樼偣鐞嗚揣鍑哄簱 = "鐩樼偣鐞嗚揣鍑哄簱";
-    }
-}
diff --git a/Controllers/ApiModel.cs b/Controllers/ApiModel.cs
deleted file mode 100644
index 9d11717..0000000
--- a/Controllers/ApiModel.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-锘縰sing System.Collections.Generic;
-
-namespace HH.WCS.Mobox3.AnGang.Controllers
-{
-    /// <summary>
-    /// 閫氱敤model
-    /// </summary>
-    public class ApiModel
-    {
-
-        #region mobox 鐩稿叧
-        /// <summary>
-        /// mobox 鍙栨秷浠诲姟銆佹爣璁板畬鎴愪换鍔�-        /// </summary>
-        public class MoboxTaskBase
-        {
-            public string TaskNo { get; set; }
-        }
-        
-
-        /// <summary>
-        /// 缁戝畾 鍙傛暟
-        /// </summary>
-        public class BindParme
-        {
-            /// <summary>
-            /// 鎵樼洏缂栫爜
-            /// </summary>
-            public string CntrCode { get; set; }
-            /// <summary>
-            /// 鎵樼洏绫诲瀷
-            /// </summary>
-            public string CntrType { get; set; }
-            /// <summary>
-            /// 璐т綅缂栫爜
-            /// </summary>
-            public string LocCode { get; set; }
-            /// <summary>
-            /// 鐗╂枡缂栫爜
-            /// </summary>
-            public string ItemCode { get; set; }
-            /// <summary>
-            /// 鐗╂枡鏁伴噺
-            /// </summary>
-            public int ItemQuantity { get; set; }
-        }
-
-        /// <summary>
-        /// 瑙g粦 鍙傛暟
-        /// </summary>
-        public class UnBindParme
-        {
-            /// <summary>
-            /// 鎵樼洏缂栫爜
-            /// </summary>
-            public string CntrCode { get; set; }
-
-        }
-
-        public class sendTask
-        {
-
-            /// <summary>
-            /// 璁㈠崟鍚�-            /// </summary>
-            public string ts { get; set; }
-        }
-
-
-
-        /// <summary>
-        /// 瀹夊叏浜や簰
-        /// </summary>
-        public class Interaction
-        {
-            public string station_name { get; set; }
-            public string apply_code { get; set; }
-            public int orderid { get; set; }
-        }
-
-        
-        #endregion
-    }
-}
diff --git a/Controllers/DebugController.cs b/Controllers/DebugController.cs
deleted file mode 100644
index 8d56d64..0000000
--- a/Controllers/DebugController.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-锘縰sing System.Linq;
-using HH.WCS.Mobox3.AnGang.ServiceCore;
-using HH.WCS.Mobox3.AnGang.Devices;
-using HH.WCS.Mobox3.AnGang.Dispatch;
-using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Web.Http;
-using static Opc.Ua.ContentFilter;
-using System.Threading.Tasks;
-
-using HH.WCS.Mobox3.AnGang.Models;
-using HH.WCS.Mobox3.AnGang.Services;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Debug;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.DebugRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.DebugResponse;
-using static HH.WCS.Mobox3.AnGang.Models.DebugModel;
-
-namespace HH.WCS.Mobox3.AnGang.Controllers
-{
-    /// <summary>
-    /// 娴嬭瘯鐢紝濡傛灉椤圭洰涓鍜岃澶囧鎺ワ紝鍓嶆湡璁惧鏃犳硶娴嬭瘯锛岀敤鎺ュ彛妯℃嫙
-    /// </summary>
-    [RoutePrefix("api")]
-    public class DebugController : System.Web.Http.ApiController
-    {
-        /// <summary>
-        /// 妯℃嫙 AGV 澶氭鍥炴姤浠诲姟鐘舵�
-        /// </summary>
-        /// <param name="model">瀹瑰櫒鍙�/param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("AgvSeriesReports")]
-        public ReturnResults AgvSeriesReports(UpdateTaskState model) {
-            return DebugService.AgvSeriesReports(model);
-        }
-
-        /// <summary>
-        /// 鍒濆鍖栨暟鎹簱
-        /// </summary>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("CreateDatabase")]
-        public string CreateDatabase(CoverInfo model) {
-            return DebugService.CreateDatabase(model.IsCover);
-        }
-
-        /// <summary>
-        /// DEBUG锛氭彃鍏ヨ揣浣嶃�瀹瑰櫒銆佽揣鍝佷俊鎭�-        /// </summary>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("InsertLocCntrCg")]
-        public string InsertLocCntrCg(LocCntrCg model) {
-            return DebugService.InsertLocCntrCg(model);
-        }
-
-        [HttpPost]
-        [Route("SetTaskWeight")]
-        public string SetTaskWeight(SetTaskWeightInfo model) {
-            return DebugService.SetTaskWeight(model);
-        }
-    }
-}
diff --git a/Controllers/MoboxController.cs b/Controllers/MoboxController.cs
deleted file mode 100644
index 351737b..0000000
--- a/Controllers/MoboxController.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-锘縰sing Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Web.Http;
-
-using HH.WCS.Mobox3.AnGang.Services;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.MoboxRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.MoboxResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Controllers 
-{
-    /// <summary>
-    /// Mobox3 璋冪敤锛岃剼鏈腑璋冪敤
-    /// </summary>
-    [RoutePrefix("api")]
-    public class MoboxController : ApiController {
-        /// <summary>
-        /// 璐у搧鍏ュ簱(PDA)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("Inbound")]
-        public SimpleResult Inbound(InboundInfo model) {
-            return MoboxService.Inbound(model);
-        }
-
-        /// <summary>
-        /// PDA閫夋嫨缁堢偣璐т綅
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("SelectLocation")]
-        public SimpleResult SelectLocation(SelectLocationInfo model) {
-            return MoboxService.SelectLocation(model);
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍑哄簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("PartOutbound")]
-        public SimpleResult PartOutbound(PartOutboundInfo model) {
-            return MoboxService.PartOutbound(model);
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍥炲簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("PartInbound")]
-        public SimpleResult PartInbound(PartInboundInfo model) {
-            return MoboxService.PartInbound(model);
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍑哄簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("CheckOutbound")]
-        public SimpleResult CheckOutbound(CheckOutboundInfo model) {
-            return MoboxService.CheckOutbound(model);
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍥炲簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("CheckInbound")]
-        public SimpleResult CheckInbound(CheckInboundInfo model) {
-            return MoboxService.CheckInbound(model);
-        }
-    }
-}
diff --git a/Dispatch/GZRobot.cs b/Dispatch/GZRobot.cs
index 5d4e4e9..070607e 100644
--- a/Dispatch/GZRobot.cs
+++ b/Dispatch/GZRobot.cs
@@ -2,26 +2,19 @@
 using System.Collections.Generic;
 using System.IdentityModel.Protocols.WSTrust;
 using System.Threading.Tasks;
-
 using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Models;
-using HH.WCS.Mobox3.AnGang.Services;
-
+using HH.WCS.Mobox3.AnGang.core;
+using HH.WCS.Mobox3.AnGang.models;
 using Newtonsoft.Json;
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
 
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Dispatch {
+namespace HH.WCS.Mobox3.AnGang.dispatch {
     /// <summary>
     /// 鍥借嚜璋冨害杈呭姪绫�     /// </summary>
     public class GZRobot {
         private static readonly HttpHelper apiHelper = new HttpHelper();
-        private static readonly string baseUrl = AppStart.Settings.Config.RCSApiUrl;//閰嶇疆鏂囦欢鑾峰彇鍥借嚜璋冨害鍦板潃
+        private static readonly string baseUrl = Settings.RCSApiUrl;//閰嶇疆鏂囦欢鑾峰彇鍥借嚜璋冨害鍦板潃
         //private static readonly string logName = "guozi";
         public static List<IOState> GetIO() {
             var result = apiHelper.Get(baseUrl + "api/engine/view/iostates/");
@@ -33,7 +26,6 @@
             var result = apiHelper.Post(baseUrl + "api/engine/tasks/iostates/", JsonConvert.SerializeObject(data));
             var dataResult = JsonConvert.DeserializeObject<gzResult<IOStatesInfoResult>>(result);
         }
-
 
         public static int CreateOrder(string taskNo, int priority, string param, string ts = "churuku", string created_user = "hanhe") {
             LogHelper.Info($"CreateOrder鍙傛暟淇℃伅:taskNo:{taskNo},priority:{priority},param:{param},ts:{ts}锛宑reated_user锛歿created_user}", "API");
@@ -157,7 +149,14 @@
             if (agv.state != 0) {
                 agv.task_no = model.orderName;
                 agv.forklift_no = model.agvIDList;
-                AgvService.OperateAgvTaskStatus(agv);
+                WCSCore.OperateAgvTaskStatus(agv);
+            }
+            else {
+                result.resultCode = 2;
+                result.orderID = model.orderID;
+                result.msg = "鍙嶉璁㈠崟鐘舵�澶辫触锛宱rderStatus鍙傛暟涓嶆纭�;
+                LogHelper.Info(result.msg, "API");
+                return result;
             }
 
             result.resultCode = 0;
diff --git a/Dispatch/HanAo.cs b/Dispatch/HanAo.cs
index 0f17a24..9de4477 100644
--- a/Dispatch/HanAo.cs
+++ b/Dispatch/HanAo.cs
@@ -4,7 +4,7 @@
 using System.Collections.Generic;
 using System.Web.Services.Description;
 
-namespace HH.WCS.Mobox3.AnGang.Dispatch {
+namespace HH.WCS.Mobox3.AnGang.dispatch {
     /// <summary>
     /// 鍥借嚜璋冨害杈呭姪绫�     /// </summary>
diff --git a/Dispatch/NDC.cs b/Dispatch/NDC.cs
index 26f3b8c..58a7300 100644
--- a/Dispatch/NDC.cs
+++ b/Dispatch/NDC.cs
@@ -5,7 +5,7 @@
 
 using Newtonsoft.Json;
 
-namespace HH.WCS.Mobox3.AnGang.Dispatch {
+namespace HH.WCS.Mobox3.AnGang.dispatch {
     public class NDC
     {
         private static HostToAGV callClient = null;
diff --git a/Dispatch/NDCApi.cs b/Dispatch/NDCApi.cs
index 59aab7d..ca4973a 100644
--- a/Dispatch/NDCApi.cs
+++ b/Dispatch/NDCApi.cs
@@ -1,19 +1,18 @@
 锘縰sing System;
 using System.Collections.Generic;
 
-using HH.WCS.Mobox3.AnGang.AppStart;
 using HH.WCS.Mobox3.AnGang.config;
 
 using Newtonsoft.Json;
 
-namespace HH.WCS.Mobox3.AnGang.Dispatch {
+namespace HH.WCS.Mobox3.AnGang.dispatch {
     public class NDCApi
     {
         public static string NDCApiUrl { set; get; }
         static NDCApi()
         {
 
-            NDCApiUrl = Settings.Config.NDCApiUrl;
+            NDCApiUrl = Settings.NDCApiUrl;
         }
 
 
diff --git a/Dispatch/NDCHelper.cs b/Dispatch/NDCHelper.cs
index 3cd639b..aa200d7 100644
--- a/Dispatch/NDCHelper.cs
+++ b/Dispatch/NDCHelper.cs
@@ -2,7 +2,7 @@
 using System.Collections.Generic;
 using System.Text;
 
-namespace HH.WCS.Mobox3.AnGang.Dispatch
+namespace HH.WCS.Mobox3.AnGang.dispatch
 {
     public class NDCHelper
     {
diff --git a/Dtos/Request/AgvRequest.cs b/Dtos/Request/AgvRequest.cs
deleted file mode 100644
index c5d7e76..0000000
--- a/Dtos/Request/AgvRequest.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Request {
-    public class AgvRequest {
-        /// <summary>
-        /// hosttoagv涓婃姤浠诲姟鐘舵�
-        /// </summary>
-        public class AgvTaskState {
-            public int state { get; set; }
-            public string task_no { get; set; }
-            public string forklift_no { get; set; }
-
-            /// <summary>
-            /// 瀹夊叏闂ㄧ紪鍙�-            /// </summary>
-            public string lock_no { get; set; }
-            public string ext_data { get; set; }
-        }
-
-        public class SafetyInteractionInfo {
-            public int station_id { get; set; }
-
-            /// <summary>
-            /// 璇锋眰涓婄嚎/涓嬬嚎鐨勭殑绔欏彴搴撲綅鍚嶇О锛屼緥濡倃ork6銆亀ork8
-            /// </summary>
-            public string station_name { get; set; }
-
-            /// <summary>
-            /// 璇锋眰鐮�-            /// </summary>
-            public string apply_code { get; set; }
-            public string task_no { set; get; }
-        }
-
-        public class orderStatusReportParme {
-            /// <summary>
-            /// 璁㈠崟ID
-            /// </summary>
-            public int orderID { get; set; }
-            /// <summary>
-            /// 璁㈠崟鍚�-            /// </summary>
-            public string orderName { get; set; }
-            /// <summary>
-            /// 璁㈠崟鐘舵�
-            /// </summary>
-            public string orderStatus { get; set; }
-            /// <summary>
-            /// agv杞﹀彿鍒楄〃
-            /// </summary>
-            public string agvIDList { get; set; }
-            /// <summary>
-            /// 浼樺厛绾�-            /// </summary>
-            public string priority { get; set; }
-            /// <summary>
-            /// 璁㈠崟褰撳墠鐨勭洰鐨勫湴
-            /// </summary>
-            public string currentDes { get; set; }
-            /// <summary>
-            /// 褰撳墠鎸囦护
-            /// </summary>
-            public string currentCmd { get; set; }
-
-            /// <summary>
-            /// 閿欒鐮�-            /// </summary>
-            public int errorCode { get; set; }
-
-            /// <summary>
-            /// 璁㈠崟鐨勬埅鑷虫椂闂�-            /// </summary>
-            public string deadLine { get; set; }
-
-            /// <summary>
-            /// 璁㈠崟鐨勫垱寤烘椂闂�-            /// </summary>
-            public string createdTime { get; set; }
-
-            /// <summary>
-            /// 棰濆淇℃伅1
-            /// </summary>
-            public string extraInfo1 { get; set; }
-
-            /// <summary>
-            /// 棰濆淇℃伅2
-            /// </summary>
-            public string extraInfo2 { get; set; }
-        }
-    }
-}
diff --git a/Dtos/Request/DebugRequest.cs b/Dtos/Request/DebugRequest.cs
deleted file mode 100644
index 164e7f5..0000000
--- a/Dtos/Request/DebugRequest.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Request {
-    public class DebugRequest {
-        /// <summary>
-        /// 妯℃嫙 AGV 浼犻�淇″彿锛岀敤浜庢洿鏀逛换鍔$姸鎬�-        /// </summary>
-        public class UpdateTaskState {
-            /// <summary>
-            /// 浠诲姟ID
-            /// </summary>
-            public string TaskID { set; get; }
-            /// <summary>
-            /// AGV 灏忚溅鍙�-            /// </summary>
-            public string ForkliftNo { set; get; }
-            /// <summary>
-            /// AGV 涓嬩竴涓姸鎬�-            /// </summary>
-            public int NextState { set; get; }
-        }
-
-        public class CoverInfo {
-            public bool IsCover { set; get; } = true;
-        }
-
-        public class SetTaskWeightInfo {
-            public string TaskNo { set; get; }
-            public float Weight { set; get; }
-        }
-    }
-}
diff --git a/Dtos/Request/ErpRequest.cs b/Dtos/Request/ErpRequest.cs
deleted file mode 100644
index 3947973..0000000
--- a/Dtos/Request/ErpRequest.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Request {
-    public class ErpRequest {
-        /// <summary>
-        /// 鍏ュ簱鏁版嵁鍚屾淇℃伅
-        /// </summary>
-        public class InboundDataSyncInfo {
-            /// <summary>
-            /// 搴撳瓨鏄庣粏锛堝垪琛級
-            /// </summary>
-            public List<StockTransaction> stockTransactions { get; set; }
-
-            /// <summary>
-            /// 鎬昏褰曟暟
-            /// </summary>
-            public string totalRecords { get; set; }
-
-            /// <summary>
-            /// 鏁版嵁鐢熸垚鏃堕棿鎴�-            /// </summary>
-            public string timestamp { get; set; }
-        }
-
-        /// <summary>
-        /// 搴撳瓨鏄庣粏淇℃伅
-        /// </summary>
-        public class StockTransaction {
-            /// <summary>
-            /// 鍌ㄤ綅鐮�-            /// </summary>
-            public string locationCode { get; set; }
-
-            /// <summary>
-            /// 搴撳瓨鏄庣粏浜ゆ槗鍙�-            /// </summary>
-            public string stockTransactionId { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡缂栫爜
-            /// </summary>
-            public string itemCode { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡鍚嶇О
-            /// </summary>
-            public string itemName { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡鐭弿杩�-            /// </summary>
-            public string itemShortDesc { get; set; }
-
-            /// <summary>
-            /// 搴撳瓨鏁伴噺
-            /// </summary>
-            public string stockQuantity { get; set; }
-
-            /// <summary>
-            /// 鍏ュ簱鏁伴噺
-            /// </summary>
-            public string inQuantity { get; set; }
-
-            /// <summary>
-            /// 搴撳瓨鎬讳环
-            /// </summary>
-            public string totalPrice { get; set; }
-
-            /// <summary>
-            /// 鍏ュ簱鏃堕棿
-            /// </summary>
-            public string stockInTime { get; set; }
-
-            /// <summary>
-            /// 淇濈鍛�-            /// </summary>
-            public string storeKeeper { get; set; }
-
-            /// <summary>
-            /// 浜х嚎閮ㄩ棬浠g爜
-            /// </summary>
-            public string lineCode { get; set; }
-
-            /// <summary>
-            /// 閫佽揣鍗曡鍙�-            /// </summary>
-            public string deliveryItemNo { get; set; }
-
-            /// <summary>
-            /// 渚涘簲鍟嗗悕绉�-            /// </summary>
-            public string supplierName { get; set; }
-
-            /// <summary>
-            /// 搴撳瓨璐d换浜哄鍚�-            /// </summary>
-            public string inventoryManager { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁1
-            /// </summary>
-            public string ext1 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁2
-            /// </summary>
-            public string ext2 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁3
-            /// </summary>
-            public string ext3 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁4
-            /// </summary>
-            public string ext4 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁5
-            /// </summary>
-            public string ext5 { get; set; }
-        }
-
-        /// <summary>
-        /// 鍑哄簱鍙戞枡鍚屾淇℃伅
-        /// </summary>
-        public class OutboundDataSyncInfo {
-            /// <summary>
-            /// 鍙戞枡璁板綍鏄庣粏鍒楄〃
-            /// </summary>
-            public List<MaterialIssue> materialIssues { get; set; }
-
-            /// <summary>
-            /// 鎬昏褰曟暟
-            /// </summary>
-            public string totalRecords { get; set; }
-
-            /// <summary>
-            /// 鏁版嵁鐢熸垚鏃堕棿鎴�-            /// </summary>
-            public string timestamp { get; set; }
-        }
-
-        /// <summary>
-        /// 鍙戞枡璁板綍鏄庣粏淇℃伅
-        /// </summary>
-        public class MaterialIssue {
-            /// <summary>
-            /// 鍌ㄤ綅鐮�-            /// </summary>
-            public string locationCode { get; set; }
-
-            /// <summary>
-            /// 棰嗙敤鍗曞彿
-            /// </summary>
-            public string withdrawalOrderNo { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡缂栫爜
-            /// </summary>
-            public string itemCode { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡鍚嶇О
-            /// </summary>
-            public string itemName { get; set; }
-
-            /// <summary>
-            /// 鐗╂枡鐭弿杩�-            /// </summary>
-            public string itemShortDesc { get; set; }
-
-            /// <summary>
-            /// 瀹炲彂鏁伴噺
-            /// </summary>
-            public string actualIssuedQty { get; set; }
-
-            /// <summary>
-            /// 瀹炲彂閲戦
-            /// </summary>
-            public string issuedAmount { get; set; }
-
-            /// <summary>
-            /// 渚涘簲鍟嗗悕绉�-            /// </summary>
-            public string supplierName { get; set; }
-
-            /// <summary>
-            /// 瀹炲彂浜�-            /// </summary>
-            public string issuer { get; set; }
-
-            /// <summary>
-            /// 鍙戞枡鏃ユ湡
-            /// </summary>
-            public string issueDate { get; set; }
-
-            /// <summary>
-            /// 淇濈鍛�-            /// </summary>
-            public string storeKeeper { get; set; }
-
-            /// <summary>
-            /// 浜х嚎閮ㄩ棬浠g爜
-            /// </summary>
-            public string lineCode { get; set; }
-
-            /// <summary>
-            /// 鎵规
-            /// </summary>
-            public string batchNo { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁1
-            /// </summary>
-            public string ext1 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁2
-            /// </summary>
-            public string ext2 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁3
-            /// </summary>
-            public string ext3 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁4
-            /// </summary>
-            public string ext4 { get; set; }
-
-            /// <summary>
-            /// 澶囩敤瀛楁5
-            /// </summary>
-            public string ext5 { get; set; }
-        }
-    }
-}
diff --git a/Dtos/Request/MoboxRequest.cs b/Dtos/Request/MoboxRequest.cs
deleted file mode 100644
index 57d13bf..0000000
--- a/Dtos/Request/MoboxRequest.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-锘縰sing Newtonsoft.Json;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Request {
-    public class MoboxRequest {
-
-        #region 妯℃澘鏁版嵁绫�-
-        /// <summary>
-        /// 妯℃澘鏁版嵁绫伙細鏍囧噯鍑哄叆搴撲俊鎭�-        /// </summary>
-        public class BaseBoundInfo {
-            /// <summary>
-            /// 璧风偣璐т綅
-            /// </summary>
-            public string startLoc { get; set; }
-            /// <summary>
-            /// 瀹瑰櫒鍙�-            /// </summary>
-            public string cntId { get; set; }
-            /// <summary>
-            /// 缁堢偣璐т綅
-            /// </summary>
-            public string endLoc { get; set; }
-        }
-
-        #endregion
-        public class InboundInfo {
-            /// <summary>
-            /// 璧风偣璐т綅
-            /// </summary>
-            [JsonProperty("StartLoc")]
-            public string StartLoc { get; set; }
-
-            /// <summary>
-            /// 缁堢偣璐ф灦锛堝彲閫夛級
-            /// </summary>
-            [JsonProperty("Nrow")]
-            public string Row { get; set; }
-        }
-
-        public class SelectLocationInfo {
-            public string forklift_no { get; set; }
-
-            public string endLoc { get; set; }
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍥炲簱淇℃伅
-        /// </summary>
-        public class PartInboundInfo {
-            /// <summary>
-            /// 璧风偣浣嶇疆
-            /// </summary>
-            public string startLoc { get; set; }
-
-            /// <summary>
-            /// 缁堢偣浣嶇疆
-            /// </summary>
-            public string endLoc { get; set; }
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍑哄簱淇℃伅
-        /// </summary>
-        public class PartOutboundInfo {
-            /// <summary>
-            /// 璧风偣浣嶇疆
-            /// </summary>
-            public string startLoc { get; set; }
-
-            /// <summary>
-            /// 缁堢偣浣嶇疆
-            /// </summary>
-            public string endLoc { get; set; }
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍑哄簱淇℃伅
-        /// </summary>
-        public class CheckOutboundInfo {
-            /// <summary>
-            /// 璧风偣浣嶇疆
-            /// </summary>
-            public string startLoc { get; set; }
-
-            /// <summary>
-            /// 缁堢偣浣嶇疆
-            /// </summary>
-            public string endLoc { get; set; }
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍥炲簱淇℃伅
-        /// </summary>
-        public class CheckInboundInfo {
-            /// <summary>
-            /// 璧风偣浣嶇疆
-            /// </summary>
-            public string startLoc { get; set; }
-
-            /// <summary>
-            /// 缁堢偣浣嶇疆
-            /// </summary>
-            public string endLoc { get; set; }
-        }
-        
-    }
-}
diff --git a/Dtos/Response/AgvResponse.cs b/Dtos/Response/AgvResponse.cs
deleted file mode 100644
index 2192704..0000000
--- a/Dtos/Response/AgvResponse.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Response {
-    public class AgvResponse {
-        /// <summary>
-        /// 杩斿洖缁檋osttoagv
-        /// </summary>
-        public class ReturnResult {
-            public int ResultCode { get; set; }
-            public string ResultMsg { get; set; }
-        }
-
-        /// <summary>
-        /// 杩斿洖缁橤Z
-        /// </summary>
-        public class GzResult {
-            public int resultCode { get; set; }
-            public string msg { get; set; }
-            public int orderID { get; set; }
-        }
-    }
-}
diff --git a/Dtos/Response/DebugResponse.cs b/Dtos/Response/DebugResponse.cs
deleted file mode 100644
index c90ebfb..0000000
--- a/Dtos/Response/DebugResponse.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Response {
-    public class DebugResponse {
-        /// <summary>
-        /// 
-        /// </summary>
-        public class ReturnResults {
-            public List<ReturnResult> ResultList { set; get; }
-        }
-    }
-}
diff --git a/Dtos/Response/ErpResponse.cs b/Dtos/Response/ErpResponse.cs
deleted file mode 100644
index 935d425..0000000
--- a/Dtos/Response/ErpResponse.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Response {
-    public class ErpResponse {
-        public class ErpResult {
-            /// <summary>
-            /// 鎺ュ彛鍙嶉鐮�-            /// </summary>
-            public int errCode { get; set; }
-            /// <summary>
-            /// 閿欒璇存槑
-            /// </summary>
-            public string errMsg { get; set; }
-        }
-
-        public static ErpResult BuildErpResult(int code, string message, bool printLog = true) {
-            if (printLog) {
-                LogHelper.Info(message);
-            }
-            return new ErpResult { errCode = code, errMsg = message };
-        }
-    }
-}
diff --git a/Dtos/Response/MoboxResponse.cs b/Dtos/Response/MoboxResponse.cs
deleted file mode 100644
index f1b6376..0000000
--- a/Dtos/Response/MoboxResponse.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-锘縰sing System.Collections.Generic;
-
-using Newtonsoft.Json;
-
-namespace HH.WCS.Mobox3.AnGang.Dtos.Response {
-    public class MoboxResponse {
-        /// <summary>
-        /// Mobox 鎺ュ彛杩斿洖
-        /// </summary>
-        public class SimpleResult {
-            [JsonProperty("resultCode")]
-            public int resultCode { get; set; }
-
-            [JsonProperty("resultMsg")]
-            public string resultMsg { get; set; }
-
-            [JsonProperty("result")]
-            public List<object> Results { get; set; } = new List<object>();
-        }
-
-        public static SimpleResult BuildSimpleResult(int code, string message, bool pringLog = true) {
-            if (pringLog) {
-                LogHelper.Info(message);
-            }
-            return new SimpleResult { resultCode = code, resultMsg = message };
-        }
-    }
-}
diff --git a/HH.WCS.Mobox3.AnGang.csproj b/HH.WCS.Mobox3.AnGang.csproj
index 70b4f33..608bae9 100644
--- a/HH.WCS.Mobox3.AnGang.csproj
+++ b/HH.WCS.Mobox3.AnGang.csproj
@@ -257,76 +257,60 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="AppStart\Config.cs" />
-    <Compile Include="Consts\AgvStateCode.cs" />
-    <Compile Include="Consts\AgvStateName.cs" />
-    <Compile Include="Consts\AreaCode.cs" />
-    <Compile Include="Consts\LockStateCode.cs" />
-    <Compile Include="Consts\LockStateName.cs" />
-    <Compile Include="Consts\TaskName.cs" />
-    <Compile Include="Controllers\DebugController.cs" />
-    <Compile Include="Controllers\ErpController.cs" />
-    <Compile Include="Controllers\MoboxController.cs" />
-    <Compile Include="Controllers\AgvController.cs" />
-    <Compile Include="Controllers\ApiModel.cs" />
-    <Compile Include="AppStart\SwaggerControllerDescProvider.cs" />
-    <Compile Include="Devices\SnapDevice.cs" />
-    <Compile Include="Devices\SnapManager.cs" />
-    <Compile Include="Dtos\Request\DebugRequest.cs" />
-    <Compile Include="Dtos\Request\ErpRequest.cs" />
-    <Compile Include="Dtos\Response\DebugResponse.cs" />
-    <Compile Include="Dtos\Response\ErpResponse.cs" />
-    <Compile Include="Helpers\AgvHelper.cs" />
-    <Compile Include="Helpers\DbHelper.cs" />
-    <Compile Include="Models\DebugModel.cs" />
-    <Compile Include="Models\TN_Inbound_Order.cs" />
-    <Compile Include="Models\TN_Outbound_Order.cs" />
-    <Compile Include="ServiceCore\WMSCore.cs" />
-    <Compile Include="Models\BaseModel.cs" />
-    <Compile Include="Services\DebugService.cs" />
-    <Compile Include="Devices\ModbusHelper.cs" />
-    <Compile Include="Devices\OpcUaHelper.cs" />
-    <Compile Include="Devices\PlcHelper.cs" />
-    <Compile Include="Devices\S7Helper.cs" />
-    <Compile Include="Devices\TcpClient.cs" />
-    <Compile Include="Devices\TcpServer.cs" />
-    <Compile Include="Dispatch\GZRobot.cs" />
-    <Compile Include="Dispatch\HanAo.cs" />
-    <Compile Include="Dispatch\NDC.cs" />
-    <Compile Include="ServiceCore\Monitor.cs" />
-    <Compile Include="Dispatch\NDCApi.cs" />
-    <Compile Include="Dtos\Request\AgvRequest.cs" />
-    <Compile Include="Dtos\Request\MoboxRequest.cs" />
-    <Compile Include="Dtos\Response\AgvResponse.cs" />
-    <Compile Include="Dtos\Response\MoboxResponse.cs" />
-    <Compile Include="Models\TN_CG_Detail.cs" />
-    <Compile Include="Models\TN_CAR_IN.cs" />
-    <Compile Include="Models\TN_Container.cs" />
-    <Compile Include="Models\TN_Location.cs" />
-    <Compile Include="Models\TN_Loc_Container.cs" />
-    <Compile Include="Models\TN_WorkOrder.cs" />
-    <Compile Include="Models\TN_Task.cs" />
-    <Compile Include="Models\TN_Task_Action.cs" />
-    <Compile Include="Helpers\DeviceProcess.cs" />
-    <Compile Include="ServiceCore\WCSCore.cs" />
-    <Compile Include="Controllers\WmsController.cs" />
-    <Compile Include="Dispatch\HostToAGV.cs" />
-    <Compile Include="Helpers\TaskHelper.cs" />
-    <Compile Include="Services\AgvService.cs" />
-    <Compile Include="Services\ErpService.cs" />
-    <Compile Include="Services\MoboxService.cs" />
-    <Compile Include="Helpers\LogHelper.cs" />
-    <Compile Include="Helpers\ContainerHelper.cs" />
-    <Compile Include="Helpers\LocationHelper.cs" />
-    <Compile Include="Helpers\WMSHelper.cs" />
-    <Compile Include="Helpers\SysHelper.cs" />
+    <Compile Include="api\ApiHelper.cs" />
+    <Compile Include="api\DebugController.cs" />
+    <Compile Include="api\ErpController.cs" />
+    <Compile Include="api\MoboxController.cs" />
+    <Compile Include="api\AgvController.cs" />
+    <Compile Include="api\ApiModel.cs" />
+    <Compile Include="App_Start\SwaggerControllerDescProvider.cs" />
+    <Compile Include="device\SnapDevice.cs" />
+    <Compile Include="device\SnapManager.cs" />
+    <Compile Include="models\TN_Count_CG_Detail.cs" />
+    <Compile Include="models\TN_Count_Diff.cs" />
+    <Compile Include="models\TN_Count_Order.cs" />
+    <Compile Include="models\TN_Count_Plan.cs" />
+    <Compile Include="models\TN_Inbound_Order.cs" />
+    <Compile Include="models\TN_Outbound_Order.cs" />
+    <Compile Include="core\WMSCore.cs" />
+    <Compile Include="models\BaseModel.cs" />
+    <Compile Include="device\ModbusHelper.cs" />
+    <Compile Include="device\OpcUaHelper.cs" />
+    <Compile Include="device\PlcHelper.cs" />
+    <Compile Include="device\S7Helper.cs" />
+    <Compile Include="device\TcpClient.cs" />
+    <Compile Include="device\TcpServer.cs" />
+    <Compile Include="dispatch\GZRobot.cs" />
+    <Compile Include="dispatch\HanAo.cs" />
+    <Compile Include="dispatch\NDC.cs" />
+    <Compile Include="core\Monitor.cs" />
+    <Compile Include="dispatch\NDCApi.cs" />
+    <Compile Include="models\TN_CG_Detail.cs" />
+    <Compile Include="models\TN_CAR_IN.cs" />
+    <Compile Include="models\TN_Container.cs" />
+    <Compile Include="models\TN_Location.cs" />
+    <Compile Include="models\TN_Loc_Container.cs" />
+    <Compile Include="models\TN_WorkOrder.cs" />
+    <Compile Include="models\TN_Task.cs" />
+    <Compile Include="models\TN_Task_Action.cs" />
+    <Compile Include="process\DeviceProcess.cs" />
+    <Compile Include="core\WCSCore.cs" />
+    <Compile Include="api\WmsController.cs" />
+    <Compile Include="dispatch\HostToAGV.cs" />
+    <Compile Include="util\LogHelper.cs" />
+    <Compile Include="wms\ContainerHelper.cs" />
+    <Compile Include="wms\LocationHelper.cs" />
+    <Compile Include="wms\WMSHelper.cs" />
+    <Compile Include="wms\SYSHelper.cs" />
+    <Compile Include="process\TaskProcess.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="AppStart\Settings.cs" />
-    <Compile Include="AppStart\Startup.cs" />
-    <Compile Include="Dispatch\NDCHelper.cs" />
-    <Compile Include="Helpers\HttpHelper.cs" />
-    <Compile Include="Helpers\WCSHelper.cs" />
+    <Compile Include="util\Settings.cs" />
+    <Compile Include="App_Start\Startup.cs" />
+    <Compile Include="dispatch\NDCHelper.cs" />
+    <Compile Include="util\HttpHelper.cs" />
+    <Compile Include="wms\WCSHelper.cs" />
+    <Compile Include="util\SqlHelper.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include=".editorconfig" />
diff --git a/Helpers/AgvHelper.cs b/Helpers/AgvHelper.cs
deleted file mode 100644
index 962af92..0000000
--- a/Helpers/AgvHelper.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Helpers {
-    public class AgvHelper {
-        /// <summary>
-        /// AGV 浠诲姟鐘舵�浼樺厛绾э細1->3->4->5->6->2
-        /// </summary>
-        private static readonly int[] _agvTaskStatePri = { 0, 1, 6, 2, 3, 4, 5 };
-
-        /// <summary>
-        /// AGV 鐘舵�鍙樺寲琛細1->3->4->5->6->2 | 0->0 | 2->0
-        /// </summary>
-        private static readonly int[] _agvNextState = new int[] { 0, 3, 0, 4, 5, 6, 2 };
-
-        /// <summary>
-        /// 鍒ゆ柇AGV鐘舵�鏄惁涓哄悎娉曠殑涓嬩釜鐘舵�锛堝寘鍚鏌ョ姸鎬佹槸鍚︿负浠诲姟鐘舵�锛�-        /// </summary>
-        /// <remarks>
-        /// 1. 鍓嶅悗鐘舵�鍙鏈変笉鍚堟硶閮戒細杩斿洖 <see langword="false"/><br/>
-        /// 2. nextState 鍙互涓�lastState 鐩稿悓
-        /// </remarks>
-        /// <param name="lastState"></param>
-        /// <param name="nextState"></param>
-        /// <returns></returns>
-        public static bool IsNextStateOk(int lastState, int nextState) {
-            var lastPri = GetPri(lastState);
-            var nextPri = GetPri(nextState);
-            return lastPri != 0 && nextPri != 0 && lastPri <= nextPri;
-        }
-
-        /// <summary>
-        /// 鑾峰彇AGV褰撳墠鐘舵�鐨勪笅涓姸鎬侊細涓嶅悎娉曟垨涓�2(瀹屾垚) 鏃惰繑鍥�0
-        /// </summary>
-        /// <param name="curState"></param>
-        /// <returns></returns>
-        public static int GetNextState(int curState) {
-            if (!IsTaskState(curState)) return 0;
-            return _agvNextState[curState];
-        }
-
-        /// <summary>
-        /// 鍒ゆ柇 AGV 鐘舵�鏄惁涓烘甯哥殑鎵ц浠诲姟鐘舵�锛�34562
-        /// </summary>
-        /// <param name="state"></param>
-        /// <returns></returns>
-        private static bool IsTaskState(int state) {
-            return state > 0 && state < 7;
-        }
-
-        /// <summary>
-        /// GetTaskStatePri锛氳幏鍙�AGV 浠诲姟鐘舵�鐨勪紭鍏堢骇锛堝寘鍚鏌ョ姸鎬佹槸鍚︿负浠诲姟鐘舵�锛�-        /// </summary>
-        /// <param name="state"></param>
-        /// <returns></returns>
-        private static int GetPri(int state) {
-            if (!IsTaskState(state)) { return 0; }
-            return _agvTaskStatePri[state];
-        }
-    }
-}
diff --git a/Helpers/DbHelper.cs b/Helpers/DbHelper.cs
deleted file mode 100644
index 697c767..0000000
--- a/Helpers/DbHelper.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-锘縰sing System;
-using System.Linq;
-
-using HH.WCS.Mobox3.AnGang.AppStart;
-
-using SqlSugar;
-
-using Task = System.Threading.Tasks.Task;
-
-namespace HH.WCS.Mobox3.AnGang.Helpers {
-    // SqlSugar 鏁欑▼锛歨ttps://www.donet5.com/Home/Doc
-
-    /// <summary>
-    /// 鏁版嵁搴撳府鍔╃被锛氬寘鎷崟渚嬫ā寮忓拰鍒涘缓鏂拌繛鎺ョ殑鏂规硶
-    /// </summary>
-    public static class DbHelper {
-        private static SqlSugarScope _sqlSugar;
-
-        static DbHelper() {
-            Init();
-        }
-
-        public static void Init() {
-            _sqlSugar = new SqlSugarScope(new ConnectionConfig() {
-                ConnectionString = Settings.Config.SqlServer,
-                DbType = DbType.SqlServer,
-                IsAutoCloseConnection = true,
-                InitKeyType = InitKeyType.Attribute // 浠庣壒鎬ц鍙栦富閿嚜澧炰俊鎭�-            },
-            db => {
-                // 鐩戞帶鎵�湁瓒呰繃1绉掔殑Sql
-                db.Aop.OnLogExecuted = (sql, p) => {
-                    // 鎵ц鏃堕棿瓒呰繃1绉�-                    if (db.Ado.SqlExecutionTime.TotalSeconds > 1) {
-                        Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(p.ToDictionary(it => it.ParameterName, it => it.Value)));
-                        // 浠g爜CS鏂囦欢鍚�-                        var fileName = db.Ado.SqlStackTrace.FirstFileName;
-                        // 浠g爜琛屾暟
-                        var fileLine = db.Ado.SqlStackTrace.FirstLine;
-                        // 鏂规硶鍚�-                        var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
-                    }
-                    // 鐩稿綋浜嶦F鐨�PrintToMiniProfiler
-                };
-
-                // 姣忔璁剧疆鏁板�鏃堕兘鍘婚櫎鍓嶅鍚庡绌烘牸
-                db.Aop.DataExecuted = (value, entity) => {
-                    entity.EntityColumnInfos.ToList().ForEach(a => {
-                        var pvalue = entity.GetValue(a.PropertyName);
-                        if (pvalue != null && pvalue.GetType() == typeof(String)) {
-                            entity.SetValue(a.PropertyName, pvalue.ToString().Trim());
-                        }
-                    });
-                };
-
-                // 閰嶇疆AOP鏃ュ織
-                //db.Aop.OnLogExecuting = (sql, pars) =>
-                //{
-                //    Console.WriteLine(sql); // 杈撳嚭绾疭QL璇彞
-                //};
-
-                // 姣廚灏忔椂娓呯悊涓�缂撳瓨
-                Task.Run(async () => {
-                    while (true) {
-                        await Task.Delay(TimeSpan.FromHours(2));
-                        db.QueryFilter.Clear();
-                    }
-                });
-            });
-        }
-
-        /// <summary>
-        /// 鑾峰彇鐢ㄤ簬鎿嶆帶鏁版嵁搴撶殑 SqlSugarClient 瀵硅薄
-        /// </summary>
-        /// <returns></returns>
-        public static SqlSugarScope GetDbClient() {
-            return _sqlSugar;
-        }
-
-        /// <summary>
-        /// 鐢熸垚鐢ㄤ簬鎿嶆帶鏁版嵁搴撶殑 SqlSugarClient 瀵硅薄
-        /// </summary>
-        /// <remarks>
-        /// 濡傛灉鐢�Oracle 鏁版嵁闇�鍖�Oracle.ManagedDataAccess/21.15.0锛岀幆澧�netframework 4.62锛屽お鏂颁簡 4.8 鏈夌殑鏈嶅姟鍣ㄥ畨瑁呬笉涓婂幓
-        /// </remarks>
-        /// <param name="url"></param>
-        /// <returns></returns>
-        public static SqlSugarClient NewDbClient(string url = "") {
-            // 鍒涘缓鏁版嵁搴撳璞�-            SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() {
-                ConnectionString = string.IsNullOrEmpty(url) ? Settings.Config.SqlServer : url,
-                DbType = DbType.SqlServer,
-                IsAutoCloseConnection = true,
-                InitKeyType = InitKeyType.Attribute // 浠庣壒鎬ц鍙栦富閿嚜澧炰俊鎭�-            });
-
-            // 鐩戞帶鎵�湁瓒呰繃1绉掔殑Sql
-            db.Aop.OnLogExecuted = (sql, p) => {
-                // 鎵ц鏃堕棿瓒呰繃1绉�-                if (db.Ado.SqlExecutionTime.TotalSeconds > 1) {
-                    Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(p.ToDictionary(it => it.ParameterName, it => it.Value)));
-                    // 浠g爜CS鏂囦欢鍚�-                    var fileName = db.Ado.SqlStackTrace.FirstFileName;
-                    // 浠g爜琛屾暟
-                    var fileLine = db.Ado.SqlStackTrace.FirstLine;
-                    // 鏂规硶鍚�-                    var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
-                }
-                // 鐩稿綋浜嶦F鐨�PrintToMiniProfiler
-            };
-
-            // 姣忔璁剧疆鏁板�鏃堕兘鍘婚櫎鍓嶅鍚庡绌烘牸
-            db.Aop.DataExecuted = (value, entity) => {
-                entity.EntityColumnInfos.ToList().ForEach(a => {
-                    var pvalue = entity.GetValue(a.PropertyName);
-                    if (pvalue != null && pvalue.GetType() == typeof(String)) {
-                        entity.SetValue(a.PropertyName, pvalue.ToString().Trim());
-                    }
-                });
-            };
-
-            // 鎹浆鎹�(ExecuteCommand 鎵嶄細鎷︽埅锛屾煡璇笉琛�
-            //db.Aop.DataExecuting = (value, entity) => {
-            //    //var val=entity.EntityColumnInfo
-            //    Console.WriteLine(entity.EntityName);
-            //};
-
-            // 鐢ㄤ簬鎵撳嵃 SqlSugar 瑙g爜鍚庣殑 SQL 璇彞
-            db.Aop.OnLogExecuting = (sql, pars) => {
-                Console.WriteLine(sql);
-            };
-
-            return db;
-        }
-    }
-}
diff --git a/Models/BaseModel.cs b/Models/BaseModel.cs
index a06762c..e4b3e9c 100644
--- a/Models/BaseModel.cs
+++ b/Models/BaseModel.cs
@@ -2,7 +2,7 @@
 
 using SqlSugar;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     /// <summary>
     /// 銆愭鏋躲�妯℃澘鎶借薄绫伙細鍩烘湰琛ㄦ暟鎹ā鍨�     /// </summary>
diff --git a/Models/DebugModel.cs b/Models/DebugModel.cs
deleted file mode 100644
index 10771a8..0000000
--- a/Models/DebugModel.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HH.WCS.Mobox3.AnGang.Models {
-    public class DebugModel {
-        public class LocCntrCg {
-            public string LocCode { get; set; }
-            public string LocArea { get; set; }
-            public string CntrCode { get; set; }
-            public string ItemCode { get; set; }
-            public string BatchNo { get; set; }
-        }
-    }
-}
diff --git a/Models/TN_CAR_IN.cs b/Models/TN_CAR_IN.cs
index 6943991..c88098f 100644
--- a/Models/TN_CAR_IN.cs
+++ b/Models/TN_CAR_IN.cs
@@ -5,7 +5,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Models
+namespace HH.WCS.Mobox3.AnGang.models
 {
     /// <summary>
     /// 瀹瑰櫒鐢熶骇杞︽暟鍏宠仈瀛愯〃
diff --git a/Models/TN_CG_Detail.cs b/Models/TN_CG_Detail.cs
index 9a9e5c5..7330b17 100644
--- a/Models/TN_CG_Detail.cs
+++ b/Models/TN_CG_Detail.cs
@@ -1,6 +1,6 @@
 using SqlSugar;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     /// <summary>
     /// 鐗╂枡-瀹瑰櫒 鍏崇郴琛�     /// </summary>
@@ -37,7 +37,6 @@
         /// 鏁伴噺锛氳繖閲屽綋鍋氶噸閲�         /// </summary>
         public float F_QTY { get; set; } = 0f;
-
 
         /// <summary>
         /// 鍥剧墖閾炬帴
diff --git a/Models/TN_Container.cs b/Models/TN_Container.cs
index 4f0cc79..d34d913 100644
--- a/Models/TN_Container.cs
+++ b/Models/TN_Container.cs
@@ -1,7 +1,7 @@
 using SqlSugar;
 using System.Collections.Generic;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     [SugarTable("TN_Container")]
     public class TN_Container : BaseModel {
         public string S_CODE { get; set; }
diff --git a/Models/TN_Inbound_Order.cs b/Models/TN_Inbound_Order.cs
index fc5efc7..5d3a3d7 100644
--- a/Models/TN_Inbound_Order.cs
+++ b/Models/TN_Inbound_Order.cs
@@ -4,7 +4,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     public class TN_Inbound_Order : BaseModel {
         /// <summary>
         /// 鍌ㄤ綅鐮�diff --git a/Models/TN_Loc_Container.cs b/Models/TN_Loc_Container.cs
index ff07b70..e2edf67 100644
--- a/Models/TN_Loc_Container.cs
+++ b/Models/TN_Loc_Container.cs
@@ -1,7 +1,7 @@
 using SqlSugar;
 using System.Collections.Generic;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     //TN_Loc_Container
     //LocCntrRel
     [SugarTable("TN_Loc_Container")]
diff --git a/Models/TN_Location.cs b/Models/TN_Location.cs
index 4674e6d..f0b724f 100644
--- a/Models/TN_Location.cs
+++ b/Models/TN_Location.cs
@@ -1,7 +1,7 @@
 using SqlSugar;
 using System.Collections.Generic;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
 
     [SugarTable("TN_Location")]
     public class TN_Location : BaseModel {
diff --git a/Models/TN_Outbound_Order.cs b/Models/TN_Outbound_Order.cs
index c090f21..e0fee36 100644
--- a/Models/TN_Outbound_Order.cs
+++ b/Models/TN_Outbound_Order.cs
@@ -4,7 +4,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     public class TN_Outbound_Order : BaseModel {
         /// <summary>
         /// 鍌ㄤ綅鐮�diff --git a/Models/TN_Task.cs b/Models/TN_Task.cs
index c779c7f..e129de9 100644
--- a/Models/TN_Task.cs
+++ b/Models/TN_Task.cs
@@ -1,7 +1,7 @@
 using SqlSugar;
 using System;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     [SugarTable("TN_Task")]
     public class TN_Task : BaseModel {
 
diff --git a/Models/TN_Task_Action.cs b/Models/TN_Task_Action.cs
index ca96775..8d8c7d9 100644
--- a/Models/TN_Task_Action.cs
+++ b/Models/TN_Task_Action.cs
@@ -1,6 +1,6 @@
 using SqlSugar;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     [SugarTable("TN_Task_Action")]
     public  class TN_Task_Action : BaseModel
     {
diff --git a/Models/TN_WorkOrder.cs b/Models/TN_WorkOrder.cs
index ea9794f..7e25ac4 100644
--- a/Models/TN_WorkOrder.cs
+++ b/Models/TN_WorkOrder.cs
@@ -1,6 +1,6 @@
 using SqlSugar;
 
-namespace HH.WCS.Mobox3.AnGang.Models {
+namespace HH.WCS.Mobox3.AnGang.models {
     /// <summary>
     /// 鐢熶骇宸ュ崟
     /// </summary>
diff --git a/Program.cs b/Program.cs
index 942c7dd..577f06e 100644
--- a/Program.cs
+++ b/Program.cs
@@ -3,8 +3,7 @@
 using System.Threading;
 using System.Threading.Tasks;
 
-using HH.WCS.Mobox3.AnGang.AppStart;
-using HH.WCS.Mobox3.AnGang.Devices;
+using HH.WCS.Mobox3.AnGang.device;
 
 using Microsoft.Owin.Hosting;
 
@@ -59,7 +58,7 @@
             Console.WriteLine("Startup ApiController");
             Task.Run(() =>
             {
-                var url = Settings.Config.WebApiUrl;
+                var url = Settings.WebApiUrl;
                 Console.WriteLine(url);
                 using (WebApp.Start<Startup>(url))
                 {
@@ -74,8 +73,8 @@
         /// </summary>
         private static void StartTcp()
         {
-            var tcpServerIP = Settings.Config.TCPServerIP;
-            var tcpServerPort = Settings.Config.TCPServerPort;
+            var tcpServerIP = Settings.TCPServerIP;
+            var tcpServerPort = Settings.TCPServerPort;
             new TcpServer(tcpServerIP, tcpServerPort);
 
         }
@@ -115,8 +114,7 @@
         }
 
         private static void StartSnap() {
-            //new SnapManager(Settings.Snap);
-            new SnapManager(Settings.Config.Snap[0]);
+            new SnapManager(Settings.Snaps[0]);
         }
 
         public class WorkThread
@@ -127,11 +125,7 @@
                 // 娣诲姞浠诲姟鎺ㄩ�绾跨▼
                 //tasks.Add(GetTask(WCSCore.Dispatch));
 
-                ////娣诲姞鑷畾涔夌嚎绋�-                //tasks.Add(GetTask(Monitor.CheckEmptyCnt));//妫�祴绌烘墭鐩� 
-                ////鏍规嵁S7/Modbus鍗忚鍒ゆ柇杈撻�绾跨殑淇″彿  鍘熸潗鏂欎骇绾垮簱鍖�>婊℃墭缂撳瓨搴撳尯锛岀┖鎵樼紦瀛樺簱鍖�>鍘熸潗鏂欎骇绾垮簱鍖�-                //tasks.Add(GetTask(Monitor.CheckS7Devices));
 
                 Task.WaitAll(tasks.ToArray());
             }
diff --git a/ServiceCore/Monitor.cs b/ServiceCore/Monitor.cs
deleted file mode 100644
index 1f0fc3f..0000000
--- a/ServiceCore/Monitor.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-锘縩amespace HH.WCS.Mobox3.AnGang.ServiceCore {
-    /// <summary>
-    /// 瀹氭椂杞浠诲姟
-    /// </summary>
-    public class Monitor
-    {
-    
-
-        
-
-        ///// <summary>
-        ///// 绌烘墭鍫嗗彔鍏ュ簱
-        ///// </summary>
-        //internal static void CheckEmptyCnt()
-        //{
-        //    var db = DbHelper.GetDbClient();
-
-        //    try
-        //    {
-        //        var startLoc = db.Queryable<TN_Location>().
-        //        Where(a => a.S_AREA_CODE == Settings.Areas[3] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == a.N_CAPACITY).
-        //        OrderBy(a => a.T_MODIFY, OrderByType.Desc).
-        //        First();
-        //        if (startLoc == null)
-        //        {
-        //            LogHelper.Info($"绌烘墭鍫嗗彔鍖簕Settings.Areas[3]}鏆傛棤鍫嗘弧鐨勭┖鎵�);
-        //            return;
-        //        }
-
-        //        var endLoc = db.Queryable<TN_Location>().
-        //            Where(a => a.S_AREA_CODE == Settings.Areas[4] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == 0).
-        //            OrderBy(a => a.N_CURRENT_NUM, OrderByType.Asc).
-        //            First();
-
-        //        if (endLoc == null)
-        //        {
-        //            LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣璐т綅锛岄渶婊¤冻{Settings.Areas[4]}閲屾湁鏈攣瀹氫笖褰撳墠鏁伴噺绛変簬0鐨勮揣浣�);
-        //            return;
-        //        }
-
-        //        var cntrList = db.Queryable<TN_Loc_Container>().Where(a => a.S_LOC_CODE == startLoc.S_CODE).OrderBy(a => a.T_CREATE, OrderByType.Asc).ToList();
-
-        //        if (cntrList.Count < 1)
-        //        {
-        //            LogHelper.Info($"璧风偣{startLoc.S_CODE}鏈壘鍒拌揣浣嶅鍣ㄥ叧绯讳俊鎭�);
-        //            return;
-        //        }
-
-        //        string cntrString = "";
-        //        for (int i = 0; i < cntrList.Count; i++)
-        //        {
-        //            if (i == cntrList.Count - 1)//鏈�悗涓�釜瀛楃涓茶繛鎺ヤ笉鍔犻�鍙�-        //            {
-        //                cntrString += cntrList[i].S_CNTR_CODE;
-        //            }
-        //            else
-        //            {
-        //                cntrString += cntrList[i].S_CNTR_CODE + ",";
-        //            }
-        //        }
-
-        //        if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "绌烘墭鍫嗗彔鍏ュ簱", 3, cntrString))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-        //        {
-        //            LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-        //            LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-        //            LogHelper.Info($"鐢熸垚绌烘墭鍫嗗彔鍏ュ簱浠诲姟鎴愬姛锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}");
-        //        }
-        //        else
-        //        {
-        //            LogHelper.Info($"鐢熸垚绌烘墭鍫嗗彔鍏ュ簱浠诲姟澶辫触锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}");
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        LogHelper.Info($"绌烘墭鍫嗗彔鍏ュ簱寮傚父锛歿ex.Message}");
-        //    }
-
-        //}
-    }
-
-    /// <summary>
-    /// 涓嶴7璁惧浜や簰鏃剁殑model
-    /// </summary>
-    public class CheckDeciveModel
-    {
-        /// <summary>
-        /// 蹇冭烦
-        /// </summary>
-        public int Heart { set; get; }
-
-        /// <summary>
-        /// RFID锛屾槸瀹瑰櫒鏄墭鐩�-        /// </summary>
-        public string RfidData { set; get; }
-
-        /// <summary>
-        /// 鍏佽涓婁笅鏂� 0=鏃犱换鍔★紝11=涓婃枡锛�1=涓嬫枡锛岋紙璇锋眰AGV宸ヤ綔锛�-        /// </summary>
-        public int AgvAllow { set; get; }
-
-        /// <summary>
-        /// 浠诲姟灞炴�  1 OK锛�绉伴噸澶辫触锛�鏉$爜澶辫触锛� RFID璇诲彇澶辫触
-        /// </summary>
-        public int TaskProperties { set; get; }
-
-        /// <summary>
-        /// 鍑嗗灏辩华  0=鏈噯澶囧ソ锛�=鍑嗗濂�-        /// </summary>
-        public int Ready { set; get; }
-
-        /// <summary>
-        /// 杞借揣鐘舵� 0=杈撻�绾挎棤浜у搧锛�=杈撻�绾挎湁浜у搧
-        /// </summary>
-        public int CargoStatus { set; get; }
-
-        /// <summary>
-        /// 宸ヤ綅鐘舵� 0寰呮満涓紝1鍏ュ簱鏂瑰悜杩愯涓紝2鍑哄簱鏂瑰悜杩愯涓紝3璁惧鏁呴殰
-        /// </summary>
-        public int StationStatus { set; get; }
-
-        /// <summary>
-        /// 鍘诲悜璇锋眰 0寰呮満涓紝1鍒颁綅璇锋眰
-        /// </summary>
-        public int DestinationRequests { set; get; }
-
-        /// <summary>
-        /// 鎵爜淇℃伅 鎵爜鏋弽棣堜俊鎭�-        /// </summary>
-        public string BarcodeCode { set; get; }
-
-        /// <summary>
-        /// 閲嶉噺  
-        /// </summary>
-        public float Weight { set; get; }
-
-        /// <summary>
-        /// 浜х嚎鍦板潃
-        /// </summary>
-        public string LineIP { set; get; }
-    }
-}
-
diff --git a/ServiceCore/WCSCore.cs b/ServiceCore/WCSCore.cs
deleted file mode 100644
index da80ddd..0000000
--- a/ServiceCore/WCSCore.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Devices;
-using HH.WCS.Mobox3.AnGang.Dispatch;
-using HH.WCS.Mobox3.AnGang.Models;
-using HH.WCS.Mobox3.AnGang.process;
-using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
-using Newtonsoft.Json;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-
-namespace HH.WCS.Mobox3.AnGang.ServiceCore
-{
-    internal class WCSCore
-    {
-        public static ReturnResult OperateAgvTaskStatus(AgvTaskState model)
-        {
-            var result = new ReturnResult();
-            try
-            {
-                switch (model.state) {
-                    case 1023:
-                    case 1025:
-
-                        break;
-                    case 1012:
-                        break;
-                    case 1004:
-                        break;
-                    case 1103:
-                        break;
-                    default:
-                        // AGV 鎵ц浠诲姟鐨勯�杈戝鐞�-                        if (!AgvTaskProcessOk(model)) {
-                            // 鎵ц涓峅K锛岃鏄庢病鏈夋壘鍒颁换鍔�-                            result.ResultCode = 1;
-                            result.ResultMsg = $"鏍规嵁Model.No鏈壘鍒板搴旂殑浠诲姟锛寋model.task_no}";
-                            LogHelper.Info(result.ResultMsg, "API");
-                            return result;
-                        }
-                        break;
-                }
-
-                result.ResultCode = 0;
-                result.ResultMsg = "success";
-                LogHelper.Info(result.ResultMsg, "API");
-                return result;
-            }
-            catch(Exception ex)
-            {
-                result.ResultCode = -1;
-                result.ResultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}";
-                LogHelper.Info(result.ResultMsg, "Error");
-                return result;
-            }
-
-        }
-
-        /// <summary>
-        /// 鎵цAGV浠诲姟锛屾煡璇笉鍒颁换鍔¤繑鍥瀎alse
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        private static bool AgvTaskProcessOk(AgvTaskState model) {
-            var TN_Task = WCSHelper.GetTask(model.task_no); // 鏍规嵁褰撳墠model缂栧彿鏌ヨ浠诲姟
-            if (TN_Task == null) { return false; }
-
-            if (model.state > 7) {
-                //瀹夊叏璇锋眰绛�-                TaskHelper.OperateReq(model.task_no, model.state, model.forklift_no, model.ext_data);
-                return true;
-            }
-            
-            // AGV 浠诲姟 134562(7) 鐘舵�澶勭悊
-            switch (model.state) {
-                case 1:
-                    WCSHelper.Begin(TN_Task, model.forklift_no); // 宸叉帹閫佺殑浠诲姟鐨勭姸鎬佹敼鎴愭墽琛�-                    break;
-                case 3:
-                    WCSHelper.UpdateStatus(TN_Task, "寮�鍙栬揣"); // 浠诲姟鐘舵�鏀规垚寮�鍙栬揣
-                    break;
-                case 4:
-                    WCSHelper.UpdateStatus(TN_Task, "鍙栬揣瀹屾垚"); // 浠诲姟鐘舵�鏀规垚鍙栬揣瀹屾垚
-                    TaskHelper.OperateStatus(TN_Task, 4); // 璧风偣瀹瑰櫒璐т綅瑙g粦,瑙i攣璧风偣
-                    break;
-                case 5:
-                    WCSHelper.UpdateStatus(TN_Task, "寮�鍗歌揣"); // 浠诲姟鐘舵�鏀规垚寮�鍗歌揣
-                    break;
-                case 6:
-                    WCSHelper.UpdateStatus(TN_Task, "鍗歌揣瀹屾垚"); // 浠诲姟鐘舵�鏀规垚鍗歌揣瀹屾垚
-                    TaskHelper.OperateStatus(TN_Task, 6); // 缁堢偣瀹瑰櫒璐т綅缁戝畾,瑙i攣缁堢偣
-                    break;
-                case 2:
-                    WCSHelper.End(TN_Task); // 浠诲姟鐘舵�鏀规垚缁撴潫
-                    break;
-                case 7:
-                    TaskHelper.OperateStatus(TN_Task, 7); // 寮傚父澶勭悊
-                    WCSHelper.Fail(TN_Task); // 浠诲姟鐘舵�鏀规垚閿欒
-                    break;
-            }
-
-            WCSHelper.AddActionRecord(model.task_no, model.state, model.forklift_no, model.ext_data);
-            //璋冪敤绗笁鏂规帴鍙o紙濡傛灉鏈夛級TaskProcess.ReportStatus锛屾坊鍔犱换鍔″姩浣滃叧绯昏〃
-
-            return true;
-        }
-
-        /// <summary>
-        /// 浠诲姟鍒嗗彂锛屾牴鎹皟搴︾被鍨嬪彂缁欎笉鍚岀殑璋冨害绯荤粺
-        /// </summary>
-        internal static void Dispatch()
-        {
-            //鏌ヨ浠诲姟
-            //鑾峰彇鎵�湁绛夊緟鐨勪换鍔�-            var list = WCSHelper.GetWaitingTaskList();
-            LogHelper.Info("绛夊緟浠诲姟淇℃伅" + JsonConvert.SerializeObject(list), "API");
-            if (list.Count > 0)
-            {
-                list.ForEach(task =>
-                {
-                    //浣跨敤鑷畾涔変换鍔℃帹閫�-                    TaskHelper.SendTask(task);//璋冨害NDC鎴栨澀濂ユ垨鍥借嚜璁惧
-                    //TaskProcess.SendGZTask(task);///璋冨害鍥借嚜璁惧
-
-                });
-            }
-            else
-            {
-                LogHelper.Info("鏆傛棤浠诲姟");
-            }
-        }
-
-        
-
-        /// <summary>
-        /// 绌烘墭涓嬬嚎鍫嗗彔
-        /// </summary>
-        /// <param name="tN_Task"></param>
-        //public static void EmptyInStackArea(TN_Task tN_Task)
-        //{
-        //    if (tN_Task.S_TYPE == "婊℃墭鍑哄簱涓婄嚎")
-        //    {
-        //        var result = new SimpleResult();
-        //        var db = DbHelper.GetDbClient();
-        //        try
-        //        {
-        //            var startLocLists = 
-        //                db.Queryable<TN_Location>().Where(a => a.S_AREA_CODE == Settings.Areas[6] && a.N_CURRENT_NUM >0 && a.N_LOCK_STATE==0 && a.S_LOCK_STATE == "鏃�).ToList();
-
-        //            if (startLocLists.Count == 0)
-        //            {
-        //                LogHelper.Info($"浜哄伐鎵樼洏鍖烘殏鏃犲凡缁戝畾鐨勭┖鎵橈紝闇�婊¤冻锛氳揣浣嶆暟閲忓ぇ浜�锛屾湭閿佸畾鐨勶紝灞炰簬搴撳尯{Settings.Areas[6]}鐨勮揣浣�);
-        //                return;
-        //            }
-
-        //            foreach (var item in startLocLists)
-        //            {
-        //                //鏌ヨ绗﹀悎鐨勬湭閿佸畾宸插惎鐢ㄦ寚瀹氳揣鍖虹殑褰撳墠鏁伴噺鍚堣鍚庢渶鎺ヨ繎瀹归噺鐨勮揣浣嶏紝缁堢偣
-        //                var endLoc = db.Queryable<TN_Location>().
-        //                    Where(a => a.N_CURRENT_NUM + item.N_CURRENT_NUM <= a.N_CAPACITY && a.S_AREA_CODE == Settings.Areas[3] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y").
-        //                    OrderBy(a => a.N_CURRENT_NUM + item.N_CURRENT_NUM - a.N_CAPACITY, OrderByType.Desc).First();
-
-        //                if (endLoc == null)
-        //                {
-        //                    LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣锛岄渶瑕佹弧瓒筹細灞炰簬{Settings.Areas[3]}鐨勬湭閿佸畾鐨勫閲忓厖瓒崇殑璐т綅");
-        //                    continue;
-        //                }
-        //                var locCnt = db.Queryable<TN_Loc_Container>().First(a=>a.S_LOC_CODE == item.S_CODE);
-
-        //                if (locCnt == null)
-        //                {
-        //                    LogHelper.Info($"璐т綅{item.S_CODE}鏈粦瀹氬鍣�);
-        //                    continue;
-        //                }
-
-        //                //鍒涘缓绌烘墭涓嬬嚎鍫嗗彔浠诲姟
-        //                if (WCSHelper.CreateTask(item.S_CODE, endLoc.S_CODE, "绌烘墭涓嬬嚎鍫嗗彔", 3, locCnt.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-        //                {
-        //                    LocationHelper.LockLoc(item.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-        //                    LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-        //                    LogHelper.Info($"鐢熸垚绌烘墭涓嬬嚎鍫嗗彔浠诲姟鎴愬姛锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋item.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-        //                }
-        //                else
-        //                {
-        //                    LogHelper.Info($"鐢熸垚绌烘墭涓嬬嚎鍫嗗彔浠诲姟澶辫触锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋item.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-        //                    continue;
-        //                }
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}", "Error");
-        //        }
-        //    }
-        //}
-
-        
-    }
-}
diff --git a/Services/DebugService.cs b/Services/DebugService.cs
deleted file mode 100644
index 63be575..0000000
--- a/Services/DebugService.cs
+++ /dev/null
@@ -1,243 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-
-using CsvHelper;
-using CsvHelper.Configuration;
-
-using HH.WCS.Mobox3.AnGang.Helper;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Models;
-using HH.WCS.Mobox3.AnGang.Services;
-
-using Newtonsoft.Json;
-
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.DebugRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.DebugResponse;
-using static HH.WCS.Mobox3.AnGang.Models.DebugModel;
-
-namespace HH.WCS.Mobox3.AnGang.Debug {
-    public class DebugService {
-        /// <summary>
-        /// 妯℃嫙 AGV 澶氭鍥炴姤浠诲姟鐘舵�
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        public static ReturnResults AgvSeriesReports(UpdateTaskState model) {
-            var returnResults = new ReturnResults();
-            returnResults.ResultList = new List<ReturnResult>();
-
-            //if (!AgvHelper.IsTaskState(model.NextState)) {
-            //    return returnResults;
-            //}
-
-            var agvCurrentState = 1; // 濡傛灉娌℃湁鎵惧埌鏈�柊鐨�TaskAction锛岄粯璁ゅ綋鍓嶇姸鎬佷负 1(鎵ц)  
-
-            // 鏌ヨ TaskAction 琛ㄤ腑涓庡綋鍓嶄换鍔″彿鍖归厤鐨勬渶鏂拌褰�-            var db = DbHelper.GetDbClient();
-            var taskAction = db.Queryable<TN_Task_Action>()
-                .Where(a => a.S_TASK_CODE == model.TaskID)
-                .OrderBy(a => a.T_CREATE, SqlSugar.OrderByType.Desc).First();
-
-            if (taskAction != null) {
-                // 濡傛灉鏈夊尮閰嶏紝灏嗗綋鍓嶄换鍔$姸鎬佽缃负琛ㄥ崟涓殑鏈�柊鐘舵�
-                agvCurrentState = taskAction.N_ACTION_CODE;
-            }
-
-            if (!AgvHelper.IsNextStateOk(agvCurrentState, model.NextState)) {
-                LogHelper.Info($"Debug: AGV 鐘舵� '{model.NextState}' 涓嶆槸 '{agvCurrentState}' 鐨�鍚堟硶涓嬩竴鐘舵�");
-                return returnResults;
-            }
-
-            var agvTaskState = new AgvTaskState() {
-                task_no = model.TaskID,
-                forklift_no = model.ForkliftNo,
-            };
-
-            var result = new ReturnResult();
-
-            // 褰撳墠鐘舵�娌℃湁杈惧埌鏈�粓鐘舵�鏃讹紝寰幆鍔犲叆杩斿洖鍒楄〃
-            while (agvCurrentState != model.NextState) {
-                agvTaskState.state = agvCurrentState;
-                result = AgvService.OperateAgvTaskStatus(agvTaskState);
-                returnResults.ResultList.Add(result);
-                agvCurrentState = AgvHelper.GetNextState(agvCurrentState);
-            }
-
-            // 灏嗗惊鐜病鏈夊埌杈剧殑鏈�粓鐘舵�锛屼篃鍔犲叆杩斿洖鍒楄〃
-            agvTaskState.state = model.NextState;
-            result = AgvService.OperateAgvTaskStatus(agvTaskState);
-            returnResults.ResultList.Add(result);
-
-            return returnResults;
-        }
-
-        /// <summary>
-        /// 鍒濆鏁版嵁搴撳缓绔�-        /// </summary>
-        /// <returns></returns>
-        public static string CreateDatabase(bool cover = true) {
-            try {
-                var db = DbHelper.GetDbClient();
-
-                var entityTypes = new Type[] {
-                    typeof(TN_CAR_IN),
-                    typeof(TN_CG_Detail),
-                    typeof(TN_Container),
-                    typeof(TN_Loc_Container),
-                    typeof(TN_Location),
-                    typeof(TN_Task),
-                    typeof(TN_Task_Action),
-                    typeof(SysHelper.OI_SYS_MAXID),
-
-                };
-
-                using (var tran = db.Ado.UseTran()) {
-                    if (cover) {
-                        // 鍒犻櫎鎵�湁琛紙鎸変緷璧栧叧绯诲�搴忥級
-                        var tables = db.DbMaintenance.GetTableInfoList();
-                        foreach (var table in tables.OrderByDescending(t => t.Name)) {
-                            db.DbMaintenance.DropTable(table.Name);
-                        }
-
-                        // 鍒涘缓鏂拌〃
-                        db.CodeFirst.InitTables(entityTypes);
-
-                        //db.CodeFirst.BackupTable().InitTables(entityTypes);
-                    }
-                    else {
-                        db.CodeFirst.InitTables(entityTypes);
-                    }
-
-                    tran.CommitTran();
-                }
-
-            }
-            catch (Exception ex) {
-                LogHelper.Info($"鍙戠敓浜嗗紓甯�);
-                return "鍒濆鍖栨暟鎹簱閿欒" + ex.Message;
-            }
-
-            return "鎴愬姛";
-        }
-
-        public static string InsertLocCntrCg(LocCntrCg locCntrCg) {
-            var db = DbHelper.GetDbClient();
-
-            try {
-                using (var tran = db.UseTran()) {
-                    LogHelper.Info("LogCntrCg锛� + JsonConvert.SerializeObject(locCntrCg));
-                    if (string.IsNullOrEmpty(locCntrCg.LocCode)) {
-                        return "鍙傛暟闈炴硶";
-                    }
-
-                    var loc = db.Queryable<TN_Location>().First(a => a.S_CODE == locCntrCg.LocCode);
-                    if (loc == null) {
-                        var newLoc = new TN_Location {
-                            S_CODE = locCntrCg.LocCode,
-                            S_AREA_CODE = locCntrCg.LocArea ?? ""
-                        };
-
-                        if (db.Insertable<TN_Location>(newLoc).ExecuteCommand() <= 0) {
-                            tran.RollbackTran();
-                            LogHelper.Info($"鎻掑叆浣嶇疆{locCntrCg.LocCode}澶辫触");
-                            return "鎻掑叆澶辫触";
-                        }
-
-                        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)) {
-                        tran.CommitTran();
-                        LogHelper.Info("瀹瑰櫒鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
-                        return "瀹瑰櫒鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�;
-                    }
-
-                    var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == locCntrCg.LocCode
-                        && a.S_CNTR_CODE == locCntrCg.CntrCode);
-
-                    if (locCntrRel == null) {
-                        var newLocCntrRel = new TN_Loc_Container {
-                            S_LOC_CODE = locCntrCg.LocCode,
-                            S_CNTR_CODE = locCntrCg.CntrCode
-                        };
-
-                        loc.N_CURRENT_NUM = 1;
-
-                        if (db.Insertable<TN_Loc_Container>(newLocCntrRel).ExecuteCommand() <= 0
-                            && db.Updateable<TN_Location>(loc).UpdateColumns(c => c.N_CURRENT_NUM).ExecuteCommand() <= 0) {
-                            tran.RollbackTran();
-                            LogHelper.Info($"鎻掑叆浣嶇疆鎵樼洏鍏崇郴{locCntrCg.LocCode}-{locCntrCg.CntrCode}澶辫触");
-                            return "鎻掑叆澶辫触";
-                        }
-                    }
-
-                    if (string.IsNullOrEmpty(locCntrCg.ItemCode)) {
-                        tran.CommitTran();
-                        LogHelper.Info("鐗╂枡鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
-                        return "鐗╂枡鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�;
-                    }
-
-                    var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrCg.CntrCode
-                        && 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.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();
-                }
-
-                return "鎻掑叆鏁版嵁鎴愬姛";
-
-            }
-            catch (Exception ex) {
-                return $"{ex.Message}";
-            }
-        }
-
-        public static string SetTaskWeight(SetTaskWeightInfo model) {
-            var db = DbHelper.GetDbClient();
-            var cgDetail = db.Queryable<TN_CG_Detail, TN_Task>((d, t) => d.S_CNTR_CODE == t.S_CNTR_CODE)
-                .Where((d, t) => t.S_CODE == model.TaskNo).First();
-
-            if (cgDetail == null) {
-                return "鎵句笉鍒板搴旂殑鐗╂枡淇℃伅";
-            }
-
-            cgDetail.F_QTY = model.Weight;
-
-            try {
-                if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY)
-                    .ExecuteCommand() <= 0 ) {
-                    return "淇敼澶辫触";
-                }
-                return "淇敼鎴愬姛";
-
-            }
-            catch (Exception ex) {
-
-                return ex.Message;
-            }
-
-        }
-    }
-}
diff --git a/Services/ErpService.cs b/Services/ErpService.cs
deleted file mode 100644
index 1d6abec..0000000
--- a/Services/ErpService.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Models;
-
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.ErpRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.ErpResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Services {
-    public class ErpService {
-        public static ErpResult InboundDataSync(InboundDataSyncInfo model) {
-            var db = DbHelper.GetDbClient();
-
-            try {
-
-            }
-            catch (Exception ex) {
-                return BuildErpResult(1, ex.Message);
-            }
-            return BuildErpResult(0, null);
-        }
-
-        public static ErpResult OutboundDataSync(OutboundDataSyncInfo model) {
-            var db = DbHelper.GetDbClient();
-
-            try {
-
-
-            }
-            catch (Exception ex) {
-                return BuildErpResult(1, ex.Message);
-            }
-            return BuildErpResult(1, null);
-        }
-    }
-}
diff --git a/Services/MoboxService.cs b/Services/MoboxService.cs
deleted file mode 100644
index e74bb71..0000000
--- a/Services/MoboxService.cs
+++ /dev/null
@@ -1,363 +0,0 @@
-锘縰sing System;
-
-using HH.WCS.Mobox3.AnGang.AppStart;
-using HH.WCS.Mobox3.AnGang.Consts;
-using HH.WCS.Mobox3.AnGang.Helper;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Models;
-
-using Newtonsoft.Json;
-
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.ErpRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.MoboxRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.MoboxResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Services {
-    public class MoboxService {
-
-        /// <summary>
-        /// 浜у搧鍏ュ簱(PDA)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult Inbound(InboundInfo model) {
-            LogHelper.Info("瑙﹀彂API锛氫骇鍝佸叆搴�PDA)" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-            var startLoc = new TN_Location();
-
-            try {
-                // 璧风偣浣嶇疆蹇呴』锛氫负绌恒�鏃犻攣銆佸惎鐢ㄣ�灞炰簬鏀跺彂鍖哄煙
-                startLoc = db.Queryable<TN_Location>().
-                    First(a => a.S_CODE == model.StartLoc
-                    && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" 
-                    && a.S_AREA_CODE == AreaCode.鏀跺彂鍖�;
-
-                if (startLoc == null) {
-                    return BuildSimpleResult(1, $"璧风偣浣嶇疆{model.StartLoc}涓嶅瓨鍦紒");
-                }
-
-                // 瀹瑰櫒 ID 鍜�鐗╂枡 ID 鏈寚瀹氾紝鐢辩郴缁熺洿鎺ョ敓鎴�-                var cntID = Guid.NewGuid().ToString("D");
-                var CgId = Guid.NewGuid().ToString("D");
-
-                // 鍒濆鏄病鏈夌粦瀹氫俊鎭殑锛屽厛灏嗚捣鐐逛綅缃笌瀹瑰櫒缁戝畾锛屽鍣ㄤ笌鐗╂枡缁戝畾
-                var cntLoc = new TN_Loc_Container() {
-                    S_LOC_CODE = startLoc.S_CODE,
-                    S_CNTR_CODE = cntID,
-                };
-                var cgCnt = new TN_CG_Detail() {
-                    S_ITEM_CODE = CgId,
-                    S_CNTR_CODE = cntID,
-                };
-
-                var endLoc = "0"; // 鍋囩殑榛樿缁堢偣鍦板潃
-
-                // 鎸囧畾璐т綅鎺掑彿锛堜笉鑳戒负绌恒�绌哄瓧绗︿覆鎴栫┖鏍硷級
-                if (model.Row != null && model.Row.Trim() != "") {
-                    endLoc = model.Row; // 鐢ㄦ帓鍙峰瓧绗︿覆褰撳仛鍋囧湴鍧�-                    if (!int.TryParse(model.Row.Trim(), out int row)) {
-                        return BuildSimpleResult(2, $"{model.Row} 涓嶅悎娉曪細鏃犳硶杞垚鏁存暟绫诲瀷");
-                    }
-                    // 璐ф灦鎺掑彿鍙兘鏄�0 - 8
-                    if (row <= 0 || row > 8) {
-                        return BuildSimpleResult(2, $"璐ф灦鍙�{model.Row} 蹇呴』鏄�-8涔嬮棿鐨勬暣鏁�);
-                    }
-                }
-
-                // 鏃犺鏄惁閫夋嫨缁堢偣璐ф灦锛岄兘绛夊埌绉伴噸涔嬪悗鍐嶈绠楃粓鐐硅揣浣�-                using (var trans = db.Ado.UseTran()) {
-                    if (db.Insertable<TN_Loc_Container>(cntLoc).ExecuteCommand() > 0
-                        && db.Insertable<TN_CG_Detail>(cgCnt).ExecuteCommand() > 0) {
-                        //鍒涘缓浜у搧鍏ュ簱浠诲姟锛氬垱寤烘惉閫佷换鍔★紝璧风偣缁堢偣瀹瑰櫒
-                        if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc, TaskName.浜у搧鍏ュ簱, 3, cntID)) {
-                            //濡傛灉鎿嶄綔TN_Location浼氶�鎴愭閿�-                            LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-                            //LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                            trans.CommitTran();
-
-                            return BuildSimpleResult(0, $"鐢熸垚 浜у搧鍏ュ簱 鎴愬姛锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc} 锛岀粓鐐硅揣浣嶆湭鎸囧畾");
-                        }
-                        else {
-                            trans.RollbackTran();
-
-                            return BuildSimpleResult(5, $"鐢熸垚 浜у搧鍏ュ簱 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc} 锛岀粓鐐硅揣浣嶆湭鎸囧畾");
-                        }
-                    }
-                    else {
-                        return BuildSimpleResult(6, $"鎻掑叆琛ㄦ暟鎹け璐�);
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// PDA閫夋嫨缁堢偣璐т綅
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult SelectLocation(SelectLocationInfo model) {
-            LogHelper.Info("瑙﹀彂API锛歅DA閫夋嫨缁堢偣璐т綅" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-
-            try {
-                // 浠诲姟鍙峰瓨鍦細缁堢偣璐ф灦鍜岀粓鐐逛綅缃负绌猴紝涓斾换鍔′负浜у搧鍏ュ簱(PDA)
-                //var task = db.Queryable<TN_Task>().First(a => a.S_EQ_NO == model.forklift_no && a.S_END_AREA == "HJQ" && a.S_END_LOC == "0" && a.S_TYPE == "浜у搧鍏ュ簱(PDA)");
-                var task = db.Queryable<TN_Task>()
-                    .Where(a => a.S_B_STATE == "鍙栬揣瀹屾垚" && a.S_TYPE == TaskName.浜у搧鍏ュ簱)
-                    .OrderBy(a => a.T_CREATE, SqlSugar.OrderByType.Desc).First();
-                
-                if (task == null) {
-                    return BuildSimpleResult(2, $"褰撳墠涓嶅瓨鍦ㄧ姸鎬佷负 鍙栬揣瀹屾垚 鐨�浜у搧鍏ュ簱 浠诲姟");
-                }
-                
-                if (task.S_END_LOC != null && task.S_END_LOC != "0") {
-                    return BuildSimpleResult(3, $"璇ヤ换鍔″凡鏈夌粓鐐�);
-                }
-
-                var cgDetail = db.Queryable<TN_CG_Detail>()
-                    .Where(a => a.S_CNTR_CODE == task.S_CNTR_CODE).First();
-
-                if (cgDetail == null) {
-                    return BuildSimpleResult(4, $"鎵樼洏鐗╂枡涓嶅瓨鍦�);
-                }
-
-                var endLoc = new TN_Location();
-                if (cgDetail.F_QTY > 1500) {
-                    // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-3灞傝揣鏋�-                    endLoc = db.Queryable<TN_Location>().First(
-                        a => a.S_CODE == model.endLoc && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == 0 && a.N_LAYER <= 3 && a.S_AREA_CODE == AreaCode.璐ф灦鍖�;
-                }
-                else if (cgDetail.F_QTY > 0) {
-                    endLoc = db.Queryable<TN_Location>().First(
-                        a => a.S_CODE == model.endLoc && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == 0 && a.S_AREA_CODE == AreaCode.璐ф灦鍖�;
-                }
-                else {
-                    return BuildSimpleResult(5, $"鐗╂枡閲嶉噺淇℃伅涓嶅悎娉曪細{cgDetail.F_QTY}");
-                }
-
-                // 娌℃湁绗﹀悎鏉′欢鐨勮揣浣�-                if (endLoc == null) {
-                    return BuildSimpleResult(6, $"璐т綅{model.endLoc}涓嶅瓨鍦紝鎴栦笉婊¤冻绉伴噸鏀剧疆瑕佹眰");
-                }
-
-                // 淇敼浠诲姟缁堢偣涓篜DA鎸囧畾缁堢偣
-                task.S_END_LOC = endLoc.S_CODE;
-
-                using (var trans = db.Ado.UseTran()) {
-                    if (db.Updateable<TN_Task>(task).UpdateColumns(a => a.S_END_LOC).ExecuteCommand() > 0) {
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-                        trans.CommitTran();
-
-                        return BuildSimpleResult(0, $"浠诲姟{task.S_CODE}淇敼鎴愬姛锛屼慨鏀圭粓鐐逛綅缃负{endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-
-                        return BuildSimpleResult(7, $"浠诲姟{task.S_CODE}淇敼澶辫触锛屼慨鏀圭粓鐐逛綅缃负{endLoc.S_CODE}");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍑哄簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult PartOutbound(PartOutboundInfo model) {
-            LogHelper.Info("瑙﹀彂API锛氫骇鍝侀儴鍒嗗嚭搴�WMS)" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-
-            try {
-                // 璧风偣浣嶇疆锛氳揣鏋讹紙鏈夎揣銆佹病鏈夐攣銆佸凡鍚敤锛�-                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
-
-                if (startLoc == null) {
-                    return BuildSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶅瓨鍦ㄦ垨涓嶅叿澶囧彇璐ц姹�);
-                }
-
-                var locCtnrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
-
-                if (locCtnrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙嚭搴撶殑鐗╂枡");
-                }
-
-                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == AreaCode.鏀跺彂鍖�;
-
-                if (endLoc == null) {
-                    return BuildSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
-                }
-
-                using (var trans = db.Ado.UseTran()) {
-                    // 瑙g粦锛氳捣鐐硅揣浣嶄笌寰呮惉杩愬鍣紙涓嶉渶瑕佹墜鍔╠eleteable鎿嶄綔锛屽唴閮ㄤ細鑷姩鎿嶄綔鐨勶級
-                    if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, TaskName.浜у搧閮ㄥ垎鍑哄簱, 3, locCtnrRel.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-                        {//濡傛灉鎿嶄綔TN_Location浼氶�鎴愭閿�-                        LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        return BuildSimpleResult(0, $"鐢熸垚 浜у搧閮ㄥ垎鍑哄簱 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-                        return BuildSimpleResult(5, $"鐢熸垚 浜у搧閮ㄥ垎鍑哄簱 澶辫触锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// 浜у搧閮ㄥ垎鍥炲簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult PartInbound(PartInboundInfo model) {
-            LogHelper.Info("瑙﹀彂API锛氫骇鍝侀儴鍒嗗洖搴�WMS)" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-
-            try {
-                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
-                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == AreaCode.鏀跺彂鍖�;
-                if (startLoc == null) {
-                    return BuildSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝洖搴撴潯浠�);
-                }
-
-                var locCtnrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
-                if (locCtnrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
-                }
-
-                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�-                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
-                if (endLoc == null) {
-                    return BuildSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
-                }
-
-                using (var trans = db.Ado.UseTran()) {
-                    // 瑙g粦锛氳捣鐐硅揣浣嶄笌寰呮惉杩愬鍣紙涓嶉渶瑕佹墜鍔╠eleteable鎿嶄綔锛屽唴閮ㄤ細鑷姩鎿嶄綔鐨勶級
-                    if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "浜у搧閮ㄥ垎鍏ュ簱(WMS)", 3, locCtnrRel.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-                        {//濡傛灉鎿嶄綔TN_Location浼氶�鎴愭閿�-                        LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        return BuildSimpleResult(0, $"鐢熸垚 浜у搧閮ㄥ垎鍥炲簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-                        return BuildSimpleResult(5, $"鐢熸垚 浜у搧閮ㄥ垎鍥炲簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍑哄簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult CheckOutbound(CheckOutboundInfo model) {
-            LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у嚭搴�WMS)" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-
-            try {
-                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
-                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == AreaCode.鏀跺彂鍖�;
-                if (startLoc == null) {
-                    return BuildSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝嚭搴撴潯浠�);
-                }
-
-                var locCtnrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
-                if (locCtnrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
-                }
-
-                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�-                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
-                if (endLoc == null) {
-                    return BuildSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
-                }
-
-                using (var trans = db.Ado.UseTran()) {
-                    // 瑙g粦锛氳捣鐐硅揣浣嶄笌寰呮惉杩愬鍣紙涓嶉渶瑕佹墜鍔╠eleteable鎿嶄綔锛屽唴閮ㄤ細鑷姩鎿嶄綔鐨勶級
-                    if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "鐩樼偣鐞嗚揣鍑哄簱(WMS)", 3, locCtnrRel.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-                        {//濡傛灉鎿嶄綔TN_Location浼氶�鎴愭閿�-                        LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        return BuildSimpleResult(0, $"鐢熸垚 鐩樼偣鐞嗚揣鍑哄簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-                        return BuildSimpleResult(5, $"鐢熸垚 鐩樼偣鐞嗚揣鍑哄簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// 鐩樼偣鐞嗚揣鍥炲簱(WMS)
-        /// </summary>
-        /// <param name="model"></param>
-        /// <returns></returns>
-        internal static SimpleResult CheckInbound(CheckInboundInfo model) {
-            LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у洖搴�WMS)" + JsonConvert.SerializeObject(model), "API");
-            var db = DbHelper.GetDbClient();
-
-            try {
-                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
-                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == AreaCode.鏀跺彂鍖�;
-                if (startLoc == null) {
-                    return BuildSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝洖搴撴潯浠�);
-                }
-
-                var locCtnrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
-                if (locCtnrRel == null) {
-                    return BuildSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
-                }
-
-                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�-                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
-                if (endLoc == null) {
-                    return BuildSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
-                }
-
-                using (var trans = db.Ado.UseTran()) {
-                    // 瑙g粦锛氳捣鐐硅揣浣嶄笌寰呮惉杩愬鍣紙涓嶉渶瑕佹墜鍔╠eleteable鎿嶄綔锛屽唴閮ㄤ細鑷姩鎿嶄綔鐨勶級
-                    if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "鐩樼偣鐞嗚揣鍥炲簱(WMS)", 3, locCtnrRel.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�-                        {//濡傛灉鎿嶄綔TN_Location浼氶�鎴愭閿�-                        LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        return BuildSimpleResult(0, $"鐢熸垚 鐩樼偣鐞嗚揣鍥炲簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-                        return BuildSimpleResult(5, $"鐢熸垚 鐩樼偣鐞嗚揣鍥炲簱(WMS) 鎴愬姛锛屽鍣ㄥ彿{locCtnrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}");
-                    }
-                }
-            }
-            catch (Exception ex) {
-                return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
-            }
-        }
-    }
-}
diff --git a/Controllers/AgvController.cs b/api/AgvController.cs
similarity index 76%
rename from Controllers/AgvController.cs
rename to api/AgvController.cs
index 16c1fe5..1dcacb9 100644
--- a/Controllers/AgvController.cs
+++ b/api/AgvController.cs
@@ -1,21 +1,19 @@
-锘縰sing HH.WCS.Mobox3.AnGang.ServiceCore;
-using HH.WCS.Mobox3.AnGang.Dispatch;
+锘縰sing HH.WCS.Mobox3.AnGang.core;
+using HH.WCS.Mobox3.AnGang.dispatch;
 using HH.WCS.Mobox3.AnGang.process;
-using HH.WCS.Mobox3.AnGang.Helper;
+using HH.WCS.Mobox3.AnGang.wms;
 using Newtonsoft.Json;
 using System.Collections.Generic;
 using System.Reflection;
 using System.Web.Http;
-using static HH.WCS.Mobox3.AnGang.Dispatch.NDC;
+using static HH.WCS.Mobox3.AnGang.dispatch.NDC;
 using System.Linq;
 using HH.WCS.Mobox3.AnGang.config;
 
-using HH.WCS.Mobox3.AnGang.Services;
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
 
-namespace HH.WCS.Mobox3.AnGang.Controllers
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+
+namespace HH.WCS.Mobox3.AnGang.api
 {
     /// <summary>
     /// 璁惧淇℃伅涓婃姤锛坔osttoagv涓婃姤銆佹澀濂ュ爢鍨涙満銆佸浗鑷猘gv锛�@@ -55,7 +53,7 @@
         [HttpPost]
         [Route("safetyInteraction")]
         public ReturnResult SafetyInteraction(SafetyInteractionInfo model) {
-            return AgvService.SafetyInteraction(model);
+            return WCSCore.SafetyInteraction(model);
         }
     }
 }
diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs
new file mode 100644
index 0000000..317676f
--- /dev/null
+++ b/api/ApiHelper.cs
@@ -0,0 +1,612 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HH.WCS.Mobox3.AnGang.models;
+using HH.WCS.Mobox3.AnGang.util;
+using HH.WCS.Mobox3.AnGang.wms;
+
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using static HH.WCS.Mobox3.AnGang.api.OtherModel;
+
+namespace HH.WCS.Mobox3.AnGang.api {
+    public class ApiHelper {
+        /// <summary>
+        /// 浜у搧鍏ュ簱(PDA)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult Inbound(InboundInfo model) {
+            var taskName = TaskName.浜у搧鍏ュ簱;
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 璧风偣浣嶇疆蹇呴』锛氫负绌恒�鏃犻攣銆佸惎鐢ㄣ�灞炰簬鏀跺彂鍖哄煙
+                var startLoc = db.Queryable<TN_Location>()
+                    .Where(a => a.S_CODE == model.StartLoc)
+                    .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y")
+                    .Where(a => a.N_CURRENT_NUM == 0)
+                    .Where(a => a.S_AREA_CODE == "SFQ")
+                    .First();
+
+                if (startLoc == null) {
+                    return NewSimpleResult(1, $"璧风偣浣嶇疆{model.StartLoc}涓嶅瓨鍦紒");
+                }
+
+                // 瀹瑰櫒 ID 鍜�鐗╂枡 ID 鏈寚瀹氾紝鐢辩郴缁熺洿鎺ョ敓鎴�+                var cntId = Guid.NewGuid().ToString("D");
+                var CgId = Guid.NewGuid().ToString("D");
+
+                // 鍒濆鏄病鏈夌粦瀹氫俊鎭殑锛屽厛灏嗚捣鐐逛綅缃笌瀹瑰櫒缁戝畾锛屽鍣ㄤ笌鐗╂枡缁戝畾
+                var locCntrRel = new TN_Loc_Container() {
+                    S_LOC_CODE = startLoc.S_CODE,
+                    S_CNTR_CODE = cntId,
+                };
+                var cgDetail = new TN_CG_Detail() {
+                    S_ITEM_CODE = CgId,
+                    S_CNTR_CODE = cntId,
+                };
+
+                var endLocCode = "0"; // 鍋囩殑榛樿缁堢偣鍦板潃
+
+                // 鎸囧畾璐т綅鎺掑彿锛堜笉鑳戒负绌恒�绌哄瓧绗︿覆鎴栫┖鏍硷級
+                if (model.Row != null && model.Row.Trim() != "") {
+                    endLocCode = model.Row; // 鐢ㄦ帓鍙峰瓧绗︿覆褰撳仛鍋囧湴鍧�+                    if (!int.TryParse(model.Row.Trim(), out int row)) {
+                        return NewSimpleResult(2, $"{model.Row} 涓嶅悎娉曪細鏃犳硶杞垚鏁存暟绫诲瀷");
+                    }
+                    // 璐ф灦鎺掑彿鍙兘鏄�0 - 8
+                    if (row <= 0 || row > 8) {
+                        return NewSimpleResult(2, $"璐ф灦鍙�{model.Row} 蹇呴』鏄�-8涔嬮棿鐨勬暣鏁�);
+                    }
+                }
+
+                var task = WCSHelper.BuildInboundTask(startLoc, endLocCode, cntId);
+                LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+
+                // 鏃犺鏄惁閫夋嫨缁堢偣璐ф灦锛岄兘绛夊埌绉伴噸涔嬪悗鍐嶈绠楃粓鐐硅揣浣�+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄥけ璐ワ細璐т綅{locCntrRel.S_LOC_CODE}锛屽鍣▄locCntrRel.S_CNTR_CODE}");
+                    }
+
+                    if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鎻掑叆瀹瑰櫒璐у搧鏄庣粏琛ㄥけ璐ワ細瀹瑰櫒{cgDetail.S_CNTR_CODE}锛岀墿鏂檣cgDetail.S_ITEM_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鏇存柊璧风偣璐т綅閿佺姸鎬佸け璐ワ細璧风偣璐т綅{startLoc.S_CODE}");
+                    }
+
+                    if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚浠诲姟 {taskName} 澶辫触锛氬鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLocCode} 锛岀粓鐐硅揣浣嶆湭鎸囧畾");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0,
+                        $"鐢熸垚浠诲姟 {taskName} 鎴愬姛锛氬鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLocCode} 锛岀粓鐐硅揣浣嶆湭鎸囧畾");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// PDA閫夋嫨缁堢偣璐т綅
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult SelectLocation(SelectLocationInfo model) {
+
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 浠诲姟鍙峰瓨鍦細缁堢偣璐ф灦鍜岀粓鐐逛綅缃负绌猴紝涓斾换鍔′负浜у搧鍏ュ簱(PDA)
+                var task = db.Queryable<TN_Task>()
+                    .Where(a => a.S_B_STATE == "鍙栬揣瀹屾垚" && a.S_TYPE == TaskName.浜у搧鍏ュ簱)
+                    .OrderBy(a => a.T_CREATE, SqlSugar.OrderByType.Desc).First();
+
+                if (task == null) {
+                    return NewSimpleResult(2, $"褰撳墠涓嶅瓨鍦ㄧ姸鎬佷负 鍙栬揣瀹屾垚 鐨�浜у搧鍏ュ簱 浠诲姟");
+                }
+
+                if (task.S_END_LOC != null && task.S_END_LOC != "0") {
+                    return NewSimpleResult(3, $"璇ヤ换鍔″凡鏈夌粓鐐�);
+                }
+
+                var cgDetail = db.Queryable<TN_CG_Detail>()
+                    .Where(a => a.S_CNTR_CODE == task.S_CNTR_CODE).First();
+
+                if (cgDetail == null) {
+                    return NewSimpleResult(4, $"鎵樼洏鐗╂枡涓嶅瓨鍦�);
+                }
+
+                var endLoc = new TN_Location();
+                if (cgDetail.F_QTY > 1500) {
+                    // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-3灞傝揣鏋�+                    endLoc = db.Queryable<TN_Location>()
+                        .Where(a => a.S_CODE == model.endLoc)
+                        .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y")
+                        .Where(a => a.N_CURRENT_NUM == 0)
+                        .Where(a => a.S_AREA_CODE == "HJQ")
+                        .Where(a => a.N_LAYER <= 3)
+                        .First();
+                }
+                else if (cgDetail.F_QTY > 0) {
+                    endLoc = db.Queryable<TN_Location>()
+                        .Where(a => a.S_CODE == model.endLoc)
+                        .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y")
+                        .Where(a => a.N_CURRENT_NUM == 0)
+                        .Where(a => a.S_AREA_CODE == "HJQ")
+                        //.Where(a => a.N_LAYER <= 3)
+                        .First();
+                }
+                else {
+                    return NewSimpleResult(5, $"鐗╂枡閲嶉噺淇℃伅涓嶅悎娉曪細{cgDetail.F_QTY}");
+                }
+
+                // 娌℃湁绗﹀悎鏉′欢鐨勮揣浣�+                if (endLoc == null) {
+                    return NewSimpleResult(6, $"璐т綅{model.endLoc}涓嶅瓨鍦紝鎴栦笉婊¤冻绉伴噸鏀剧疆瑕佹眰");
+                }
+
+                // 淇敼浠诲姟缁堢偣涓篜DA鎸囧畾缁堢偣
+                task.S_END_LOC = endLoc.S_CODE;
+                LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿�+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Task>(task).UpdateColumns(a => a.S_END_LOC).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(7, $"浠诲姟{task.S_CODE}淇敼澶辫触锛屼慨鏀圭粓鐐逛綅缃负{endLoc.S_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(7, $"浠诲姟{task.S_CODE}淇敼澶辫触锛屼慨鏀圭粓鐐逛綅缃负{endLoc.S_CODE}");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0, $"浠诲姟{task.S_CODE}淇敼鎴愬姛锛屼慨鏀圭粓鐐逛綅缃负{endLoc.S_CODE}");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍑哄簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult PartOutbound(PartOutboundInfo model) {
+            var taskName = TaskName.浜у搧閮ㄥ垎鍑哄簱;
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 璧风偣浣嶇疆锛氳揣鏋讹紙鏈夎揣銆佹病鏈夐攣銆佸凡鍚敤锛�+                var startLoc = db.Queryable<TN_Location>()
+                    .Where(a => a.S_CODE == model.startLoc)
+                    .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y")
+                    .Where(a => a.N_CURRENT_NUM == 1)
+                    .First();
+
+                if (startLoc == null) {
+                    return NewSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶅瓨鍦ㄦ垨涓嶅叿澶囧彇璐ц姹�);
+                }
+
+                var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
+
+                if (locCntrRel == null) {
+                    return NewSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙嚭搴撶殑鐗╂枡");
+                }
+
+                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == "SFQ");
+
+                if (endLoc == null) {
+                    return NewSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
+                }
+
+                var cntId = locCntrRel.S_CNTR_CODE;
+                var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName);
+
+                LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+                LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0,
+                        $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍥炲簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult PartInbound(PartInboundInfo model) {
+            var taskName = TaskName.浜у搧閮ㄥ垎鍥炲簱;
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
+                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == "SFQ");
+                if (startLoc == null) {
+                    return NewSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝洖搴撴潯浠�);
+                }
+
+                var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
+                if (locCntrRel == null) {
+                    return NewSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
+                }
+
+                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�+                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
+                if (endLoc == null) {
+                    return NewSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
+                }
+
+                var cntId = locCntrRel.S_CNTR_CODE;
+                var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName);
+                LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+                LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0,
+                        $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        public static SimpleResult CreateCountPlan(CreateCountPlanInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+            try {
+
+                var countPlan = new TN_Count_Plan() {
+                    S_CP_NO = GenerateNo("鐩樼偣璁″垝", "CP"),
+                    S_TYPE = model.countType,
+                };
+
+                if (model.countType == "璐т綅") {
+                    countPlan.S_LOC_CODE = model.targetId;
+                }
+                else if (model.countType == "鐗╂枡") {
+                    countPlan.S_ITEM_CODE = model.targetId;
+                }
+                else {
+                    return NewSimpleResult(2, $"鍒涘缓鐩樼偣璁″垝澶辫触锛氫笉鍚堟硶鐨勭洏鐐圭被鍨�'{model.countType}'");
+                }
+
+                if (db.Insertable<TN_Count_Plan>(countPlan).ExecuteCommand() <= 0) {
+                    return NewSimpleResult(2, "鍒涘缓鐩樼偣璁″垝澶辫触");
+                }
+
+                return NewSimpleResult(0, "鍒涘缓鐩樼偣璁″垝鎴愬姛");
+
+            }
+            catch (Exception ex) {
+
+                return NewSimpleResult(1, ex.Message);
+            }
+        }
+
+        public static SimpleResult CreateCountOrder(CreateCountOrderInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+            var info = "";
+            try {
+                var countPlan = db.Queryable<TN_Count_Plan>()
+                    .Where(a => a.S_CP_NO == model.planId).First();
+
+                if (countPlan == null) {
+                    return NewSimpleResult(2, $"鐩樼偣璁″垝鍗曞彿 '{model.planId}' 涓嶅瓨鍦�);
+                }
+
+                var countOrder = new TN_Count_Order() {
+                    S_CP_NO = model.planId,
+                    S_COUNT_NO = GenerateNo("鐩樼偣鍗�, "CN"),
+                };
+
+                var countDetailList = new List<TN_Count_CG_Detail>();
+                if (countPlan.S_TYPE == "璐т綅") {
+                    var cgDetail = db.Queryable<TN_Location, TN_Loc_Container, TN_CG_Detail>
+                        ((l, c, d) => l.S_CODE == c.S_LOC_CODE && c.S_CNTR_CODE == d.S_CNTR_CODE)
+                        .Where(l => l.S_CODE == countPlan.S_LOC_CODE)
+                        .Select((l, c, d) => d).First();
+
+                    var countDetail = new TN_Count_CG_Detail {
+                        S_COUNT_NO = countOrder.S_COUNT_NO,
+                        S_CNTR_CODE = cgDetail.S_CNTR_CODE,
+                        S_ITEM_CODE = cgDetail.S_ITEM_CODE,
+                    };
+
+                    countDetailList.Add(countDetail);
+                }
+                else if (countPlan.S_TYPE == "鐗╂枡") {
+                    var cgDetailList = db.Queryable<TN_CG_Detail>()
+                        .Where(d => d.S_ITEM_CODE == countPlan.S_ITEM_CODE).ToList();
+
+                    foreach (var cgDetail in cgDetailList) {
+                        var countDetail = new TN_Count_CG_Detail {
+                            S_COUNT_NO = countOrder.S_COUNT_NO,
+                            S_CNTR_CODE = cgDetail.S_CNTR_CODE,
+                            S_ITEM_CODE = cgDetail.S_ITEM_CODE,
+                        };
+
+                        countDetailList.Add(countDetail);
+                    }
+                }
+                else {
+                    return NewSimpleResult(3, $"璁″垝鍗�{model.planId}'鐨勭被鍨媨countPlan.S_TYPE}涓嶅悎娉�);
+                }
+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Insertable<TN_Count_Order>(countOrder).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        info = "鍒涘缓鐩樼偣鍗曞け璐�;
+                        return NewSimpleResult(2, info);
+                    }
+
+                    if (db.Insertable<TN_Count_CG_Detail>(countDetailList).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        info = "鍒涘缓鐩樼偣鍗曟槑缁嗗け璐�;
+                        return NewSimpleResult(3, info); 
+                    }
+
+                    tran.CommitTran();
+                }
+
+                return NewSimpleResult(0, "鍒涘缓鐩樼偣鍗曟垚鍔�);
+            }
+            catch (Exception ex) {
+
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        public static SimpleResult CountProduct(CountProductInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+            try {
+                var cgDetail = db.Queryable<TN_CG_Detail>()
+                    .Where(d => d.S_CNTR_CODE == model.cntrCode).First();
+
+                if (cgDetail == null) {
+                    return NewSimpleResult(2, $"鎵句笉鍒板鍣ㄥ彿'{model.cntrCode}'瀵瑰簲鐨勭墿鏂�);
+                }
+
+                var countDiff = new TN_Count_Diff {
+                    S_CNTR_CODE = cgDetail.S_CNTR_CODE,
+                    F_ACTUAL_QTY = model.qty
+                };
+
+                if (db.Insertable<TN_Count_Diff>(countDiff).ExecuteCommand() <= 0) {
+                    return NewSimpleResult(3, $"鎻掑叆鐩樼偣宸紓琛ㄥけ璐�);
+                }
+
+                return NewSimpleResult(0, "鐩樼偣宸紓瀹屾垚");
+
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        internal static string GenerateNo(string snType, string prefix) {
+            var id = SYSHelper.GetSerialNumber(snType, prefix);
+            var date = DateTime.Now.ToString("yyMMdd");
+            return $"TN{date}{id.ToString().PadLeft(4, '0')}";
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍑哄簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult CheckOutbound(CheckOutboundInfo model) {
+            var taskName = TaskName.鐩樼偣鐞嗚揣鍑哄簱;
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
+                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == "SFQ");
+                if (startLoc == null) {
+                    return NewSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝嚭搴撴潯浠�);
+                }
+
+                var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
+                if (locCntrRel == null) {
+                    return NewSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
+                }
+
+                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�+                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
+                if (endLoc == null) {
+                    return NewSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
+                }
+
+                var cntID = locCntrRel.S_CNTR_CODE;
+                var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName);
+                LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+                LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0,
+                        $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍥炲簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static SimpleResult CheckInbound(CheckInboundInfo model) {
+            var taskName = TaskName.鐩樼偣鐞嗚揣鍥炲簱;
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                // 璧风偣浣嶇疆锛氬彇鏀捐揣鍖猴紙鏈夎揣鐗┿�娌℃湁閿併�宸插惎鐢級
+                var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.S_AREA_CODE == "SFQ");
+                if (startLoc == null) {
+                    return NewSimpleResult(2, $"璧风偣浣嶇疆 {model.startLoc} 涓嶇鍚堝洖搴撴潯浠�);
+                }
+
+                var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc);
+                if (locCntrRel == null) {
+                    return NewSimpleResult(3, $"璧风偣浣嶇疆 {model.startLoc} 娌℃湁缁戝畾瀹瑰櫒锛屾棤鍙洖搴撶殑鐗╂枡");
+                }
+
+                // 缁堢偣浣嶇疆锛氳揣鏋讹紙娌℃湁璐х墿锛屾病鏈夐攣锛�+                var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y");
+                if (endLoc == null) {
+                    return NewSimpleResult(4, $"缁堢偣浣嶇疆 {model.endLoc} 涓嶅叿澶囨斁璐ф潯浠�);
+                }
+
+                var cntID = locCntrRel.S_CNTR_CODE;
+                var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName);
+                LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+                LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+
+                using (var tran = db.Ado.UseTran()) {
+                    if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                        it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                        tran.RollbackTran();
+                        return NewSimpleResult(500,
+                            $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                    }
+
+                    tran.CommitTran();
+                    return NewSimpleResult(0,
+                        $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntID} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}");
+                }
+            }
+            catch (Exception ex) {
+                return NewSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}");
+            }
+        }
+
+        public static ErpResult InboundDataSync(InboundDataSyncInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+
+            }
+            catch (Exception ex) {
+                return BuildErpResult(1, ex.Message);
+            }
+            return BuildErpResult(0, null);
+        }
+
+        public static ErpResult OutboundDataSync(OutboundDataSyncInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+
+
+            }
+            catch (Exception ex) {
+                return BuildErpResult(1, ex.Message);
+            }
+            return BuildErpResult(1, null);
+        }
+    }
+}
diff --git a/api/ApiModel.cs b/api/ApiModel.cs
new file mode 100644
index 0000000..0b13b6d
--- /dev/null
+++ b/api/ApiModel.cs
@@ -0,0 +1,481 @@
+锘縰sing System.Collections.Generic;
+
+using Newtonsoft.Json;
+
+namespace HH.WCS.Mobox3.AnGang.api
+{
+    /// <summary>
+    /// 閫氱敤model
+    /// </summary>
+    public class ApiModel
+    {
+
+        #region mobox 鐩稿叧
+        public class SimpleResult {
+            public int resultCode { get; set; }
+            public string resultMsg { get; set; }
+            public List<object> result { get; set; } = new List<object>();
+        }
+
+        public static SimpleResult NewSimpleResult(int code, string message) {
+            return new SimpleResult { resultCode = code, resultMsg = message };
+        }
+
+        #endregion
+
+        /// <summary>
+        /// hosttoagv涓婃姤浠诲姟鐘舵�
+        /// </summary>
+        public class AgvTaskState {
+            public int state { get; set; }
+            public string task_no { get; set; }
+            public string forklift_no { get; set; }
+
+            /// <summary>
+            /// 瀹夊叏闂ㄧ紪鍙�+            /// </summary>
+            public string lock_no { get; set; }
+            public string ext_data { get; set; }
+        }
+
+        public class SafetyInteractionInfo {
+            public int station_id { get; set; }
+
+            /// <summary>
+            /// 璇锋眰涓婄嚎/涓嬬嚎鐨勭殑绔欏彴搴撲綅鍚嶇О锛屼緥濡倃ork6銆亀ork8
+            /// </summary>
+            public string station_name { get; set; }
+
+            /// <summary>
+            /// 璇锋眰鐮�+            /// </summary>
+            public string apply_code { get; set; }
+            public string task_no { set; get; }
+        }
+
+        public class orderStatusReportParme {
+            /// <summary>
+            /// 璁㈠崟ID
+            /// </summary>
+            public int orderID { get; set; }
+            /// <summary>
+            /// 璁㈠崟鍚�+            /// </summary>
+            public string orderName { get; set; }
+            /// <summary>
+            /// 璁㈠崟鐘舵�
+            /// </summary>
+            public string orderStatus { get; set; }
+            /// <summary>
+            /// agv杞﹀彿鍒楄〃
+            /// </summary>
+            public string agvIDList { get; set; }
+            /// <summary>
+            /// 浼樺厛绾�+            /// </summary>
+            public string priority { get; set; }
+            /// <summary>
+            /// 璁㈠崟褰撳墠鐨勭洰鐨勫湴
+            /// </summary>
+            public string currentDes { get; set; }
+            /// <summary>
+            /// 褰撳墠鎸囦护
+            /// </summary>
+            public string currentCmd { get; set; }
+
+            /// <summary>
+            /// 閿欒鐮�+            /// </summary>
+            public int errorCode { get; set; }
+
+            /// <summary>
+            /// 璁㈠崟鐨勬埅鑷虫椂闂�+            /// </summary>
+            public string deadLine { get; set; }
+
+            /// <summary>
+            /// 璁㈠崟鐨勫垱寤烘椂闂�+            /// </summary>
+            public string createdTime { get; set; }
+
+            /// <summary>
+            /// 棰濆淇℃伅1
+            /// </summary>
+            public string extraInfo1 { get; set; }
+
+            /// <summary>
+            /// 棰濆淇℃伅2
+            /// </summary>
+            public string extraInfo2 { get; set; }
+        }
+
+        /// <summary>
+        /// 杩斿洖缁檋osttoagv
+        /// </summary>
+        public class ReturnResult {
+            public int ResultCode { get; set; }
+            public string ResultMsg { get; set; }
+        }
+
+        /// <summary>
+        /// 杩斿洖缁橤Z
+        /// </summary>
+        public class GzResult {
+            public int resultCode { get; set; }
+            public string msg { get; set; }
+            public int orderID { get; set; }
+        }
+    }
+
+    public class OtherModel {
+        public class InboundInfo {
+            /// <summary>
+            /// 璧风偣璐т綅
+            /// </summary>
+            [JsonProperty("StartLoc")]
+            public string StartLoc { get; set; }
+
+            /// <summary>
+            /// 缁堢偣璐ф灦锛堝彲閫夛級
+            /// </summary>
+            [JsonProperty("Nrow")]
+            public string Row { get; set; }
+        }
+
+        public class SelectLocationInfo {
+            /// <summary>
+            /// AGV灏忚溅鍙凤細NOTE 鍚庢湡鍙兘鐪佺暐锛屽洜涓哄彧鏈変竴杈嗚溅
+            /// </summary>
+            public string forklift_no { get; set; }
+
+            public string endLoc { get; set; }
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍥炲簱淇℃伅
+        /// </summary>
+        public class PartInboundInfo {
+            /// <summary>
+            /// 璧风偣浣嶇疆
+            /// </summary>
+            public string startLoc { get; set; }
+
+            /// <summary>
+            /// 缁堢偣浣嶇疆
+            /// </summary>
+            public string endLoc { get; set; }
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍑哄簱淇℃伅
+        /// </summary>
+        public class PartOutboundInfo {
+            /// <summary>
+            /// 璧风偣浣嶇疆
+            /// </summary>
+            public string startLoc { get; set; }
+
+            /// <summary>
+            /// 缁堢偣浣嶇疆
+            /// </summary>
+            public string endLoc { get; set; }
+        }
+
+        public class CreateCountPlanInfo {
+            public string countType { get; set; }
+            public string targetId { get; set; }
+        }
+
+        public class CreateCountOrderInfo {
+            public string planId { get; set; }
+        }
+
+        public class CountProductInfo {
+            public string cntrCode { get; set; }
+            public float qty { get; set; }
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍑哄簱淇℃伅
+        /// </summary>
+        public class CheckOutboundInfo {
+            /// <summary>
+            /// 璧风偣浣嶇疆
+            /// </summary>
+            public string startLoc { get; set; }
+
+            /// <summary>
+            /// 缁堢偣浣嶇疆
+            /// </summary>
+            public string endLoc { get; set; }
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍥炲簱淇℃伅
+        /// </summary>
+        public class CheckInboundInfo {
+            /// <summary>
+            /// 璧风偣浣嶇疆
+            /// </summary>
+            public string startLoc { get; set; }
+
+            /// <summary>
+            /// 缁堢偣浣嶇疆
+            /// </summary>
+            public string endLoc { get; set; }
+        }
+
+        public class ErpResult {
+            /// <summary>
+            /// 鎺ュ彛鍙嶉鐮�+            /// </summary>
+            public int errCode { get; set; }
+            /// <summary>
+            /// 閿欒璇存槑
+            /// </summary>
+            public string errMsg { get; set; }
+        }
+
+        public static ErpResult BuildErpResult(int code, string message, bool printLog = true) {
+            if (printLog) {
+                LogHelper.Info(message);
+            }
+            return new ErpResult { errCode = code, errMsg = message };
+        }
+
+        /// <summary>
+        /// 鍏ュ簱鏁版嵁鍚屾淇℃伅
+        /// </summary>
+        public class InboundDataSyncInfo {
+            /// <summary>
+            /// 搴撳瓨鏄庣粏锛堝垪琛級
+            /// </summary>
+            public List<StockTransaction> stockTransactions { get; set; }
+
+            /// <summary>
+            /// 鎬昏褰曟暟
+            /// </summary>
+            public string totalRecords { get; set; }
+
+            /// <summary>
+            /// 鏁版嵁鐢熸垚鏃堕棿鎴�+            /// </summary>
+            public string timestamp { get; set; }
+        }
+
+        /// <summary>
+        /// 搴撳瓨鏄庣粏淇℃伅
+        /// </summary>
+        public class StockTransaction {
+            /// <summary>
+            /// 鍌ㄤ綅鐮�+            /// </summary>
+            public string locationCode { get; set; }
+
+            /// <summary>
+            /// 搴撳瓨鏄庣粏浜ゆ槗鍙�+            /// </summary>
+            public string stockTransactionId { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡缂栫爜
+            /// </summary>
+            public string itemCode { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡鍚嶇О
+            /// </summary>
+            public string itemName { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡鐭弿杩�+            /// </summary>
+            public string itemShortDesc { get; set; }
+
+            /// <summary>
+            /// 搴撳瓨鏁伴噺
+            /// </summary>
+            public string stockQuantity { get; set; }
+
+            /// <summary>
+            /// 鍏ュ簱鏁伴噺
+            /// </summary>
+            public string inQuantity { get; set; }
+
+            /// <summary>
+            /// 搴撳瓨鎬讳环
+            /// </summary>
+            public string totalPrice { get; set; }
+
+            /// <summary>
+            /// 鍏ュ簱鏃堕棿
+            /// </summary>
+            public string stockInTime { get; set; }
+
+            /// <summary>
+            /// 淇濈鍛�+            /// </summary>
+            public string storeKeeper { get; set; }
+
+            /// <summary>
+            /// 浜х嚎閮ㄩ棬浠g爜
+            /// </summary>
+            public string lineCode { get; set; }
+
+            /// <summary>
+            /// 閫佽揣鍗曡鍙�+            /// </summary>
+            public string deliveryItemNo { get; set; }
+
+            /// <summary>
+            /// 渚涘簲鍟嗗悕绉�+            /// </summary>
+            public string supplierName { get; set; }
+
+            /// <summary>
+            /// 搴撳瓨璐d换浜哄鍚�+            /// </summary>
+            public string inventoryManager { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁1
+            /// </summary>
+            public string ext1 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁2
+            /// </summary>
+            public string ext2 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁3
+            /// </summary>
+            public string ext3 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁4
+            /// </summary>
+            public string ext4 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁5
+            /// </summary>
+            public string ext5 { get; set; }
+        }
+
+        /// <summary>
+        /// 鍑哄簱鍙戞枡鍚屾淇℃伅
+        /// </summary>
+        public class OutboundDataSyncInfo {
+            /// <summary>
+            /// 鍙戞枡璁板綍鏄庣粏鍒楄〃
+            /// </summary>
+            public List<MaterialIssue> materialIssues { get; set; }
+
+            /// <summary>
+            /// 鎬昏褰曟暟
+            /// </summary>
+            public string totalRecords { get; set; }
+
+            /// <summary>
+            /// 鏁版嵁鐢熸垚鏃堕棿鎴�+            /// </summary>
+            public string timestamp { get; set; }
+        }
+
+        /// <summary>
+        /// 鍙戞枡璁板綍鏄庣粏淇℃伅
+        /// </summary>
+        public class MaterialIssue {
+            /// <summary>
+            /// 鍌ㄤ綅鐮�+            /// </summary>
+            public string locationCode { get; set; }
+
+            /// <summary>
+            /// 棰嗙敤鍗曞彿
+            /// </summary>
+            public string withdrawalOrderNo { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡缂栫爜
+            /// </summary>
+            public string itemCode { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡鍚嶇О
+            /// </summary>
+            public string itemName { get; set; }
+
+            /// <summary>
+            /// 鐗╂枡鐭弿杩�+            /// </summary>
+            public string itemShortDesc { get; set; }
+
+            /// <summary>
+            /// 瀹炲彂鏁伴噺
+            /// </summary>
+            public string actualIssuedQty { get; set; }
+
+            /// <summary>
+            /// 瀹炲彂閲戦
+            /// </summary>
+            public string issuedAmount { get; set; }
+
+            /// <summary>
+            /// 渚涘簲鍟嗗悕绉�+            /// </summary>
+            public string supplierName { get; set; }
+
+            /// <summary>
+            /// 瀹炲彂浜�+            /// </summary>
+            public string issuer { get; set; }
+
+            /// <summary>
+            /// 鍙戞枡鏃ユ湡
+            /// </summary>
+            public string issueDate { get; set; }
+
+            /// <summary>
+            /// 淇濈鍛�+            /// </summary>
+            public string storeKeeper { get; set; }
+
+            /// <summary>
+            /// 浜х嚎閮ㄩ棬浠g爜
+            /// </summary>
+            public string lineCode { get; set; }
+
+            /// <summary>
+            /// 鎵规
+            /// </summary>
+            public string batchNo { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁1
+            /// </summary>
+            public string ext1 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁2
+            /// </summary>
+            public string ext2 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁3
+            /// </summary>
+            public string ext3 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁4
+            /// </summary>
+            public string ext4 { get; set; }
+
+            /// <summary>
+            /// 澶囩敤瀛楁5
+            /// </summary>
+            public string ext5 { get; set; }
+        }
+    }
+}
diff --git a/api/DebugController.cs b/api/DebugController.cs
new file mode 100644
index 0000000..b59eb96
--- /dev/null
+++ b/api/DebugController.cs
@@ -0,0 +1,320 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web.Http;
+
+using HH.WCS.Mobox3.AnGang.dispatch;
+using HH.WCS.Mobox3.AnGang.wms;
+using HH.WCS.Mobox3.AnGang.models;
+
+using Newtonsoft.Json;
+
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using HH.WCS.Mobox3.AnGang.util;
+
+namespace HH.WCS.Mobox3.AnGang.api {
+    /// <summary>
+    /// 娴嬭瘯鐢紝濡傛灉椤圭洰涓鍜岃澶囧鎺ワ紝鍓嶆湡璁惧鏃犳硶娴嬭瘯锛岀敤鎺ュ彛妯℃嫙
+    /// </summary>
+    [RoutePrefix("api")]
+    public class DebugController : System.Web.Http.ApiController
+    {
+        /// <summary>
+        /// AGV鐘舵�涓�敭鍥炴姤1462-鍥借嚜
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("AGVSeriesReports")]
+        public GzResults AGVSeriesReports(UpdateTaskState model) {
+            GzResults gzResults = new GzResults();
+            gzResults.GzResultList = new List<GzResult>();
+            var orderStatus = new orderStatusReportParme() {
+                orderName = model.TaskID,
+                agvIDList = model.ForkliftNo,
+                orderStatus = "waiting",
+            };
+            var temp1 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp1);
+
+            orderStatus.orderStatus = "source_finish";
+            var temp2 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp2);
+
+            orderStatus.orderStatus = "dest_finish";
+            var temp3 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp3);
+
+            orderStatus.orderStatus = "finish";
+            var temp4 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp4);
+
+            return gzResults;
+        }
+
+        /// <summary>
+        /// AGV鐘舵�涓�敭鍥炴姤14-鍥借嚜
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("AGVSeriesReports-14")]
+        public GzResults AGVSeriesReports14(UpdateTaskState model) {
+            GzResults gzResults = new GzResults();
+            gzResults.GzResultList = new List<GzResult>();
+            var orderStatus = new orderStatusReportParme() {
+                orderName = model.TaskID,
+                agvIDList = model.ForkliftNo,
+                orderStatus = "waiting",
+            };
+            var temp1 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp1);
+
+            orderStatus.orderStatus = "source_finish";
+            var temp2 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp2);
+
+            return gzResults;
+        }
+
+        /// <summary>
+        /// AGV鐘舵�涓�敭鍥炴姤62-鍥借嚜
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("AGVSeriesReports-62")]
+        public GzResults AGVSeriesReports62(UpdateTaskState model) {
+            GzResults gzResults = new GzResults();
+            gzResults.GzResultList = new List<GzResult>();
+            var orderStatus = new orderStatusReportParme() {
+                orderName = model.TaskID,
+                agvIDList = model.ForkliftNo,
+                orderStatus = "dest_finish",
+            };
+
+            var temp3 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp3);
+
+            orderStatus.orderStatus = "finish";
+            var temp4 = GZRobot.orderStatusReport(orderStatus);
+            gzResults.GzResultList.Add(temp4);
+
+            return gzResults;
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栨暟鎹簱
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("CreateDatabase")]
+        public string CreateDatabase(CoverInfo model) {
+            try {
+                var db = new SqlHelper<object>().GetInstance();
+                var cover = model.IsCover;
+
+                var entityTypes = new Type[] {
+                    typeof(TN_CAR_IN),
+                    typeof(TN_CG_Detail),
+                    typeof(TN_Container),
+                    typeof(TN_Loc_Container),
+                    typeof(TN_Location),
+                    typeof(TN_Task),
+                    typeof(TN_Task_Action),
+                    typeof(SYSHelper.OI_SYS_MAXID),
+
+                };
+
+                using (var tran = db.Ado.UseTran()) {
+                    if (cover) {
+                        // 鍒犻櫎鎵�湁琛紙鎸変緷璧栧叧绯诲�搴忥級
+                        var tables = db.DbMaintenance.GetTableInfoList();
+                        foreach (var table in tables.OrderByDescending(t => t.Name)) {
+                            db.DbMaintenance.DropTable(table.Name);
+                        }
+
+                        // 鍒涘缓鏂拌〃
+                        db.CodeFirst.InitTables(entityTypes);
+
+                        //db.CodeFirst.BackupTable().InitTables(entityTypes);
+                    }
+                    else {
+                        db.CodeFirst.InitTables(entityTypes);
+                    }
+
+                    tran.CommitTran();
+                }
+
+            }
+            catch (Exception ex) {
+                LogHelper.Info($"鍙戠敓浜嗗紓甯�);
+                return "鍒濆鍖栨暟鎹簱閿欒" + ex.Message;
+            }
+
+            return "鎴愬姛";
+        }
+
+        /// <summary>
+        /// DEBUG锛氭彃鍏ヨ揣浣嶃�瀹瑰櫒銆佽揣鍝佷俊鎭�+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("InsertLocCntrCg")]
+        public string InsertLocCntrCg(LocCntrCg locCntrCg) {
+            var db = new SqlHelper<object>().GetInstance();
+
+            try {
+                using (var tran = db.UseTran()) {
+                    LogHelper.Info("LogCntrCg锛� + JsonConvert.SerializeObject(locCntrCg));
+                    if (string.IsNullOrEmpty(locCntrCg.LocCode)) {
+                        return "鍙傛暟闈炴硶";
+                    }
+
+                    var loc = db.Queryable<TN_Location>().First(a => a.S_CODE == locCntrCg.LocCode);
+                    if (loc == null) {
+                        var newLoc = new TN_Location {
+                            S_CODE = locCntrCg.LocCode,
+                            S_AREA_CODE = locCntrCg.LocArea ?? ""
+                        };
+
+                        if (db.Insertable<TN_Location>(newLoc).ExecuteCommand() <= 0) {
+                            tran.RollbackTran();
+                            LogHelper.Info($"鎻掑叆浣嶇疆{locCntrCg.LocCode}澶辫触");
+                            return "鎻掑叆澶辫触";
+                        }
+
+                        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)) {
+                        tran.CommitTran();
+                        LogHelper.Info("瀹瑰櫒鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
+                        return "瀹瑰櫒鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�;
+                    }
+
+                    var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == locCntrCg.LocCode
+                        && a.S_CNTR_CODE == locCntrCg.CntrCode);
+
+                    if (locCntrRel == null) {
+                        var newLocCntrRel = new TN_Loc_Container {
+                            S_LOC_CODE = locCntrCg.LocCode,
+                            S_CNTR_CODE = locCntrCg.CntrCode
+                        };
+
+                        loc.N_CURRENT_NUM = 1;
+
+                        if (db.Insertable<TN_Loc_Container>(newLocCntrRel).ExecuteCommand() <= 0
+                            && db.Updateable<TN_Location>(loc).UpdateColumns(c => c.N_CURRENT_NUM).ExecuteCommand() <= 0) {
+                            tran.RollbackTran();
+                            LogHelper.Info($"鎻掑叆浣嶇疆鎵樼洏鍏崇郴{locCntrCg.LocCode}-{locCntrCg.CntrCode}澶辫触");
+                            return "鎻掑叆澶辫触";
+                        }
+                    }
+
+                    if (string.IsNullOrEmpty(locCntrCg.ItemCode)) {
+                        tran.CommitTran();
+                        LogHelper.Info("鐗╂枡鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�);
+                        return "鐗╂枡鍙蜂负绌猴紝涓嶅啀璇诲彇鍚庨潰鐨勬暟鎹�;
+                    }
+
+                    var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrCg.CntrCode
+                        && 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.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();
+                }
+
+                return "鎻掑叆鏁版嵁鎴愬姛";
+
+            }
+            catch (Exception ex) {
+                return $"{ex.Message}";
+            }
+        }
+
+        [HttpPost]
+        [Route("SetTaskWeight")]
+        public string SetTaskWeight(SetTaskWeightInfo model) {
+            var db = new SqlHelper<object>().GetInstance();
+            var cgDetail = db.Queryable<TN_CG_Detail, TN_Task>((d, t) => d.S_CNTR_CODE == t.S_CNTR_CODE)
+                .Where((d, t) => t.S_CODE == model.TaskNo).First();
+
+            if (cgDetail == null) {
+                return "鎵句笉鍒板搴旂殑鐗╂枡淇℃伅";
+            }
+
+            cgDetail.F_QTY = model.Weight;
+
+            try {
+                if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY)
+                    .ExecuteCommand() <= 0) {
+                    return "淇敼澶辫触";
+                }
+                return "淇敼鎴愬姛";
+
+            }
+            catch (Exception ex) {
+
+                return ex.Message;
+            }
+        }
+    }
+
+    public class ReturnResults {
+        public List<ReturnResult> ResultList { set; get; }
+    }
+
+    public class GzResults {
+        public List<GzResult> GzResultList { set; get; }
+    }
+
+    public class LocCntrCg {
+        public string LocCode { get; set; }
+        public string LocArea { get; set; }
+        public string CntrCode { get; set; }
+        public string ItemCode { get; set; }
+        public string BatchNo { get; set; }
+    }
+
+    /// <summary>
+    /// 妯℃嫙 AGV 浼犻�淇″彿锛岀敤浜庢洿鏀逛换鍔$姸鎬�+    /// </summary>
+    public class UpdateTaskState {
+        /// <summary>
+        /// 浠诲姟ID
+        /// </summary>
+        public string TaskID { set; get; }
+        /// <summary>
+        /// AGV 灏忚溅鍙�+        /// </summary>
+        public string ForkliftNo { set; get; }
+        /// <summary>
+        /// AGV 涓嬩竴涓姸鎬�+        /// </summary>
+        public int NextState { set; get; }
+    }
+
+    public class CoverInfo {
+        public bool IsCover { set; get; } = true;
+    }
+
+    public class SetTaskWeightInfo {
+        public string TaskNo { set; get; }
+        public float Weight { set; get; }
+    }
+}
diff --git a/Controllers/ErpController.cs b/api/ErpController.cs
similarity index 70%
rename from Controllers/ErpController.cs
rename to api/ErpController.cs
index 50483c5..191162c 100644
--- a/Controllers/ErpController.cs
+++ b/api/ErpController.cs
@@ -1,11 +1,8 @@
 锘縰sing System.Web.Http;
 
-using HH.WCS.Mobox3.AnGang.Services;
+using static HH.WCS.Mobox3.AnGang.api.OtherModel;
 
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.ErpRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.ErpResponse;
-
-namespace HH.WCS.Mobox3.AnGang.Controllers {
+namespace HH.WCS.Mobox3.AnGang.api {
     /// <summary>
     /// ERP 璋冪敤鐨勬帴鍙�     /// </summary>
@@ -19,7 +16,7 @@
         [HttpPost]
         [Route("InboundDataSync")]
         public static ErpResult InboundDataSync(InboundDataSyncInfo model) {
-            return ErpService.InboundDataSync(model);
+            return ApiHelper.InboundDataSync(model);
         }
 
         /// <summary>
@@ -30,7 +27,7 @@
         [HttpPost]
         [Route("OutboundDataSync")]
         public static ErpResult OutboundDataSync(OutboundDataSyncInfo model) {
-            return ErpService.OutboundDataSync(model);
+            return ApiHelper.OutboundDataSync(model);
         }
     }
 }
\ No newline at end of file
diff --git a/api/MoboxController.cs b/api/MoboxController.cs
new file mode 100644
index 0000000..10bf84a
--- /dev/null
+++ b/api/MoboxController.cs
@@ -0,0 +1,115 @@
+锘縰sing System.Web.Http;
+
+using Newtonsoft.Json;
+
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using static HH.WCS.Mobox3.AnGang.api.OtherModel;
+
+namespace HH.WCS.Mobox3.AnGang.api {
+    /// <summary>
+    /// Mobox3 璋冪敤锛岃剼鏈腑璋冪敤
+    /// </summary>
+    [RoutePrefix("api")]
+    public class MoboxController : ApiController {
+        /// <summary>
+        /// 璐у搧鍏ュ簱(PDA)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("Inbound")]
+        public SimpleResult Inbound(InboundInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氫骇鍝佸叆搴�PDA)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.Inbound(model);
+        }
+
+        /// <summary>
+        /// PDA閫夋嫨缁堢偣璐т綅
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("SelectLocation")]
+        public SimpleResult SelectLocation(SelectLocationInfo model) {
+            LogHelper.Info("瑙﹀彂API锛歅DA閫夋嫨缁堢偣璐т綅" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.SelectLocation(model);
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍑哄簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("PartOutbound")]
+        public SimpleResult PartOutbound(PartOutboundInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氫骇鍝侀儴鍒嗗嚭搴�WMS)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.PartOutbound(model);
+        }
+
+        /// <summary>
+        /// 浜у搧閮ㄥ垎鍥炲簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("PartInbound")]
+        public SimpleResult PartInbound(PartInboundInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氫骇鍝侀儴鍒嗗洖搴�WMS)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.PartInbound(model);
+        }
+
+        /// <summary>
+        /// 鍒涘缓鐩樼偣璁″垝鍗�WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("CreateCountPlan")]
+        public SimpleResult CreateCountPlan(CreateCountPlanInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐硅鍒掑崟(WMS)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.CreateCountPlan(model);
+        }
+
+        /// <summary>
+        /// 鍒涘缓鐩樼偣鍗�PDA)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("CreateCountOrder")]
+        public SimpleResult CreateCountOrder(CreateCountOrderInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐瑰崟(PDA)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.CreateCountOrder(model);
+        }
+ 
+        public SimpleResult CountProduct(CountProductInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐�PDA)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.CountProduct(model);
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍑哄簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("CheckOutbound")]
+        public SimpleResult CheckOutbound(CheckOutboundInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у嚭搴�WMS)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.CheckOutbound(model);
+        }
+
+        /// <summary>
+        /// 鐩樼偣鐞嗚揣鍥炲簱(WMS)
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("CheckInbound")]
+        public SimpleResult CheckInbound(CheckInboundInfo model) {
+            LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у洖搴�WMS)" + JsonConvert.SerializeObject(model), "API");
+            return ApiHelper.CheckInbound(model);
+        }
+    }
+}
diff --git a/Controllers/WmsController.cs b/api/WmsController.cs
similarity index 75%
rename from Controllers/WmsController.cs
rename to api/WmsController.cs
index 56908dc..56e489d 100644
--- a/Controllers/WmsController.cs
+++ b/api/WmsController.cs
@@ -3,9 +3,9 @@
 using Newtonsoft.Json;
 using System.Collections.Generic;
 using System.Web.Http;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
 
-namespace HH.WCS.Mobox3.AnGang.Controllers
+namespace HH.WCS.Mobox3.AnGang.api
 {
     /// <summary>
     /// 绗笁鏂硅皟鐢ㄧ殑鎺ュ彛
diff --git a/config/config.json b/config/config.json
index fe668e8..ce60527 100644
--- a/config/config.json
+++ b/config/config.json
@@ -2,7 +2,7 @@
     "WebApiUrl": "http://127.0.0.1:8901",
     "RCSApiUrl": "http://127.0.0.1:6001",
     "NDCApiUrl": "http://127.0.0.1:5201/api/order/",
-    "SqlServer": "Data Source=192.168.1.144;Initial Catalog=YinKouAnGan;User ID=hhuser;Password=Am123123",
+    "SqlServer": "Data Source=(local);Initial Catalog=AnGangTest;User ID=sa;Password=123456",
     "TCPServerIP": "127.0.0.1",
     "TCPServerPort": 8085,
     "Areas": [
@@ -15,7 +15,7 @@
             "Codes": [ "HJQ" ]
         }
     ],
-    "Snap": [
+    "Snaps": [
         {
             "Ip": "172.23.8.95",
             "Port": 37777,
diff --git a/core/Monitor.cs b/core/Monitor.cs
new file mode 100644
index 0000000..11ed38f
--- /dev/null
+++ b/core/Monitor.cs
@@ -0,0 +1,159 @@
+锘�+using HH.WCS.Mobox3.AnGang.models;
+using HH.WCS.Mobox3.AnGang.process;
+using HH.WCS.Mobox3.AnGang.util;
+using HH.WCS.Mobox3.AnGang.wms;
+
+using Newtonsoft.Json;
+
+using System;
+using System.Collections.Generic;
+
+namespace HH.WCS.Mobox3.AnGang.core {
+    /// <summary>
+    /// 瀹氭椂杞浠诲姟
+    /// </summary>
+    public class Monitor
+    {
+        public static void CheckCountOrder() {
+            var taskName = TaskName.鐩樼偣鐞嗚揣鍑哄簱;
+            var db = new SqlHelper<object>().GetInstance();
+            var info = "";
+
+            try {
+                var orderList = db.Queryable<TN_Count_Order>()
+                    .Where(c => c.N_B_STATE == 1)
+                    .OrderBy(c => c.T_CREATE, SqlSugar.OrderByType.Asc)
+                    .ToList();
+
+                if (orderList.Count == 0) {
+                    LogHelper.Info("杞--鍑哄簱--鏆傛棤寰呮墽琛岀殑Order");
+                    return;
+                }
+
+                var detailList = new List<TN_Count_CG_Detail>();
+                foreach (var order in orderList) {
+                    var doingCount = db.Queryable<TN_Count_CG_Detail>()
+                        .Count(d => d.S_COUNT_NO == order.S_COUNT_NO && d.N_B_STATE >= 2); // 鎵ц涓�+                    var allCount = db.Queryable<TN_Count_CG_Detail>()
+                        .Count(d => d.S_COUNT_NO == order.S_COUNT_NO);
+                    LogHelper.Info($"杞--{taskName}--缁熻{taskName}鍗�{order.S_COUNT_NO}'浠诲姟宸蹭笅鍙戯細{doingCount}/{allCount}");
+
+                    if (doingCount == allCount) {
+                        order.N_B_STATE = 2; // 鎵�湁浠诲姟閮藉凡鎵ц
+                        db.Updateable<TN_Count_Order>(order).UpdateColumns(it => new { it.N_B_STATE }).ExecuteCommand();
+                        continue;
+                    }
+
+                    var lastDetail = db.Queryable<TN_Count_CG_Detail>()
+                        .Where(d => d.S_COUNT_NO == order.S_COUNT_NO && d.N_B_STATE == 2) // TODO 鎴栬�鏀规垚鏌ask
+                        .First();
+                    if (lastDetail != null) {
+                        LogHelper.Info($"杞--{taskName}--{taskName}鍗�{order.S_COUNT_NO}'涓婁竴涓换鍔′粛鍦ㄨ繘琛屼腑锛�
+                            + JsonConvert.SerializeObject(lastDetail));
+                        continue;
+                    }
+
+                    var outboundDetail = db.Queryable<TN_Count_CG_Detail>()
+                        .Where(a => a.S_COUNT_NO == order.S_COUNT_NO && a.N_B_STATE == 1) // 宸蹭笅鍙�+                        .First();
+                    if (outboundDetail != null) {
+                        LogHelper.Info($"杞--{taskName}--");
+                        continue;
+                    }
+
+                    detailList.Add(outboundDetail);
+                }
+
+                if (detailList.Count == 0) {
+                    return;
+                }
+
+                var startLocList = new List<TN_Location>();
+                var endLocList = new List<TN_Location>();
+
+                var taskList = new List<TN_Task>();
+
+                foreach (var detail in detailList) {
+                    var startLoc = db.Queryable<TN_Location>()
+                        .LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE)
+                        .Where((l, c) => c.S_CNTR_CODE == detail.S_CNTR_CODE)
+                        .First();
+
+                    if (startLoc == null) {
+                        LogHelper.Info($"杞--鍑哄簱锛氭病鏈夋壘鍒板悎閫傜殑璧风偣璐т綅锛�);
+                        continue;
+                    }
+
+                    var endLoc = db.Queryable<TN_Location>()
+                        .Where(a => a.S_AREA_CODE == "SFQ")
+                        .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y")
+                        .Where(a => a.N_CURRENT_NUM == 0).First();
+
+                    if (endLoc == null) {
+                        LogHelper.Info($"杞--鍑哄簱锛氭病鏈夋壘鍒板悎閫傜殑缁堢偣璐т綅锛丼_NO涓�'{detail.S_COUNT_NO}'");
+                        continue;
+                    }
+
+                    detail.N_B_STATE = 2;
+
+                    var cntId = detail.S_CNTR_CODE;
+                    var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName);
+
+                    LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+                    LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+
+                    using (var tran = db.Ado.UseTran()) {
+                        if (db.Updateable<TN_Count_CG_Detail>(detail).UpdateColumns(it => it.N_B_STATE).ExecuteCommand() <= 0) {
+                            tran.RollbackTran();
+                            LogHelper.Info($"杞--鍑哄簱--淇敼鏄庣粏琛ㄧ姸鎬佷负瀹屾垚澶辫触锛�);
+                        }
+
+                        if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new {
+                            it.N_LOCK_STATE,
+                            it.S_LOCK_STATE,
+                            it.S_LOCK_OP,
+                            it.T_MODIFY
+                        }).ExecuteCommand() <= 0) {
+                            tran.RollbackTran();
+                            info = $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}";
+                            LogHelper.Info(info);
+                            continue;
+                        }
+
+                        if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new {
+                            it.N_LOCK_STATE,
+                            it.S_LOCK_STATE,
+                            it.S_LOCK_OP,
+                            it.T_MODIFY
+                        }).ExecuteCommand() <= 0) {
+
+                            tran.RollbackTran();
+                            info = $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}";
+                            LogHelper.Info(info);
+                            continue;
+                        }
+
+                        if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) {
+                            tran.RollbackTran();
+                            info = $"鐢熸垚 {taskName} 澶辫触锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}";
+                            LogHelper.Info(info);
+                            continue;
+                        }
+
+                        tran.CommitTran();
+                        info = $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣浣�{endLoc.S_CODE}";
+                        LogHelper.Info(info);
+                        continue;
+                    }
+                }
+            }
+            catch (Exception ex) {
+                info = $"鍙戠敓浜嗗紓甯革細{ex.Message}";
+                LogHelper.Info(info);
+            }
+        }
+    }
+
+}
+
diff --git a/Services/AgvService.cs b/core/WCSCore.cs
similarity index 67%
rename from Services/AgvService.cs
rename to core/WCSCore.cs
index 5a2cd96..c7fe69d 100644
--- a/Services/AgvService.cs
+++ b/core/WCSCore.cs
@@ -1,47 +1,34 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Models;
+锘縰sing HH.WCS.Mobox3.AnGang.device;
+using HH.WCS.Mobox3.AnGang.dispatch;
+using HH.WCS.Mobox3.AnGang.models;
 using HH.WCS.Mobox3.AnGang.process;
 using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
 using Newtonsoft.Json;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using HH.WCS.Mobox3.AnGang.wms;
+using HH.WCS.Mobox3.AnGang.util;
 
-using static HH.WCS.Mobox3.AnGang.Dtos.Request.AgvRequest;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.AgvResponse;
-using HH.WCS.Mobox3.AnGang.Consts;
-using HH.WCS.Mobox3.AnGang.Dispatch;
-using HH.WCS.Mobox3.AnGang.Devices;
-
-namespace HH.WCS.Mobox3.AnGang.Services {
-    public class AgvService {
+namespace HH.WCS.Mobox3.AnGang.core
+{
+    internal class WCSCore
+    {
         public static ReturnResult OperateAgvTaskStatus(AgvTaskState model) {
             var result = new ReturnResult();
             try {
-                switch (model.state) {
-                    case 1023:
-                        break;
-                    case 1025:
-                        break;
-                    case 1012:
-                        break;
-                    case 1004:
-                        break;
-                    case 1103:
-                        break;
-                    default:
-                        // AGV 鎵ц浠诲姟鐨勯�杈戝鐞�-                        if (!AgvTaskProcessOk(model)) {
-                            // 鎵ц涓峅K锛岃鏄庢病鏈夋壘鍒颁换鍔�-                            result.ResultCode = 1;
-                            result.ResultMsg = $"鏍规嵁Model.No鏈壘鍒板搴旂殑浠诲姟锛寋model.task_no}";
-                            LogHelper.Info(result.ResultMsg, "API");
-                            return result;
-                        }
-                        break;
+                if (model.state > 0 && model.state < 1000) {
+                    // AGV 鎵ц浠诲姟鐨勯�杈戝鐞�+                    if (!AgvTaskProcessOk(model)) {
+                        // 鎵ц涓峅K锛岃鏄庢病鏈夋壘鍒颁换鍔�+                        result.ResultCode = 1;
+                        result.ResultMsg = $"鏍规嵁Model.No鏈壘鍒板搴旂殑浠诲姟锛寋model.task_no}";
+                        LogHelper.Info(result.ResultMsg, "API");
+                        return result;
+                    }
                 }
 
                 result.ResultCode = 0;
@@ -69,48 +56,48 @@
 
             if (model.state > 7) {
                 //瀹夊叏璇锋眰绛�-                TaskHelper.OperateReq(model.task_no, model.state, model.forklift_no, model.ext_data);
+                TaskProcess.OperateReq(model.task_no, model.state, model.forklift_no, model.ext_data);
                 return true;
             }
 
             // AGV 浠诲姟 134562(7) 鐘舵�澶勭悊
             switch (model.state) {
-                case AgvStateCode.鎵ц:
+                case 1: // 鎵ц
                     WCSHelper.Begin(TN_Task, model.forklift_no); // 宸叉帹閫佺殑浠诲姟鐨勭姸鎬佹敼鎴愭墽琛�                     break;
-                case AgvStateCode.寮�鍙栬揣:
+                case 3: // 寮�鍙栬揣
                     WCSHelper.UpdateStatus(TN_Task, "寮�鍙栬揣"); // 浠诲姟鐘舵�鏀规垚寮�鍙栬揣
                     break;
-                case AgvStateCode.鍙栬揣瀹屾垚:
+                case 4: // 鍙栬揣瀹屾垚
                     WCSHelper.UpdateStatus(TN_Task, "鍙栬揣瀹屾垚"); // 浠诲姟鐘舵�鏀规垚鍙栬揣瀹屾垚
 
-                    var captureTask = Task.Run(() => {
-                        if (TN_Task.S_TYPE == TaskName.浜у搧鍏ュ簱 || TN_Task.S_TYPE == TaskName.浜у搧閮ㄥ垎鍥炲簱) {
+                    if (TN_Task.S_TYPE == TaskName.浜у搧鍏ュ簱 || TN_Task.S_TYPE == TaskName.浜у搧閮ㄥ垎鍥炲簱) {
+                        var captureTask = Task.Run(() => {
                             CapturePic(TN_Task);
-                        }
-                    });
+                        });
+                    }
 
-                    var setEndLocTask = Task.Run(() => {
-                        // 鍙浠诲姟涓轰骇鍝佸叆搴�PDA)锛屽氨闇�閲嶆柊鎸囧畾缁堢偣锛堥粯璁ndLoc涓�"锛�-                        if (TN_Task.S_TYPE == TaskName.浜у搧鍏ュ簱) {
+                    if (TN_Task.S_TYPE == TaskName.浜у搧鍏ュ簱) {
+                        var setEndLocTask = Task.Run(() => {
+                            // 鍙浠诲姟涓轰骇鍝佸叆搴�PDA)锛屽氨闇�閲嶆柊鎸囧畾缁堢偣锛堥粯璁ndLoc涓�"锛�                             SetEndLoc(TN_Task);
-                        }
-                    });
+                        });
+                    }
 
-                    TaskHelper.OperateStatus(TN_Task, 4); // 璧风偣瀹瑰櫒璐т綅瑙g粦,瑙i攣璧风偣
+                    TaskProcess.OperateStatus(TN_Task, 4); // 璧风偣瀹瑰櫒璐т綅瑙g粦,瑙i攣璧风偣
                     break;
-                case AgvStateCode.寮�鍗歌揣:
+                case 5: // 寮�鍗歌揣
                     WCSHelper.UpdateStatus(TN_Task, "寮�鍗歌揣"); // 浠诲姟鐘舵�鏀规垚寮�鍗歌揣
                     break;
-                case AgvStateCode.鍗歌揣瀹屾垚:
+                case 6: // 鍗歌揣瀹屾垚
                     WCSHelper.UpdateStatus(TN_Task, "鍗歌揣瀹屾垚"); // 浠诲姟鐘舵�鏀规垚鍗歌揣瀹屾垚
-                    TaskHelper.OperateStatus(TN_Task, 6); // 缁堢偣瀹瑰櫒璐т綅缁戝畾,瑙i攣缁堢偣
+                    TaskProcess.OperateStatus(TN_Task, 6); // 缁堢偣瀹瑰櫒璐т綅缁戝畾,瑙i攣缁堢偣
                     break;
-                case AgvStateCode.瀹屾垚:
+                case 2: // 瀹屾垚
                     WCSHelper.End(TN_Task); // 浠诲姟鐘舵�鏀规垚缁撴潫
                     break;
-                case AgvStateCode.寮傚父:
-                    TaskHelper.OperateStatus(TN_Task, 7); // 寮傚父澶勭悊
+                case 7: // 寮傚父
+                    TaskProcess.OperateStatus(TN_Task, 7); // 寮傚父澶勭悊
                     WCSHelper.Fail(TN_Task); // 浠诲姟鐘舵�鏀规垚閿欒
                     break;
             }
@@ -122,7 +109,7 @@
         }
 
         public static void CapturePic(TN_Task model) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
 
             var filepath = SnapManager.GetCapturePicturePath();
             if (string.IsNullOrEmpty(filepath)) {
@@ -140,7 +127,7 @@
         }
 
         public static void SetEndLoc(TN_Task tn_task) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var endLoc = db.Queryable<TN_Location>()
                 .First(a => a.S_CODE == tn_task.S_END_LOC);
 
@@ -218,45 +205,58 @@
                 //};
 
                 //GZRobot.UpdateInteractInfo(request);
-
-                using (var trans = db.Ado.UseTran()) {
-                    if (db.Updateable<TN_Task>(tn_task).UpdateColumns(it => new { it.S_END_LOC })
+                if (db.Updateable<TN_Task>(tn_task).UpdateColumns(it => new { it.S_END_LOC })
                         .ExecuteCommand() > 0) {
-                        //LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        LogHelper.Info($"閲嶆柊璁$畻鍚庢病鏈夊悎閫傝揣浣嶏紝浠诲姟 {tn_task.S_CODE} 淇敼鎴愬姛锛屼慨鏀圭粓鐐硅揣浣嶄负 0绌�);
-                    }
-                    else {
-                        trans.RollbackTran();
-                        LogHelper.Info($"閲嶆柊璁$畻鍚庢病鏈夊悎閫傝揣浣嶏紝浠诲姟 {tn_task.S_CODE} 淇敼澶辫触锛屼慨鏀圭粓鐐硅揣浣嶄负 0绌�);
-                    }
+                    //LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+                    LogHelper.Info($"閲嶆柊璁$畻鍚庢病鏈夊悎閫傝揣浣嶏紝浠诲姟 {tn_task.S_CODE} 淇敼鎴愬姛锛屼慨鏀圭粓鐐硅揣浣嶄负 0绌�);
+                }
+                else {
+                    LogHelper.Info($"閲嶆柊璁$畻鍚庢病鏈夊悎閫傝揣浣嶏紝浠诲姟 {tn_task.S_CODE} 淇敼澶辫触锛屼慨鏀圭粓鐐硅揣浣嶄负 0绌�);
                 }
             }
             else {
                 // 鎵惧埌鍚堥�鐨勮揣浣嶏紝鎺ㄩ�
                 tn_task.S_END_LOC = endLoc.S_CODE;
 
-                using (var trans = db.Ado.UseTran()) {
-                    if (db.Updateable<TN_Task>(tn_task).UpdateColumns(it => new { it.S_END_LOC })
+                if (db.Updateable<TN_Task>(tn_task).UpdateColumns(it => new { it.S_END_LOC })
                         .ExecuteCommand() > 0) {
-                        LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�-
-                        trans.CommitTran();
-                        LogHelper.Info($"璁$畻璐т綅鎴愬姛锛屼换鍔�{tn_task.S_CODE} 淇敼鎴愬姛锛岀粓鐐硅揣鏋朵负 {endLoc.N_ROW}锛屼慨鏀圭粓鐐逛綅缃负 {endLoc.S_CODE}");
-                    }
-                    else {
-                        trans.RollbackTran();
-
-                        LogHelper.Info($"璁$畻璐т綅鎴愬姛锛屼换鍔�{tn_task.S_CODE} 淇敼澶辫触锛岀粓鐐硅揣鏋朵负 {endLoc.N_ROW}锛屼慨鏀圭粓鐐逛綅缃负 {endLoc.S_CODE}");
-                    }
+                    LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+                    LogHelper.Info($"璁$畻璐т綅鎴愬姛锛屼换鍔�{tn_task.S_CODE} 淇敼鎴愬姛锛岀粓鐐硅揣鏋朵负 {endLoc.N_ROW}锛屼慨鏀圭粓鐐逛綅缃负 {endLoc.S_CODE}");
                 }
+                else {
+                    LogHelper.Info($"璁$畻璐т綅鎴愬姛锛屼换鍔�{tn_task.S_CODE} 淇敼澶辫触锛岀粓鐐硅揣鏋朵负 {endLoc.N_ROW}锛屼慨鏀圭粓鐐逛綅缃负 {endLoc.S_CODE}");
+                }
+            }
+        }
+
+        /// <summary>
+        /// 浠诲姟鍒嗗彂锛屾牴鎹皟搴︾被鍨嬪彂缁欎笉鍚岀殑璋冨害绯荤粺
+        /// </summary>
+        internal static void Dispatch()
+        {
+            //鏌ヨ浠诲姟
+            //鑾峰彇鎵�湁绛夊緟鐨勪换鍔�+            var list = WCSHelper.GetWaitingTaskList();
+            LogHelper.Info("绛夊緟浠诲姟淇℃伅" + JsonConvert.SerializeObject(list), "API");
+            if (list.Count > 0)
+            {
+                list.ForEach(task =>
+                {
+                    //浣跨敤鑷畾涔変换鍔℃帹閫�+                    TaskProcess.SendTask(task);//璋冨害NDC鎴栨澀濂ユ垨鍥借嚜璁惧
+                    //TaskProcess.SendGZTask(task);///璋冨害鍥借嚜璁惧
+
+                });
+            }
+            else
+            {
+                LogHelper.Info("鏆傛棤浠诲姟");
             }
         }
 
         public static ReturnResult SafetyInteraction(SafetyInteractionInfo model) {
             var gzResult = new ReturnResult();
-            //var db = DbHelper.GetDbClient();
+            //var db = new SqlHelper<object>().GetInstance();
             //ModbusHelper.Relink();
 
             //var productionLineInfo = Settings.ProductionLines[0];
diff --git a/ServiceCore/WMSCore.cs b/core/WMSCore.cs
similarity index 69%
rename from ServiceCore/WMSCore.cs
rename to core/WMSCore.cs
index 72f73ba..1af449e 100644
--- a/ServiceCore/WMSCore.cs
+++ b/core/WMSCore.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Helper;
+锘� using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -6,7 +6,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.ServiceCore {
+namespace HH.WCS.Mobox3.AnGang.core {
     internal class WMSCore 
     {
        
diff --git a/Devices/ModbusHelper.cs b/device/ModbusHelper.cs
similarity index 99%
rename from Devices/ModbusHelper.cs
rename to device/ModbusHelper.cs
index ad4675e..6bdc3ec 100644
--- a/Devices/ModbusHelper.cs
+++ b/device/ModbusHelper.cs
@@ -6,7 +6,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Helpers
+namespace HH.WCS.Mobox3.AnGang.device
 {
     /// <summary>
     /// modbus tcp 鐢ㄧ涓夋柟鐨勫寘
diff --git a/Devices/OpcUaHelper.cs b/device/OpcUaHelper.cs
similarity index 99%
rename from Devices/OpcUaHelper.cs
rename to device/OpcUaHelper.cs
index 1032aa3..70edd0b 100644
--- a/Devices/OpcUaHelper.cs
+++ b/device/OpcUaHelper.cs
@@ -3,7 +3,7 @@
 using System;
 using Opc.Ua.Configuration;
 
-namespace HH.WCS.Mobox3.AnGang.Devices
+namespace HH.WCS.Mobox3.AnGang.device
 {
     internal class OpcUaHelper
     {
diff --git a/Devices/PlcHelper.cs b/device/PlcHelper.cs
similarity index 98%
rename from Devices/PlcHelper.cs
rename to device/PlcHelper.cs
index 7a502e9..0bbb90b 100644
--- a/Devices/PlcHelper.cs
+++ b/device/PlcHelper.cs
@@ -5,7 +5,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Devices
+namespace HH.WCS.Mobox3.AnGang.device
 {
     internal class PlcHelper
     {
diff --git a/Devices/S7Helper.cs b/device/S7Helper.cs
similarity index 98%
rename from Devices/S7Helper.cs
rename to device/S7Helper.cs
index c9c9931..fe0d897 100644
--- a/Devices/S7Helper.cs
+++ b/device/S7Helper.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Controllers;
+锘縰sing HH.WCS.Mobox3.AnGang.api;
 using Newtonsoft.Json.Linq;
 using S7.Net;
 using S7.Net.Types;
@@ -10,7 +10,7 @@
 using System.Threading.Tasks;
 using System.Web.Services.Description;
 
-namespace HH.WCS.Mobox3.AnGang.Devices
+namespace HH.WCS.Mobox3.AnGang.device
 {
 
     /// <summary>
diff --git a/Devices/SnapDevice.cs b/device/SnapDevice.cs
similarity index 95%
rename from Devices/SnapDevice.cs
rename to device/SnapDevice.cs
index ede530c..754d14f 100644
--- a/Devices/SnapDevice.cs
+++ b/device/SnapDevice.cs
@@ -9,7 +9,7 @@
 
 using NetSDKCS;
 
-namespace HH.WCS.Mobox3.AnGang.Devices {
+namespace HH.WCS.Mobox3.AnGang.device {
     public class SnapDevice {
         private IntPtr _LoginID = IntPtr.Zero;
         private IntPtr _PlayID = IntPtr.Zero;
@@ -27,7 +27,7 @@
                 //NETClient.SetSnapRevCallBack(_SnapRevCallBack, IntPtr.Zero);
             }
             catch (Exception ex) {
-                LogHelper.InfoEx(ex);
+                LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}");
             }
         }
 
@@ -35,10 +35,10 @@
             NETClient.Cleanup();
         }
 
-        public void LoadInfo(AppStart.Snap snap) {
+        public void LoadInfo(Config.Snap snap) {
             LoadInfo(snap.Ip, snap.Port, snap.Name, snap.Pwd);
         }
-
+        
         public void LoadInfo(string ip, int port, string name, string pwd) {
             if (IntPtr.Zero == _LoginID) {
                 ushort uPort = 0;
@@ -151,7 +151,7 @@
                     }
                 }
                 catch (Exception ex) {
-                    LogHelper.InfoEx(ex);
+                    LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}");
                     return;
                 }
                 // 鏇夸唬Demo绋嬪簭鐨凢rame鍥剧墖灞曠ず
diff --git a/Devices/SnapManager.cs b/device/SnapManager.cs
similarity index 87%
rename from Devices/SnapManager.cs
rename to device/SnapManager.cs
index b872ee6..3a647a3 100644
--- a/Devices/SnapManager.cs
+++ b/device/SnapManager.cs
@@ -4,12 +4,10 @@
 using System.Text;
 using System.Threading.Tasks;
 
-using HH.WCS.Mobox3.AnGang.AppStart;
-
-namespace HH.WCS.Mobox3.AnGang.Devices {
+namespace HH.WCS.Mobox3.AnGang.device {
     public class SnapManager {
         private static SnapDevice _snapDevice { get; set; }
-        public SnapManager(AppStart.Snap snap) {
+        public SnapManager(Config.Snap snap) {
             if (_snapDevice == null) {
                 _snapDevice = new SnapDevice();
             }
diff --git a/Devices/TcpClient.cs b/device/TcpClient.cs
similarity index 97%
rename from Devices/TcpClient.cs
rename to device/TcpClient.cs
index 78ca7de..bc69863 100644
--- a/Devices/TcpClient.cs
+++ b/device/TcpClient.cs
@@ -1,5 +1,5 @@
 锘縰sing HH.WCS.Mobox3.AnGang;
-using HH.WCS.Mobox3.AnGang.Devices;
+using HH.WCS.Mobox3.AnGang.device;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,7 +7,7 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Devices {
+namespace HH.WCS.Mobox3.AnGang.device {
     internal class TcpClient
     {
         /// <summary>
diff --git a/Devices/TcpServer.cs b/device/TcpServer.cs
similarity index 98%
rename from Devices/TcpServer.cs
rename to device/TcpServer.cs
index f17e677..a404534 100644
--- a/Devices/TcpServer.cs
+++ b/device/TcpServer.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Dispatch;
+锘縰sing HH.WCS.Mobox3.AnGang.dispatch;
 using HH.WCS.Mobox3.AnGang.config;
 using Newtonsoft.Json;
 using System;
@@ -8,7 +8,7 @@
 using System.Net.Sockets;
 using System.Text;
 
-namespace HH.WCS.Mobox3.AnGang.Devices
+namespace HH.WCS.Mobox3.AnGang.device
 {
     public class TcpServer
     {
diff --git a/models/TN_Count_CG_Detail.cs b/models/TN_Count_CG_Detail.cs
new file mode 100644
index 0000000..6302d34
--- /dev/null
+++ b/models/TN_Count_CG_Detail.cs
@@ -0,0 +1,22 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SqlSugar;
+
+namespace HH.WCS.Mobox3.AnGang.models {
+    /// <summary>
+    /// 鐩樼偣鍗曟槑缁嗚〃
+    /// </summary>
+    [SugarTable("TN_Count_CG_Detail")]
+    public class TN_Count_CG_Detail {
+        public string S_COUNT_NO { get; set; }
+        public string S_ITEM_CODE { get; set; }
+        public string S_CNTR_CODE { get; set; }
+        
+        public int N_B_STATE { get; set; }
+
+    }
+}
diff --git a/models/TN_Count_Diff.cs b/models/TN_Count_Diff.cs
new file mode 100644
index 0000000..f295999
--- /dev/null
+++ b/models/TN_Count_Diff.cs
@@ -0,0 +1,21 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SqlSugar;
+
+namespace HH.WCS.Mobox3.AnGang.models {
+    /// <summary>
+    /// 鐩樼偣宸紓琛�+    /// </summary>
+    [SugarTable("TN_Count_Diff")]
+    public class TN_Count_Diff : BaseModel {
+        public string S_COUNT_NO { get; set; }
+        public string S_CNTR_CODE { get; set; }
+        public float F_QTY { get; set; }
+        public float F_ACTUAL_QTY { get; set; }
+        public string S_ITEM_CODE { get; set; }
+    }
+}
diff --git a/models/TN_Count_Order.cs b/models/TN_Count_Order.cs
new file mode 100644
index 0000000..6d70cd5
--- /dev/null
+++ b/models/TN_Count_Order.cs
@@ -0,0 +1,24 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SqlSugar;
+
+namespace HH.WCS.Mobox3.AnGang.models {
+    [SugarTable("TN_Count_Order")]
+    public class TN_Count_Order : BaseModel {
+        public string S_CP_NO { get; set; }
+
+        /// <summary>
+        /// 鐩樼偣鍗曞彿
+        /// </summary>
+        public string S_COUNT_NO { get; set; }
+
+        /// <summary>
+        /// 涓氬姟鐘舵�锛�绛夊緟鎵ц 1宸叉墽琛屽緟鐢熸垚浠诲姟 2浠诲姟鎵ц涓�3浠诲姟瀹屾垚
+        /// </summary>
+        public int N_B_STATE { get; set; }
+    }
+}
diff --git a/models/TN_Count_Plan.cs b/models/TN_Count_Plan.cs
new file mode 100644
index 0000000..5ae7fc1
--- /dev/null
+++ b/models/TN_Count_Plan.cs
@@ -0,0 +1,38 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SqlSugar;
+
+namespace HH.WCS.Mobox3.AnGang.models {
+    [SugarTable("TN_Count_Plan")]
+    public class TN_Count_Plan : BaseModel {
+        /// <summary>
+        /// 鐩樼偣璁″垝鍙�+        /// </summary>
+        public string S_CP_NO { get; set; }
+
+        /// <summary>
+        /// 鐩樼偣绫诲瀷锛氳揣鐗╃洏鐐�璐т綅鐩樼偣
+        /// </summary>
+        public string S_TYPE { get; set; }
+
+        /// <summary>
+        /// 鐩樼偣鐘舵�锛� 鈥�鏈墽琛�1 鈥�鍚姩涓�2 鈥�鎵ц涓�3 鈥�瀹屾垚 4 鈥�鍑洪敊
+        /// </summary>
+        public int N_B_STATE { get; set; } = 0;
+
+        ///// <summary>
+        ///// 璁″垝鐩樼偣鐗╂枡鏁伴噺
+        ///// </summary>
+        //public int N_PLAN_TOTAL { get; set; }
+
+        // ------
+
+        public string S_LOC_CODE { get; set; } = "";
+
+        public string S_ITEM_CODE { get; set; } = "";
+    }
+}
diff --git a/Helpers/DeviceProcess.cs b/process/DeviceProcess.cs
similarity index 84%
rename from Helpers/DeviceProcess.cs
rename to process/DeviceProcess.cs
index 431f9e4..3b66baf 100644
--- a/Helpers/DeviceProcess.cs
+++ b/process/DeviceProcess.cs
@@ -1,8 +1,7 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Devices;
+锘縰sing HH.WCS.Mobox3.AnGang.device;
 
-using HH.WCS.Mobox3.AnGang.Dispatch;
+using HH.WCS.Mobox3.AnGang.dispatch;
 using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
 using System;
 using System.Collections.Generic;
 using System.Linq;
diff --git a/Helpers/TaskHelper.cs b/process/TaskProcess.cs
similarity index 82%
rename from Helpers/TaskHelper.cs
rename to process/TaskProcess.cs
index 4115c46..9925ec0 100644
--- a/Helpers/TaskHelper.cs
+++ b/process/TaskProcess.cs
@@ -1,21 +1,14 @@
-锘縰sing HH.WCS.Mobox3.AnGang.ServiceCore;
-using HH.WCS.Mobox3.AnGang.Dispatch;
-using HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helper;
+锘縰sing HH.WCS.Mobox3.AnGang.dispatch;
+using HH.WCS.Mobox3.AnGang.wms;
 using Newtonsoft.Json;
-using Opc.Ua;
 using SqlSugar;
-using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Security.Cryptography;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
-using Org.BouncyCastle.Crypto;
-using HH.WCS.Mobox3.AnGang.Devices;
-using HH.WCS.Mobox3.AnGang.Models;
+using HH.WCS.Mobox3.AnGang.models;
+using System;
 
 namespace HH.WCS.Mobox3.AnGang.process {
-    internal class TaskHelper {
+    internal class TaskProcess {
         #region 浠诲姟鐩稿叧
         //--------------------------------------------------浠诲姟鐩稿叧--------------------------------------------------
         /// <summary>
@@ -35,6 +28,7 @@
                 LogHelper.Info($"浠诲姟{mst.S_CODE} 璐т綅{mst.S_END_LOC}鍗歌揣瀹屾垚锛岀粓鐐圭粦瀹氬鍣▄mst.S_CNTR_CODE}");
                 LocationHelper.BindingLoc(mst.S_END_LOC, mst.S_CNTR_CODE.Split(',').ToList());
             }
+
         }
 
         /// <summary>
@@ -59,16 +53,13 @@
 
         }
 
-        
-
         /// <summary>
         /// 浠诲姟鐘舵�鏇存柊澶勭悊
         /// </summary>
         /// <param name="mst"></param>
         /// <param name="state"></param>
         internal static void OperateStatus(TN_Task mst, int state) {
-            if (state == 4) 
-            {
+            if (state == 4) {
                 CacheBitUpdate(mst, true);
             }
             if (state == 6)//鍗歌揣瀹屾垚
@@ -87,15 +78,11 @@
         /// <param name="state"></param>
         /// <param name="forkliftNo"></param>
         /// <param name="extData"></param>
-        internal static void OperateReq(string no, int state, string forkliftNo, string extData = "")
-        {
-            if (state == 1101)
-            {
+        internal static void OperateReq(string no, int state, string forkliftNo, string extData = "") {
+            if (state == 1101) {
                 //璇锋眰鍙栬揣锛�-
             }
-            if (state == 1102)
-            {
+            if (state == 1102) {
                 //璇锋眰鍗歌揣锛�                 //鏍规嵁缁堢偣鍒ゆ柇锛屾槸cb02鐨勫叆鍙o紝鍒ゆ柇鍐呭瓨涓姸鎬侊紙瑕佺姸鎬佹椂闂达級锛屽厑璁稿嵏璐э紝閫氱煡agv鏀瑰弬鏁�                 var dic = new Dictionary<string, string>();
@@ -106,8 +93,7 @@
                 NDC.ChangeOrder(dic);
                 //鏀瑰畬鍙傛暟杞﹀瓙灏变細鑷繁鍗歌揣
             }
-            if (state == 1103)
-            {
+            if (state == 1103) {
                 //澶ч搧妗嗗弶璧颁互鍚庨�鐭ワ紝鎴戜滑瑕侀�鐭ヨ緭閫佺嚎
             }
         }
@@ -115,12 +101,11 @@
         private static object locLocker = new object();
 
 
-       /// <summary>
+        /// <summary>
         /// 鎺ㄩ�浠诲姟
         /// </summary>
         /// <param name="mst"></param>
-        internal static bool SendTask(TN_Task mst) 
-        {
+        internal static bool SendTask(TN_Task mst) {
 
             var result = false;
             var start = "0"; var end = "0";
@@ -131,10 +116,9 @@
                     start = LocationHelper.GetAgvSite(mst.S_START_LOC);
                     end = LocationHelper.GetAgvSite(mst.S_END_LOC);
 
-                    if (mst.S_TYPE == "绌烘墭涓嬬嚎鍫嗗彔")
-                    {
-                        end = LocationHelper.GetAgvSite(mst.S_END_LOC,true);
-                    }
+                    //if (mst.S_TYPE == "绌烘墭涓嬬嚎鍫嗗彔") {
+                    //    end = LocationHelper.GetAgvSite(mst.S_END_LOC, true);
+                    //}
 
                     LogHelper.Info($"NDC鎺ㄩ�浠诲姟 {mst.S_CODE};" + "start=" + start + "end= " + end);
                     var startLoc = LocationHelper.GetLoc(mst.S_START_LOC);
@@ -147,19 +131,16 @@
 
                     dic.Add(new param() { name = "Ctype", value = "0" });
 
-                    
-                    if (mst.S_TYPE == "浣欐枡涓嬬嚎鍏ュ簱" || mst.S_TYPE == "浜哄伐鎷嗙洏鍏ュ簱")
-                    {
-                        dic.Add(new param() { name = "DATA", value = "1024" });
-                    }
-                    else
-                    {
-                        dic.Add(new param() { name = "DATA", value = "0" });
-                    }
+
+                    //if (mst.S_TYPE == "浣欐枡涓嬬嚎鍏ュ簱" || mst.S_TYPE == "浜哄伐鎷嗙洏鍏ュ簱") {
+                    //    dic.Add(new param() { name = "DATA", value = "1024" });
+                    //}
+                    //else {
+                    //    dic.Add(new param() { name = "DATA", value = "0" });
+                    //}
 
                     var res = NDCApi.AddOrderNew(1, 1, mst.S_CODE, dic);//娣诲姞鏂板懡浠�-                    if (res != null && (res.err_code == 0 || res.err_code == 50009))
-                    {
+                    if (res != null && (res.err_code == 0 || res.err_code == 50009)) {
                         //鎺ㄩ�鎴愬姛锛屼慨鏀逛换鍔′紭鍏堢骇
                         mst.N_B_STATE = 1;
                         mst.S_B_STATE = TN_Task.GetStateStr(1);
@@ -167,16 +148,14 @@
                         result = true;
                         LogHelper.Info($"NDC鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE}start= {mst.S_START_LOC} + end = {mst.S_END_LOC}");
                     }
-                    else
-                    {
+                    else {
                         LogHelper.Info($"NDC鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};Res:" + JsonConvert.SerializeObject(res));
                     }
                 }
                 else if (mst.N_SCHEDULE_TYPE == 5)//閫氳繃鏉ゥ璋冨害璁惧 
                 {
                     //璋冪涓夋柟鎺ュ彛
-                    var model = new HanAo.TaskInfoModel
-                    {
+                    var model = new HanAo.TaskInfoModel {
                         requestPk = mst.S_CODE,
                         frmPos = mst.S_START_LOC,
                         toPos = mst.S_END_LOC,
@@ -188,8 +167,7 @@
                         WCSHelper.UpdateStatus(mst);
                         LogHelper.Info($"鏉ゥ鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE};" + "start=" + model.frmPos + "end= " + model.toPos);
                     }
-                    else
-                    {
+                    else {
                         LogHelper.Info($"鏉ゥ鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};" + JsonConvert.SerializeObject(model));
                     }
                 }
@@ -204,8 +182,7 @@
                         WCSHelper.UpdateEQNo(mst);
                         LogHelper.Info($"鍥借嚜鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE};" + "start=" + mst.S_START_LOC + "end= " + mst.S_END_LOC);
                     }
-                    else
-                    {
+                    else {
                         LogHelper.Info($"鍥借嚜鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};" + JsonConvert.SerializeObject(mst));
                     }
                 }
diff --git a/Helpers/HttpHelper.cs b/util/HttpHelper.cs
similarity index 100%
rename from Helpers/HttpHelper.cs
rename to util/HttpHelper.cs
diff --git a/Helpers/LogHelper.cs b/util/LogHelper.cs
similarity index 94%
rename from Helpers/LogHelper.cs
rename to util/LogHelper.cs
index ab9158b..94ef1d8 100644
--- a/Helpers/LogHelper.cs
+++ b/util/LogHelper.cs
@@ -35,8 +35,6 @@
             }
         }
 
-
-
         public static void Info(string message, string name = "") {
             //logger.Info(message);
             ILogger logger = null;
@@ -77,15 +75,6 @@
             }
         }
 
-        #region 鑷畾涔夋柟娉�-        public static void InfoEx(Exception ex) {
-            Info($"寮傚父锛歿ex.Message}");
-        }
-
-        public static void InfoApi(string taskType, object model) {
-            Info($"瑙﹀彂API锛歿taskType} " + JsonConvert.SerializeObject(model), "API");
-        }
-        #endregion
     }
 
     internal class LogFactory
diff --git a/util/Settings.cs b/util/Settings.cs
new file mode 100644
index 0000000..7717084
--- /dev/null
+++ b/util/Settings.cs
@@ -0,0 +1,113 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+
+using HH.WCS.Mobox3.AnGang;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+// 鏍规嵁 JSON 鏂囦欢 鐢熸垚瀵瑰簲鐨�C# 瀵硅薄锛涚綉鍧�細https://json2csharp.com/
+
+namespace HH.WCS.Mobox3.AnGang {
+    public class Settings {
+        public static string WebApiUrl { get; set; }
+        public static string RCSApiUrl { get; set; }
+        public static string NDCApiUrl { get; set; }
+        public static string SqlServer { get; set; }
+        public static string TCPServerIP { get; set; }
+        public static int TCPServerPort { get; set; }
+        public static List<Config.Area> Areas { get; set; }
+        public static List<Config.Snap> Snaps { get; set; }
+        public static string CaptureUrl { get; set; }
+
+        /// <summary>
+        /// 搴撳尯瀛楀吀锛堝姞杞藉悗灏变笉鍙橈級
+        /// </summary>
+        public static Dictionary<string, List<string>> AreaMap { get; set; } = new Dictionary<string, List<string>>();
+
+        public static void Init() {
+            // 鍔犺浇閰嶇疆鏂囦欢
+            LoadJson();
+
+            // 閽堝 Areas 杩涜杞崲锛氬皢 Config 鐨�List 鍔犺浇鍒�Dict 涓�+            LoadAreas();
+        }
+
+        private static void LoadJson() {
+            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 寮�");
+            // JSON 鏂囦欢璺緞
+            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./config/config.json");
+
+            try {
+                // 璇诲彇 JSON 鏂囦欢鍐呭
+                string jsonContent = File.ReadAllText(filePath);
+
+                // 鍙嶅簭鍒楀寲涓�Root 瀵硅薄
+                var root = JsonConvert.DeserializeObject<Config.Root>(jsonContent);
+
+                WebApiUrl = root.WebApiUrl;
+                RCSApiUrl = root.RCSApiUrl;
+                NDCApiUrl = root.NDCApiUrl;
+                SqlServer = root.SqlServer;
+                TCPServerIP = root.TCPServerIP;
+                TCPServerPort = root.TCPServerPort;
+                Areas = root.Areas;
+                Snaps = root.Snaps;
+                CaptureUrl = root.CaptureUrl;
+
+            }
+            catch (FileNotFoundException) {
+                LogHelper.Info("JSON 鏂囦欢鏈壘鍒�);
+            }
+            catch (JsonException ex) {
+                LogHelper.Info($"JSON 瑙f瀽閿欒: {ex.Message}");
+            }
+            catch (Exception ex) {
+                LogHelper.Info($"鍙戠敓閿欒: {ex.Message}");
+            }
+            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚");
+        }
+
+        private static void LoadAreas() {
+            foreach (var area in Areas) {
+                AreaMap.Add(area.Name, area.Codes);
+            }
+        }
+    }
+
+    public class Config {
+        // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
+        public class Area {
+            public string Name { get; set; }
+            public List<string> Codes { get; set; }
+        }
+
+        public class Root {
+            public string WebApiUrl { get; set; }
+            public string RCSApiUrl { get; set; }
+            public string NDCApiUrl { get; set; }
+            public string SqlServer { get; set; }
+            public string TCPServerIP { get; set; }
+            public int TCPServerPort { get; set; }
+            public List<Area> Areas { get; set; }
+            public List<Snap> Snaps { get; set; }
+            public string CaptureUrl { get; set; }
+        }
+
+        public class Snap {
+            public string Ip { get; set; }
+            public int Port { get; set; }
+            public string Name { get; set; }
+            public string Pwd { get; set; }
+        }
+    }
+
+    public class TaskName {
+        public const string 浜у搧鍏ュ簱 = "浜у搧鍏ュ簱";
+        public const string 浜у搧閮ㄥ垎鍑哄簱 = "浜у搧閮ㄥ垎鍑哄簱";
+        public const string 浜у搧閮ㄥ垎鍥炲簱 = "浜у搧閮ㄥ垎鍥炲簱";
+        public const string 鐩樼偣鐞嗚揣鍑哄簱 = "鐩樼偣鐞嗚揣鍑哄簱";
+        public const string 鐩樼偣鐞嗚揣鍥炲簱 = "鐩樼偣鐞嗚揣鍥炲簱";
+    }
+}
diff --git a/util/SqlHelper.cs b/util/SqlHelper.cs
new file mode 100644
index 0000000..3827382
--- /dev/null
+++ b/util/SqlHelper.cs
@@ -0,0 +1,70 @@
+锘縰sing HH.WCS.Mobox3.AnGang;
+
+using Newtonsoft.Json;
+
+using SqlSugar;
+
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Linq.Expressions;
+
+namespace HH.WCS.Mobox3.AnGang.util {
+    //https://www.donet5.com/Home/Doc
+    public class SqlHelper<T> where T : class, new() {
+
+        /// <summary>
+        /// 濡傛灉鐢∣racle鏁版嵁闇�鍖匫racle.ManagedDataAccess/21.15.0锛岀幆澧僴etframework 4.62锛屽お鏂颁簡4.8鏈夌殑鏈嶅姟鍣ㄥ畨瑁呬笉涓婂幓
+        /// </summary>
+        /// <param name="url"></param>
+        /// <returns></returns>
+        public SqlSugarClient GetInstance(string url = "") {
+            //鍒涘缓鏁版嵁搴撳璞�+            SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() {
+                ConnectionString = string.IsNullOrEmpty(url) ? Settings.SqlServer : url,
+                //ConnectionString = @"Data Source=192.168.1.198\sql2008;Initial Catalog=OIMobox;User ID=sa;Password=sa@2015",
+                DbType = DbType.SqlServer,
+                //ConnectionString = @"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OIMobox)));User Id=system;Password=Am123123;",
+                //DbType = DbType.Oracle,
+                IsAutoCloseConnection = true,
+                InitKeyType = InitKeyType.Attribute//浠庣壒鎬ц鍙栦富閿嚜澧炰俊鎭�+            });
+
+            //鐩戞帶鎵�湁瓒呰繃1绉掔殑Sql
+            db.Aop.OnLogExecuted = (sql, p) => {
+                //鎵ц鏃堕棿瓒呰繃1绉�+                if (db.Ado.SqlExecutionTime.TotalSeconds > 1) {
+                    Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(p.ToDictionary(it => it.ParameterName, it => it.Value)));
+                    //浠g爜CS鏂囦欢鍚�+                    var fileName = db.Ado.SqlStackTrace.FirstFileName;
+                    //浠g爜琛屾暟
+                    var fileLine = db.Ado.SqlStackTrace.FirstLine;
+                    //鏂规硶鍚�+                    var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
+                }
+                //鐩稿綋浜嶦F鐨�PrintToMiniProfiler
+            };
+
+            //姣忔璁剧疆鏁板�鏃堕兘鍘婚櫎鍓嶅鍚庡绌烘牸
+            db.Aop.DataExecuted = (value, entity) => {
+                entity.EntityColumnInfos.ToList().ForEach(a => {
+                    var pvalue = entity.GetValue(a.PropertyName);
+                    if (pvalue != null && pvalue.GetType() == typeof(String)) {
+                        entity.SetValue(a.PropertyName, pvalue.ToString().Trim());
+                    }
+                });
+            };
+
+            //鎹浆鎹�(ExecuteCommand鎵嶄細鎷︽埅锛屾煡璇笉琛�
+            //db.Aop.DataExecuting = (value, entity) => {
+            //    //var val=entity.EntityColumnInfo
+            //    Console.WriteLine(entity.EntityName);
+            //};
+
+            return db;
+        }
+
+    }
+
+}
diff --git a/Helpers/ContainerHelper.cs b/wms/ContainerHelper.cs
similarity index 94%
rename from Helpers/ContainerHelper.cs
rename to wms/ContainerHelper.cs
index bd914e6..4adb140 100644
--- a/Helpers/ContainerHelper.cs
+++ b/wms/ContainerHelper.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Models;
+锘縰sing HH.WCS.Mobox3.AnGang.models;
 using HH.WCS.Mobox3.AnGang.config;
 using Newtonsoft.Json;
 using System;
@@ -6,10 +6,10 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using static HH.WCS.Mobox3.AnGang.Dispatch.NDC;
-using HH.WCS.Mobox3.AnGang.Helpers;
+using static HH.WCS.Mobox3.AnGang.dispatch.NDC;
+using HH.WCS.Mobox3.AnGang.util;
 
-namespace HH.WCS.Mobox3.AnGang.Helper {
+namespace HH.WCS.Mobox3.AnGang.wms {
     /// <summary>
     /// 瀹瑰櫒甯姪绫�     /// </summary>
@@ -23,7 +23,7 @@
         /// <returns></returns>
         public static string BindingCG(string cnt, List<string> cGs)
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var logs = $"瀹瑰櫒锛歿cnt}锛岃揣鍝侊細{JsonConvert.SerializeObject(cGs)}";
             try
             {
@@ -88,7 +88,7 @@
         /// <returns></returns>
         public static string UnBindingCG(string cnt, List<string> cGs)
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var logs = $"瀹瑰櫒锛歿cnt}锛岃揣鍝侊細{JsonConvert.SerializeObject(cGs)}";
             try
             {
diff --git a/Helpers/LocationHelper.cs b/wms/LocationHelper.cs
similarity index 92%
rename from Helpers/LocationHelper.cs
rename to wms/LocationHelper.cs
index 8102958..50e1f21 100644
--- a/Helpers/LocationHelper.cs
+++ b/wms/LocationHelper.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Models;
+锘縰sing HH.WCS.Mobox3.AnGang.models;
 using HH.WCS.Mobox3.AnGang.config;
 using Newtonsoft.Json;
 using SqlSugar;
@@ -7,11 +7,10 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.MoboxResponse;
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using HH.WCS.Mobox3.AnGang.util;
 
-namespace HH.WCS.Mobox3.AnGang.Helper {
+namespace HH.WCS.Mobox3.AnGang.wms {
     public class LocationHelper
     {
         private static Dictionary<string, TN_Location> Locations = null;
@@ -54,7 +53,7 @@
         /// <returns></returns>
         internal static List<TN_Location> GetAllLocList()
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             return db.Queryable<TN_Location>().ToList();
         }
 
@@ -131,8 +130,29 @@
 
         internal static TN_Location GetLoc(string code)
         {
-            var db = DbHelper.GetDbClient();
+            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="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�2:鍏跺畠閿�/param>
+        /// <param name="lockSource">閿佺殑鏉ユ簮=浠诲姟鍙�/param>
+        /// <returns></returns>
+        public static bool LockLoc(ref TN_Location loc, int lockState, string lockSource = "") {
+            //if (loc == null || loc.N_LOCK_STATE != 0) {
+            //    return false;
+            //}
+
+            loc.N_LOCK_STATE = lockState;
+            loc.S_LOCK_STATE = TN_Location.GetLockStateStr(lockState);
+            loc.S_LOCK_OP = lockSource;
+            loc.T_MODIFY = System.DateTime.Now;
+
+            return true;
         }
 
         /// <summary>
@@ -146,7 +166,7 @@
         public static bool LockLoc(string loc, int lockState, string lockSource = "")
         {
             var res = false;
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var model = db.Queryable<TN_Location>().Where(a => a.S_CODE == loc).First();
             LogHelper.Info($"閿佽揣浣峽loc},鐘舵�{lockState},淇℃伅" + JsonConvert.SerializeObject(model));
             if (model != null && model.N_LOCK_STATE == 0)
@@ -171,7 +191,7 @@
         {
             LogHelper.Info("UnLockLoc:" + loc);
             var res = false;
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var model = db.Queryable<TN_Location>().Where(a => a.S_CODE == loc).First();
             if (model != null)
             {
@@ -197,7 +217,7 @@
         /// <returns></returns>
         public static string UnBindingLoc(string loc, List<string> cntrs)
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var logs = $"璐т綅锛歿loc}锛屽鍣細{JsonConvert.SerializeObject(cntrs)}";
             try
             {
@@ -270,7 +290,7 @@
         /// <returns></returns>
         public static string BindingLoc(string loc, List<string> cntrs)
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var logs = $"璐т綅锛歿loc}锛屽鍣細{JsonConvert.SerializeObject(cntrs)}";
             try
             {
@@ -379,7 +399,7 @@
             LogHelper.Info("瑙﹀彂API锛氳揣浣嶅鍣ㄩ噸缃� + JsonConvert.SerializeObject(model), "API");
 
             var result = new SimpleResult();
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
 
             try
             {
diff --git a/Helpers/SYSHelper.cs b/wms/SYSHelper.cs
similarity index 89%
rename from Helpers/SYSHelper.cs
rename to wms/SYSHelper.cs
index 1d75384..86ba94d 100644
--- a/Helpers/SYSHelper.cs
+++ b/wms/SYSHelper.cs
@@ -1,5 +1,5 @@
 锘縰sing HH.WCS.Mobox3.AnGang.config;
-using HH.WCS.Mobox3.AnGang.Helpers;
+using HH.WCS.Mobox3.AnGang.util;
 
 using SqlSugar;
 using System;
@@ -8,15 +8,15 @@
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HH.WCS.Mobox3.AnGang.Helper
+namespace HH.WCS.Mobox3.AnGang.wms
 {
-    internal class SysHelper
+    internal class SYSHelper
     {
         private static object locker = new object();
         internal static int GetSerialNumber(string snType, string prefix) {
             int result = 0;
             lock (locker) {
-                var db = DbHelper.GetDbClient();
+                var db = new SqlHelper<object>().GetInstance();
                 var sId = db.Queryable<OI_SYS_MAXID>().Where(a => a.CN_S_TYPE.Trim() == snType && a.CN_S_PRE.Trim() == prefix).First();
                 if (sId != null) {
                     sId.CN_N_MAX++;
diff --git a/Helpers/WCSHelper.cs b/wms/WCSHelper.cs
similarity index 76%
rename from Helpers/WCSHelper.cs
rename to wms/WCSHelper.cs
index e907819..5041a23 100644
--- a/Helpers/WCSHelper.cs
+++ b/wms/WCSHelper.cs
@@ -1,4 +1,4 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Models;
+锘縰sing HH.WCS.Mobox3.AnGang.models;
 using HH.WCS.Mobox3.AnGang.config;
 using Newtonsoft.Json;
 using System;
@@ -6,27 +6,26 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using HH.WCS.Mobox3.AnGang.Consts;
+using HH.WCS.Mobox3.AnGang.util;
 
-namespace HH.WCS.Mobox3.AnGang.Helper {
+namespace HH.WCS.Mobox3.AnGang.wms {
     internal class WCSHelper {
         internal static string GenerateTaskNo() {
-            var id = SysHelper.GetSerialNumber("浠诲姟鍙�, "TN");
+            var id = SYSHelper.GetSerialNumber("浠诲姟鍙�, "TN");
             var date = DateTime.Now.ToString("yyMMdd");
             return $"TN{date}{id.ToString().PadLeft(4, '0')}";
         }
         internal static bool UpdateStatus(TN_Task task, string status) 
         {
             var res = false;
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             task.S_B_STATE = status;
             res = db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE }).ExecuteCommand()>0;
             return res;
         }
         internal static bool UpdateStatus(TN_Task task) {
             var res = false;
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE);
             task.T_MODIFY = DateTime.Now;
             db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_MODIFY }).ExecuteCommand();
@@ -35,16 +34,53 @@
 
         internal static bool UpdateEQNo(TN_Task task) {
             var res = false;
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             task.T_MODIFY = DateTime.Now;
             db.Updateable(task).UpdateColumns(it => new { it.S_EQ_TASK_CODE, it.T_MODIFY }).ExecuteCommand();
             return res;
         }
 
         internal static TN_Task GetTask(string no) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var task = db.Queryable<TN_Task>().Where(a => a.S_CODE == no).First();
             return task;
+        }
+
+        public static TN_Task BuildTask(TN_Location startLoc, TN_Location endLoc, string cntId, string type) {
+            TN_Task TN_Task = new TN_Task() {
+                S_CODE = GenerateTaskNo(),
+                S_START_AREA = startLoc.S_AREA_CODE,
+                S_END_AREA = endLoc.S_AREA_CODE,
+                S_START_LOC = startLoc.S_CODE,
+                S_END_LOC = endLoc.S_CODE,
+                S_TYPE = type,
+                N_PRIORITY = 3,
+                N_SCHEDULE_TYPE = 3, // 鍥借嚜
+                N_B_STATE = 0,
+                S_CNTR_CODE = cntId,
+            };
+
+            return TN_Task;
+        }
+
+        public static TN_Task BuildInboundTask(TN_Location startLoc, string endLocCode, string cntId) {
+            var type = TaskName.浜у搧鍏ュ簱;
+            var endArea = "HJQ";
+
+            TN_Task TN_Task = new TN_Task() {
+                S_CODE = GenerateTaskNo(),
+                S_START_AREA = startLoc.S_AREA_CODE,
+                S_END_AREA = endArea,
+                S_START_LOC = startLoc.S_CODE,
+                S_END_LOC = endLocCode,
+                S_TYPE = type,
+                N_PRIORITY = 3,
+                N_SCHEDULE_TYPE = 3, // 鍥借嚜
+                N_B_STATE = 0,
+                S_CNTR_CODE = cntId,
+            };
+
+            return TN_Task;
         }
 
         /// <summary>
@@ -90,7 +126,7 @@
             };
 
             var log = JsonConvert.SerializeObject(TN_Task);
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var res = db.Insertable(TN_Task).ExecuteCommand() > 0;
             if (res)
             {
@@ -130,7 +166,7 @@
                     });
                 }
                 var log = JsonConvert.SerializeObject(tN_Tasks);
-                var db = DbHelper.GetDbClient();
+                var db = new SqlHelper<object>().GetInstance();
                 var res = db.Insertable<TN_Task>(tN_Tasks).ExecuteCommand() > 0;
                 if (res)
                 {
@@ -148,13 +184,13 @@
 
 
         internal static bool CheckActionRecordExist(string no, int code) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             return db.Queryable<TN_Task_Action>().Count(a => a.S_TASK_CODE == no && a.N_ACTION_CODE == code) > 0;
         }
 
         internal static void Begin(TN_Task task, string forklift_no) 
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             if (task != null) 
             {
                 if (task.N_B_STATE == 1) 
@@ -169,7 +205,7 @@
             }
         }
         internal static void End(TN_Task task) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             if (task != null) {
                 task.N_B_STATE = 3;
                 task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE);
@@ -178,7 +214,7 @@
             }
         }
         internal static void Fail(TN_Task task) {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             if (task != null) {
                 //鍒ゆ柇鏈夋病鏈夊彇璐у畬鎴愶紝娌℃湁灏卞彉鎴愬け璐ャ�鏈夊彇璐у畬鎴愰粯璁ゅ畬鎴愪簡锛堣窡鎹」鐩�瀹氾紝鏈変簺椤圭洰浜哄伐鎷夎蛋浜嗕篃娌℃湁鏀惧埌缁堢偣锛夈�
                 task.N_B_STATE = 4;
@@ -189,7 +225,7 @@
 
         internal static bool AddActionRecord(string no, int state, string forkliftNo, string extData)
         {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             var action = new TN_Task_Action()
             {
                 N_ACTION_CODE = state,
@@ -202,7 +238,7 @@
         }
 
         internal static List<TN_Task> GetWaitingTaskList() {
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             return db.Queryable<TN_Task>().Where(a => a.N_B_STATE == 0 && (a.S_B_STATE == "绛夊緟" || a.S_B_STATE == "寰呮帹閫�)).ToList();
         }
     }
diff --git a/Helpers/WMSHelper.cs b/wms/WMSHelper.cs
similarity index 90%
rename from Helpers/WMSHelper.cs
rename to wms/WMSHelper.cs
index 3c13c21..e9a57d7 100644
--- a/Helpers/WMSHelper.cs
+++ b/wms/WMSHelper.cs
@@ -1,6 +1,6 @@
-锘縰sing HH.WCS.Mobox3.AnGang.Controllers;
-using HH.WCS.Mobox3.AnGang.Dispatch;
-using HH.WCS.Mobox3.AnGang.Models;
+锘縰sing HH.WCS.Mobox3.AnGang.api;
+using HH.WCS.Mobox3.AnGang.dispatch;
+using HH.WCS.Mobox3.AnGang.models;
 using HH.WCS.Mobox3.AnGang.config;
 using System;
 using System.Collections.Generic;
@@ -10,11 +10,10 @@
 using System.Runtime.Remoting.Messaging;
 using System.Text;
 using System.Threading.Tasks;
-using static HH.WCS.Mobox3.AnGang.Controllers.ApiModel;
-using HH.WCS.Mobox3.AnGang.Helpers;
-using static HH.WCS.Mobox3.AnGang.Dtos.Response.MoboxResponse;
+using static HH.WCS.Mobox3.AnGang.api.ApiModel;
+using HH.WCS.Mobox3.AnGang.util;
 
-namespace HH.WCS.Mobox3.AnGang.Helper
+namespace HH.WCS.Mobox3.AnGang.wms
 {
     /// <summary>
     /// wms绠″埌浣滀笟
@@ -29,7 +28,7 @@
         internal static SimpleResult PDACancleTask(CancleTaskInfo model)
         {
             SimpleResult simpleResult = new SimpleResult();
-            var db = DbHelper.GetDbClient();
+            var db = new SqlHelper<object>().GetInstance();
             try
             {
                 if (model.taskNO.Length > 0)

--
Gitblit v1.9.1