From 28e67084df6e36f7b3ac3b914d97fa51acb21f8f Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期五, 06 二月 2026 18:22:31 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 113 insertions(+), 5 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
index 4e18074..eec793d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
@@ -177,7 +177,7 @@
                     return content.Error($"涓�涓噰璐崟鎹噷闈笉鍏佽缁勭洏涓や釜浠撳簱锛岃閲嶆柊閫夋嫨浠撳簱锛屼笂涓�涓粍鐩樹粨搴撲负{isWarehouse.WarehouseCode}");
                 }
 
-                if (inboundOrder.BusinessType == "11" && inboundOrder.IsTestMaterials == 1 && (palletDto.WarehouseType != "1076" || palletDto.WarehouseType != "5057"))
+                if (inboundOrder.BusinessType == "11" && inboundOrder.IsTestMaterials == 1 && palletDto.WarehouseType != "1076" && palletDto.WarehouseType != "5057")
                 {
                     return content.Error($"璇ュ崟鎹负璇曚骇鐗╂枡锛岄渶瑕佸叆搴撳埌璇曚骇浠擄紝璇烽噸鏂版牴鎹巶鍖洪�夋嫨璇曚骇浠撳簱杩涜缁勭洏鍏ュ簱");
                 }
@@ -318,7 +318,10 @@
                 {
                     return content.Error($"鏈壘鍒拌鏉$爜{palletDto.Barcode}闇�璋冨叆鏅轰粨鐨勪俊鎭�");
                 }
-
+                if(allocateMaterialInfo.WarehouseCode != palletDto.WarehouseType)
+                {
+                    return content.Error($"璇ユ潯鐮佽皟鍏ヤ粨搴撲负{allocateMaterialInfo.WarehouseCode},涓庨�夋嫨鐨剓palletDto.WarehouseType}浠撳簱涓嶄竴鑷�");
+                }
                 stockInfo.Details.Add(new Dt_StockInfoDetail
                 {
                     StockId = stockInfo == null ? 0 : stockInfo.Id,
@@ -533,7 +536,18 @@
                     {
                         if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                         {
-                            inboundOrder.ReturnToMESStatus = 1;
+                            if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                            {
+                                inboundOrder.ReturnToMESStatus = 1;
+                            }
+                            else if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                            {
+                                inboundOrder.ReturnToMESStatus = 3;
+                            }
+                            else
+                            {
+                                inboundOrder.ReturnToMESStatus = 0;
+                            }
                         }
                         else if (returnRecords.Count(x => x.ReturnStatus == 2) > 0)
                         {
@@ -554,6 +568,22 @@
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
 
+                        if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 3 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 0 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+
                         _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
                         {
                             Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
@@ -563,6 +593,22 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
                          .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 4 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 0 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
                         return content.Error("鍥炰紶MES澶辫触");
                     }
                 }
@@ -585,7 +631,18 @@
                     {
                         if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                         {
-                            inboundOrder.ReturnToMESStatus = 1;
+                            if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                            {
+                                inboundOrder.ReturnToMESStatus = 1;
+                            }
+                            else if(inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                            {
+                                inboundOrder.ReturnToMESStatus = 3;
+                            }
+                            else
+                            {
+                                inboundOrder.ReturnToMESStatus = 0;
+                            }
                         }
                         else if (returnRecords.Count(x => x.ReturnStatus == 2) > 0)
                         {
@@ -605,6 +662,22 @@
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
 
+                        if(inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else if(inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 3})
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 0 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+
                         _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
                         {
                             Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
@@ -614,6 +687,22 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
                          .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt())
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 4 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
+                        else
+                        {
+                            _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 0 })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                        }
                         return content.Error("鍥炰紶MES澶辫触");
                     }
                 }
@@ -757,7 +846,16 @@
                 {
                     return content.Error("宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏");
                 }
-
+                var nullpallet = _stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+                if (nullpallet != null)
+                {
+                    return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+                }
+                var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+                if (outbundPallet != null)
+                {
+                    return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
+                }
                 Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                     .Where(x => x.Barcode == palletDto.Barcode && x.StockId == 0)
                     .First();
@@ -877,6 +975,16 @@
                 {
                     return content.Error($"璇ユ墭鐩樼粍鐩樹粨搴撲负{stockInfo.Details.FirstOrDefault()?.WarehouseCode}涓庡綋鍓嶄粨搴搟palletDto.WarehouseType}涓嶄竴鑷达紝涓嶅厑璁哥粍鐩�");
                 }
+                var nullpallet = _stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+                if (nullpallet != null)
+                {
+                    return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+                }
+                var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+                if (outbundPallet != null)
+                {
+                    return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
+                }
                 Dt_StockInfoDetail stockInfoDetail = _stockInfoRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.Barcode == palletDto.Barcode && x.Status == StockStatusEmun.閲嶆涓�.ObjToInt()).First();
                 if(stockInfoDetail == null)
                 {

--
Gitblit v1.9.3