From 7a70c16d9fb28646a0f22e9f699746df6c651e8c Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期一, 15 十二月 2025 20:14:04 +0800
Subject: [PATCH] 最新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs |   79 +++++++++++++++++++++++++++++++--------
 1 files changed, 62 insertions(+), 17 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
index 48b9dfe..7554779 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
@@ -380,7 +380,7 @@
             {
                 WebResponseContent content = new WebResponseContent();
                 List<Dt_LocationInfo> loca = new List<Dt_LocationInfo>();
-                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum);
+                Dt_Task task = BaseDal.QueryData().Where(x => x.TaskNum == TaskNum).FirstOrDefault();
                 if (task == null)
                 {
                     return content = WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅锛屼换鍔″彿锛歿TaskNum}");
@@ -388,7 +388,7 @@
                 else
                 {
                     //鍒ゆ柇鏄惁闇�瑕佺Щ搴�
-                    string[] targetCodes = SourceAddress.Split("-");
+                    string[] targetCodes = SourceAddress.Split("-");  //	R02 - 002 - 001 - 011 - 01
                     if (targetCodes[1] == "001")
                     {
                         targetCodes[1] = "002";
@@ -404,7 +404,7 @@
                     }
                     targetCodes[4] = "01";
                     string LocationCode = string.Join("-", targetCodes); //缁勮娴呭簱浣嶅湴鍧�
-                    Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && (x.LocationStatus == (int)LocationStatusEnum.Free || x.LocationStatus == (int)LocationStatusEnum.InStock));
+                    Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationCode == LocationCode).Where(x=> x.LocationStatus == (int)LocationStatusEnum.Free || x.LocationStatus == (int)LocationStatusEnum.InStock || x.LocationStatus == (int)LocationStatusEnum.Pallet).FirstOrDefault();
                     if (locationInfos == null)
                     {
                         return content = WebResponseContent.Instance.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{locationInfos}");
@@ -417,7 +417,7 @@
                         }
                         else
                         {
-                            Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && x.StockStatus== (int)StockStatusEmun.宸插叆搴�);
+                            Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.LocationCode == LocationCode).Where(x=> x.StockStatus == (int)StockStatusEmun.宸插叆搴�).FirstOrDefault();
                             if (dt_StockInfo == null)
                             {
                                 return content = WebResponseContent.Instance.Error($"鏈壘鍒拌璐т綅鐨勫簱瀛樹俊鎭�,璐т綅缂栧彿:{LocationCode}");
@@ -439,23 +439,48 @@
                                 if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.鎴愬搧)
                                 {
                                     string[] targetCodesst = dt_StockInfo.PalletCode.Split("*");
-                                    Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodesst[0]);
+                                    Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryData().Where(x => x.OrderName == targetCodesst[0]).FirstOrDefault();
                                     if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0)
                                     {
-                                        newLocation = _basicService.LocationInfoService.GetLocation2(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn);
+                                        newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn);
+                                        if (newLocation == null)
+                                        {
+                                            return content.Error($"鏃犳硶鑾峰彇搴撲綅,娌℃壘鍒板贩閬擄細{locationInfos.RoadwayNo}锛屽垪锛歿dt_Inbound.Startingcolumn}==>{dt_Inbound.Terminationcolumn}锛岀殑鍙敤璐т綅,,锛屼换鍔$紪鍙凤細{TaskNum}");
+                                        }
                                     }
                                     else
                                     {
-                                        newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype);
+                                        newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype, 0, 0);
+                                        if (newLocation == null)
+                                        {
+                                            return content.Error($"鎴愬搧鏂欒繘琛岀Щ搴擄紝鏃犳硶鑾峰彇搴撲綅,娌℃壘鍒板贩閬擄細{locationInfos.RoadwayNo}锛屼换鍔$紪鍙凤細{TaskNum}");
+                                        }
                                     }
 
                                 }
                                 else
                                 {
-                                    newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype);
+                                    newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype, 0, 0);
+                                    if (newLocation == null)
+                                    {
+                                        return content.Error($"鍘熸潗鏂欒繘琛岀Щ搴擄紝鏃犳硶鑾峰彇搴撲綅,娌℃壘鍒板贩閬擄細{locationInfos.RoadwayNo}锛屼换鍔$紪鍙凤細{TaskNum}");
+                                    }
                                 }
 
 
+
+                                //鐩爣璐т綅鏌ユ壘搴撲綅鏄惁鏈夎揣
+                                Dt_StockInfo dt_StockCurren = _stockService.StockInfoService.Repository.QueryData().Where(x => x.LocationCode == newLocation.LocationCode).FirstOrDefault();
+                                if (dt_StockCurren != null) return content.Error($"鍏ュ簱澶辫触锛屾墭鐩樻潯鐮侊細{dt_StockInfo.PalletCode}锛屾煡鎵惧嚭鐨勮揣浣嶄俊鎭搴斿凡鏈夊簱瀛�");
+
+                                Dt_Task taskcurren = BaseDal.QueryFirst(x => x.TargetAddress == newLocation.LocationCode || x.SourceAddress == newLocation.LocationCode);
+                                if (taskcurren != null) return content.Error($"鍏ュ簱澶辫触锛屾墭鐩樻潯鐮侊細{dt_StockInfo.PalletCode}锛屾煡鎵惧嚭鐨勮揣浣嶄俊鎭凡鏈夊叆搴撲换鍔�");
+
+                                bool crutaskthy = _taskHtyService.CrueeTaskHty(newLocation.LocationCode);
+                                if (crutaskthy) return content.Error($"鍏ュ簱澶辫触锛屾墭鐩樻潯鐮侊細{dt_StockInfo.PalletCode}锛屾煡鎵惧嚭鐨勮揣浣嶅湪浠诲姟鍘嗗彶淇℃伅涓紝鏈夊叆搴撴垨绉诲簱淇℃伅");
+
+
+                                //鎵剧殑娣卞簱鍖猴紝鍒欏垽鏂祬搴撲綅鏄惁鏈�
                                 if (newLocation != null)
                                 {
                                     Dt_Task dt_Task = new()
@@ -528,7 +553,7 @@
                 if (task == null)
                 {
                     string RoadwayNo = "1";
-                    if (generate.SourceAddress != "R01-002-041-001-01")
+                    if (generate.SourceAddress != "R01-002-041-001-01" && generate.SourceAddress != "R01-002-043-001-01")
                     {
                         RoadwayNo = "2";
                     }
@@ -693,7 +718,7 @@
                 for (int i = 0; i < saveModel.DelKeys.Count; i++)
                 {
                     Dt_StockInfo stockt = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == saveModel.DelKeys[i].ToString());
-                    if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.杩斿伐))
+                    if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.杩斿伐 || stockt.Wlstatus == (int)InventoryMaterialStatus.鐗归噰) )
                     {
                         if(stockt.MaterialType != (int)InventoryMaterialType.鍘熸潗鏂�)
                         {
@@ -758,7 +783,7 @@
                     }
                     else
                     {
-                        return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃閫夋嫨宸插叆搴撲笖鍚堟牸鐨勭墿鏂欏嚭搴擄紒锛侊紒锛屽嚭搴撴潯鐮侊細{saveModel.DelKeys[i].ToString()}");
+                        return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃閫夋嫨宸插叆搴撲笖锛堝悎鏍硷紝杩斿伐锛岀壒閲囷級鐨勭墿鏂欏嚭搴擄紒锛侊紒锛屽嚭搴撴潯鐮侊細{saveModel.DelKeys[i].ToString()}");
                     }
 
                 }
@@ -808,7 +833,7 @@
                     Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.PalletCode == palletCode);
                     if (stockt !=null)
                     {
-                        if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.閫�璐� || stockt.Wlstatus == (int)InventoryMaterialStatus.鐗归噰))
+                        if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.閫�璐� || stockt.Wlstatus == (int)InventoryMaterialStatus.鐗归噰 || stockt.Wlstatus == (int)InventoryMaterialStatus.绌烘墭))
                         {
                             Dt_StockInfoDetail stocktdetail = StockInfoDetailData.FirstOrDefault(x => x.StockId == stockt.Id);
                             if(stocktdetail != null)
@@ -1216,10 +1241,33 @@
                     {
                         Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id);
                         Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode);
+                        Dt_Task_Hty task_Hty = new Dt_Task_Hty()
+                        {
+                            TaskNum = 001,
+                            PalletCode = stockt.PalletCode,
+                            Roadway = locationinfo.RoadwayNo,
+                            TaskType = (int)TaskTypeEnum.Outbound,
+                            TaskStatus = (int)OutTaskStatusEnum.OutFinish,
+                            SourceAddress = locationinfo.LocationCode,
+                            TargetAddress = locationinfo.LocationCode,
+                            CurrentAddress = locationinfo.LocationCode,
+                            NextAddress = locationinfo.LocationCode,
+                            Grade = 1,
+                            Dispatchertime = DateTime.Now,
+                            Creater = App.User.UserName,
+                        CreateDate = DateTime.Now,
+                            ModifyDate = DateTime.Now,
+                            Modifier = App.User.UserName,
+                            Remark = "浜哄伐鍑哄簱",
+                            PLCTo = 1,
+                            PalletCodequantity = 1,
+                            MaterialType = 1
+                        };
+                        _taskHtyService.AddData(task_Hty);
                         locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                         dtstockt.Add(stockt);
                         locations.Add(locationinfo);
-                        if (stockt.MaterialType == (int)InventoryMaterialType.绌烘墭)
+                        if (stockt.MaterialType != (int)InventoryMaterialType.绌烘墭)
                         {
                             dtstocktdetail.Add(stocktdetail);
                         }
@@ -1233,10 +1281,7 @@
                 }
                 _unitOfWorkManage.BeginTran();
                 _stockService.StockInfoService.Repository.DeleteData(dtstockt);
-                if(dtstocktdetail.Count==0)
-                {
-                    _stockService.StockInfoDetailService.Repository.DeleteData(dtstocktdetail);
-                }
+                _stockService.StockInfoDetailService.Repository.DeleteData(dtstocktdetail);
                 _basicService.LocationInfoService.Repository.UpdateData(locations);
                 _unitOfWorkManage.CommitTran();
                 content = WebResponseContent.Instance.OK();

--
Gitblit v1.9.3