From 5dfd83bd540c2e43af2e0449c246c79a22cb1296 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期二, 20 一月 2026 16:22:56 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs |   53 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 8 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 b7b4f4a..2be3d60 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"
@@ -93,7 +93,31 @@
 
                 if (details.Count() <= 0)
                 {
-                    return content.Error("璇风‘璁ゆ槸鍚﹀凡缁忕粍鐩�");
+                    var inbounddetail =_inboundOrderDetailRepository.QueryFirst(x => x.Barcode == palletDto.Barcode || x.OutBoxbarcodes == palletDto.Barcode);
+                    if(inbounddetail == null)
+                    {
+                        return content.Error($"鏉$爜{palletDto.Barcode}涓嶅瓨鍦�");
+                    }
+                    var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == inbounddetail.OrderId).First();
+                    if (inbound == null)
+                    {
+                        return content.Error("鍗曟嵁涓嶈兘涓虹┖");
+                    }
+
+                    var detail = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().LeftJoin<Dt_InboundOrder>((d,o)=>d.OrderId==o.Id).Where((d, o) => d.OrderId == inbound.Id
+                      && d.ReceiptQuantity != 0
+                      && d.OverInQuantity == 0).Select((d, o) => new
+                {
+                    orderNo=o.InboundOrderNo,
+                    d.Barcode,
+                    d.MaterielCode,
+                    d.BatchNo,
+                    d.ReceiptQuantity,
+                    d.Unit,
+                    d.SupplyCode,
+                    d.WarehouseCode
+                }).ToList();
+                    return content.Error($"璇风‘璁ゆ潯鐮亄palletDto.Barcode}鏄惁宸茬粡缁勭洏",detail);   
                 }
                 inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Includes(x=>x.Details).Where(x => x.Id == details.First().OrderId).First();
 
@@ -142,8 +166,11 @@
 
                 foreach (var item in details)
                 {
-                    var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x=>x.MaterialCode.Contains(item.MaterielCode.Substring(0,6))).First();
-
+                    var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x => x.MaterialCode.Contains(item.MaterielCode.Substring(0, 6))).First();
+                    if (datevaliDate == null)
+                    {
+                        return content.Error($"璇ョ墿鏂檣item.MaterielCode}鏈壘鍒癕ES鎺ㄩ�佺殑鏈夋晥鏈熸暟鎹紝璇峰厛娣诲姞璇ョ墿鏂欑殑鏈夋晥鏈熷啀缁勭洏鍏ュ簱");
+                    }
                     stockInfo.Details.Add(new Dt_StockInfoDetail
                     {
                         StockId = stockInfo == null ? 0 : stockInfo.Id,
@@ -779,16 +806,19 @@
                 {
                     return content.Error($"璇ユ墭鐩樼粍鐩樹粨搴撲负{stockInfo.Details.FirstOrDefault()?.WarehouseCode}涓庡綋鍓嶄粨搴搟palletDto.WarehouseType}涓嶄竴鑷达紝涓嶅厑璁哥粍鐩�");
                 }
-                Dt_StockInfoDetail stockInfoDetail = _stockInfoRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.Barcode == palletDto.Barcode && x.Status == StockStatusEmun.鎵嬪姩鍐荤粨.ObjToInt()).First();
+                Dt_StockInfoDetail stockInfoDetail = _stockInfoRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.Barcode == palletDto.Barcode && x.Status == StockStatusEmun.閲嶆涓�.ObjToInt()).First();
                 if(stockInfoDetail == null)
                 {
                     return content.Error("鏈壘鍒板簱瀛樹腑閲嶆鍐荤粨鐨勬潯鐮�");
                 }
-                Dt_ReCheckOrder reCheckOrder = _stockInfoRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.MaterielCode == stockInfoDetail.MaterielCode && x.BatchNo == stockInfoDetail.BatchNo && x.Result == 0).First();
-                if(reCheckOrder != null)
+                Dt_ReCheckOrder reCheckOrder = _stockInfoRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.MaterielCode == stockInfoDetail.MaterielCode && x.BatchNo == stockInfoDetail.BatchNo && x.OrderNo == stockInfoDetail.OrderNo && (x.Result == 1 || x.Result == 2 )).First();
+                if(reCheckOrder == null)
                 {
-                    return content.Error($"璇ラ噸妫�鏉$爜鐨勬壒娆″湪閲嶆鍗曚腑鏈嬁鍒伴噸妫�缁撴灉锛岃妫�娴嬮噸妫�鍗晎reCheckOrder.OrderNo}鐘舵��");
+                    return content.Error($"璇ラ噸妫�鏉$爜鐨勬壒娆″湪閲嶆鍗曚腑鏈嬁鍒伴噸妫�缁撴灉锛岃妫�鏌ラ噸妫�鍗曚腑鐗╂枡{stockInfoDetail.MaterielCode}鍜寋stockInfoDetail.BatchNo}鐗╂枡鎵规鐘舵��");
                 }
+
+                int newStatus = reCheckOrder.Result == 1 ? StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(): StockStatusEmun.鎵嬪姩鍐荤粨.ObjToInt();
+
                 stockInfo.Details.Add(new Dt_StockInfoDetail
                 {
                     StockId = stockInfo == null ? 0 : stockInfo.Id,
@@ -803,7 +833,7 @@
                     BarcodeQty = stockInfoDetail.BarcodeQty,
                     BarcodeUnit = stockInfoDetail.BarcodeUnit,
                     FactoryArea = stockInfoDetail.FactoryArea,
-                    Status = stockInfoDetail.Status,
+                    Status = newStatus,
                     OrderNo = stockInfoDetail.OrderNo,
                     BusinessType = "30",
                     ValidDate = stockInfoDetail.ValidDate
@@ -819,6 +849,13 @@
                 _stockService.StockInfoService.AddMaterielGroup(stockInfo);
                 _unitOfWorkManage.CommitTran();
 
+                Dt_StockInfo oldStockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == stockInfoDetail.StockId).Includes(x=>x.Details).First();
+                if (oldStockInfo.Details.Count <= 0)
+                {
+                    oldStockInfo.PalletType = (int)PalletTypeEnum.Empty;
+                }
+                _stockInfoRepository.UpdateData(oldStockInfo);
+
                 Dt_StockInfo? NewstockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync();
 
                 return WebResponseContent.Instance.OK(data: NewstockInfo.Details.OrderByDescending(x => x.Id));

--
Gitblit v1.9.3