dengjunjie
2025-10-25 d5051e5293179c99df2e3489ad5f2f73f4061667
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs
@@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
@@ -29,9 +30,12 @@
            {
                List<Dt_DeliveryOrder> deliveryOrders = new List<Dt_DeliveryOrder>();
                List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>();
                List<Dt_InventoryInfo> _InventoryInfos = new List<Dt_InventoryInfo>();
                List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => keys.Contains(x.Id));
                foreach (var item in inventory_Batches)
                {
                    supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList();
                    if (supplyTasks.Count > 0) throw new Exception($"物料编号【{item.MaterielCode}】批次号【{item.BatchNo}】已存在盘点任务,请先完成当前盘点任务");
                    List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => item.MaterielCode == x.MaterielCode && x.BatchNo == item.BatchNo);
                    if (inventoryInfos.Count > 0)
                    {
@@ -83,13 +87,19 @@
                                    Remark = "盘点"
                                };
                                supplyTasks.Add(supplyTask);
                                _InventoryInfos.Add(inventory);
                            }
                            //}
                            #endregion
                        }
                    }
                }
                _InventoryInfos.ForEach(x =>
                {
                    x.StockStatus = StockStatusEmun.盘点锁定.ObjToInt();
                });
                _unitOfWorkManage.BeginTran();
                _inventoryInfoService.UpdateData(_InventoryInfos);
                _supplyTaskService.AddData(supplyTasks);
                BaseDal.Db.InsertNav(deliveryOrders)
                        .Include(x => x.Details)
@@ -248,13 +258,6 @@
                _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.自动完成);
                #endregion
                #region åº“存批次
                Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode);
                if (inventory_Batch == null) throw new Exception($"未找到物料编号【{inventoryInfo.MaterielCode}】物料批次【{inventoryInfo.BatchNo}】的库存批次信息");
                inventory_Batch.SupplyQuantity += supplyTask.SupplyQuantity;
                _inventory_BatchServices.UpdateData(inventory_Batch);
                #endregion
                #region åˆ¤æ–­å½“前物料批次的盘点任务是否全部完成
                List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.WarehouseCode == supplyTask.WarehouseCode).ToList();
                if (supplyTasks.Count < 1)
@@ -272,26 +275,35 @@
                supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList();
                if (supplyTasks.Count < 1)
                {
                    #region æ£€æŸ¥æ˜¯å¦æœ‰ç›˜ç‚¹å·®å¼‚,无差异直接处理数据
                    if (inventory_Batch.SupplyQuantity == inventory_Batch.StockQuantity)
                    #region æŸ¥æ‰¾åº“å­˜
                    var inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no);
                    var SupplyQuantitys = inventoryInfos.Select(x => x.SupplyQuantity).ToList().Sum();
                    #endregion
                    #region åº“存批次
                    Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no);
                    if (SupplyQuantitys == inventory_Batch.StockQuantity)
                    {
                        var inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == inventory_Batch.BatchNo && x.MaterielCode == inventory_Batch.MaterielCode);
                        foreach (var item in inventoryInfos)
                        {
                            item.StockQuantity = item.SupplyQuantity;
                            item.SupplyQuantity = 0;
                            item.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                        }
                        _inventoryInfoService.UpdateData(inventoryInfos);
                        inventory_Batch.SupplyQuantity = 0;
                    }
                    else
                    {
                        inventory_Batch.SupplyQuantity = SupplyQuantitys;
                        _inventory_BatchServices.UpdateData(inventory_Batch);
                    }
                    #endregion
                }
                #endregion
                }
                _unitOfWorkManage.CommitTran();
                #endregion
                content.OK();
                #endregion
            }
            catch (Exception ex)
            {