pan
2025-11-28 cf3050083e157819b94781d0445547ffc73e21f2
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs
@@ -96,8 +96,11 @@
                        item.Unit = purchaseToStockResult.Unit;
                        item.OrderQuantity = purchaseToStockResult.Quantity;
                    }
                    if (model.OrderType != InOrderTypeEnum.Allocat.ObjToInt())
                    {
                        model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
                    }
                    model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
                    Db.InsertNav(model).Include(x => x.Details).ExecuteCommand();
                }
                return WebResponseContent.Instance.OK();
@@ -338,12 +341,12 @@
                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))
                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);
@@ -365,10 +368,10 @@
                if (stockInfo == null)
                {
                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None,LocationType=materielGroupDTO.locationType.ObjToInt() };
                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() };
                    stockInfo.Details = new List<Dt_StockInfoDetail>();
                }
                foreach (var item in dbinboundOrderDetails)
                {
                    stockInfo.Details.Add(new Dt_StockInfoDetail
@@ -382,15 +385,15 @@
                        SupplyCode = item.SupplyCode,
                        WarehouseCode = materielGroupDTO.WarehouseType,
                        StockQuantity = item.OrderQuantity,
                        BarcodeQty=item.BarcodeQty,
                        BarcodeUnit=item.BarcodeUnit,
                        FactoryArea= inboundOrder.FactoryArea,
                        Status = 0,
                        BarcodeQty = item.BarcodeQty,
                        BarcodeUnit = item.BarcodeUnit,
                        FactoryArea = inboundOrder.FactoryArea,
                        Status = 0,
                        OrderNo = inboundOrder.InboundOrderNo,
                        BusinessType = inboundOrder.BusinessType,
                    });
                    item.ReceiptQuantity = item.BarcodeQty;
                    item.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
                    item.WarehouseCode = materielGroupDTO.WarehouseType;
@@ -437,7 +440,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
            {
                (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
                if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
@@ -447,7 +450,8 @@
                    return content = WebResponseContent.Instance.Error($"区域中没有该{materielGroupDTO.WarehouseCode}编号。");
                }
                if(_stockRepository.QueryFirst(x=>x.PalletCode == materielGroupDTO.PalletCode)!=null){
                if (_stockRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
                {
                    return WebResponseContent.Instance.Error("该托盘已经组过盘");
                }
@@ -466,7 +470,7 @@
                {
                    if (stockInfo == null)
                    {
                        stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.组盘暂存.ObjToInt(), PalletCode = materielGroupDTO.PalletCode,LocationType= materielGroupDTO.WarehouseCode.ObjToInt() };
                        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
@@ -647,13 +651,13 @@
            {
                return WebResponseContent.Instance.Error("托盘号不能为空");
            }
           var stock= _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(o=>o.Details).First(x => x.PalletCode == palletCode &&  x.StockStatus ==(int)StockStatusEmun.组盘暂存);
            var stock = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(o => o.Details).First(x => x.PalletCode == palletCode && x.StockStatus == (int)StockStatusEmun.组盘暂存);
            if (stock == null)
            {
                return WebResponseContent.Instance.Error($"未找到托盘号{palletCode}对应的库存记录");
            }
            if(stock.Details == null || !stock.Details.Any())
            if (stock.Details == null || !stock.Details.Any())
            {
                _stockRepository.DeleteData(stock);
                return WebResponseContent.Instance.OK();