From c8f338feee0b6003d8f069b1d37fd9b90dd1b7f4 Mon Sep 17 00:00:00 2001
From: 杨前锦 <1010338399@qq.com>
Date: 星期一, 07 七月 2025 17:31:38 +0800
Subject: [PATCH] 印尼佳通优化

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/api/ApiHelper.cs |  540 +++++++++++++++++++++++++----------------------------------
 1 files changed, 226 insertions(+), 314 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/api/ApiHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/api/ApiHelper.cs
index bc50dfc..4b65c2b 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/api/ApiHelper.cs
@@ -28,6 +28,7 @@
 
         }
 
+
         /// <summary>
         /// 1.鍒涘缓鍏ュ簱浠诲姟
         /// </summary>
@@ -36,7 +37,7 @@
             ReturnResult result = new ReturnResult();
             try
             {
-                if (model.taskType == "鏈哄彴鍗婂埗鍝佸叆搴� || model.taskType == "鎴愬瀷鏈轰綑鏂欏洖搴�) 
+                if (model.taskType.Contains("鏈哄彴鍗婂埗鍝佸叆搴�) || model.taskType.Contains("鎴愬瀷鏈轰綑鏂欏叆搴�)) 
                 {
                     var itemInfos = model.itemInfo;
                     if (itemInfos == null || itemInfos.Count == 0)
@@ -44,27 +45,6 @@
                         result.ResultCode = 1;
                         result.ResultMsg = "鐗╂枡淇℃伅涓嶈兘涓虹┖";
                         return result;
-                    }
-                    else 
-                    {
-                        foreach (var item in itemInfos)
-                        {
-                            var overage = WMSHelper.getOverage(item.bc_entried);
-                            if (overage != null)
-                            {
-                                DateTime txndate = DateTime.Parse(item.txndate);
-                                DateTime minTime = txndate.AddHours(overage.MINHOUR);
-                                DateTime maxTime = txndate.AddDays(overage.OVERAGE);
-                                item.effective_time = minTime.ToString("yyyy-MM-dd HH:mm:ss");
-                                item.expiration_time = maxTime.ToString("yyyy-MM-dd HH:mm:ss");
-                            }
-                            else 
-                            {
-                                result.ResultCode = 1;
-                                result.ResultMsg = $"鏈煡璇㈠埌鐗╂枡瀛樻斁鏃堕棿閰嶇疆淇℃伅锛屾潯褰㈢爜锛歿item.bc_entried}";
-                                return result;
-                            }
-                        }
                     }
                 }
 
@@ -120,6 +100,7 @@
                         S_END_AREA = endLoc.S_AREA_CODE,
                         S_TYPE = model.taskType,
                         S_OP_DEF_CODE = model.taskNo,
+                        S_OP_DEF_NAME = "鍗婂埗鍝�浣欐枡/绌烘墭涓嬪彂鍏ュ簱浠诲姟",
                         N_PRIORITY = model.priority,
                         T_START_TIME = DateTime.Now,
                     };
@@ -182,95 +163,14 @@
             ReturnResult result = new ReturnResult();
             try
             {
-                Location startLoc = WMSHelper.GetEmptyTrayStartLoc(model.trayType);
-                Location middleLoc = null;
-                string cntrCode = "";
-                string descCntrCode = "";
-                if (startLoc != null) 
+                EmptyTrayBuffer buffer = new EmptyTrayBuffer() 
                 {
-                    // 鏌ヨ璐т綅瀹瑰櫒缂栫爜 銆佺洰鏍囧鍣ㄧ紪鐮�-                    var locCntrRels = LocationHelper.GetLocCntrRel(startLoc.S_CODE);
-                    if (locCntrRels.Count > 0)
-                    {
-                        foreach (var item in locCntrRels)
-                        {
-                            var container = ContainerHelper.GetCntr(item.S_CNTR_CODE);
-                            if (model.trayType == container.N_TYPE) 
-                            {
-                                descCntrCode = item.S_CNTR_CODE;
-                            }
-                            cntrCode = cntrCode + "," + item.S_CNTR_CODE;
-                        }
-                        cntrCode = cntrCode.Substring(1, cntrCode.Length - 1);
-                    }
-
-                    var locCodes = Settings.getAgvJBLocList(1, startLoc.N_ROADWAY, 2);
-                    if (locCodes.Count > 0) 
-                    {
-                        middleLoc = LocationHelper.GetLoc(locCodes[0]); 
-                    }
-                }
-                
-                Location endLoc = LocationHelper.GetLoc(model.endLoc);
-                if (endLoc == null) 
-                {
-                    result.ResultCode = 1;
-                    result.ResultMsg = "WMS绯荤粺娌℃湁璇ヨ揣浣嶏紝璇锋鏌ョ粓鐐硅揣浣嶇紪鐮佹槸鍚︽纭�;
-                    return result;
-                }
-
-                if (startLoc != null)
-                {
-                    var wmsTask = new WMSTask()
-                    {
-                        S_CNTR_CODE = descCntrCode,
-                        S_CODE = WMSHelper.GenerateTaskNo(),
-                        S_START_LOC = startLoc.S_CODE,
-                        S_START_AREA = startLoc.S_AREA_CODE,
-                        S_END_LOC = endLoc.S_CODE,
-                        S_END_AREA = endLoc.S_AREA_CODE,
-                        S_TYPE = "绌烘墭鍑哄簱浠诲姟",
-                        S_OP_DEF_CODE = model.taskNo,
-                        N_PRIORITY = model.priority,
-                        T_START_TIME = DateTime.Now,
-                    };
-
-                    if (WMSHelper.CreateWmsTask(wmsTask))
-                    {
-                        // 鍒涘缓涓�鍑哄簱浠诲姟
-                        WCSTask wcsTask = new WCSTask()
-                        {
-                            S_OP_NAME = wmsTask.S_OP_DEF_NAME,
-                            S_OP_CODE = wmsTask.S_CODE,
-                            S_CODE = WCSHelper.GenerateTaskNo(),
-                            S_CNTR_CODE = cntrCode,
-                            S_TYPE = wmsTask.S_TYPE + "-1",
-                            S_START_LOC = startLoc.S_CODE,
-                            S_START_AREA = startLoc.S_AREA_CODE,
-                            S_END_LOC = middleLoc.S_CODE,
-                            S_END_AREA = middleLoc.S_AREA_CODE,
-                            S_SCHEDULE_TYPE = "WCS",
-                            N_PRIORITY = 1,
-                            T_START_TIME = DateTime.Now,
-                        };
-
-                        if (WCSHelper.CreateTask(wcsTask) )
-                        {
-                            // 璧风偣銆佹帴椹崇偣銆佺粓鐐瑰姞閿�-                            LocationHelper.LockLoc(wcsTask.S_START_LOC, 2);
-                            LocationHelper.LockLoc(wcsTask.S_END_LOC, 1);
-
-                            // 鏇存柊浣滀笟浠诲姟鐘舵�
-                            wmsTask.N_B_STATE = 1;
-                            WMSHelper.UpdateTaskState(wmsTask);
-                        }
-                    }
-                }
-                else
-                {
-                    result.ResultCode = 1;
-                    result.ResultMsg = "搴撳唴娌℃湁鏌ュ埌绌烘墭鐩�;
-                }
+                    TASK_NO = model.taskNo,
+                    TRAY_TYPE = model.trayType,
+                    END_LOC = model.endLoc,
+                    PRIORITY = model.priority,
+                };
+                WMSHelper.addEmptyTrayBuffer(buffer);
             }
             catch (Exception ex)
             {
@@ -291,89 +191,116 @@
             ReturnResult result = new ReturnResult();
             try
             {
-                Location startLoc = WMSHelper.GetoutStockStartLoc(model.itemCode);
-                Location middleLoc = null;
-                string descCntrCode = "";
-                string cntrCode = "";
-                if (startLoc != null)
+                Location endLoc = LocationHelper.GetLoc(model.endLoc);
+                if (endLoc.N_CURRENT_NUM == 0)
                 {
-                    // 鏌ヨ鎺ラ┏浣�-                    var locCodes = Settings.getAgvJBLocList(1, startLoc.N_ROADWAY, 2);
-                    if (locCodes.Count > 0)
+                    int taskNum = 0;
+                    for (int i = 0; i < endLoc.N_CAPACITY; i++)
                     {
-                        middleLoc = LocationHelper.GetLoc(locCodes[0]);
+                        Location startLoc = WMSHelper.GetoutStockStartLoc(model.itemCode);
+                        Location middleLoc = null;
+                        string descCntrCode = "";
+                        string cntrCode = "";
+                        if (startLoc != null)
+                        {
+                            // 鏌ヨ鎺ラ┏浣�+                            var locCodes = Settings.getAgvJBLocList(startLoc.N_ROADWAY, 2);
+                            if (locCodes.Count > 0)
+                            {
+                                middleLoc = LocationHelper.GetLoc(locCodes[0]);
+                            }
+
+                            // 鏌ヨ璐т綅瀹瑰櫒缂栫爜 銆佺洰鏍囧鍣ㄧ紪鐮�+                            var locCntrRels = LocationHelper.GetLocCntrRel(startLoc.S_CODE);
+                            if (locCntrRels.Count > 0)
+                            {
+                                foreach (var item in locCntrRels)
+                                {
+                                    var cntrItemRels = ContainerHelper.GetCntrItemRel(item.S_CNTR_CODE);
+                                    if (cntrItemRels.Count > 0)
+                                    {
+                                        descCntrCode = cntrItemRels[0].S_CNTR_CODE;
+                                    }
+                                    cntrCode = cntrCode + "," + item.S_CNTR_CODE;
+                                }
+                                cntrCode = cntrCode.Substring(1, cntrCode.Length - 1);
+                            }
+                        }
+                        else
+                        {
+                            LogHelper.Info($"搴撳唴娌℃湁鐗╂枡:{model.itemCode}", "WMS");
+                            break;
+                        }
+
+
+                        if (endLoc != null)
+                        {
+                            string taskType = "鎴愬瀷鏈哄彨鏂欏嚭搴撲换鍔�;
+                            if (model.taskType == 2) 
+                            {
+                                taskType = "鎶芥鍙枡鍑哄簱浠诲姟";
+                            }
+
+
+                            var wmsTask = new WMSTask()
+                            {
+                                S_CNTR_CODE = descCntrCode,
+                                S_CODE = WMSHelper.GenerateTaskNo(),
+                                S_START_LOC = startLoc.S_CODE,
+                                S_START_AREA = startLoc.S_AREA_CODE,
+                                S_END_LOC = endLoc.S_CODE,
+                                S_END_AREA = endLoc.S_AREA_CODE,
+                                S_TYPE = taskType,
+                                S_OP_DEF_CODE = model.taskNo,
+                                S_OP_DEF_NAME = "鍙枡鍑哄簱浠诲姟",
+                                N_PRIORITY = model.priority,
+                                T_START_TIME = DateTime.Now,
+                            };
+
+                            if (WMSHelper.CreateWmsTask(wmsTask))
+                            {
+                                // 鍒涘缓涓�鍑哄簱浠诲姟
+                                WCSTask wcsTask = new WCSTask()
+                                {
+                                    S_OP_NAME = wmsTask.S_OP_DEF_NAME,
+                                    S_OP_CODE = wmsTask.S_CODE,
+                                    S_CODE = WCSHelper.GenerateTaskNo(),
+                                    S_CNTR_CODE = cntrCode,
+                                    S_TYPE = wmsTask.S_TYPE + "-1",
+                                    S_START_LOC = startLoc.S_CODE,
+                                    S_START_AREA = startLoc.S_AREA_CODE,
+                                    S_END_LOC = middleLoc.S_CODE,
+                                    S_END_AREA = middleLoc.S_AREA_CODE,
+                                    S_SCHEDULE_TYPE = "WCS",
+                                    N_PRIORITY = 1,
+                                    T_START_TIME = DateTime.Now,
+                                };
+
+                                if (WCSHelper.CreateTask(wcsTask))
+                                {
+                                    // 璧风偣銆佹帴椹崇偣鍔犻攣
+                                    LocationHelper.LockLoc(wcsTask.S_START_LOC, 2);
+                                    LocationHelper.LockLoc(wcsTask.S_END_LOC, 1);
+
+                                    // 鏇存柊浣滀笟浠诲姟鐘舵�
+                                    wmsTask.N_B_STATE = 1;
+                                    WMSHelper.UpdateTaskState(wmsTask);
+                                    taskNum++;
+                                }
+                            }
+                        }
                     }
 
-                    // 鏌ヨ璐т綅瀹瑰櫒缂栫爜 銆佺洰鏍囧鍣ㄧ紪鐮�-                    var locCntrRels = LocationHelper.GetLocCntrRel(startLoc.S_CODE);
-                    if (locCntrRels.Count > 0)
+                    if (taskNum < endLoc.N_CAPACITY) 
                     {
-                        foreach (var item in locCntrRels)
-                        {
-                            var cntrItemRels = ContainerHelper.GetCntrItemRel(item.S_CNTR_CODE);
-                            if (cntrItemRels.Count > 0)
-                            {
-                                descCntrCode = cntrItemRels[0].S_CNTR_CODE;
-                            }
-                            cntrCode = cntrCode + "," + item.S_CNTR_CODE;
-                        }
-                        cntrCode = cntrCode.Substring(1, cntrCode.Length - 1);
+                        result.ResultCode = 1;
+                        result.ResultMsg = $"搴撳唴鐗╂枡涓嶈冻锛屽凡鐢熸垚鍑哄簱浠诲姟鏁�{taskNum}";
                     }
                 }
                 else 
                 {
                     result.ResultCode = 1;
-                    result.ResultMsg = "搴撳唴娌℃湁鏌ュ埌姝ょ墿鏂�;
-                    return result;
-                }
-
-                Location endLoc = LocationHelper.GetLoc(model.endLoc);
-                if (endLoc != null) 
-                {
-                    var wmsTask = new WMSTask()
-                    {
-                        S_CNTR_CODE = descCntrCode,
-                        S_CODE = WMSHelper.GenerateTaskNo(),
-                        S_START_LOC = startLoc.S_CODE,
-                        S_START_AREA = startLoc.S_AREA_CODE,
-                        S_END_LOC = endLoc.S_CODE,
-                        S_END_AREA = endLoc.S_AREA_CODE,
-                        S_TYPE = "鎴愬瀷鏈哄彨鏂欏嚭搴撲换鍔�,
-                        S_OP_DEF_CODE = model.taskNo,
-                        N_PRIORITY = model.priority,
-                        T_START_TIME = DateTime.Now,
-                    };
-
-                    if (WMSHelper.CreateWmsTask(wmsTask))
-                    {
-                        // 鍒涘缓涓�鍑哄簱浠诲姟
-                        WCSTask wcsTask = new WCSTask()
-                        {
-                            S_OP_NAME = wmsTask.S_OP_DEF_NAME,
-                            S_OP_CODE = wmsTask.S_CODE,
-                            S_CODE = WCSHelper.GenerateTaskNo(),
-                            S_CNTR_CODE = cntrCode,
-                            S_TYPE = wmsTask.S_TYPE + "-1",
-                            S_START_LOC = startLoc.S_CODE,
-                            S_START_AREA = startLoc.S_AREA_CODE,
-                            S_END_LOC = middleLoc.S_CODE,
-                            S_END_AREA = middleLoc.S_AREA_CODE,
-                            S_SCHEDULE_TYPE = "WCS",
-                            N_PRIORITY = 1,
-                            T_START_TIME = DateTime.Now,
-                        };
-
-                        if (WCSHelper.CreateTask(wcsTask))
-                        {
-                            // 璧风偣銆佹帴椹崇偣鍔犻攣
-                            LocationHelper.LockLoc(wcsTask.S_START_LOC, 2);
-                            LocationHelper.LockLoc(wcsTask.S_END_LOC, 1);
-
-                            // 鏇存柊浣滀笟浠诲姟鐘舵�
-                            wmsTask.N_B_STATE = 1;
-                            WMSHelper.UpdateTaskState(wmsTask);
-                        }
-                    }
+                    result.ResultMsg = "缁堢偣璐т綅褰撳墠瀹归噺涓嶄负0锛屾棤娉曞彨鏂�;
                 }
             }
             catch (Exception ex)
@@ -395,30 +322,8 @@
             ReturnResult result = new ReturnResult();
             try
             {
-                if(model.itemInfo != null && model.itemInfo.Count > 0)
-                {
-                    foreach (var item in model.itemInfo)
-                    {
-                        var overage = WMSHelper.getOverage(item.bc_entried);
-                        if (overage != null)
-                        {
-                            DateTime txndate = DateTime.Parse(item.txndate);
-                            DateTime minTime = txndate.AddHours(overage.MINHOUR);
-                            DateTime maxTime = txndate.AddDays(overage.OVERAGE);
-                            item.effective_time = minTime.ToString("yyyy-MM-dd HH:mm:ss");
-                            item.expiration_time = maxTime.ToString("yyyy-MM-dd HH:mm:ss");
-                        }
-                        else
-                        {
-                            result.ResultCode = 1;
-                            result.ResultMsg = $"鏈煡璇㈠埌鐗╂枡瀛樻斁鏃堕棿閰嶇疆淇℃伅锛屾潯褰㈢爜锛歿item.bc_entried}";
-                            return result;
-                        }
-                    }
-                }
-
                 var container = ContainerHelper.GetCntr(model.trayCode);
-                if (container != null) 
+                if (container != null)
                 {
                     Location startLoc = LocationHelper.GetLoc(model.startLoc);
                     Location endLoc = WMSHelper.GetInstockEndLoc(container.N_TYPE, model.startLoc, 2);
@@ -442,6 +347,7 @@
                             S_END_AREA = endLoc.S_AREA_CODE,
                             S_TYPE = "浜哄伐鍏ュ簱浠诲姟",
                             S_OP_DEF_CODE = model.taskNo,
+                            S_OP_DEF_NAME = "浜哄伐鍏ュ簱浠诲姟",
                             N_PRIORITY = model.priority,
                             T_START_TIME = DateTime.Now,
                         };
@@ -483,8 +389,13 @@
                     else
                     {
                         result.ResultCode = 1;
-                        result.ResultMsg = "娌℃湁绌轰綑鐨勮揣浣�;
+                        result.ResultMsg = "绔嬪簱娌℃湁绌轰綑鐨勮揣浣�;
                     }
+                }
+                else 
+                {
+                    result.ResultCode = 1;
+                    result.ResultMsg = "WMS绯荤粺涓病鏈夎瀹瑰櫒";
                 }
             }
             catch (Exception ex)
@@ -506,7 +417,7 @@
             ReturnResult result = new ReturnResult();
             try
             {
-                Location startLoc = WMSHelper.GetoutStockStartLoc(model.itemCode , model.endLoc);
+                Location startLoc = WMSHelper.GetoutStockStartLoc(model.itemCode,model.trayCode , model.endLoc);
                 Location endLoc = LocationHelper.GetLoc(model.endLoc);
 
                 if (startLoc != null)
@@ -538,6 +449,7 @@
                         S_END_AREA = endLoc.S_AREA_CODE,
                         S_TYPE = "浜哄伐鍑哄簱浠诲姟",
                         S_OP_DEF_CODE = model.taskNo,
+                        S_OP_DEF_NAME = "浜哄伐鍑哄簱浠诲姟",
                         N_PRIORITY = model.priority,
                         T_START_TIME = DateTime.Now,
                     };
@@ -576,7 +488,7 @@
                 else
                 {
                     result.ResultCode = 1;
-                    result.ResultMsg = "搴撳唴娌℃湁姝ょ墿鏂�;
+                    result.ResultMsg = "搴撳唴娌℃湁婊¤冻鏉′欢鐨勭墿鏂�;
                 }
             }
             catch (Exception ex)
@@ -633,6 +545,7 @@
                             S_END_AREA = endLoc.S_AREA_CODE,
                             S_TYPE = "姣嶆嫋鍏ュ簱浠诲姟",
                             S_OP_DEF_CODE = taskNo,
+                            S_OP_DEF_NAME = "姣嶆嫋鍏ュ簱浠诲姟",
                             N_PRIORITY = 1,
                             T_START_TIME = DateTime.Now,
                         };
@@ -689,20 +602,25 @@
         /// <param name="loc"></param>
         /// <param name="wmsTaskNo"></param>
         /// <returns></returns>
-        public static ReturnResult baseTrayInStockAgv(string loc, string wmsTaskNo)
+        public static ReturnResult autoBaseTrayInStock(string loc, string wmsTaskNo)
         {
             ReturnResult result = new ReturnResult();
             try
             {
-                var mst = WMSHelper.GetWmsTask(wmsTaskNo);
-                if (mst != null && mst.N_B_STATE < 2) 
+                var cst = WCSHelper.GetTaskByStart(loc);
+                if (cst == null) 
                 {
                     Location startLoc = LocationHelper.GetLoc(loc);
-                    Location endLoc = LocationHelper.GetLoc(Settings.baseTrayInBufferLoc);
-                    if (!(endLoc != null && endLoc.N_CURRENT_NUM == 0)) 
+                    Location endLoc = null;
+                    var baseTrayBufferLoc = Settings.baseTrayBufferLocList.Where(a => a.bufferOutLoc == loc).FirstOrDefault();
+                    if (baseTrayBufferLoc != null) 
+                    {
+                        endLoc = LocationHelper.GetLoc(baseTrayBufferLoc.bufferInLoc);
+                    }
+                    if (endLoc == null || endLoc.N_CURRENT_NUM > 0)
                     {
                         endLoc = WMSHelper.GetInstockEndLoc(0, loc, 2);
-                    } 
+                    }
 
                     if (endLoc != null && startLoc != null)
                     {
@@ -727,8 +645,7 @@
                             // 鍒涘缓涓�鍏ュ簱浠诲姟
                             WCSTask wcsTask = new WCSTask()
                             {
-                                S_OP_NAME = mst.S_OP_DEF_NAME,
-                                S_OP_CODE = mst.S_CODE,
+                                S_OP_CODE = wmsTaskNo,
                                 S_CODE = WCSHelper.GenerateTaskNo(),
                                 S_CNTR_CODE = trayCode,
                                 S_TYPE = "姣嶆嫋鍏ュ簱浠诲姟",
@@ -771,33 +688,15 @@
         /// <param name="loc"></param>
         /// <param name="taskNo"></param>
         /// <returns></returns>
-        public static ReturnResult baseTrayOutStock(string loc ,string taskNo)
+        public static ReturnResult baseTrayOutStock(string loc ,string taskNo ,int exclude = 1)
         {
             LogHelper.Info("銆愭瘝鎷栧嚭搴撲换鍔°�寮�涓嬪彂姣嶆嫋鍑哄簱浠诲姟", "WMS");
             ReturnResult result = new ReturnResult();
             try
             {
-                Location startLoc = LocationHelper.GetLoc(Settings.baseTrayInBufferLoc);
+                Location startLoc = WMSHelper.GetEmptyTrayStartLoc(0, exclude);
                 Location endLoc = LocationHelper.GetLoc(loc);
                 var agvJBLoc = Settings.getAgvJBLoc(loc);
-
-                if (startLoc != null && startLoc.N_CURRENT_NUM == 1 && agvJBLoc.type == 1)
-                {
-                   var locCntrRels = LocationHelper.GetLocCntrRel(startLoc.S_CODE);
-                    if (locCntrRels.Count > 0) 
-                    {
-                        var container = ContainerHelper.GetCntr(locCntrRels[0].S_CNTR_CODE);
-                        if (container.N_TYPE != 0) 
-                        {
-                            startLoc = null;
-                        }
-                    }
-                }
-               
-                if(startLoc == null || startLoc.N_CURRENT_NUM != 1) 
-                {
-                    startLoc = WMSHelper.GetEmptyTrayStartLoc(0);
-                }
 
                 if (startLoc != null)
                 {
@@ -819,6 +718,7 @@
                             S_END_AREA = endLoc.S_AREA_CODE,
                             S_TYPE = "姣嶆嫋鍑哄簱浠诲姟",
                             S_OP_DEF_CODE = taskNo,
+                            S_OP_DEF_NAME = "姣嶆嫋鍑哄簱浠诲姟",
                             N_PRIORITY = 1,
                             T_START_TIME = DateTime.Now,
                         };
@@ -877,15 +777,15 @@
         /// <param name="loc"></param>
         /// <param name="wmsTaskNo"></param>
         /// <returns></returns>
-        public static ReturnResult baseTrayOutStockAgv(string loc, string wmsTaskNo)
+        public static ReturnResult autoBaseTrayOutStock(string loc, string wmsTaskNo)
         {
             ReturnResult result = new ReturnResult();
             try
             {
-                var mst = WMSHelper.GetWmsTask(wmsTaskNo);
-                if (mst != null && mst.N_B_STATE < 2) 
+                var cst = WCSHelper.GetTaskByEnd(loc);
+                if (cst == null) 
                 {
-                    Location startLoc = WMSHelper.GetEmptyTrayStartLoc(0);
+                    Location startLoc = WMSHelper.GetEmptyTrayStartLoc(0, 0);
                     Location endLoc = LocationHelper.GetLoc(loc);
 
                     if (startLoc != null)
@@ -902,8 +802,7 @@
                             // 鍒涘缓鍏ュ簱浠诲姟
                             WCSTask wcsTask = new WCSTask()
                             {
-                                S_OP_NAME = mst.S_OP_DEF_NAME,
-                                S_OP_CODE = mst.S_CODE,
+                                S_OP_CODE = wmsTaskNo,
                                 S_CODE = WCSHelper.GenerateTaskNo(),
                                 S_CNTR_CODE = trayCode,
                                 S_TYPE = "姣嶆嫋鍑哄簱浠诲姟",
@@ -984,10 +883,9 @@
                                 TaskProcess.OperateStatus(cst, 6);
                                 break;
                             case 7:
-                                WCSHelper.UpdateStatus(cst, "寮傚父鍙栨秷");
+                                WCSHelper.Cancel(cst);
+                                WCSHelper.UpdateStatus(cst, "鍙栨秷");
                                 TaskProcess.OperateStatus(cst, 7);
-                                mst.N_B_STATE = 3;
-                                WMSHelper.UpdateTaskState(mst);
                                 break;
                             case 8:
                                 WCSHelper.UpdateStatus(cst, "寮哄埗瀹屾垚");
@@ -1004,7 +902,7 @@
                                 if(mst.N_B_STATE != 2)
                                 {
                                     // 鍒涘缓涓嬩釜浠诲姟
-                                    if (cst.S_TYPE.Contains("鍑哄簱") && !cst.S_TYPE.Contains("姣嶆嫋")) 
+                                    if (cst.S_TYPE.Contains("鍑哄簱") && !cst.S_TYPE.Contains("姣嶆嫋") && !cst.S_TYPE.Contains("浜哄伐")) 
                                     {
                                         WCSCore.createLastTask(cst.S_END_LOC, mst, 2);
                                     }
@@ -1015,6 +913,35 @@
                 }  
             }
             return responseResult;
+        }
+
+        /// <summary>
+        /// 璐т綅鐘舵�鍙嶉
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public static bool locStateFeedBack(LocStateFeedBackModel model)
+        {
+            bool result = false;
+            var task = WCSHelper.GetTask(model.req_no);
+            if (task != null)
+            {
+                TaskAction taskAction = null;
+                if (model.type == "1")
+                {
+                    taskAction = WCSHelper.getActionRecord(task.S_CODE, 1101);
+                }
+                if (model.type == "2")
+                {
+                    taskAction = WCSHelper.getActionRecord(task.S_CODE, 1103);
+                }
+                if (taskAction != null)
+                {
+                    taskAction.N_S_STATUS = 1;
+                    result = WCSHelper.updateActionRecord(taskAction);
+                }
+            }
+            return result;
         }
 
         /// <summary>
@@ -1111,22 +1038,15 @@
                 {
                     S_ITEM = matl.item,
                     S_BC_ENTRIED = matl.bc_entried,
+                    S_TOOLING_CODE = matl.toolineCode,
                     S_MCN = matl.mcn,
-                    S_OPR = matl.opr,
                     TXNDATE = DateTime.Parse(matl.txndate, enGB) ,
                     S_SHIFT = matl.shift,
                     N_QTY = matl.qty,
-                    N_STOCK = matl.stock,
-                    S_LOKASI = matl.lokasi,
-                    S_SARANA = matl.sarana,
-                    BOM1 = matl.bom1,
-                    BOM2 = matl.bom2,
-                    BOM3 = matl.bom3,
-                    S_FOVRAGE = matl.fovrage,
                     S_JDGE = matl.jdge,
-                    S_WMS_JDGE = matl.WMS_jdge,
-                    EFFECTIVE_TIME = matl.effective_time,
-                    EXPIRATION_TIME = matl.expiration_time,
+                    N_OVERAGE = matl.overagv,
+                    N_MINHOUR = matl.minhour,
+                    N_PRODUCT_TYPE_CODE = matl.productTypeCode,
                     LAST_MODIFY_TIME = matl.last_modify_time
                 };
                 itemBarcodeInfos.Add(itemBarcodeInfo);
@@ -1136,95 +1056,86 @@
             if (!bo) 
             {
                 responseResult.ResultCode = 1;
-                responseResult.ResultMsg = "鍚屾鐗╂枡鏉$爜淇℃伅澶辫触";
+                responseResult.ResultMsg = "鍚屾GT鏉$爜鐗╂枡淇℃伅澶辫触";
             }
             return responseResult;
         }
 
         /// <summary>
-        /// 鍚屾鐗╂枡鐘舵�淇℃伅
+        /// 鍚屾鏉$爜鐘舵�淇℃伅
         /// </summary>
         /// <param name="updateMatlStatuses"></param>
         /// <returns></returns>
-        public static ReturnResult synUpdateMatlStatus(List<UpdateMatlStatus> updateMatlStatuses)
+        public static ReturnResult synBarcodeStatus(List<UpdateMatlStatus> updateMatlStatuses)
         {
             ReturnResult responseResult = new ReturnResult();
-            var bo = WMSHelper.batchUpdateItemStatus(updateMatlStatuses);
-            if (!bo)
+            List<iWMS_semi_bld_BCstatus> list = new List<iWMS_semi_bld_BCstatus> ();
+            if (updateMatlStatuses.Count > 0) 
             {
-                responseResult.ResultCode = 1;
-                responseResult.ResultMsg = "鍚屾鐗╂枡鐘舵�淇℃伅澶辫触";
-            }
-            return responseResult;
-        }
-
-        /// <summary>
-        /// 鍚屾鏇存柊鐗╂枡瀛樻斁鏃堕棿閰嶇疆淇℃伅
-        /// </summary>
-        /// <param name="overages"></param>
-        /// <returns></returns>
-        public static ReturnResult synUpdateMatlTimeConfig(List<MatlOverage> overages)
-        {
-            ReturnResult responseResult = new ReturnResult();
-            if (overages != null && overages.Count > 0) 
-            {
-                List<Overage> overageList = new List<Overage>();
-
-                foreach (var item in overages)
+                foreach (var item in updateMatlStatuses)
                 {
-                    Overage overage = new Overage
+                    iWMS_semi_bld_BCstatus bCstatus = new iWMS_semi_bld_BCstatus() 
                     {
-                        MCNGRP = item.mcngrp,
-                        ITEMPATT = item.itempatt,
-                        OVERAGE = item.overage,
-                        MINHOUR = int.Parse(item.minhour.ToString()) ,
-                        FLAG_STS = item.flag_sts,
+                        S_BC_ENTRIED = item.bc_entried,
+                        S_MCNGRP = item.mcngrp,
+                        S_JDGE = item.jdge,
+                        LAST_MODIFY_TIME = item.last_modify_time
                     };
-                    overageList.Add(overage);
+                    list.Add(bCstatus);
                 }
-                var bo = WMSHelper.batchUpdateMatlTimeConfig(overageList);
+
+                var bo = WMSHelper.synBarcodeStatus(list);
                 if (!bo)
                 {
                     responseResult.ResultCode = 1;
-                    responseResult.ResultMsg = "鍚屾鐗╂枡鐘舵�淇℃伅澶辫触";
+                    responseResult.ResultMsg = "鍚屾鏉$爜鐘舵�淇℃伅澶辫触";
                 }
             }
             return responseResult;
         }
 
         /// <summary>
-        /// 璁板綍鏁版嵁鍚屾鏃堕棿
+        /// 鍚屾鏉$爜鐘舵�淇℃伅
         /// </summary>
-        /// <param name="model"></param>
+        /// <param name="updateMatlStatuses"></param>
         /// <returns></returns>
-        public static ReturnResult recordDataSynTime(RecordDataSynTimeModel model)
+        public static ReturnResult synSamplingStatus(List<UpdateMatlStatus> updateMatlStatuses)
         {
             ReturnResult responseResult = new ReturnResult();
-            SynDataTimeRecord record = new SynDataTimeRecord() 
+            List<iWMS_semi_bld_BCsample> list = new List<iWMS_semi_bld_BCsample>();
+            if (updateMatlStatuses.Count > 0)
             {
-                S_SYN_TIME = model.sysTime,
-                N_SYN_NUM = model.synNum,
-                RECORD_TABLE = model.recordTable
-            }; 
-            var bo = WMSHelper.addSynDataTimeReord(record);
-            if (!bo)
-            {
-                responseResult.ResultCode = 1;
-                responseResult.ResultMsg = "鍚屾鐗╂枡鐘舵�淇℃伅澶辫触";
+                foreach (var item in updateMatlStatuses)
+                {
+                    iWMS_semi_bld_BCsample bCstatus = new iWMS_semi_bld_BCsample()
+                    {
+                        S_BC_ENTRIED = item.bc_entried,
+                        S_MCNGRP = item.mcngrp,
+                        S_JDGE = item.jdge,
+                        LAST_MODIFY_TIME = item.last_modify_time
+                    };
+                    list.Add(bCstatus);
+                }
+
+                var bo = WMSHelper.synSamplingStatus(list);
+                if (!bo)
+                {
+                    responseResult.ResultCode = 1;
+                    responseResult.ResultMsg = "鍚屾鏉$爜鐘舵�淇℃伅澶辫触";
+                }
             }
             return responseResult;
         }
-
 
         /// <summary>
         /// 鏌ヨ涓婁竴娆$殑鏁版嵁鍚屾鏃堕棿
         /// </summary>
-        /// <param name="recordTable"></param>
+        /// <param name="tableType"></param>
         /// <returns></returns>
-        public static ReturnResult findLastDataSynTime(string recordTable)
+        public static ReturnResult findDataLastSynTime(int tableType)
         {
             ReturnResult responseResult = new ReturnResult();
-            var synDataTime = WMSHelper.getLastDataSynTime(recordTable);
+            var synDataTime = WMSHelper.getDataLastSynTime(tableType);
             responseResult.data = synDataTime;
             return responseResult;
         }
@@ -1290,9 +1201,11 @@
         public class CreateOutOrderModel
         {
             public string taskNo { get; set; } // 浠诲姟鍙�+            public string trayCode { get; set; } // 鎵樼洏鍙�             public string itemCode { get; set; } // 鐗╂枡缂栫爜
             public string endLoc { get; set; } // 缁堢偣璐т綅
             public int priority { get; set; } = 0; // 浼樺厛绾�榛樿0
+            public int taskType { get; set; } = 1; // 1.鎴愬瀷鏈哄彨鏂欎换鍔�2.鎶芥鍑哄簱浠诲姟
         }
 
         public class EmptyTrayOutOrderModel
@@ -1317,16 +1230,15 @@
         {
             public string item { get; set; } // 鐗╁搧浠g爜
             public string bc_entried { get; set; } // 鏉″舰鐮佺紪鍙�+            public string toolineCode { get; set; } // 宸ヨ鏉$爜
             public string mcn { get; set; } // 鏈哄櫒浠g爜缂栧彿
-            public string opr { get; set; } // 鎿嶄綔鍛�             public string txndate { get; set; } // 鐢熶骇鏃堕棿
             public string shift { get; set; } // 宸ヤ綔鐝
             public int qty { get; set; } // 浜у搧鏁伴噺
-            public string sarana { get; set; } // 浜у搧鏉愭枡鐨勬墭鐩�鐩�鎺ㄨ溅/璐ц溅ID
-            public string fovrage { get; set; } // 鏄惁杩囨湡鐨勭姸鎬�Y=杩囨湡锛孨=鏈繃鏈�-            public string jdge { get; set; } // 璐ㄩ噺鐘舵� OK=浜у搧鍚堟牸锛孨G=浜у搧涓嶅悎鏍硷紝HLM=浜у搧寰呭畾
-            public string effective_time { get; set; } // 鐢熸晥鏃堕棿 (yyyy-MM-dd HH:mm:ss)
-            public string expiration_time { get; set; } // 澶辨晥鏃堕棿 (yyyy-MM-dd HH:mm:ss)
+            public string jdge { get; set; } // 璐ㄩ噺鐘舵� OK=浜у搧鍚堟牸锛孒OLD = 浜у搧寰呭畾
+            public int overage { get; set; } // 鐢熸晥鏃堕棿 (yyyy-MM-dd HH:mm:ss)
+            public int minhour { get; set; } // 澶辨晥鏃堕棿 (yyyy-MM-dd HH:mm:ss)
+            public int productTypeCode { get; set; } // 澶辨晥鏃堕棿 (yyyy-MM-dd HH:mm:ss)
         }
 
         

--
Gitblit v1.9.1