| | |
| | | private readonly IInventoryInfoService _inventoryInfoService; |
| | | private readonly IDeliveryOrderDetailServices _deliveryOrderDetailServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | private readonly ISupplyTaskHtyService _supplyTaskHtyService; |
| | | private readonly ITacticsService _tacticsService; |
| | | 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) : base(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) |
| | | { |
| | | _basicService = basicService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _inventoryInfoService = inventoryInfoService; |
| | | _cabinOrderServices = cabinOrderServices; |
| | | _tacticsService = tacticsService; |
| | | _supplyTaskHtyService = supplyTaskHtyService; |
| | | _messageInfoService = messageInfoService; |
| | | } |
| | | #region å建åºåºå |
| | | /// <summary> |
| | | /// å建åºåºå |
| | | /// </summary> |
| | |
| | | inventory_Batch.AvailableQuantity -= item.Order_qty; |
| | | inventory_Batch.OutboundQuantity += item.Order_qty; |
| | | List<Dt_InventoryInfo> dt_InventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.AvailableQuantity > 0 && x.WarehouseCode == item.Reservoirarea); |
| | | if (dt_InventoryInfos.Count < 1) throw new Exception($"åºåºåå·ã{entityOrder.Out_no}ãä¸ç©æç¼å·ã{item.Goods_no}ãç©ææ¹æ¬¡ã{item.Batch_num}ãçåºåå½åç¶æä¸å¯åºåº"); |
| | | #region æåºåºçç¥æ¥æ¾åºå |
| | | if (tactics.SelectTactice == TacticsEnum.ComeOutonFirstTime.ObjToInt()) |
| | | dt_InventoryInfos = dt_InventoryInfos.OrderBy(x => x.ValidityPeriod).ToList(); |
| | |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | |
| | | inventory_Batch.AvailableQuantity -= detail.order_qty; |
| | | inventory_Batch.OutboundQuantity += detail.order_qty; |
| | | List<Dt_InventoryInfo> dt_InventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo && x.AvailableQuantity > 0 && (x.WarehouseCode == WareCodeDJ || x.WarehouseCode == WareCodeLK)); |
| | | if (dt_InventoryInfos.Count < 1) throw new Exception($"åºåºåå·ã{outorder.order_no}ãä¸ç©æç¼å·ã{detail.goods_no}ãç©ææ¹æ¬¡ã{detail.batch_num}ãçåºåå½åç¶æä¸å¯åºåº"); |
| | | #endregion |
| | | #region æåºåºçç¥æ¥æ¾åºå |
| | | if (tactics.SelectTactice == TacticsEnum.ComeOutonFirstTime.ObjToInt()) |
| | |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | |
| | | MaterielCode = item.MaterielCode, |
| | | MaterielSpec = item.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = item.LocationCode, |
| | |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = inventoryInfo.LocationCode, |
| | |
| | | } |
| | | return webResponseContent; |
| | | } |
| | | /// <summary> |
| | | /// çæåºåºåä»»å¡ |
| | | /// </summary> |
| | | /// <param name="order_no">åºåºåå·</param> |
| | | /// <returns></returns> |
| | | private bool CreateSupplyTask(List<string> order_no) |
| | | #endregion |
| | | |
| | | #region å建çäºåºåºå |
| | | public WebResponseContent CreateCheckOutOrder(UpstramOutOrderInfo order) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | // å
è·åç¬¦åæ¡ä»¶çä¸»è¡¨æ°æ® |
| | | var mainOrders = BaseDal.Db.Queryable<Dt_DeliveryOrder>() |
| | | .Where(x => order_no.Contains(x.Out_no)) |
| | | .ToList(); |
| | | |
| | | // è·åææä¸»è¡¨ID |
| | | var mainOrderIds = mainOrders.Select(x => x.Id).ToList(); |
| | | |
| | | // ç´æ¥æ¥è¯¢åè¡¨æ°æ® |
| | | List<Dt_DeliveryOrderDetail> filteredDetails = BaseDal.Db.Queryable<Dt_DeliveryOrderDetail>() |
| | | .Where(d => mainOrderIds.Contains(d.DeliveryOrderId) && d.OotDetailStatus == "æ°å»º") |
| | | .ToList(); |
| | | |
| | | // è·åææéè¦æ¥è¯¢çç©æç¼ç |
| | | var materielCodes = filteredDetails.Select(x => x.Goods_no).Distinct().ToList(); |
| | | |
| | | // æ¹éæ¥è¯¢ç©æä¿¡æ¯ |
| | | var materielList = BaseDal.Db.Queryable<Dt_MaterielInfo>() |
| | | .Where(x => materielCodes.Contains(x.MaterielCode)) |
| | | .ToList(); |
| | | |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | |
| | | foreach (var item in filteredDetails) |
| | | string WareCodeMJ = WarehouseEnum.麻精åº.ObjToInt().ToString("000"); |
| | | string WareCodeLD = WarehouseEnum.å·å»åº.ObjToInt().ToString("000"); |
| | | #region ç¹æ®åºæ¿ |
| | | if (order.warehouse_no == WareCodeMJ || order.warehouse_no == WareCodeLD) |
| | | { |
| | | // æ ¹æ®åè¡¨ç©æç¼ç æ¥è¯¢ç©æä¿¡æ¯ |
| | | var medication = materielList.FirstOrDefault(x => x.MaterielCode == item.Goods_no); |
| | | |
| | | // æ¥æ¾å¯¹åºçä¸»è¡¨ä¿¡æ¯ |
| | | var mainOrder = mainOrders.FirstOrDefault(x => x.Id == item.DeliveryOrderId); |
| | | //éæºçæä»»å¡ç¼å·å æ¶é´æ³ |
| | | |
| | | |
| | | if (mainOrder == null) continue; |
| | | |
| | | var location = Db.Queryable<Dt_InventoryInfo>() |
| | | .Where(x => x.MaterielCode == ""//materielCode |
| | | && x.BatchNo == ""//batchNo |
| | | && x.StockQuantity > 0) |
| | | .OrderBy(x => x.InDate) // æå
¥åºæ¶é´æåº |
| | | .First(); |
| | | |
| | | var supplyTask = new Dt_SupplyTask |
| | | #region åºåãåºåæ¹æ¬¡å¹³è´¦ |
| | | foreach (var item in order.details) |
| | | { |
| | | TaskNum = GenerateTaskNumber(), |
| | | PalletCode = "0", |
| | | BatchNo = item.Batch_num, |
| | | MaterielCode = item.Goods_no, |
| | | MaterielName = medication?.MaterielName, // å¦æç©æä¿¡æ¯ä¸åå¨ï¼ä½¿ç¨å表çç©æåç§° |
| | | MaterielSpec = medication?.MaterielSpec, // å¦æç©æä¿¡æ¯ä¸åå¨ï¼ä½¿ç¨å表çç©æè§æ ¼ |
| | | TaskType = 0, |
| | | TaskStatus = item.Status == 0 ? 0 : 1, |
| | | WarehouseCode = mainOrder.Warehouse_no, |
| | | LocationCode = item.Status == 0 ? "ç«åº" : "å¹³åº", |
| | | StockQuantity = item.Order_qty, // å设å表æQuantityåæ®µ |
| | | SupplyQuantity = 0, |
| | | OrderNo = mainOrder.Out_no, |
| | | Dispatchertime = DateTime.Now, |
| | | Remark = "" |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | var Qty = Math.Abs(inventory_Batch.StockQuantity - inventory_Batch.SupplyQuantity); |
| | | 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); |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å çäºåºåºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckOut.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "çäºå
¥åº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | #region å建çç¹å |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = order.order_no, |
| | | Out_type = order.order_type, |
| | | Client_no = order.client_no, |
| | | Client_name = order.client_name, |
| | | OutStatus = "已宿", |
| | | Account_time = order.account_time, |
| | | Warehouse_no = order.warehouse_no, |
| | | Details = order.details.Select(d => new Dt_DeliveryOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = Math.Abs(d.order_qty), |
| | | Order_Outqty = Math.Abs(d.order_qty), |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = order.warehouse_no, |
| | | OotDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | |
| | | supplyTasks.Add(supplyTask); |
| | | Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | |
| | | // æ¹éæå
¥ä¾åºä»»å¡ |
| | | if (supplyTasks.Any()) |
| | | #endregion |
| | | else |
| | | { |
| | | return BaseDal.Db.Insertable(supplyTasks).ExecuteCommand() > 0; |
| | | } |
| | | string WareCodeLK = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | string WareCodeDJ = WarehouseEnum.大件åº.ObjToInt().ToString("000"); |
| | | |
| | | return false; |
| | | foreach (var item in order.details) |
| | | { |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | var Qty = Math.Abs(inventory_Batch.StockQuantity - inventory_Batch.SupplyQuantity); |
| | | 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); |
| | | //è·å大件åºçç¹å·®å¼æ° |
| | | var inventoryDJ = inventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ).ToList(); |
| | | var DJQty = Math.Abs(inventoryDJ.Sum(x => x.StockQuantity) - inventoryDJ.Sum(x => x.SupplyQuantity)); |
| | | if (LkQty + DJQty != Qty) throw new Exception($"ã{order.order_no}ãç©æç¼å·ã{item.goods_no}ãç©ææ¹æ¬¡ã{item.batch_num}ãçç©æä¿¡æ¯ä¸ç©ææ¹æ¬¡ä¿¡æ¯ççæ°éä¸ç¬¦"); |
| | | if (LkQty == 0)//ç«åºæ å·®å¼ |
| | | { |
| | | #region åºåãåºåæ¹æ¬¡å¹³è´¦ |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å çäºåºåºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckOut.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "çäºå
¥åº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | #endregion |
| | | |
| | | #region å建大件åºçç¹å |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = order.order_no, |
| | | Out_type = order.order_type, |
| | | Client_no = order.client_no, |
| | | Account_time = order.account_time, |
| | | OutStatus = "已宿", |
| | | Client_name = order.client_name, |
| | | Warehouse_no = WareCodeDJ, |
| | | Details = order.details.Select(d => new Dt_DeliveryOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = Math.Abs(d.order_qty), |
| | | Order_Outqty = Math.Abs(d.order_qty), |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeDJ, |
| | | OotDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | //Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | #region 大件åºåºå平账 |
| | | inventoryInfos = inventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ).ToList(); |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å çäºåºåºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckOut.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "çäºåºåº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | #endregion |
| | | |
| | | #region å建大件åºçç¹å |
| | | if (DJQty != 0) |
| | | { |
| | | var cabinOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = order.order_no, |
| | | Out_type = order.order_type, |
| | | Client_name = order.client_name, |
| | | Account_time = order.account_time, |
| | | OutStatus = "已宿", |
| | | Client_no = order.client_no, |
| | | Warehouse_no = WareCodeDJ, |
| | | Details = order.details.Select(d => new Dt_DeliveryOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = DJQty, |
| | | Order_Outqty = DJQty, |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeDJ, |
| | | OotDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | //Repository.AddData(cabinOrder); |
| | | Db.InsertNav(cabinOrder).Include(it => it.Details).ExecuteCommand(); |
| | | } |
| | | #endregion |
| | | |
| | | #region å建ç«åºçç¹å |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = order.order_no, |
| | | Out_type = order.order_type, |
| | | Client_no = order.client_no, |
| | | Account_time = order.account_time, |
| | | OutStatus = "æ°å»º", |
| | | Client_name = order.client_name, |
| | | Warehouse_no = WareCodeLK, |
| | | Details = order.details.Select(d => new Dt_DeliveryOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = LkQty, |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeLK, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 0, |
| | | }).ToList() |
| | | }; |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | //Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | return WebResponseContent.Instance.OK("æå"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // è®°å½æ¥å¿ |
| | | Console.WriteLine($"å建ä¾åºä»»å¡å¤±è´¥ï¼{ex.Message}"); |
| | | return false; |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// çæéæºä»»å¡ç¼å·ï¼éæºæ° + æ¶é´æ³ï¼ |
| | | /// </summary> |
| | | /// <returns>ä»»å¡ç¼å·</returns> |
| | | private int GenerateTaskNumber() |
| | | { |
| | | // çæ4ä½éæºæ° |
| | | Random random = new Random(Guid.NewGuid().GetHashCode()); |
| | | int randomNum = random.Next(1000, 9999); // 1000-9999ä¹é´çéæºæ° |
| | | |
| | | |
| | | // ç»åæä»»å¡ç¼å·ï¼TASK + æ¶é´æ³ + éæºæ° |
| | | return randomNum; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | //çç¹ æ¿æ´ä¸ªæ¹æ¬¡ä¿¡æ¯è¡¨çååæ¹å·åååç¼å·æ¥è¿è¡çç¹ |
| | |
| | | List<Dt_DeliveryOrder> dt_ReceiveOrders = new List<Dt_DeliveryOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Warehouse_no == warehouseCode && x.Out_type != "3").Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Warehouse_no == warehouseCode && x.Out_type != "20").Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.Out_no.Contains(orderNo) || x.Client_no.Contains(orderNo)) && (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Out_type != "3" && x.Warehouse_no == warehouseCode).OrderByDescending(x => x.CreateDate).Includes(x => x.Details).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.Out_no.Contains(orderNo) || x.Client_no.Contains(orderNo)) && (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Out_type != "20" && x.Warehouse_no == warehouseCode).OrderByDescending(x => x.CreateDate).Includes(x => x.Details).ToPageList(pageNo, 5); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_DeliveryOrder cabinOrder = new Dt_DeliveryOrder(); |
| | | if (isPick) |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type == "3"); |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type == "20"); |
| | | else |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type != "3"); |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type != "20"); |
| | | //List<Dt_DeliveryOrderDetail>? cabinOrderDetails = cabinOrder.Details?.Where(x => x.Reservoirarea == pageNo.ToString()).ToList(); |
| | | List<Dt_DeliveryOrderDetail>? cabinOrderDetails = cabinOrder.Details?.Where(x => x.Status == 2).ToList(); |
| | | content.OK(data: cabinOrderDetails); |
| | |
| | | Dt_SupplyTask supplyTask = _supplyTaskService.Repository.QueryFirst(x => x.TaskId == TaskId && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt()); |
| | | if (supplyTask == null) throw new Exception("å½ååºåºä»»å¡å·²å®æ"); |
| | | if (supplyTask.LocationCode != LocationCode) throw new Exception($"å½ååºåºè´§ä½ã{LocationCode}ãä¸ä»»å¡åé
è´§ä½ä¸å¹é
"); |
| | | OutTaskFinish(supplyTask); |
| | | content = OutTaskFinish(supplyTask); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode).Includes(x => x.Details).First(); |
| | | Dt_DeliveryOrder? cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode).Includes(x => x.Details).First(); |
| | | 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(); |
| | | 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); |
| | | if (materielInfo == null) return WebResponseContent.Instance.Error($"请维æ¤ç©æç¼å·ã{cabinOrderDetail.Goods_no}ãçç©æä¿¡æ¯"); |
| | |
| | | //_deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type != "3").Includes(x => x.Details).First(); |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type != "20").Includes(x => x.Details).First(); |
| | | if (!cabinOrder1.Details.Where(x => x.OotDetailStatus != "已宿").Any()) |
| | | cabinOrder.OutStatus = "已宿"; |
| | | Repository.UpdateData(cabinOrder); |
| | |
| | | { |
| | | materielInfo.Business_qty -= supplyTask.StockQuantity; |
| | | _basicService.MaterielInfoService.Repository.UpdateData(materielInfo); |
| | | if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | //if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | // CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å¹³åºäººå·¥æ£æåºåºå¤çï¼å³äººå·¥æ«ç åºåºæ¶è°ç¨ï¼ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MatPicking(SaveModel saveModel) |
| | | public WebResponseContent FinishOutOrder(int key) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var LocationCode = saveModel.MainData["LocationCode"].ToString(); |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | var Inqty = saveModel.MainData["Inqty"].ObjToInt(); |
| | | var warehouseCode = saveModel.MainData["warehouseCode"].ToString(); |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == orderNo && x.Warehouse_no == warehouseCode && x.Out_type != "3").Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"åºåºå已宿"); |
| | | Dt_DeliveryOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == batchNo && x.Reservoirarea == warehouseCode).First(); |
| | | if (cabinOrderDetail == null) return WebResponseContent.Instance.Error($"åºåºåæç»å·²å®æ"); |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | if (materielInfo == null) return WebResponseContent.Instance.Error($"请维æ¤ç©æç¼å·ã{cabinOrderDetail.Goods_no}ãçç©æä¿¡æ¯"); |
| | | cabinOrderDetail.Order_Outqty += Inqty; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | return WebResponseContent.Instance.Error($"åºåºæ°éä¸å¯è¶
åºåæ®æ°é"); |
| | | |
| | | #region å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | 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(); |
| | | |
| | | #region åºåºå |
| | | cabinOrder.OutStatus = "å¼å§"; |
| | | cabinOrderDetail.OotDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Outqty == cabinOrderDetail.Order_qty) |
| | | foreach (var item in deliveryOrders) |
| | | { |
| | | cabinOrderDetail.OotDetailStatus = "已宿"; |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.èªå¨å®æ); |
| | | if (item.Details != null) |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(item.Details, OperateTypeEnum.äººå·¥å®æ); |
| | | item.Modifier = App.User.UserName; |
| | | item.ModifyDate = DateTime.Now; |
| | | item.Details = null; |
| | | } |
| | | else |
| | | BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.äººå·¥å®æ); |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk"; |
| | | var requestDate = new |
| | | { |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | } |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Out_type != "3").Includes(x => x.Details).First(); |
| | | if (cabinOrder1.Details == null || cabinOrder1.Details.Count < 1) cabinOrder.OutStatus = "已宿"; |
| | | Repository.UpdateData(cabinOrder); |
| | | #endregion |
| | | |
| | | #region åºå |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.LocationCode == LocationCode); |
| | | if (inventoryInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°è´§ä½ã{LocationCode}ãçåºåä¿¡æ¯"); |
| | | inventoryInfo.StockQuantity -= Inqty; |
| | | if (inventoryInfo.StockQuantity <= 0) |
| | | _inventoryInfoService.DeleteData(inventoryInfo); |
| | | else |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | #endregion |
| | | |
| | | #region è´§ä½ |
| | | var location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); |
| | | if (location == null) return WebResponseContent.Instance.Error($"请维æ¤è´§ä½ç¼å·ã{LocationCode}ãçè´§ä½ä¿¡æ¯"); |
| | | if (location.EnableStatus == EnableStatusEnum.Disable.ObjToInt()) |
| | | return WebResponseContent.Instance.Error($"è´§ä½ç¼å·ã{LocationCode}ãå·²ç¦ç¨ï¼è¯·æ¢å¤æ£å¸¸å使ç¨"); |
| | | Dt_InventoryInfo inventoryInfo1 = _inventoryInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); |
| | | if (inventoryInfo1 == null) |
| | | { |
| | | location.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | } |
| | | #endregion |
| | | |
| | | #region ä»»å¡è®°å½ |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = cabinOrderDetail.Reservoirarea, |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = location.LocationCode, |
| | | OrderNo = cabinOrder.Out_no, |
| | | StockQuantity = Inqty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | order_no = deliveryOrder.Out_no |
| | | }; |
| | | _supplyTaskService.AddData(supplyTask); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | 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 -= Inqty; |
| | | if (inventory_Batch.StockQuantity <= 0) |
| | | _inventory_BatchServices.DeleteData(inventory_Batch); |
| | | else |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | 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(); |
| | | #endregion |
| | | |
| | | content.OK(cabinOrderDetail.Order_Outqty.ToString()); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |