yanjinhui
4 天以前 b0ed419ede8bd1829e670891ffe878630ba517e2
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs
@@ -28,6 +28,7 @@
                List<Dt_MaterielInfo> materielInfos = _materielInfoService.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
                List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => deliveryOrder.Warehouse_no == x.WarehouseCode && deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
                List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
                List<Dt_MaterielInfo> MaterieInfoBusiness =new List<Dt_MaterielInfo>();
                #region ç›˜äºå‡ºåº“单
                if (deliveryOrder.Out_type == "6")
                {
@@ -39,22 +40,28 @@
                            if (orderDetail == null) throw new Exception($"未找到盘点单【{deliveryOrder.Out_no}】物料编号【{detail.productCode}】物料批次【{detail.batchNo}】的明细信息");
                            decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) ?? 0;
                            Dt_InventoryInfo inventoryInfo = inventoryInfos.Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo).First();
                            var qty = inventoryInfo.SupplyQuantity - inventoryInfo.StockQuantity;
                            if (orderQty != qty)
                                throw new Exception($"盘亏出库数量不一致,上传数量【{orderQty}】,库存盘亏数量【{qty}】");
                            inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
                            if (orderQty != Math.Abs(inventoryInfo.SupplyQuantity))
                                throw new Exception($"盘亏出库数量不一致,上传数量【{orderQty}】,库存盘亏数量【{Math.Abs(inventoryInfo.SupplyQuantity)}】");
                            //添加物料信息中的立库业务库存信息
                            var mater = materielInfos.FirstOrDefault(x => x.MaterielCode == detail.productCode);
                            if (mater != null)
                            {
                                mater.Business_qty += inventoryInfo.SupplyQuantity;
                                MaterieInfoBusiness.Add(mater);
                            }
                            inventoryInfo.StockQuantity += inventoryInfo.SupplyQuantity;
                            inventoryInfo.AvailableQuantity = inventoryInfo.StockQuantity;
                            inventoryInfo.SupplyQuantity = 0;
                            inventoryInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                            infosUp.Add(inventoryInfo);
                            Dt_Inventory_Batch inventory_Batch = inventory_Batches.First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo);
                            inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity;
                            inventory_Batch.StockQuantity += inventory_Batch.SupplyQuantity;
                            inventory_Batch.AvailableQuantity = inventory_Batch.StockQuantity;
                            inventory_Batch.SupplyQuantity = 0;
                            batchesUp.Add(inventory_Batch);
                            orderDetail.OotDetailStatus = "已完成";
                            cabinOrderDetailsUp.Add(orderDetail);
                            #region æ·»åŠ ç›˜ç›ˆå…¥åº“ä»»åŠ¡
                            #region æ·»åŠ ç›˜äºå‡ºåº“ä»»åŠ¡
                            Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty()
                            {
                                WarehouseCode = inventoryInfo.WarehouseCode,
@@ -86,6 +93,8 @@
                        _inventory_BatchServices.UpdateData(batchesUp);
                        _deliveryOrderDetailServices.UpdateData(cabinOrderDetailsUp);
                        BaseDal.UpdateData(deliveryOrder);
                        //添加物料信息中的立库业务库存信息
                        _materielInfoService.UpdateData(MaterieInfoBusiness);
                        _unitOfWorkManage.CommitTran();
                    }
                    catch (Exception ex)