From 37faeb3fd7d8f204298d4d24a8a98110992d6b58 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期三, 19 十一月 2025 08:38:28 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs |   47 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 12 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/InboundOrderService.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/InboundOrderService.cs"
index 8a288c1..c7fa1c9 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/InboundOrderService.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/InboundOrderService.cs"
@@ -37,9 +37,10 @@
         private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository;
         private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
         private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
+        private readonly IRepository<Dt_StockInfo> _stockRepository;
         public IRepository<Dt_InboundOrder> Repository => BaseDal;
 
-        public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository) : base(BaseDal)
+        public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository,IRepository<Dt_StockInfo> stockRepository) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -51,6 +52,7 @@
             _stockDetailRepository = stockDetailRepository;
             _inboundOrderRepository = inboundOrderRepository;
             _warehouseAreaRepository = warehouseAreaRepository;
+            _stockRepository = stockRepository;
         }
 
         public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType)
@@ -221,11 +223,13 @@
                     }
                     //Db.DeleteNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
                     _unitOfWorkManage.BeginTran();
-                    BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.鑷姩鍒犻櫎);
+                    //BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.鑷姩鍒犻櫎);
                     foreach (var item in inboundOrder.Details)
                     {
-                        _inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
+                        _inboundOrderDetailRepository.DeleteData(item);
+                        //_inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
                     }
+                    BaseDal.DeleteData(inboundOrder);
                     _unitOfWorkManage.CommitTran();
                 }
                 return WebResponseContent.Instance.OK();
@@ -320,6 +324,14 @@
                 (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
                 if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
 
+                //  materielGroupDTO.WarehouseCode
+                var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x=>x.Code).First();
+                if(string.IsNullOrEmpty(code))
+                {
+                    return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseType}缂栧彿銆�");
+                }
+                
+
                 Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
 
                 var dbinboundOrderDetails = _inboundOrderDetailService.GetByBarcode(materielGroupDTO.Barcodes);
@@ -340,12 +352,10 @@
 
                 if (stockInfo == null)
                 {
-                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None };
+                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None,LocationType=materielGroupDTO.locationType.ObjToInt() };
                     stockInfo.Details = new List<Dt_StockInfoDetail>();
                 }
-                var warehouseareas = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().ToList();
-                var warehousearea = warehouseareas.First(x => x.Name == materielGroupDTO.locationTypeDesc.Trim() && x.FactoryArea == inboundOrder.FactoryArea);
-                
+               
                 foreach (var item in dbinboundOrderDetails)
                 {
                     stockInfo.Details.Add(new Dt_StockInfoDetail
@@ -357,17 +367,20 @@
                         Unit = item.Unit,
                         InboundOrderRowNo = item.lineNo,
                         SupplyCode = item.SupplyCode,
-                        WarehouseCode = warehousearea!=null? warehousearea.Code:  item.WarehouseCode,
+                        WarehouseCode = materielGroupDTO.WarehouseType,
                         StockQuantity = item.OrderQuantity,
+                        BarcodeQty=item.BarcodeQty,
+                        BarcodeUnit=item.BarcodeUnit,
+                        FactoryArea= inboundOrder.FactoryArea,
                         Status = 0,                         
                         OrderNo = inboundOrder.InboundOrderNo,
                         BusinessType = inboundOrder.BusinessType,
-                        ProductionDate = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss")
+                   
                     });
                    
                     item.ReceiptQuantity = item.BarcodeQty;
                     item.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
-                    item.WarehouseCode = warehousearea != null ? warehousearea.Code : "";
+                    item.WarehouseCode = materielGroupDTO.WarehouseType;
                 }
 
                 if (stockInfo.Id == 0)
@@ -411,10 +424,19 @@
 
             WebResponseContent content = new WebResponseContent();
             try
-            {
+            {                                           
                 (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
                 if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
 
+                bool code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Id == materielGroupDTO.WarehouseCode).Any();
+                if (!code)
+                {
+                    return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseCode}缂栧彿銆�");
+                }
+
+                if(_stockRepository.QueryFirst(x=>x.PalletCode == materielGroupDTO.PalletCode)!=null){
+                    return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡缁忕粍杩囩洏");
+                }
 
                 Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
                 if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
@@ -431,13 +453,14 @@
                 {
                     if (stockInfo == null)
                     {
-                        stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode };
+                        stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode,LocationType= materielGroupDTO.WarehouseCode.ObjToInt() };
                         stockInfo.Details = new List<Dt_StockInfoDetail>();
                     }
                     else
                     {
                         stockInfo.PalletType = PalletTypeEnum.Empty.ObjToInt();
                         stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+                        stockInfo.LocationType = materielGroupDTO.WarehouseCode.ObjToInt();
                     }
 
                     _unitOfWorkManage.BeginTran();

--
Gitblit v1.9.3