| | |
| | | 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; |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | 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) |
| | |
| | | _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) |
| | |
| | | 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) |
| | | { |