yanjinhui
16 小时以前 07b532a6a6adf0a9d965b037cf98c1f98accd138
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs
@@ -33,11 +33,18 @@
                //List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>();
                List<Dt_SupplyTask> supplyTasks1 = 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));
                List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => keys.Contains(x.Id)).ToList();
                foreach (var item in inventory_Batches)
                {
                    var supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList();
                    if (item.SupplyQuantity != 0) throw new Exception($"物料编号【{item.MaterielCode}】批次号【{item.BatchNo}】已存在盘点差异!");
                    //if (item.SupplyQuantity != 0) throw new Exception($"物料编号【{item.MaterielCode}】批次号【{item.BatchNo}】已存在盘点差异!");
                    if (item.SupplyQuantity != 0)
                    {
                        item.SupplyQuantity = 0;
                        // è¿™é‡Œéœ€è¦æ›´æ–°æ‰¹æ¬¡è¡¨çš„差异数量
                        _inventory_BatchServices.UpdateData(item);
                    }
                    if (supplyTasks.Count > 0) throw new Exception($"物料编号【{item.MaterielCode}】批次号【{item.BatchNo}】已存在盘点任务,请先完成当前盘点任务");
                    supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt()).ToList();
                    if (supplyTasks.Count > 0) throw new Exception($"物料编号【{item.MaterielCode}】批次号【{item.BatchNo}】已存在出库任务,请先完成当前出库任务");
@@ -79,6 +86,8 @@
                            #region åˆ›å»ºç›˜ç‚¹ä»»åŠ¡
                            foreach (var inventory in items)
                            {
                                //在创建盘点任务时重置库存的盘点差异为0
                                inventory.SupplyQuantity = 0;
                                Dt_SupplyTask supplyTask = new Dt_SupplyTask()
                                {
                                    WarehouseCode = inventory.WarehouseCode,
@@ -206,7 +215,7 @@
            {
                var LocationCode = saveModel.MainData["locationCode"].ToString();
                var TaskId = saveModel.MainData["taskId"].ObjToInt();
                var qty = saveModel.MainData["qty"].ObjToInt();
                var qty = saveModel.MainData["qty"].ObjToDecimal();
                Dt_SupplyTask supplyTask = _supplyTaskService.Repository.QueryFirst(x => x.TaskId == TaskId && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt());
                if (supplyTask == null) throw new Exception("当前盘点任务已完成");
                if (supplyTask.LocationCode != LocationCode) throw new Exception($"当前盘点货位【{LocationCode}】与任务分配货位不匹配");
@@ -249,8 +258,8 @@
                #endregion
                #region åº“å­˜
                List<Dt_Inventory_Batch> inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).Contains(x.MaterielCode));
                List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).Contains(x.MaterielCode) && x.WarehouseCode == supplyTask.WarehouseCode && x.StockStatus == StockStatusEmun.盘点锁定.ObjToInt());
                List<Dt_Inventory_Batch> inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).Contains(x.MaterielCode)).ToList();
                List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).Contains(x.MaterielCode) && x.WarehouseCode == supplyTask.WarehouseCode && x.StockStatus == StockStatusEmun.盘点锁定.ObjToInt()).ToList();
                Dt_InventoryInfo? inventoryInfo = new();
                List<Dt_InventoryInfo> inventoryInfosDel = new List<Dt_InventoryInfo>();
                if (supplyTask.WarehouseCode != WarehouseEnum.立库.ObjToInt().ToString("000"))
@@ -263,7 +272,7 @@
                    inventoryInfo = inventoryInfos.FirstOrDefault(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no);
                }
                if (inventoryInfo == null) return WebResponseContent.Instance.Error($"未找到立库的库存信息");
                inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity - inventoryInfo.StockQuantity;
                inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity - inventoryInfo.StockQuantity;//盘点差异数
                #endregion
                List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.OrderNo == supplyTask.OrderNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.TaskId != supplyTask.TaskId).ToList();//查找当前盘点单的盘点任务
@@ -275,7 +284,7 @@
                    #region å¤„理当前物料批次的库存和批次信息
                    Dt_Inventory_Batch inventory_Batch = inventory_Batchs.First(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode);
                    var SupplyQuantitys = inventoryInfos.Where(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode).Sum(x => x.SupplyQuantity);
                    if (SupplyQuantitys == 0)
                    if (SupplyQuantitys == 0)//不存在盘点差异
                    {
                        foreach (var item in inventoryInfos.Where(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode))
                        {