| | |
| | | try |
| | | { |
| | | List<Dt_DeliveryOrder> deliveryOrders = new List<Dt_DeliveryOrder>(); |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | //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)); |
| | | 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(); |
| | | 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) |
| | | { |
| | |
| | | deliveryOrder.Details.Add(deliveryOrderDetail); |
| | | deliveryOrders.Add(deliveryOrder); |
| | | #region å建çç¹ä»»å¡ |
| | | //if (items.Key != "001")// éç«åºåºåéè¦å建çç¹ä»»å¡ |
| | | //{ |
| | | foreach (var inventory in items) |
| | | { |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | |
| | | SupplyQuantity = 0, |
| | | Remark = "çç¹" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | supplyTasks1.Add(supplyTask); |
| | | _InventoryInfos.Add(inventory); |
| | | } |
| | | //} |
| | |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inventoryInfoService.UpdateData(_InventoryInfos); |
| | | _supplyTaskService.AddData(supplyTasks); |
| | | _supplyTaskService.AddData(supplyTasks1); |
| | | BaseDal.Db.InsertNav(deliveryOrders) |
| | | .Include(x => x.Details) |
| | | .ExecuteCommand(); |
| | |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"çç¹å已宿"); |
| | | Dt_DeliveryOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == supplyTask.BatchNo && x.Reservoirarea == supplyTask.WarehouseCode && x.Goods_no == supplyTask.MaterielCode).First(); |
| | | if (cabinOrderDetail == null) return WebResponseContent.Instance.Error($"çç¹åæç»å·²å®æ"); |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | Dt_MaterielInfo materielInfo = _materielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | if (materielInfo == null) return WebResponseContent.Instance.Error($"请维æ¤ç©æç¼å·ã{cabinOrderDetail.Goods_no}ãçç©æä¿¡æ¯"); |
| | | cabinOrderDetail.Order_Outqty += supplyTask.SupplyQuantity; |
| | | #region å¹³åºçç¹åªè½åºç°æ´ç®±å·®å¼ |
| | |
| | | if (Qty != 0) return WebResponseContent.Instance.Error($"大件åºåºå为æ´ç®±ï¼çç¹æ°éä¸è½å卿£ä»¶"); |
| | | } |
| | | #endregion |
| | | //if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | // return WebResponseContent.Instance.Error($"å®çæ°éä¸å¯è¶
åºè´¦é¢æ°é"); |
| | | |
| | | #region å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #region ä¿®æ¹çç¹å |
| | | cabinOrder.OutStatus = "å¼å§"; |
| | | cabinOrderDetail.OotDetailStatus = "å¼å§"; |
| | | Repository.UpdateData(cabinOrder); |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | #endregion |
| | | |
| | | #region åºå |
| | |
| | | inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.WarehouseCode == supplyTask.WarehouseCode); |
| | | } |
| | | inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity; |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | #endregion |
| | | |
| | | #region ä»»å¡è®°å½ |
| | | //_supplyTaskService.UpdateData(supplyTask); |
| | | _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.èªå¨å®æ); |
| | | #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> 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 && x.Id != inventoryInfo.Id); |
| | | var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity) + supplyTask.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) |
| | | { |
| | | foreach (var item in inventoryInfos) |
| | | { |
| | | item.StockQuantity = item.SupplyQuantity; |
| | | item.SupplyQuantity = 0; |
| | | item.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | inventoryInfo.StockQuantity = supplyTask.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch.SupplyQuantity = SupplyQuantitys; |
| | | } |
| | | #endregion |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | #region å¤ççç¹å |
| | | if (supplyTasks.Count < 1) |
| | | { |
| | | #region 宿çç¹å |
| | |
| | | }); |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrder.Details, OperateTypeEnum.èªå¨å®æ); |
| | | cabinOrder.Details = null; |
| | | Repository.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | BaseDal.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | #endregion |
| | | } |
| | | supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList(); |
| | | if (supplyTasks.Count < 1) |
| | | else |
| | | { |
| | | #region æ¥æ¾åºå |
| | | var inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | //妿çç¹æ°åæ¹æ¬¡æ»æ°å¯¹ä¸äºï¼çç¹æ°èµå¼ä¸º0ï¼èµå¼å°±æ·»å çç¹æ° |
| | | if (SupplyQuantitys == inventory_Batch.StockQuantity) |
| | | { |
| | | foreach (var item in inventoryInfos) |
| | | { |
| | | item.StockQuantity = item.SupplyQuantity; |
| | | item.SupplyQuantity = 0; |
| | | item.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch.SupplyQuantity = SupplyQuantitys; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | 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); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | content.OK(); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |