| | |
| | | public partial class DeliveryOrderServices : ServiceBase<Dt_DeliveryOrder, IRepository<Dt_DeliveryOrder>>, IDeliveryOrderServices |
| | | { |
| | | private readonly ICabinOrderServices _cabinOrderServices; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IInventory_BatchServices _inventory_BatchServices; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IInventoryInfoService _inventoryInfoService; |
| | | private readonly IDeliveryOrderDetailServices _deliveryOrderDetailServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | private readonly ISupplyTaskHtyService _supplyTaskHtyService; |
| | | private readonly ITacticsService _tacticsService; |
| | | private readonly IMaterielInfoService _materielInfoService; |
| | | private readonly IMessageInfoService _messageInfoService; |
| | | public IRepository<Dt_DeliveryOrder> Repository => BaseDal; |
| | | public DeliveryOrderServices(IRepository<Dt_DeliveryOrder> BaseDal, IBasicService basicService, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, IDeliveryOrderDetailServices deliveryOrderDetailServices, ISupplyTaskService supplyTaskService, ICabinOrderServices cabinOrderServices, ITacticsService tacticsService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService) : base(BaseDal) |
| | | public DeliveryOrderServices(IRepository<Dt_DeliveryOrder> BaseDal, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, IDeliveryOrderDetailServices deliveryOrderDetailServices, ISupplyTaskService supplyTaskService, ICabinOrderServices cabinOrderServices, ITacticsService tacticsService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService, IMaterielInfoService materielInfoService, ILocationInfoService locationInfoService) : base(BaseDal) |
| | | { |
| | | _basicService = basicService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _deliveryOrderDetailServices = deliveryOrderDetailServices; |
| | | _supplyTaskService = supplyTaskService; |
| | |
| | | _tacticsService = tacticsService; |
| | | _supplyTaskHtyService = supplyTaskHtyService; |
| | | _messageInfoService = messageInfoService; |
| | | _materielInfoService = materielInfoService; |
| | | _locationInfoService = locationInfoService; |
| | | } |
| | | #region å建åºåºå |
| | | /// <summary> |
| | |
| | | #endregion |
| | | var Order_qty = Math.Abs(detail.order_qty);//åºåºåæ°é |
| | | #region æ ¹æ®ç©æç¼ç æ¥è¯¢ç©æä¿¡æ¯ |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == detail.goods_no); |
| | | Dt_MaterielInfo materielInfo = _materielInfoService.Repository.QueryFirst(x => x.MaterielCode == detail.goods_no); |
| | | if (materielInfo == null) throw new Exception($"æªæ¾å°è¯åç¼ç ã{detail.goods_no}ãçä¿¡æ¯"); |
| | | if (!Enum.IsDefined(typeof(MaterielSourceTypeEnum), materielInfo.MaterielSourceType)) |
| | | throw new Exception($"请设置è¯åç¼å·ã{detail.goods_no}ãç屿§åç±»"); |
| | | if (materielInfo.BoxQty < 1) throw new Exception($"请设置è¯åç¼å·ã{detail.goods_no}ãçç®±è§æ°é"); |
| | | #endregion |
| | | #region 大件 |
| | | if (materielInfo.MaterielSourceType == MaterielSourceTypeEnum.PurchasePart)//å¦æç©ææ¯å¤§ä»¶ |
| | |
| | | #endregion |
| | | else |
| | | { |
| | | if (materielInfo.BoxQty < 1) throw new Exception($"请设置è¯åç¼å·ã{detail.goods_no}ãçç®±è§æ°é"); |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | Dt_DeliveryOrderDetail orderDetail = null; |
| | | Dt_DeliveryOrderDetail orderDetailLK = null; |
| | |
| | | if (Qty != item.order_qty) throw new Exception($"ççå
¥åºåã{order.order_no}ãç©æç¼å·ã{item.goods_no}ãç©ææ¹æ¬¡ã{item.batch_num}ãçççæ°éæè¯¯"); |
| | | //æ¾ææåºå |
| | | List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo); |
| | | //è·åç«åºçç¹å·®å¼æ° |
| | | //è·åç«åºçç¹å·®å¼æ°.ãããããããããããã |
| | | var inventoryLK = inventoryInfos.Where(x => x.WarehouseCode == WareCodeLK).First(); |
| | | var LkQty = Math.Abs(inventoryLK.StockQuantity - inventoryLK.SupplyQuantity); |
| | | //è·å大件åºçç¹å·®å¼æ° |
| | |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | Repository.AddData(entityOrder); |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | //Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | else |
| | |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "ççå
¥åº" |
| | | Remark = "çäºåºåº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | Repository.AddData(cabinOrder); |
| | | //Repository.AddData(cabinOrder); |
| | | Db.InsertNav(cabinOrder).Include(it => it.Details).ExecuteCommand(); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | Status = 0, |
| | | }).ToList() |
| | | }; |
| | | Repository.AddData(entityOrder); |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | //Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | return WebResponseContent.Instance.OK("æå"); |
| | | } |
| | | } |
| | | } |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// padåºåºå®æ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutFinish(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | |
| | | Dt_DeliveryOrderDetail? cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == supplyTask.BatchNo && x.Reservoirarea == supplyTask.WarehouseCode && x.Goods_no == supplyTask.MaterielCode).FirstOrDefault(); |
| | | 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.StockQuantity; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | |
| | | #region è´§ä½ |
| | | if (supplyTask.WarehouseCode != WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | { |
| | | var location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == supplyTask.LocationCode); |
| | | var location = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == supplyTask.LocationCode); |
| | | if (location == null) |
| | | return WebResponseContent.Instance.Error($"请维æ¤è´§ä½ç¼å·ã{supplyTask.LocationCode}ãçè´§ä½ä¿¡æ¯"); |
| | | //if (location.EnableStatus == EnableStatusEnum.Disable.ObjToInt()) |
| | |
| | | if (inventoryInfo1 == null) |
| | | { |
| | | location.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | _locationInfoService.UpdateData(location); |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | supplyTask.TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(); |
| | | _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.äººå·¥å®æ); |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode); |
| | | if (inventory_Batch != null) |
| | | #region åºåæ¹æ¬¡ 妿任å¡ç±»åæ¯è°æ¨åºåºä»»å¡ï¼8ï¼å°±ä¸ä¿®æ¹æ¹æ¬¡åºå |
| | | if (supplyTask.TaskType != TaskTypeEnum.AllocatOut.ObjToInt()) |
| | | { |
| | | inventory_Batch.StockQuantity -= supplyTask.StockQuantity; |
| | | inventory_Batch.OutboundQuantity -= supplyTask.StockQuantity; |
| | | if (inventory_Batch.StockQuantity <= 0) |
| | | _inventory_BatchServices.DeleteData(inventory_Batch); |
| | | else |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode); |
| | | if (inventory_Batch != null) |
| | | { |
| | | inventory_Batch.StockQuantity -= supplyTask.StockQuantity; |
| | | inventory_Batch.OutboundQuantity -= supplyTask.StockQuantity; |
| | | if (inventory_Batch.StockQuantity <= 0) |
| | | _inventory_BatchServices.DeleteData(inventory_Batch); |
| | | else |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | } |
| | | #endregion |
| | | if (supplyTask.WarehouseCode == WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | { |
| | | materielInfo.Business_qty -= supplyTask.StockQuantity; |
| | | _basicService.MaterielInfoService.Repository.UpdateData(materielInfo); |
| | | //if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | // CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | _materielInfoService.UpdateData(materielInfo); |
| | | if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 人工å¨åºåºåä¸ç¹å»å®ææé®å®ç°ä¸æ¥ |
| | | /// </summary> |
| | | /// <param name="key">id</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent FinishOutOrder(int key) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_DeliveryOrder deliveryOrder = BaseDal.QueryFirst(x => x.Id == key); |
| | | List<Dt_DeliveryOrder> deliveryOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == deliveryOrder.Out_no).Includes(x => x.Details).ToList();//æ¾åºææåºåºåå·ç¸åçåºåºå |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | foreach (var item in deliveryOrders) |
| | | { |
| | | if (item.Details != null) |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(item.Details, OperateTypeEnum.äººå·¥å®æ); |
| | | item.Modifier = App.User.UserName; |
| | | item.ModifyDate = DateTime.Now; |
| | | item.Details = null; |
| | | } |
| | | BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.äººå·¥å®æ); |
| | | if (deliveryOrder.Out_type == OutOrderTypeEnum.Allocate.ObjToInt().ToString()) |
| | | _unitOfWorkManage.CommitTran(); |
| | | else |
| | | { |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk"; |
| | | |
| | | var requestDate = new |
| | | { |
| | | order_no = deliveryOrder.Out_no |
| | | }; |
| | | var result = HttpHelper.Post(url, requestDate.ToJsonString()); |
| | | var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result); |
| | | if (response == null) throw new Exception("䏿¥ERPåºåºåå®æå¤±è´¥ï¼"); |
| | | if (response.resultCode != "0") throw new Exception(response.resultMsg); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |