From 261ec6b250b3aea2d26e629203c7d699747c27ea Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 03 二月 2026 17:02:04 +0800
Subject: [PATCH] 空托回流区分叠盘或直接回立库

---
 /dev/null                                                                     |    0 
 项目代码/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs               |    6 ++
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs           |   98 ++++++++++++++++++++++----------
 项目代码/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs |    2 
 项目资料/通信协议/成品输送线通讯协议_20250707.xlsx                                             |    0 
 项目代码/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs       |    4 
 项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs                |   10 ++-
 项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/StackPlateJob/StackPlate.cs             |    8 +-
 项目代码/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs                 |    3 
 项目代码/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs                  |    6 ++
 10 files changed, 95 insertions(+), 42 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs"
index b56670b..74f749c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs"
@@ -148,6 +148,12 @@
         EmptyProductBack = 630,
 
         /// <summary>
+        /// 绌烘墭鍙犵洏
+        /// </summary>
+        [Description("绌烘墭鍙犵洏")]
+        EmptyStackPlate = 635,
+
+        /// <summary>
         /// 鍒嗗垏鍗婃垚鍝佸叆搴�
         /// </summary>
         [Description("鍒嗗垏鍗婃垚鍝佸叆搴�")]
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
index 6db9852..05a3d45 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
@@ -262,7 +262,7 @@
                             {
                                 throw new Exception($"{task.NextAddress}AGV绔欏彴鏈畾涔�");
                             }
-                            if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt())
+                            if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt() || task.TaskType == TaskTypeEnum.EmptyStackPlate.ObjToInt())
                             {
                                 List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.NextAddress == x.StartPosi);
                                 Dt_Router router = routers.FirstOrDefault();
@@ -278,7 +278,7 @@
                                 _taskService.UpdateTask(task, TaskStatusEnum.AGV_Finish);
                                 PutFinish(oldAddress, task.TaskNum);
                             }
-                            else if (task.TaskType == TaskTypeEnum.WFBLMYLBackInbound.ObjToInt() || task.TaskType == TaskTypeEnum.WFBYLInbound.ObjToInt())
+                            else if (task.TaskType == TaskTypeEnum.WFBLMYLBackInbound.ObjToInt() || task.TaskType == TaskTypeEnum.WFBYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.WFBLMYLInbound.ObjToInt())
                             {
                                 _taskService.TaskCompleted(task.TaskNum);
                             }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
index ccfabbc..9ea819c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -243,7 +243,7 @@
                             //鍏ュ簱
                             if (taskTypeGroup == TaskTypeGroup.InboundGroup)
                             {
-                                if (router.NextPosi == "AGV" && router.StartPosi=="AGV")
+                                if (router.NextPosi == "AGV" && router.StartPosi=="AGV") //鏃犵汉甯�&绾告澂绾哥墖渚涙枡
                                 {
                                     task.CurrentAddress = item.SourceAddress;
                                     task.NextAddress = item.TargetAddress;
@@ -265,8 +265,7 @@
                         }
                         else
                         {
-                            //鎴愬搧鐮佸灈浠诲姟鐢熸垚
-                            if (taskTypeGroup == TaskTypeGroup.InboundGroup && !task.Roadway.Contains("YL"))
+                            if (taskTypeGroup == TaskTypeGroup.InboundGroup && !task.Roadway.Contains("YL")) //鎴愬搧鐮佸灈浠诲姟鐢熸垚
                             {
                                 task.CurrentAddress = router.StartPosi;
                                 task.NextAddress = "";
@@ -299,7 +298,10 @@
                             if (routers.Count == 1)
                             {
                                 task.NextAddress = router.NextPosi;
-                                task.DeviceCode = router.ChildPosi;
+                                if (task.Roadway.Contains("StackPlate"))
+                                    task.DeviceCode = router.ChildPosiDeviceCode;
+                                else
+                                    task.DeviceCode = router.ChildPosi;
                             }
                         }
                         
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/StackPlateJob/StackPlate.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/StackPlateJob/StackPlate.cs"
index bf9f142..3d671f7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/StackPlateJob/StackPlate.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/StackPlateJob/StackPlate.cs"
@@ -10,6 +10,7 @@
 using WIDESEAWCS_IPackInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
@@ -68,7 +69,7 @@
             var station = _stationMangerRepository.QueryFirst(x => x.StationDeviceCode == device.DeviceCode);
             if (station != null && station.Remark != null)//鑾峰彇绔欏彴閲岄潰鐨勬墭鐩樺彿
             {
-                var task = _taskRepository.QueryFirst(x => x.DeviceCode == device.DeviceCode && (x.TaskState == (int)TaskStatusEnum.AGV_Execute || x.TaskState == (int)TaskStatusEnum.AGV_Executing) && x.SourceAddress == station.AGVStationCode);
+                var task = _taskRepository.QueryData(x => x.SourceAddress == device.DeviceCode && (x.TaskState == (int)TaskStatusEnum.AGV_Execute || x.TaskState == (int)TaskStatusEnum.AGV_Executing));
                 if (task == null)
                 {
                     WebResponseContent content = _taskService.CPEmptyInbound(station.Remark, station.AGVStationCode);
@@ -87,12 +88,13 @@
             var tasks = _taskRepository.QueryData(x => x.Roadway == device.DeviceCode && (x.TaskState == (int)TaskStatusEnum.AGV_Execute || x.TaskState == (int)TaskStatusEnum.AGV_Executing) && x.TargetAddress == device.DeviceCode);
             if (tasks.Count + Convert.ToInt32(command.Num) < 9)
             {
-                var task = _taskRepository.QueryFirst(x => x.Roadway == device.DeviceCode && x.TaskState == (int)TaskStatusEnum.StackPlate_Execute);
+                var task = _taskRepository.Db.Queryable<Dt_Task>().Where(x => x.Roadway == device.DeviceCode && x.TaskState == (int)TaskStatusEnum.New).OrderBy(x=>x.TaskNum).First();
                 if (task != null && station != null)
                 {
                     task.TaskState = (int)TaskStatusEnum.AGV_Execute;
-                    _taskRepository.UpdateData(task);
+                    task.DeviceCode = station.StackerCraneCode;
                     station.Remark = task.PalletCode;
+                    _taskRepository.UpdateData(task);
                     _stationMangerRepository.UpdateData(station);
                 }
             }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs"
index f7a7320..2d3d85d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs"
@@ -148,6 +148,12 @@
         EmptyProductBack = 630,
 
         /// <summary>
+        /// 绌烘墭鍙犵洏
+        /// </summary>
+        [Description("绌烘墭鍙犵洏")]
+        EmptyStackPlate = 635,
+
+        /// <summary>
         /// 鍒嗗垏鍗婃垚鍝佸叆搴�
         /// </summary>
         [Description("鍒嗗垏鍗婃垚鍝佸叆搴�")]
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs"
index 4d11768..01f9f3b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs"
@@ -16,6 +16,7 @@
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using Microsoft.AspNetCore.Mvc;
+using Org.BouncyCastle.Asn1.X509;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -143,7 +144,7 @@
         /// <param name="barCode"></param>
         /// <param name="startPoint"></param>
         /// <returns></returns>
-        WebResponseContent EmptyBackTask(string barCode, string startPoint);
+        WebResponseContent EmptyBackTask(string barCode, string startPoint,int target);
 
         /// <summary>
         /// 杈呮枡/鎴愬搧涓存椂鍏ュ簱
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index a441c4b..b916eef 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -982,6 +982,19 @@
                     {
                         agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
                     }
+                    //鍙犵洏浠诲姟鍗曠嫭瀹屾垚
+                    if (task.TaskType==TaskTypeEnum.EmptyStackPlate.ObjToInt())
+                    {
+                        task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+                        _unitOfWorkManage.BeginTran();
+                        if (agvstation != null)
+                        {
+                            _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
+                        }
+                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                        _unitOfWorkManage.CommitTran();
+                        return content.OK();
+                    }
                     Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First();
                     if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt())
                     {
@@ -1226,7 +1239,7 @@
         /// <summary>
         /// 鎴愬搧绌烘墭鍥炲簱
         /// </summary>
-        public WebResponseContent EmptyBackTask(string barCode, string startPoint)
+        public WebResponseContent EmptyBackTask(string barCode, string startPoint,int target)
         {
             WebResponseContent content = new WebResponseContent();
             try
@@ -1253,41 +1266,64 @@
                 {
                     return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�");
                 }
-                Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
-                if (proStockInfoOld!=null)
+                Dt_Task newTask = null;
+                Dt_ProStockInfo proStockInfo = null;
+                if (target==WhetherEnum.False.ObjToInt())//鍙犵洏绌烘墭浠诲姟
                 {
-                    return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+                    newTask = new Dt_Task()
+                    {
+                        CurrentAddress = startPoint,
+                        Grade = 0,
+                        NextAddress = "",
+                        PalletCode = barCode,
+                        Roadway = agvstation.AGVStationCode.StartsWith("PNT_1") ? "StackPlate1": "StackPlate2",
+                        SourceAddress = startPoint,
+                        TargetAddress = "",
+                        TaskType = TaskTypeEnum.EmptyStackPlate.ObjToInt(),
+                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+                        PalletType = 1
+                    };
                 }
-                //鍒嗛厤宸烽亾
-                string roadWay=AssignCPRoadwayNo();
-                
-                Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+                else //绔嬪簱绌烘墭浠诲姟
                 {
-                    PalletCode=barCode,
-                    ProStockAttribute=ProStockAttributeEnum.绌烘墭.ObjToInt(),
-                    PalletType=1,
-                    LocationCode="",
-                    WarehouseId= WarehouseEnum.LLDFL.ObjToInt(),
-                    StockStatus=StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()
-                }; 
-
-                Dt_Task newTask = new Dt_Task()
-                {
-                    CurrentAddress = startPoint,
-                    Grade = 0,
-                    NextAddress = "",
-                    PalletCode = barCode,
-                    Roadway = roadWay,
-                    SourceAddress = startPoint,
-                    TargetAddress = "",
-                    TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
-                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
-                    WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
-                    PalletType = 1
-                };
+                    Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
+                    if (proStockInfoOld != null)
+                    {
+                        return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+                    }
+                    //鍒嗛厤宸烽亾
+                    string roadWay = AssignCPRoadwayNo();
+                    proStockInfo = new Dt_ProStockInfo()
+                    {
+                        PalletCode = barCode,
+                        ProStockAttribute = ProStockAttributeEnum.绌烘墭.ObjToInt(),
+                        PalletType = 1,
+                        LocationCode = "",
+                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+                        StockStatus = StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()
+                    };
+                    newTask = new Dt_Task()
+                    {
+                        CurrentAddress = startPoint,
+                        Grade = 0,
+                        NextAddress = "",
+                        PalletCode = barCode,
+                        Roadway = roadWay,
+                        SourceAddress = startPoint,
+                        TargetAddress = "",
+                        TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
+                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+                        PalletType = 1
+                    };
+                }
                 _unitOfWorkManage.BeginTran();
                 int taskId = BaseDal.AddData(newTask);
-                _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
+                if (proStockInfo!=null)
+                {
+                    _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
+                }
                 newTask.TaskId = taskId;
                 _unitOfWorkManage.CommitTran();
                 //鎺ㄩ�佷换鍔�
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs"
index cafc5b2..8f05be9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs"
@@ -69,7 +69,7 @@
         [HttpPost, HttpGet, Route("EmptyBackTask"), AllowAnonymous]
         public WebResponseContent EmptyBackTask(string barCode, string startPoint,int target)
         {
-            return Service.EmptyBackTask(barCode, startPoint);
+            return Service.EmptyBackTask(barCode, startPoint, target);
         }
 
         /// <summary>
diff --git "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\346\210\220\345\223\201\350\276\223\351\200\201\347\272\277\351\200\232\350\256\257\345\215\217\350\256\256_20250707.xlsx" "b/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\346\210\220\345\223\201\350\276\223\351\200\201\347\272\277\351\200\232\350\256\257\345\215\217\350\256\256_20250707.xlsx"
index 58f1ccb..35bcfce 100644
--- "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\346\210\220\345\223\201\350\276\223\351\200\201\347\272\277\351\200\232\350\256\257\345\215\217\350\256\256_20250707.xlsx"
+++ "b/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\346\210\220\345\223\201\350\276\223\351\200\201\347\272\277\351\200\232\350\256\257\345\215\217\350\256\256_20250707.xlsx"
Binary files differ
diff --git "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\344\272\214\347\273\264\347\240\201\350\247\204\345\210\231.xlsx" "b/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\344\272\214\347\273\264\347\240\201\350\247\204\345\210\231.xlsx"
deleted file mode 100644
index 83ec23c..0000000
--- "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\344\272\214\347\273\264\347\240\201\350\247\204\345\210\231.xlsx"
+++ /dev/null
Binary files differ
diff --git "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\347\274\226\347\240\201\350\247\204\345\210\23120250618.xlsx" "b/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\347\274\226\347\240\201\350\247\204\345\210\23120250618.xlsx"
deleted file mode 100644
index 4cc1c85..0000000
--- "a/\351\241\271\347\233\256\350\265\204\346\226\231/\351\200\232\344\277\241\345\215\217\350\256\256/\347\211\251\346\226\231\347\274\226\347\240\201\350\247\204\345\210\23120250618.xlsx"
+++ /dev/null
Binary files differ

--
Gitblit v1.9.3