| | |
| | | var 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}ãå·²åå¨çç¹ä»»å¡ï¼è¯·å
宿å½åçç¹ä»»å¡"); |
| | | 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}ãå·²åå¨çç¹ä»»å¡ï¼è¯·å
宿å½åçç¹ä»»å¡"); |
| | | 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) |
| | | { |
| | | foreach (var items in inventoryInfos.GroupBy(x => x.WarehouseCode)) |
| | | { |
| | | Dt_DeliveryOrder deliveryOrder = new Dt_DeliveryOrder() |
| | | Dt_DeliveryOrder? deliveryOrder = deliveryOrders.Where(x => x.Warehouse_no == items.Key).FirstOrDefault(); |
| | | bool isNull = false; |
| | | if (deliveryOrder == null) |
| | | { |
| | | Out_no = item.MaterielCode + "_" + item.BatchNo, |
| | | Out_type = "20", |
| | | OutStatus = "æ°å»º", |
| | | Warehouse_no = items.Key, |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | | }; |
| | | isNull = true; |
| | | deliveryOrder = new Dt_DeliveryOrder() |
| | | { |
| | | //Out_no = item.MaterielCode + "_" + item.BatchNo, |
| | | Out_no = $"PD{items.Key}{DateTime.Now.ToString("yyMMddHHmmss")}", |
| | | Out_type = "20", |
| | | OutStatus = "æ°å»º", |
| | | Warehouse_no = items.Key, |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | | }; |
| | | } |
| | | var Status = items.Key == "001" ? 0 : 2;//夿æ¯å¦ä¸ºç«åºåºå |
| | | Dt_DeliveryOrderDetail deliveryOrderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | |
| | | Reservoirarea = items.Key |
| | | }; |
| | | deliveryOrder.Details.Add(deliveryOrderDetail); |
| | | deliveryOrders.Add(deliveryOrder); |
| | | if (isNull) deliveryOrders.Add(deliveryOrder); |
| | | #region å建çç¹ä»»å¡ |
| | | foreach (var inventory in items) |
| | | { |
| | |
| | | { |
| | | inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.WarehouseCode == supplyTask.WarehouseCode); |
| | | } |
| | | inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity - inventoryInfo.StockQuantity; |
| | | #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(); |
| | | List<Dt_SupplyTask> supplyTasks1 = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList(); |
| | | 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 && x.TaskId != supplyTask.TaskId).ToList(); |
| | | List<Dt_SupplyTask> supplyTasks1 = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.TaskId != supplyTask.TaskId).ToList(); |
| | | Dt_Inventory_Batch inventory_Batch = new Dt_Inventory_Batch(); |
| | | List<Dt_InventoryInfo> inventoryInfos = new List<Dt_InventoryInfo>(); |
| | | if (supplyTasks1.Count < 1) |
| | | { |
| | | #region æ¥æ¾åºå |
| | | inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity); |
| | | inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.Id != inventoryInfo.Id); |
| | | var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity) + inventoryInfo.SupplyQuantity;//计ç®çç¹æ»æ° |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | //妿çç¹æ°åæ¹æ¬¡æ»æ°å¯¹ä¸äºï¼çç¹æ°èµå¼ä¸º0ï¼èµå¼å°±æ·»å çç¹æ° |
| | | if (SupplyQuantitys == inventory_Batch.StockQuantity) |
| | | |
| | | if (SupplyQuantitys == 0) |
| | | { |
| | | foreach (var item in inventoryInfos) |
| | | { |
| | | item.StockQuantity = item.SupplyQuantity; |
| | | item.StockQuantity += item.SupplyQuantity; |
| | | item.SupplyQuantity = 0; |
| | | item.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | inventoryInfo.StockQuantity += inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch.SupplyQuantity = SupplyQuantitys; |
| | | inventory_Batch.SupplyQuantity += SupplyQuantitys; |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | }); |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrder.Details, OperateTypeEnum.èªå¨å®æ); |
| | | cabinOrder.Details = null; |
| | | Repository.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | BaseDal.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | Repository.UpdateData(cabinOrder); |
| | | BaseDal.UpdateData(cabinOrder); |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | } |
| | | #endregion |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.èªå¨å®æ); |
| | | if (inventoryInfos.Count > 1) |
| | | { |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | content.OK(); |