From 25d4333015921e7a2445564e7099c1503e0a2eac Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 10 二月 2026 17:21:44 +0800
Subject: [PATCH] 更新回库异常处理操作

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs |  104 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 73 insertions(+), 31 deletions(-)

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..87a5efe 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"
@@ -21,6 +21,7 @@
 using WIDESEA_Common.TaskEnum;
 using WIDESEA_Common.WareHouseEnum;
 using WIDESEA_Core;
+using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO;
 using WIDESEA_DTO.Basic;
@@ -228,6 +229,11 @@
                         //璁板綍搴撳瓨鍙樺姩
                         _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength- oldQty: oldQty- stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
                         return content.OK($"鑰佸巶棰嗘枡閫�搴揜FID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}");
+                    }
+                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfoOld.StockLength<=0 && stationCode.IsNullOrEmpty())
+                    {
+                        _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfoOld, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+                        throw new Exception($"{palletCode}RFID淇℃伅鑰佸巶棰嗘枡鍚庢棤搴撳瓨閫�鏂�");
                     }
                     else if (stockInfoOld != null)
                     {
@@ -982,6 +988,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 +1245,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 +1272,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();
                 //鎺ㄩ�佷换鍔�

--
Gitblit v1.9.3