From b04c7a175efa4cc5097729dcfd9bbea9b8cd0df2 Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期二, 24 十二月 2024 13:02:00 +0800
Subject: [PATCH] 合并

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs       |    4 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs                    |   34 ++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs    |   15 +
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs                       |   12 +
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs                             |    9 +
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs                     |   48 ++++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs             |    2 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                                    |    3 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs |    6 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs                   |    2 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs            |  211 ++++++++++++++++-------------
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs                   |    4 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs       |   18 ++
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_StationManager.cs                   |    1 
 Code Management/WCS/WIDESEAWCS_Client/src/api/http.js                                                       |    4 
 15 files changed, 255 insertions(+), 118 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Client/src/api/http.js b/Code Management/WCS/WIDESEAWCS_Client/src/api/http.js
index bd5780f..de9cdc7 100644
--- a/Code Management/WCS/WIDESEAWCS_Client/src/api/http.js
+++ b/Code Management/WCS/WIDESEAWCS_Client/src/api/http.js
@@ -12,8 +12,8 @@
 let loadingInstance;
 let loadingStatus = false;
 if (process.env.NODE_ENV == 'development') {
-    axios.defaults.baseURL = 'http://127.0.0.1:9291/';
-    // axios.defaults.baseURL = 'http://192.168.5.251:9291/';
+     axios.defaults.baseURL = 'http://127.0.0.1:9291/';
+    //axios.defaults.baseURL = 'http://192.168.5.251:9291/';
 }
 else if (process.env.NODE_ENV == 'debug') {
     axios.defaults.baseURL = 'http://127.0.0.1:8098/';
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs
index f226258..7e70e6f 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/dt_needBarcode.cs
@@ -56,7 +56,7 @@
         /// <summary>
         /// 宸插垱寤哄嚭搴撲换鍔℃暟閲�
         /// </summary>
-        [NotMapped]
-        public int haveOutNum { get; set; } = 0;
+        //[NotMapped]
+        //public int haveOutNum { get; set; } = 0;
     }
 }
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
index 44f23f1..860d38a 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
@@ -14,6 +14,9 @@
   //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
   //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=True",
   //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=True",
+  //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   "ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //璺ㄥ煙
   "Cors": {
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
index 5923b5e..590d8b3 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -13,6 +13,7 @@
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob.Models;
+using System.Drawing;
 
 namespace WIDESEAWCS_TaskInfoService
 {
@@ -93,6 +94,7 @@
 
                 var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString());
                 content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+                ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}绔欏彴璇锋眰鍝嶅簲淇℃伅:{content.ToJsonString()}");
                 if (!content.Status)
                 {
                     // wms澶辫触杩斿洖鍘籒G鍙d换鍔�
@@ -137,7 +139,7 @@
                 }
                 var wmsIpAddrss = wmsBase + requestTask;
 
-                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { }.ToJsonString());
+                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = stationManager.stationChildCode }.ToJsonString());
                 content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                 if (!content.Status)
                 {
@@ -147,7 +149,7 @@
 
                 var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                 ConsoleHelper.WriteSuccessLine(content.Data.ToString());
-                content = ReceiveByWMSTask(task);
+                content = ReceiveByBZOtuTask(task);
                 //if (content.Status)
                 //{
                 //    //鐩稿簲鐨勫湪閫旀暟鎹�+1
@@ -218,6 +220,46 @@
             }
             return content;
         }
+
+        /// <summary>
+        /// 鎺ユ敹WMS浠诲姟淇℃伅
+        /// </summary>
+        /// <param name="taskDTOs">WMS浠诲姟瀵硅薄闆嗗悎</param>
+        /// <returns>杩斿洖澶勭悊缁撴灉</returns>
+        public WebResponseContent ReceiveByBZOtuTask([NotNull] WMSTaskDTO taskDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode) != null)
+                {
+                    return content.OK();
+                }
+                Dt_Task task = _mapper.Map<Dt_Task>(taskDTO);
+                task.Creater = "WMS";
+
+                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                {
+                    var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay);
+                    task.TaskState = (int)TaskOutStatusEnum.OutNew;
+                    task.CurrentAddress = stationinfo.stationChildCode;
+                    task.NextAddress = stationinfo.stationChildCode;
+                    task.SourceAddress = taskDTO.SourceAddress;
+                    task.TargetAddress = taskDTO.TargetAddress;
+                }
+                BaseDal.AddData(task);
+
+                _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "鎺ユ敹WMS浠诲姟");
+
+                content = WebResponseContent.Instance.OK("鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
+            }
+            return content;
+        }
+
 
         /// <summary>
         /// 楂樻俯鍑哄簱
@@ -296,7 +338,7 @@
         }
 
         /// <summary>
-        /// 鏍规嵁鎵樼洏鍙峰拰璁惧鍙锋煡璇㈠叆搴撲换鍔�
+        /// 鏍规嵁鎵樼洏鍙峰拰璁惧鍙锋煡璇换鍔�
         /// </summary>
         /// <param name="taskNum">浠诲姟鍙�</param>
         /// <param name="currentAddress">褰撳墠鍦板潃</param>
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index f18b745..d630db8 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -503,6 +503,15 @@
                         BaseDal.DeleteData(task);
                         _taskHtyRepository.AddData(task_Hty);
                     }
+                    if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
+                    {
+                        Dt_Task? tasks = UpdatePosition(task.TaskNum, task.CurrentAddress);
+                        if (tasks != null)
+                        {
+                            task.CurrentAddress = tasks.CurrentAddress;
+                            task.NextAddress = tasks.NextAddress;
+                        }
+                    }
                 }
                 else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                 {
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
index ae2d148..fb3c7b2 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
@@ -188,11 +188,11 @@
                 }
                 else   //濡傛灉浠诲姟璇锋眰澶辫触 
                 { 
-                    //濡傛灉璇锋眰浣嶇疆涓嶯G浣嶇疆涓�鐩� 鍒欏啓褰撳墠浣嶇疆璁╃嚎浣撻��鍥�
+                    //濡傛灉璇锋眰浣嶇疆涓嶯G浣嶇疆涓�鑷� 鍒欏啓褰撳墠浣嶇疆璁╃嚎浣撻��鍥�
                     if (stationInfo.stationChildCode == stationInfo.stationNGChildCode)
                     {
-                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, stationInfo.stationChildCode);
-                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationInfo.stationChildCode, stationInfo.stationChildCode);
+                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 2, stationInfo.stationChildCode);
+                        //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationInfo.stationChildCode, stationInfo.stationChildCode);
                     }
                 }
             }
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
index b498b61..9aa4687 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
@@ -193,7 +193,7 @@
         public void RequestOutbound(CommonConveyorLine_BZ conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager station)
         {
             //鏌ヨ瀵瑰簲浜х嚎鐨勫湪閫旀暟鎹�
-            dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine);
+            dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine && x.toArea == station.stationChildCode);
 
             needBarcode.inLineNum = _taskRepository.QueryData(x => x.TargetAddress == station.stationChildCode).Count();
 
@@ -260,7 +260,7 @@
                 }
                 else
                 {
-                    //鍐欏叆瀵瑰簲浜х嚎鐩爣鍦板潃
+                    //鍐欏叆瀵瑰簲浜х嚎鐨勭洰鏍囧湴鍧�
                     if (station.productLine == "ZJ-7")
                     {
                         conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, "", station.stationChildCode);
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
index f637dd2..63f98fd 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -382,6 +382,24 @@
                 //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                 content = _taskService.UpdateTaskStatusToNext(task);
             }
+            //else
+            //{
+            //    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode && x.stationArea == "Cache");
+            //    ////鏌ヨ瀵瑰簲浜х嚎鐨勫湪閫旀暟鎹�
+            //    //dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine);
+
+            //    //needBarcode.inLineNum = _taskRepository.QueryData(x => x.TargetAddress == station.stationChildCode).Count();
+
+            //    //鑻ュ湪閫旀暟閲忓皬浜庣洰鏍囦綅缃殑缂撳瓨鏁伴噺 鍒欏鎵惧搴斿父娓╁簱瀛樹腑甯告俯3宸ュ簭鐨勫彲鍑哄簱鏁版嵁 骞跺缓绔嬪嚭搴撲换鍔�
+            //    //if (needBarcode.inLineNum <= needBarcode.cacheNum)
+            //    //{
+            //    //}
+            //    //濡傛灉鍖呰缂撳瓨绔欏彴瀛樺湪 涓旀湁璇锋眰  鍒�
+            //    if (stationManager != null)
+            //    {
+            //        _taskService.RequestOutTaskToBZAsync(stationManager);
+            //    }
+            //}
         }
 
         /// <summary>
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 232f01e..c9b8c07 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -338,7 +338,7 @@
                 {
                     return candidateTask;
                 }
-                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵occupiedStation.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵occupiedStation.NextAddress}銆戜笉鍏佽鏀捐揣");
+                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵candidateTask.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵candidateTask.NextAddress}銆戜笉鍏佽鏀捐揣");
             }
 
             return null;
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
index 9711018..42d16dd 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -183,7 +183,7 @@
                 {
                     // 濡傛灉褰撳墠鍑哄簱浠诲姟绔欏彴涓嶅厑璁告斁璐э紝鎺掗櫎褰撳墠浠诲姟锛屾煡鎵惧叾浠栧嚭搴撲换鍔�
                     ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵task.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵task.NextAddress}銆戜笉鍏佽鏀捐揣");
-                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId);
+                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                 }
                 else
                 {
@@ -223,16 +223,19 @@
         }
 
         /// <summary>
-        /// 鏌ユ壘鍏朵粬鍑哄簱浠诲姟鐨勮緟鍔╂柟娉曪紙鎺掗櫎鎸囧畾浠诲姟ID鐨勪换鍔★級
+        /// 鏌ユ壘鍏朵粬鍑哄簱浠诲姟鐨勮緟鍔╂柟娉曪紙鎺掗櫎涓嶅彲鍑虹殑鍑哄簱鍙d换鍔★級
         /// </summary>
         /// <param name="deviceCode">璁惧浠g爜</param>
         /// <param name="excludedTaskId">瑕佹帓闄ょ殑浠诲姟ID</param>
         /// <returns></returns>
-        private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId)
+        private Dt_Task? FindAnotherOutboundTask(string deviceCode, Dt_Task task)
         {
-            // 鍏堣幏鍙栨墍鏈夌鍚堟潯浠讹紙鎺掗櫎鎸囧畾浠诲姟ID锛夌殑鍑哄簱浠诲姟鍒楄〃
+            // 鍏堣幏鍙栨墍鏈夌鍚堟潯浠讹紙鎺掗櫎涓嶅彲鍑虹殑锛夌殑鍑哄簱浠诲姟鍒楄〃
             var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode);
-            var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList();
+            Console.WriteLine(allOutboundTasks.Count);
+            var availableTasks = allOutboundTasks?.Where(t => t.TargetAddress != task.TargetAddress && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList();
+
+            Console.WriteLine("鍏朵粬鍑哄簱鍙d换鍔★細" + availableTasks?.Count);
 
             if (availableTasks == null || availableTasks.Count == 0)
             {
@@ -247,7 +250,7 @@
                 {
                     return candidateTask;
                 }
-                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵occupiedStation.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵occupiedStation.NextAddress}銆戜笉鍏佽鏀捐揣");
+                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵candidateTask.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵candidateTask.NextAddress}銆戜笉鍏佽鏀捐揣");
             }
 
             return null;
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
index 5338032..557390a 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
@@ -212,4 +212,6 @@
     /// <returns></returns>
     WebResponseContent EmergencyTask(object obj);
 
+    Task<WebResponseContent> RequestOutTaskToBZAsync(RequestTaskDto json);
+
 }
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_StationManager.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_StationManager.cs
index 5c7c210..ba205fc 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_StationManager.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_StationManager.cs
@@ -109,6 +109,7 @@
         public string stationNGLocation { get; set; }
         public string remark { get; set; }
 
+        public string stationStatus { get; set; }
         /// <summary>
         /// 浜х嚎
         /// </summary>
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 1764161..48cd4a9 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -455,7 +455,7 @@
             Remark = boxing.BoxingInfoDetails.Count().ToString(),
         };
 
-        if (boxing.ProcessCode != "OCVB")
+        if (boxing.ProcessCode != "OCVB" && !task.Roadway.Contains("FR"))
         {
             // 澶勭悊璇锋眰鍙傛暟
             AgingInputDto agingInputDto = new AgingInputDto()
@@ -1471,7 +1471,35 @@
     {
         return await BaseDal.Delete(ids);
     }
+    public override WebResponseContent DeleteData(object[] key)
+    {
+        WebResponseContent content = new WebResponseContent();
+        // 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷
+        try
+        {
+            Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0]));
+            if (task == null)
+            {
+                return content.Error("鏈壘鍒颁换鍔′俊鎭�!");
+            }
+            var taskHtyNG = CreateHistoricalTask(task, true);
 
+            // 鎵ц鏁版嵁搴撲簨鍔�
+
+            // 娣诲姞鍘嗗彶浠诲姟
+            var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
+
+            // 鍒犻櫎浠诲姟鏁版嵁
+            var isTaskDelete = BaseDal.Delete(task.TaskId);
+
+            return content.OK("鍒犻櫎鎴愬姛!");
+        }
+        catch (Exception ex)
+        {
+            return content.Error("鍒犻櫎浠诲姟寮傚父锛�" + ex.Message);
+        }
+
+    }
     /// <summary>
     /// 閫氳繃ID鑾峰彇浠诲姟
     /// </summary>
@@ -1581,7 +1609,7 @@
     /// </summary>
     /// <param name="task"></param>
     /// <returns></returns>
-    private Dt_Task_Hty CreateHistoricalTask(Dt_Task task)
+    private Dt_Task_Hty CreateHistoricalTask(Dt_Task task, bool isHand = false)
     {
         // 鏇存柊浠诲姟鐘舵��
         task.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt();
@@ -1591,7 +1619,7 @@
         var taskHty = _mapper.Map<Dt_Task_Hty>(task);
         taskHty.FinishTime = DateTime.Now;
         taskHty.TaskId = 0;
-        taskHty.OperateType = (int)OperateTypeEnum.鑷姩瀹屾垚;
+        taskHty.OperateType = isHand ? (int)OperateTypeEnum.浜哄伐鍒犻櫎 : (int)OperateTypeEnum.鑷姩瀹屾垚;
         taskHty.SourceId = task.TaskId;
         taskHty.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt();
         return taskHty;
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 559f10b..af55b8a 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -163,105 +163,121 @@
 
     private async Task<Dt_Task> CreateInToOutTaskAsync(RequestTaskDto input, Dt_StationManager stationManager)
     {
-        //if (stationManager.stationType != 5) throw new Exception("閿欒鐨勮皟鍙�");
-
-        input.EquiCodeMOM = "24MEJQ11-1006-1";
-
-        // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪��
-        TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
+        try
         {
-            Software = "WMS",
-            TrayBarcode = input.PalletCode,
-            //EquipmentCode = "EQ_CWJZ01"
-            EquipmentCode = input.EquiCodeMOM
-        };
+            //if (stationManager.stationType != 5) throw new Exception("閿欒鐨勮皟鍙�");
 
-        // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺�
-        WebResponseContent content = await GetTrayCellStatusAsync(trayCells);
-        // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖content
-        if (!content.Status) throw new Exception(content.Message);
+            input.EquiCodeMOM = "24MEJQ11-1006-1";
 
-        // 娣诲姞缁勭洏淇℃伅
-        // 灏哻ontent.Data杞崲涓篟esultTrayCellsStatus瀵硅薄
-        var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
-        if (result.SerialNos.Count <= 0)
-        {
-            ConsoleHelper.WriteErrorLine(result.MOMMessage);
-            if (stationManager.stationType != 3)
+            // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪��
+            TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
             {
-                var taskNG = new Dt_Task
+                Software = "WMS",
+                TrayBarcode = input.PalletCode,
+                //EquipmentCode = "EQ_CWJZ01"
+                EquipmentCode = input.EquiCodeMOM
+            };
+
+            // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺�
+            WebResponseContent content = await GetTrayCellStatusAsync(trayCells);
+            // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖content
+            if (!content.Status) throw new Exception(content.Message);
+
+            // 缁勭洏淇℃伅
+            // 灏哻ontent.Data杞崲涓篟esultTrayCellsStatus瀵硅薄
+            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
+            if (result.SerialNos.Count <= 0)
+            {
+                ConsoleHelper.WriteErrorLine(result.MOMMessage);
+                if (stationManager.stationType != 3)
                 {
-                    CurrentAddress = input.Position,
-                    Grade = 3,
-                    Roadway = input.Roadways,
-                    TargetAddress = stationManager.stationNGLocation,
-                    Dispatchertime = DateTime.Now,
-                    MaterialNo = "",
-                    NextAddress = stationManager.stationNGChildCode,
-                    OrderNo = null,
-                    PalletCode = input.PalletCode,
-                    SourceAddress = stationManager.stationLocation,
-                    TaskState = (int)TaskInStatusEnum.Line_InFinish,
-                    TaskType = (int)TaskOutboundTypeEnum.InToOut,
-                    TaskNum = await BaseDal.GetTaskNo(),
-                    Creater = "Systeam"
-                };
-                return taskNG;
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        // 澶勭悊寮傚父鐢佃姱鎯呭喌
-        var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1).ToList();
-        if (serialNosError.Count > 0)
-        {
-            if (stationManager.stationType != 3)
-            {
-                var taskNG = new Dt_Task
+                    var taskNG = new Dt_Task
+                    {
+                        CurrentAddress = input.Position,
+                        Grade = 3,
+                        Roadway = input.Roadways,
+                        TargetAddress = stationManager.stationNGLocation,
+                        Dispatchertime = DateTime.Now,
+                        MaterialNo = "",
+                        NextAddress = stationManager.stationNGChildCode,
+                        OrderNo = null,
+                        PalletCode = input.PalletCode,
+                        SourceAddress = stationManager.stationLocation,
+                        TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                        TaskType = (int)TaskOutboundTypeEnum.InToOut,
+                        TaskNum = await BaseDal.GetTaskNo(),
+                        Creater = "Systeam"
+                    };
+                    return taskNG;
+                }
+                else
                 {
-                    CurrentAddress = input.Position,
-                    Grade = 1,
-                    Roadway = input.Roadways,
-                    TargetAddress = stationManager.stationNGLocation,
-                    Dispatchertime = DateTime.Now,
-                    MaterialNo = "",
-                    NextAddress = stationManager.stationNGChildCode,
-                    OrderNo = null,
-                    PalletCode = input.PalletCode,
-                    SourceAddress = stationManager.stationLocation,
-                    TaskState = (int)TaskInStatusEnum.Line_InFinish,
-                    TaskType = (int)TaskOutboundTypeEnum.OutNG,
-                    TaskNum = await BaseDal.GetTaskNo(),
-                    Creater = "Systeam"
-                };
-                return taskNG;
+                    //鏃犵數鑺� 鈫� 褰撶┖妗嗭紵 杩樻槸杩斿洖寮傚父锛�
+                    return null;
+                }
             }
+
+            // 澶勭悊寮傚父鐢佃姱鎯呭喌
+            var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1).ToList();
+            if (serialNosError.Count > 0)
+            {
+                if (stationManager.stationType != 3)
+                {
+                    var taskNG = new Dt_Task
+                    {
+                        CurrentAddress = input.Position,
+                        Grade = 1,
+                        Roadway = input.Roadways,
+                        TargetAddress = stationManager.stationNGLocation,
+                        Dispatchertime = DateTime.Now,
+                        MaterialNo = "",
+                        NextAddress = stationManager.stationNGChildCode,
+                        OrderNo = null,
+                        PalletCode = input.PalletCode,
+                        SourceAddress = stationManager.stationLocation,
+                        TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                        TaskType = (int)TaskOutboundTypeEnum.InToOut,
+                        TaskNum = await BaseDal.GetTaskNo(),
+                        Creater = "Systeam"
+                    };
+                    return taskNG;
+                }
+                else
+                {
+                    Console.WriteLine($"绔欏彴{stationManager.stationChildCode}MOM杩斿洖鐢佃姱寮傚父:{result.MOMMessage}");
+                    return null;
+                }
+            }
+            //else
+            //{
+            //    throw new Exception($"绔欏彴{stationManager.stationChildCode}MOM杩斿洖鐢佃姱寮傚父:{result.MOMMessage}");
+            //}
+
+            var targetStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == stationManager.stationPLC && x.Roadway == stationManager.Roadway && x.stationType == 2);
+
+            var task = new Dt_Task
+            {
+                CurrentAddress = input.Position,
+                Grade = 3,
+                Roadway = input.Roadways,
+                TargetAddress = targetStation.stationLocation,
+                Dispatchertime = DateTime.Now,
+                MaterialNo = "",
+                NextAddress = input.Roadways,
+                OrderNo = null,
+                PalletCode = input.PalletCode,
+                SourceAddress = stationManager.stationLocation,
+                TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                TaskType = (int)TaskOutboundTypeEnum.InToOut,
+                TaskNum = await BaseDal.GetTaskNo(),
+                Creater = "Systeam"
+            };
+            return task;
         }
-
-        var targetStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == stationManager.stationPLC && x.Roadway == stationManager.Roadway && x.stationType == 2);
-
-        var task = new Dt_Task
+        catch (Exception ex)
         {
-            CurrentAddress = input.Position,
-            Grade = 1,
-            Roadway = input.Roadways,
-            TargetAddress = targetStation.stationLocation,
-            Dispatchertime = DateTime.Now,
-            MaterialNo = "",
-            NextAddress = input.Roadways,
-            OrderNo = null,
-            PalletCode = input.PalletCode,
-            SourceAddress = stationManager.stationLocation,
-            TaskState = (int)TaskInStatusEnum.Line_InFinish,
-            TaskType = (int)TaskOutboundTypeEnum.InToOut,
-            TaskNum = await BaseDal.GetTaskNo(),
-            Creater = "Systeam"
-        };
-
-        return task;
+            throw new Exception(ex.Message);
+        }
     }
 
     #endregion 鐩存帴鍑哄簱浠诲姟
@@ -521,7 +537,8 @@
         {
             //娣诲姞鍘嗗彶
             var taskHty = CreateHistoricalTask(task);
-
+            // 娣诲姞鍘嗗彶浠诲姟
+            var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;
             //鍒犻櫎浠诲姟
             BaseDal.DeleteData(task);
 
@@ -578,7 +595,7 @@
                 var Epmtytask = new Dt_Task
                 {
                     CurrentAddress = input.Position,
-                    Grade = 3,  //浼樺厛澶勭悊寮傚父鎺掑嚭鍙g殑浠诲姟 闃叉姝e父闇�鎺掑嚭寮傚父鍙g殑浠诲姟鍫电嚎
+                    Grade = 4,  //浼樺厛澶勭悊寮傚父鎺掑嚭鍙g殑浠诲姟 闃叉姝e父闇�鎺掑嚭寮傚父鍙g殑浠诲姟鍫电嚎
                     Roadway = input.Roadways,
                     TargetAddress = EmptylocationInfo.LocationCode,
                     Dispatchertime = DateTime.Now,
@@ -846,20 +863,21 @@
         WebResponseContent content = new WebResponseContent();
         try
         {
-            Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position);
+            Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call");
 
             DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == station.productLine);
             if (stockInfo == null) throw new Exception("搴撳唴鏃犳弧瓒虫潯浠剁殑搴撳瓨鍙嚭搴�");
 
-            Dt_StationManager OutStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1016" && x.stationType == 10);
+            DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode);
 
+            Dt_StationManager OutStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1016" && x.stationType == 10 && x.Roadway == locationInfo.RoadwayNo && x.stationStatus == "1");
 
             // 鍒涘缓鏂颁换鍔″疄渚�
             var task = new Dt_Task
             {
-                CurrentAddress = stockInfo.LocationInfo.RoadwayNo,
+                CurrentAddress = locationInfo.RoadwayNo,
                 Grade = 1,
-                Roadway = stockInfo.LocationInfo.RoadwayNo,
+                Roadway = locationInfo.RoadwayNo,
                 TargetAddress = json.Position,
                 Dispatchertime = DateTime.Now,
                 MaterialNo = "",
@@ -880,6 +898,7 @@
         }
         catch (Exception ex)
         {
+            Console.WriteLine($"CW3鑷冲寘瑁呭嚭搴撳紓甯�:{ex.ToString()}");
             return content.Error($"澶辫触锛歿ex.Message}");
         }
     }
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
index e7c31d9..53d61a3 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
@@ -178,4 +178,16 @@
     //{
     //    //return Service.EmergencyTask(input);
     //}
+
+
+    /// <summary>
+    /// CW3 鍑哄簱鑷冲寘瑁�
+    /// </summary>
+    /// <param name="input">璇锋眰鏁版嵁</param>
+    /// <returns></returns>
+    [HttpPost, AllowAnonymous, Route("RequestOutTaskToBZAsync")]
+    public async Task<WebResponseContent> RequestOutTaskToBZAsync([FromBody] RequestTaskDto input)
+    {
+        return await Service.RequestOutTaskToBZAsync(input);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3