| | |
| | | { |
| | | public partial class DeliveryOrderServices : ServiceBase<Dt_DeliveryOrder, IRepository<Dt_DeliveryOrder>>, IDeliveryOrderServices |
| | | { |
| | | static string SearchDate = ""; |
| | | private readonly IBasicService _basicService; |
| | | private readonly ICabinOrderServices _cabinOrderServices; |
| | | 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 ICabinOrderServices _cabinOrderServices; |
| | | 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) : 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; |
| | |
| | | _inventoryInfoService = inventoryInfoService; |
| | | _cabinOrderServices = cabinOrderServices; |
| | | _tacticsService = tacticsService; |
| | | _supplyTaskHtyService = supplyTaskHtyService; |
| | | _messageInfoService = messageInfoService; |
| | | _materielInfoService = materielInfoService; |
| | | _locationInfoService = locationInfoService; |
| | | } |
| | | public WebResponseContent GetUpstreamOutOrder() |
| | | { |
| | | var responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/outOrder"; |
| | | //var url = "http://127.0.0.1:4523/m1/5660322-5340849-default/GYZ2/95fck/outOrder"; |
| | | if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //// 请æ±åæ° |
| | | var requestData = new |
| | | { |
| | | searchDate = SearchDate |
| | | //searchDate = "2022-10-10 20:45:16" // æ£ç¡®çæ ¼å¼ |
| | | }; |
| | | SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | var result = HttpHelper.Post(url, requestData.ToJsonString()); |
| | | var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstramOutOrderInfo>>(result); |
| | | |
| | | if (response.resultCode != "0") |
| | | { |
| | | SendErrorToUpstream(3, "", response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败", ""); |
| | | return responseContent.Error(response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败"); |
| | | } |
| | | |
| | | if (response.data == null || !response.data.Any()) |
| | | { |
| | | return responseContent.OK("æ æ°åºåºåæ°æ®"); |
| | | } |
| | | |
| | | // å·²åå¨åºåºåå· |
| | | var existingOutOrderNos = BaseDal.Db.Queryable<Dt_DeliveryOrder>() |
| | | .Select(x => x.Out_no) |
| | | .ToList(); |
| | | |
| | | // æ°åºåºå |
| | | var newOutOrders = response.data |
| | | .Where(outorder => !existingOutOrderNos.Contains(outorder.order_no)) |
| | | .ToList(); |
| | | |
| | | List<string> order_no = newOutOrders.Select(x => x.order_no).ToList(); |
| | | |
| | | if (!newOutOrders.Any()) |
| | | { |
| | | return responseContent.OK("ææåºåºåå·²åå¨ï¼æ éæ°å¢"); |
| | | } |
| | | |
| | | Db.Ado.BeginTran(); |
| | | try |
| | | { |
| | | List<Dt_DeliveryOrder> _DeliveryOrders = new List<Dt_DeliveryOrder>(); |
| | | List<string> orderNos = new List<string>(); |
| | | |
| | | foreach (var outorder in newOutOrders) |
| | | { |
| | | bool skipOrder = false; // æ è®°æ¯å¦è·³è¿è¯¥åºåºå |
| | | |
| | | // 妿è¿ä¸ªåºåºåç±»åä¸çäº1ï¼å±äºåºåºéè´§ï¼è¦å
¥è´§ä¸æ¸¸ä¼ è¿æ¥çæ°éä¸ºè´æ°ï¼ |
| | | if (outorder.order_type != "1") |
| | | { |
| | | // å建åºåºéè´§å - è¿ééè¦æ ¹æ®ä¸å¡é»è¾å®ç° |
| | | // ææ¶è·³è¿æå®ç°éè´§é»è¾ |
| | | continue; |
| | | } |
| | | else if (outorder.order_type == "1") // æ£å¸¸åºåºå |
| | | { |
| | | CreateOutboundOrder(outorder);//å建åºåºåãå¤çåºåãæ·»å åºåºä»»å¡ |
| | | // æé¤ç¹æ®è¯å,ç¹æ®è¯åç´æ¥æå
¥ |
| | | if (outorder.warehouse_no != "001" && (outorder.warehouse_no == "010" || outorder.warehouse_no == "003" || outorder.warehouse_no == "017")) |
| | | { |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = outorder.order_no, |
| | | Out_type = outorder.order_type, |
| | | Client_no = outorder.client_no, |
| | | Client_name = outorder.client_name, |
| | | Account_time = outorder.account_time, |
| | | Warehouse_no = outorder.warehouse_no, |
| | | OutStatus = "æ°å»º", |
| | | Details = outorder.details.Select(d => new Dt_DeliveryOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = Math.Abs(d.order_qty), // åºåºæ°éè½¬ä¸ºæ£æ° |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 2, // padå¹³åºï¼æ é忥 |
| | | }).ToList() |
| | | }; |
| | | _DeliveryOrders.Add(entityOrder); |
| | | } |
| | | else // 常è§è¯å001æ¿ç»ç«åº,è¦æ¯ææ´ç®±å°±ç»å¹³åº |
| | | { |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = outorder.order_no, |
| | | Out_type = outorder.order_type, |
| | | Client_no = outorder.client_no, |
| | | Client_name = outorder.client_name, |
| | | Account_time = outorder.account_time, |
| | | Warehouse_no = outorder.warehouse_no, |
| | | OutStatus = "æ°å»º", |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | | }; |
| | | |
| | | // éååºåºæç» |
| | | foreach (var item in outorder.details) |
| | | { |
| | | // å°ä¸æ¸¸åºåºæ°éè½¬ä¸ºæ£æ° |
| | | decimal orderQty = Math.Abs((decimal)item.order_qty); |
| | | |
| | | #region æ ¹æ®ç©æç¼ç æ¥è¯¢ç©æä¿¡æ¯ |
| | | var medication = BaseDal.Db.Queryable<Dt_MaterielInfo>() |
| | | .Where(m => m.MaterielCode == item.goods_no) |
| | | .First(); |
| | | |
| | | // å¦æç©æä¿¡æ¯ä¸åå¨ï¼è·³è¿æ´ä¸ªåºåºå |
| | | if (medication == null) |
| | | { |
| | | skipOrder = true; |
| | | Console.WriteLine($"è·³åºå¤åºå {outorder.order_no}ï¼åå ï¼æªæ¾å°åå [{item.goods_no}] çç©æä¿¡æ¯ã"); |
| | | break; |
| | | } |
| | | |
| | | // è¥ç©æä¸å卿 MaterielSourceType 为空ï¼åè·³è¿æ´ä¸ªåºåºå |
| | | if (medication == null || !Enum.IsDefined(typeof(MaterielSourceTypeEnum), medication.MaterielSourceType)) |
| | | { |
| | | skipOrder = true; |
| | | break; |
| | | } |
| | | #endregion |
| | | |
| | | /// æ ¹æ®ç©æä¿¡æ¯å¤§å°ä»¶å±æ§åºåæ¯å¦ä»ç«åºåºåº // 大件ä»å¹³åºåºåº |
| | | if (medication.MaterielSourceType == MaterielSourceTypeEnum.PurchasePart) // å¦æç©ææ¯å¤§ä»¶ |
| | | { |
| | | var orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = outorder.warehouse_no, |
| | | Goods_no = item.goods_no, |
| | | Order_qty = orderQty, |
| | | Batch_num = item.batch_num, |
| | | Exp_date = item.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 2 // å¹³åºï¼æ é忥 |
| | | }; |
| | | entityOrder.Details.Add(orderDetail); |
| | | } |
| | | else |
| | | { |
| | | Dt_DeliveryOrderDetail orderDetail = null; |
| | | |
| | | // è®¡ç®æ´ç®±åæ£ä»¶æ°é |
| | | var ys = orderQty % medication.BoxQty; // ä¸è½æ´é¤ç®±è§çæ£ä»¶æ° |
| | | var xs = (int)(orderQty / medication.BoxQty); // æ´ç®±æ°éï¼ä¿çæ´æ°ï¼ |
| | | |
| | | #region ä»ç«åºåºåºæ£ä»¶ |
| | | |
| | | #region 夿æ¯å¦ææ£ä»¶ |
| | | if (ys > 0 && medication.Business_qty >= ys) |
| | | { |
| | | orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = outorder.warehouse_no, |
| | | Goods_no = item.goods_no, |
| | | Order_qty = ys, |
| | | Batch_num = item.batch_num, |
| | | Exp_date = item.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 0 // ç«åºï¼éè¦åæ¥ç»WCS |
| | | }; |
| | | medication.Business_qty -= ys; |
| | | } |
| | | #endregion |
| | | |
| | | #region 夿ç«åºåºåæ¯å¦è¶³å¤åºæ´ç®± |
| | | while (medication.Business_qty >= medication.BoxQty && xs > 0) |
| | | { |
| | | xs--; |
| | | if (orderDetail == null) |
| | | { |
| | | orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = outorder.warehouse_no, |
| | | Goods_no = item.goods_no, |
| | | Order_qty = medication.BoxQty, |
| | | Batch_num = item.batch_num, |
| | | Exp_date = item.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 0 // ç«åº |
| | | }; |
| | | medication.Business_qty -= medication.BoxQty; |
| | | } |
| | | else |
| | | { |
| | | orderDetail.Order_qty += medication.BoxQty; |
| | | medication.Business_qty -= medication.BoxQty; |
| | | } |
| | | } |
| | | |
| | | if (orderDetail != null) |
| | | entityOrder.Details.Add(orderDetail); |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region å©ä½æ´ä»¶ä»å¹³åºåºåº |
| | | if (xs > 0) |
| | | { |
| | | orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = outorder.warehouse_no, |
| | | Goods_no = item.goods_no, |
| | | Order_qty = medication.BoxQty * xs, |
| | | Batch_num = item.batch_num, |
| | | Exp_date = item.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 2 // å¹³åº |
| | | }; |
| | | entityOrder.Details.Add(orderDetail); |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | // æ´æ°ç©æä¿¡æ¯ |
| | | _basicService.MaterielInfoService.Repository.UpdateData(medication); |
| | | |
| | | } |
| | | |
| | | // å¦æè·³è¿è¯¥åï¼åç´æ¥continueï¼ä¸ä¿å |
| | | if (skipOrder) |
| | | { |
| | | Console.WriteLine($"è·³åºå¤åºå {outorder.order_no}ï¼å 为å卿ªå®ä¹ç©æå±æ§çååã"); |
| | | continue; |
| | | } |
| | | |
| | | // ç¡®ä¿åºåºåææç»ææ·»å |
| | | if (entityOrder.Details.Any()) |
| | | { |
| | | _DeliveryOrders.Add(entityOrder); |
| | | orderNos.Add(outorder.order_no); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æ¹éæå
¥åºåºååæç» |
| | | if (_DeliveryOrders.Any()) |
| | | { |
| | | BaseDal.Db.InsertNav(_DeliveryOrders).Include(x => x.Details).ExecuteCommand(); |
| | | } |
| | | //ä¸ååºåºåä»»å¡ç»wcs |
| | | |
| | | |
| | | Db.Ado.CommitTran(); |
| | | var tex = CreateSupplyTask(order_no); |
| | | if (!tex) |
| | | { |
| | | return responseContent.Error("å建ä¾åºä»»å¡å¤±è´¥"); |
| | | } |
| | | return responseContent.OK($"忥åºåºåæåï¼å
±{_DeliveryOrders.Count}æ¡"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | SendErrorToUpstream(3, "", ex.Message, ""); |
| | | return responseContent.Error("åæ¥å¤±è´¥: " + ex.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SendErrorToUpstream(3, "", ex.Message, ""); |
| | | return responseContent.Error("åæ¥å¤±è´¥: " + ex.Message); |
| | | } |
| | | } |
| | | #region å建åºåºå |
| | | /// <summary> |
| | | /// å建åºåºå |
| | | /// </summary> |
| | |
| | | try |
| | | { |
| | | Dt_Tactics tactics = _tacticsService.Repository.QueryFirst(x => x.TacticeName == "åºåºçç¥"); |
| | | if (outorder.warehouse_no == WarehouseEnum.麻精åº.ObjToInt().ToString("000") || outorder.warehouse_no == WarehouseEnum.å·å»åº.ObjToInt().ToString("000")) |
| | | #region ç¹æ®åºæ¿åºåº |
| | | string WareCodeMJ = WarehouseEnum.麻精åº.ObjToInt().ToString("000"); |
| | | string WareCodeLD = WarehouseEnum.å·å»åº.ObjToInt().ToString("000"); |
| | | if (outorder.warehouse_no == WareCodeMJ || outorder.warehouse_no == WareCodeLD) |
| | | { |
| | | #region æ·»å åºåºå |
| | | var entityOrder = new Dt_DeliveryOrder |
| | |
| | | Status = 2, // padå¹³åºï¼æ é忥 |
| | | }).ToList() |
| | | }; |
| | | BaseDal.Db.InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand(); |
| | | #endregion |
| | | List<Dt_InventoryInfo> dt_InventoryInfos = new List<Dt_InventoryInfo>(); |
| | | #region å¤çåºåãæ·»å åºåºä»»å¡ |
| | | #region å¤çåºåãåºåæ¹æ¬¡ãæ·»å åºåºä»»å¡ |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | List<Dt_Inventory_Batch> batchesUp = new List<Dt_Inventory_Batch>(); |
| | | List<Dt_InventoryInfo> inventoryInfosUp = new List<Dt_InventoryInfo>(); |
| | | var inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode)); |
| | | var InventoryInfos = _inventoryInfoService.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.AvailableQuantity > 0 && x.WarehouseCode == outorder.warehouse_no); |
| | | foreach (var item in entityOrder.Details) |
| | | { |
| | | dt_InventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.MaterielCode == item.Goods_no && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.StockQuantity > x.OutboundQuantity && x.WarehouseCode == item.Reservoirarea); |
| | | Dt_Inventory_Batch? inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num).FirstOrDefault(); |
| | | if (inventory_Batch == null) throw new Exception($"æªæ¾å°åºåºåå·ã{entityOrder.Out_no}ãä¸ç©æç¼å·ã{item.Goods_no}ãç©ææ¹æ¬¡ã{item.Batch_num}ãçåºåæ¹æ¬¡ä¿¡æ¯"); |
| | | if (inventory_Batch.AvailableQuantity < item.Order_qty) throw new Exception($"åºåºåå·ã{entityOrder.Out_no}ãä¸ç©æç¼å·ã{item.Goods_no}ãç©ææ¹æ¬¡ã{item.Batch_num}ãçåºåæ¹æ¬¡ä¿¡æ¯å¯ç¨æ°éä¸è¶³"); |
| | | inventory_Batch.AvailableQuantity -= item.Order_qty; |
| | | inventory_Batch.OutboundQuantity += item.Order_qty; |
| | | List<Dt_InventoryInfo> dt_InventoryInfos = InventoryInfos.Where(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num).ToList(); |
| | | 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(); |
| | | else |
| | | dt_InventoryInfos = dt_InventoryInfos.OrderBy(x => x.InDate).ToList(); |
| | | #endregion |
| | | var Order_qty = item.Order_qty; |
| | | var Order_qty = item.Order_qty;//åºåºåæ°é |
| | | foreach (var InventoryInfo in dt_InventoryInfos) |
| | | { |
| | | if (InventoryInfo.AvailableQuantity < Order_qty) |
| | | if (Order_qty <= 0) break; |
| | | if (InventoryInfo.AvailableQuantity <= Order_qty) |
| | | { |
| | | |
| | | Order_qty -= InventoryInfo.AvailableQuantity; |
| | | InventoryInfo.OutboundQuantity += InventoryInfo.AvailableQuantity; |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = InventoryInfo.WarehouseCode, |
| | | BatchNo = InventoryInfo.BatchNo, |
| | | MaterielName = InventoryInfo.MaterielName, |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = InventoryInfo.AvailableQuantity, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | InventoryInfo.AvailableQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | InventoryInfo.AvailableQuantity -= Order_qty; |
| | | InventoryInfo.OutboundQuantity += Order_qty; |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = InventoryInfo.WarehouseCode, |
| | | BatchNo = InventoryInfo.BatchNo, |
| | | MaterielName = InventoryInfo.MaterielName, |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = Order_qty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | Order_qty = 0; |
| | | } |
| | | inventoryInfosUp.Add(InventoryInfo); |
| | | } |
| | | batchesUp.Add(inventory_Batch); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _supplyTaskService.AddData(supplyTasks); |
| | | _inventory_BatchServices.UpdateData(batchesUp); |
| | | _inventoryInfoService.UpdateData(inventoryInfosUp); |
| | | BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | string WareCodeDJ = WarehouseEnum.大件åº.ObjToInt().ToString("000"); |
| | | string WareCodeLK = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | #region å建大件åºãç«åºåºåºå¤´è¡¨ |
| | | var entityOrder = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = outorder.order_no, |
| | | Out_type = outorder.order_type, |
| | | OutStatus = "æ°å»º", |
| | | Client_name = outorder.client_name, |
| | | Account_time = outorder.account_time, |
| | | Client_no = outorder.client_no, |
| | | Warehouse_no = WareCodeDJ, |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | | }; |
| | | var entityOrderLK = new Dt_DeliveryOrder |
| | | { |
| | | Out_no = outorder.order_no, |
| | | Out_type = outorder.order_type, |
| | | OutStatus = "æ°å»º", |
| | | Client_name = outorder.client_name, |
| | | Account_time = outorder.account_time, |
| | | Client_no = outorder.client_no, |
| | | Warehouse_no = WareCodeLK, |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | | }; |
| | | #endregion |
| | | #region æ¥æ¾åºå |
| | | List<Dt_Inventory_Batch> batchesUp = new List<Dt_Inventory_Batch>(); |
| | | List<Dt_InventoryInfo> inventoryInfosUp = new List<Dt_InventoryInfo>(); |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | List<Dt_MaterielInfo> materielInfos = _materielInfoService.Repository.QueryData(x => outorder.details.Select(e => e.goods_no).Contains(x.MaterielCode)); |
| | | var inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => outorder.details.Select(e => e.goods_no).Contains(x.MaterielCode)); |
| | | var InventoryInfos = _inventoryInfoService.Repository.QueryData(x => outorder.details.Select(e => e.goods_no).Contains(x.MaterielCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.AvailableQuantity > 0 && (x.WarehouseCode == WareCodeDJ || x.WarehouseCode == WareCodeLK)); |
| | | foreach (var detail in outorder.details) |
| | | { |
| | | #region æ¥è¯¢åºåæ¹æ¬¡ååºå |
| | | Dt_Inventory_Batch? inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == detail.goods_no && x.BatchNo == detail.batch_num).FirstOrDefault(); |
| | | if (inventory_Batch == null) throw new Exception($"æªæ¾å°åºåºåå·ã{outorder.order_no}ãä¸ç©æç¼å·ã{detail.goods_no}ãç©ææ¹æ¬¡ã{detail.batch_num}ãçåºåæ¹æ¬¡ä¿¡æ¯"); |
| | | if (inventory_Batch.AvailableQuantity < detail.order_qty) throw new Exception($"åºåºåå·ã{outorder.order_no}ãä¸ç©æç¼å·ã{detail.goods_no}ãç©ææ¹æ¬¡ã{detail.batch_num}ãçåºåæ¹æ¬¡ä¿¡æ¯å¯ç¨æ°éä¸è¶³"); |
| | | inventory_Batch.AvailableQuantity -= detail.order_qty; |
| | | inventory_Batch.OutboundQuantity += detail.order_qty; |
| | | List<Dt_InventoryInfo> dt_InventoryInfos = InventoryInfos.Where(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo).ToList(); |
| | | 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()) |
| | | dt_InventoryInfos = dt_InventoryInfos.OrderBy(x => x.ValidityPeriod).ToList(); |
| | | else |
| | | dt_InventoryInfos = dt_InventoryInfos.OrderBy(x => x.InDate).ToList(); |
| | | #endregion |
| | | var Order_qty = Math.Abs(detail.order_qty);//åºåºåæ°é |
| | | #region æ ¹æ®ç©æç¼ç æ¥è¯¢ç©æä¿¡æ¯ |
| | | Dt_MaterielInfo? materielInfo = materielInfos.Where(x => x.MaterielCode == detail.goods_no).FirstOrDefault(); |
| | | if (materielInfo == null) throw new Exception($"æªæ¾å°è¯åç¼ç ã{detail.goods_no}ãçä¿¡æ¯"); |
| | | if (!Enum.IsDefined(typeof(MaterielSourceTypeEnum), materielInfo.MaterielSourceType)) |
| | | throw new Exception($"请设置è¯åç¼å·ã{detail.goods_no}ãç屿§åç±»"); |
| | | #endregion |
| | | #region 大件 |
| | | if (materielInfo.MaterielSourceType == MaterielSourceTypeEnum.PurchasePart)//å¦æç©ææ¯å¤§ä»¶ |
| | | { |
| | | #region æ·»å åºåºè¯¦æ
|
| | | Dt_DeliveryOrderDetail orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = entityOrder.Warehouse_no, |
| | | Goods_no = detail.goods_no, |
| | | Order_qty = detail.order_qty, |
| | | Batch_num = detail.batch_num, |
| | | Exp_date = detail.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Order_Outqty = 0, |
| | | Status = 2 |
| | | }; |
| | | entityOrder.Details.Add(orderDetail); |
| | | #endregion |
| | | |
| | | #region 计ç®åºåãæ·»å åºåºä»»å¡ |
| | | foreach (var InventoryInfo in dt_InventoryInfos) |
| | | { |
| | | if (Order_qty <= 0) break; |
| | | if (InventoryInfo.AvailableQuantity < Order_qty) |
| | | { |
| | | Order_qty -= InventoryInfo.AvailableQuantity; |
| | | InventoryInfo.OutboundQuantity += InventoryInfo.AvailableQuantity; |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = InventoryInfo.WarehouseCode, |
| | | BatchNo = InventoryInfo.BatchNo, |
| | | MaterielName = InventoryInfo.MaterielName, |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = InventoryInfo.AvailableQuantity, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | InventoryInfo.AvailableQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | InventoryInfo.AvailableQuantity -= Order_qty; |
| | | InventoryInfo.OutboundQuantity += Order_qty; |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = InventoryInfo.WarehouseCode, |
| | | BatchNo = InventoryInfo.BatchNo, |
| | | MaterielName = InventoryInfo.MaterielName, |
| | | MaterielCode = InventoryInfo.MaterielCode, |
| | | MaterielSpec = InventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = InventoryInfo.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = Order_qty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | Order_qty = 0; |
| | | } |
| | | } |
| | | #endregion |
| | | inventoryInfosUp.AddRange(dt_InventoryInfos); |
| | | batchesUp.Add(inventory_Batch); |
| | | //_inventory_BatchServices.Repository.UpdateData(inventory_Batch); |
| | | //_inventoryInfoService.Repository.UpdateData(dt_InventoryInfos); |
| | | //_supplyTaskService.AddData(supplyTasks); |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | if (materielInfo.BoxQty < 1) throw new Exception($"请设置è¯åç¼å·ã{detail.goods_no}ãçç®±è§æ°é"); |
| | | Dt_DeliveryOrderDetail orderDetail = null; |
| | | Dt_DeliveryOrderDetail orderDetailLK = null; |
| | | var ys = Order_qty % materielInfo.BoxQty; //ä¸è½æ´é¤ç®±è§çæ£ä»¶æ° |
| | | var xs = (int)(Order_qty / materielInfo.BoxQty);//ä¿çæ´æ° |
| | | #region æ£ä»¶ä¼å
åé
ç«åº |
| | | if (ys > 0) |
| | | { |
| | | orderDetailLK = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = entityOrderLK.Warehouse_no, |
| | | Goods_no = detail.goods_no, |
| | | Order_qty = ys, |
| | | Batch_num = detail.batch_num, |
| | | Exp_date = detail.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Order_Outqty = 0, |
| | | Status = 0 |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region æ´ä»¶ä¼å
åé
大件åº,计ååºå,æ·»å åºåºä»»å¡ |
| | | foreach (var item in dt_InventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ)) |
| | | { |
| | | if (xs <= 0) break; |
| | | decimal outqty = 0; |
| | | while (item.AvailableQuantity > 0 && xs > 0) |
| | | { |
| | | xs--; |
| | | if (orderDetail == null) |
| | | { |
| | | orderDetail = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = entityOrder.Warehouse_no, |
| | | Goods_no = detail.goods_no, |
| | | Order_qty = materielInfo.BoxQty, |
| | | Batch_num = detail.batch_num, |
| | | Exp_date = detail.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Order_Outqty = 0, |
| | | Status = 2 |
| | | }; |
| | | item.AvailableQuantity -= materielInfo.BoxQty; |
| | | item.OutboundQuantity += materielInfo.BoxQty; |
| | | outqty += materielInfo.BoxQty; |
| | | } |
| | | else |
| | | { |
| | | orderDetail.Order_qty += materielInfo.BoxQty; |
| | | item.AvailableQuantity -= materielInfo.BoxQty; |
| | | item.OutboundQuantity += materielInfo.BoxQty; |
| | | outqty += materielInfo.BoxQty; |
| | | } |
| | | } |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = item.WarehouseCode, |
| | | BatchNo = item.BatchNo, |
| | | MaterielName = item.MaterielName, |
| | | MaterielCode = item.MaterielCode, |
| | | MaterielSpec = item.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = item.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = outqty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | inventoryInfosUp.Add(item); |
| | | //_inventoryInfoService.Repository.UpdateData(item); |
| | | } |
| | | #endregion |
| | | |
| | | #region åé
å®å¤§ä»¶åºå¦æè¿æç®±æ°ï¼åéæ©åé
ç«åº |
| | | if (xs > 0) |
| | | { |
| | | if (orderDetailLK == null) |
| | | { |
| | | orderDetailLK = new Dt_DeliveryOrderDetail() |
| | | { |
| | | Reservoirarea = entityOrderLK.Warehouse_no, |
| | | Goods_no = detail.goods_no, |
| | | Order_qty = xs * materielInfo.BoxQty, |
| | | Batch_num = detail.batch_num, |
| | | Exp_date = detail.exp_date, |
| | | OotDetailStatus = "æ°å»º", |
| | | Order_Outqty = 0, |
| | | Status = 0 |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | orderDetailLK.Order_qty += xs * materielInfo.BoxQty; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ç«åºåºåºåï¼ä¿®æ¹ç«åºåºåï¼æ·»å ç«åºåºåºä»»å¡ |
| | | if (orderDetailLK != null) |
| | | { |
| | | #region æ·»å åºåºä»»å¡ãä¿®æ¹åºåä¿¡æ¯ |
| | | Dt_InventoryInfo inventoryInfo = dt_InventoryInfos.Where(x => x.WarehouseCode == WareCodeLK).First(); |
| | | inventoryInfo.AvailableQuantity -= orderDetailLK.Order_qty; |
| | | inventoryInfo.OutboundQuantity += orderDetailLK.Order_qty; |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.NewOut.ObjToInt(), |
| | | TaskType = outorder.order_type == "1" ? TaskTypeEnum.Out.ObjToInt() : TaskTypeEnum.InReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName ?? "System", |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = entityOrder.Out_no, |
| | | StockQuantity = orderDetailLK.Order_qty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | #endregion |
| | | //_inventoryInfoService.Repository.UpdateData(inventoryInfo); |
| | | inventoryInfosUp.Add(inventoryInfo); |
| | | entityOrderLK.Details.Add(orderDetailLK); |
| | | } |
| | | #endregion |
| | | if (orderDetail != null) entityOrder.Details.Add(orderDetail); |
| | | batchesUp.Add(inventory_Batch); |
| | | //_inventory_BatchServices.Repository.UpdateData(inventory_Batch); |
| | | //_supplyTaskService.AddData(supplyTasks); |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _supplyTaskService.AddData(supplyTasks); |
| | | _inventory_BatchServices.UpdateData(batchesUp); |
| | | _inventoryInfoService.UpdateData(inventoryInfosUp); |
| | | if (entityOrder.Details.Count > 0) |
| | | BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand(); |
| | | if (entityOrderLK.Details.Count > 0) |
| | | BaseDal.Db.CopyNew().InsertNav(entityOrderLK).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | } |
| | | webResponseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | webResponseContent.Error(ex.Message); |
| | | } |
| | | 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"); |
| | | List<Dt_SupplyTask_Hty> supplyTask_Hties = new List<Dt_SupplyTask_Hty>(); |
| | | List<Dt_Inventory_Batch> batchesUp = new List<Dt_Inventory_Batch>(); |
| | | List<Dt_InventoryInfo> infosUp = new List<Dt_InventoryInfo>(); |
| | | var codes = order.details.Select(x => x.goods_no).ToList(); |
| | | #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 |
| | | List<Dt_Inventory_Batch> inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => codes.Contains(x.MaterielCode)); |
| | | List<Dt_InventoryInfo> _InventoryInfos = _inventoryInfoService.Repository.QueryData(x => codes.Contains(x.MaterielCode)); |
| | | #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 = "" |
| | | }; |
| | | |
| | | supplyTasks.Add(supplyTask); |
| | | } |
| | | |
| | | // æ¹éæå
¥ä¾åºä»»å¡ |
| | | if (supplyTasks.Any()) |
| | | { |
| | | return BaseDal.Db.Insertable(supplyTasks).ExecuteCommand() > 0; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // è®°å½æ¥å¿ |
| | | Console.WriteLine($"å建ä¾åºä»»å¡å¤±è´¥ï¼{ex.Message}"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <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; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// åºåºåæ¨éç» WCS |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent EdiOut() |
| | | { |
| | | var responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | // 1. æ¥è¯¢ç¬¦åæ¡ä»¶ç订åï¼è¡¨å¤´=æ°å»º && å
嫿ææç»ï¼ |
| | | var outOrders = BaseDal.Db.CopyNew().Queryable<Dt_DeliveryOrder>() |
| | | .Where(o => o.OutStatus == "æ°å»º" && o.Warehouse_no == WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | .Includes(o => o.Details, d => d.MedicineGoods) |
| | | .ToList(); |
| | | |
| | | // 2. åè¿æ»¤æä¸ç¬¦åæ¡ä»¶çæç»ï¼åªä¿ç Status=0 ï¼ |
| | | foreach (var order in outOrders) |
| | | { |
| | | order.Details = order.Details.Where(d => d.Status == 0).ToList(); |
| | | } |
| | | |
| | | if (outOrders == null || !outOrders.Any()) |
| | | { |
| | | Console.WriteLine("没æç¬¦åæ¡ä»¶ç订åéè¦æ¨é"); |
| | | return responseContent.Error("没æç¬¦åæ¡ä»¶ç订åéè¦æ¨é"); |
| | | } |
| | | |
| | | foreach (var order in outOrders) |
| | | { |
| | | try |
| | | { |
| | | string materialCode = "YY";//é»è®¤å¼ |
| | | //è·åå½å订åç第ä¸ä¸ªæç»é¡¹ |
| | | var firstDetail = order.Details.FirstOrDefault(); |
| | | if (firstDetail?.MedicineGoods != null && !string.IsNullOrEmpty(firstDetail.MedicineGoods.MaterielErpType)) |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).First(); |
| | | 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 = _InventoryInfos.Where(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo).ToList(); |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | //妿æ¡ä»¶æ»¡è¶³ï¼å°ç©æä»£ç 设置为第ä¸ä¸ªæç»é¡¹å¯¹åºçè¯åç©æä»£ç |
| | | materialCode = firstDetail.MedicineGoods.MaterielErpType; |
| | | } |
| | | // 3. ç»è£
DTO |
| | | var ediDto = new TowcsDto.ToediOutInfo |
| | | { |
| | | customerCode = "905", |
| | | materialCode = materialCode, |
| | | externalOrderNo = order.Out_no, |
| | | outOrderType = order.Out_type == "1" ? "10" : order.Out_type == "3" ? "20" : "30",//åºåºåç±»åæ¯1å°±æ¯æ£å¸¸çï¼3å°±æ¯çç¹ |
| | | priority = 1, |
| | | Is_cancel = 0, |
| | | details = order.Details.Select(d => new TowcsDto.ToeOutdiInDetail |
| | | #region æ·»å çäºåºåºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | batchNo = d.Batch_num, |
| | | productCode = d.Goods_no, |
| | | productName = d.MedicineGoods?.MaterielName, |
| | | productSpecifications = d.MedicineGoods?.MaterielModel, |
| | | quantity = (int)d.Order_qty, |
| | | //stocktakingDetails = order.Out_type == "3" |
| | | // ? new List<ToOutediInStock> |
| | | // { |
| | | // new ToOutediInStock { palletCode = "FC00001", quantity = d.Order_qty.ToString() } |
| | | // } |
| | | // : null |
| | | }).ToList() |
| | | }; |
| | | 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); |
| | | supplyTask_Hties.Add(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | infosUp.AddRange(inventoryInfos); |
| | | batchesUp.Add(inventory_Batch); |
| | | //_inventoryInfoService.UpdateData(inventoryInfos); |
| | | //_inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | // 4. è°ç¨æ¥å£ |
| | | var url = "http://172.16.1.2:9357/file-admin/api/out/ediOut"; |
| | | //var url = "http://127.0.0.1:4523/m2/5660322-5340849-default/363076920"; |
| | | |
| | | var result = HttpHelper.Post(url, ediDto.ToJsonString()); |
| | | var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result); |
| | | |
| | | if (resp != null && resp.code == "0") |
| | | #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 |
| | | { |
| | | // æ´æ°è¡¨å¤´ç¶æ |
| | | BaseDal.Db.Updateable<Dt_DeliveryOrder>() |
| | | .SetColumns(o => new Dt_DeliveryOrder { OutStatus = "å¼å§" }) |
| | | .Where(o => o.Id == order.Id) |
| | | .ExecuteCommand(); |
| | | 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() |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _supplyTaskHtyService.AddData(supplyTask_Hties); |
| | | _inventoryInfoService.UpdateData(infosUp); |
| | | _inventory_BatchServices.UpdateData(batchesUp); |
| | | BaseDal.Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | List<Dt_DeliveryOrder> deliveryOrdersAdd = new List<Dt_DeliveryOrder>(); |
| | | string WareCodeLK = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | string WareCodeDJ = WarehouseEnum.大件åº.ObjToInt().ToString("000"); |
| | | List<Dt_Inventory_Batch> inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => codes.Contains(x.MaterielCode)); |
| | | List<Dt_InventoryInfo> _InventoryInfos = _inventoryInfoService.Repository.QueryData(x => codes.Contains(x.MaterielCode)); |
| | | foreach (var item in order.details) |
| | | { |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).First(); |
| | | 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 = _InventoryInfos.Where(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo).ToList(); |
| | | //è·åç«åºçç¹å·®å¼æ°.ãããããããããããã |
| | | 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); |
| | | supplyTask_Hties.Add(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); |
| | | infosUp.AddRange(inventoryInfos); |
| | | batchesUp.Add(inventory_Batch); |
| | | #endregion |
| | | |
| | | // æ´æ°æç»ç¶æ |
| | | BaseDal.Db.Updateable<Dt_DeliveryOrderDetail>() |
| | | .SetColumns(d => new Dt_DeliveryOrderDetail { Status = 1, OotDetailStatus = "å¼å§" }) |
| | | .Where(d => d.DeliveryOrderId == order.Id && d.Status == 0) |
| | | .ExecuteCommand(); |
| | | Console.WriteLine($"订å {order.Out_no} æ¨éæå"); |
| | | #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); |
| | | deliveryOrdersAdd.Add(entityOrder); |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | SendErrorToUpstream(3, order.Out_no, resp?.msg ?? "WCS æ¨é失败", ""); |
| | | Console.WriteLine($"订å {order.Out_no} æ¨é失败ï¼{resp?.msg}"); |
| | | } |
| | | //å é¤å
¨é¨ç¶ä¸ºå·²å®æçæç»å表头ï¼ç§»å
¥åå²è¡¨ |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SendErrorToUpstream(3, order.Out_no, ex.Message, ""); |
| | | Console.WriteLine($"订å {order.Out_no} æ¨éå¼å¸¸ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | #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); |
| | | supplyTask_Hties.Add(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | //_inventoryInfoService.UpdateData(inventoryInfos); |
| | | infosUp.AddRange(inventoryInfos); |
| | | #endregion |
| | | |
| | | return responseContent.OK("åºåºè®¢åæ¨é宿"); |
| | | #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(); |
| | | deliveryOrdersAdd.Add(cabinOrder); |
| | | } |
| | | #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); |
| | | deliveryOrdersAdd.Add(entityOrder); |
| | | #endregion |
| | | } |
| | | //return WebResponseContent.Instance.OK("æå"); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _supplyTaskHtyService.AddData(supplyTask_Hties); |
| | | _inventoryInfoService.UpdateData(infosUp); |
| | | _inventory_BatchServices.UpdateData(batchesUp); |
| | | BaseDal.Db.InsertNav(deliveryOrdersAdd).Include(it => it.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | return WebResponseContent.Instance.OK("æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("EdiOut å¼å¸¸ï¼" + ex.Message); |
| | | return responseContent.Error("åºåºè®¢åæ¨é失败ï¼" + ex.Message); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | //çç¹ æ¿æ´ä¸ªæ¹æ¬¡ä¿¡æ¯è¡¨çååæ¹å·åååç¼å·æ¥è¿è¡çç¹ |
| | |
| | | try |
| | | { |
| | | // 1ï¸â£ æ¥æ¾æå®æ¹æ¬¡ä¸ç©æçåºåä¿¡æ¯ |
| | | var batchInfo = BaseDal.Db.Queryable<Dt_Inventory_Batch>() |
| | | var batchInfo = BaseDal.Db.CopyNew().Queryable<Dt_Inventory_Batch>() |
| | | .Where(x => x.BatchNo == batchNo && x.MaterielCode == goodsNo) |
| | | .First(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// åºåºæ¥å®ææ¥å£ |
| | | /// </summary> |
| | | /// <param name="out_no">åºåºåå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CompleteAllOutOrders() |
| | | { |
| | | var responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | #region æ¥æ¾ææå·²å®æåºåºå |
| | | var outorders = BaseDal.QueryData(x => x.OutStatus == "已宿").Select(x => x.Out_no).Distinct().ToList(); |
| | | foreach (var outorder in outorders) |
| | | { |
| | | var Orders = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == outorder).Includes(x => x.Details).ToList(); |
| | | if (!Orders.Where(x => x.OutStatus != "已宿").Any()) |
| | | { |
| | | BaseDal.Db.Ado.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(Orders, OperateTypeEnum.èªå¨å®æ); |
| | | foreach (var item in Orders) |
| | | { |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(item.Details, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk"; |
| | | var requestDate = new |
| | | { |
| | | order_no = outorder |
| | | }; |
| | | var result = HttpHelper.Post(url, requestDate.ToJsonString()); |
| | | var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result); |
| | | if (response.resultCode == "0") BaseDal.Db.Ado.CommitTran(); |
| | | else |
| | | { |
| | | BaseDal.Db.Ado.RollbackTran(); |
| | | SendErrorToUpstream(4, "", $"䏿¸¸æ¥å£è¿å失败: {response.resultMsg}", outorder); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | return responseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | BaseDal.Db.Ado.RollbackTran(); |
| | | return responseContent.Error("æ¹éå¤ç失败ï¼" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¨éå¼å¸¸ä¿¡æ¯ç»ä¸æ¸¸ç³»ç» 1.å
¥åºåæ¥å£ï¼2.å
¥åºåæ¥å®ææ¥å£ï¼3.åºåºåæ¥å£ï¼4.åºåºæ¥å®ææ¥å£ï¼5.è¯ååºç¡ä¿¡æ¯åæ¥æ¥å£ï¼6.ä¾åºåä¿¡æ¯æ¥å£ï¼7.客æ·ä¿¡æ¯æ¥å£ï¼8.åºåæ¥è¯¢æ¥å£ |
| | | /// </summary> |
| | | public void SendErrorToUpstream(int type, string code, string message, string remark) |
| | | { |
| | | try |
| | | { |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/exceptionLog"; |
| | | |
| | | var requestData = new |
| | | { |
| | | type = type.ToString(), |
| | | code = code, |
| | | message = message, |
| | | remark = remark |
| | | }; |
| | | |
| | | var result = HttpHelper.Post(url, requestData.ToJsonString()); |
| | | // å¯ä»¥ååºååæ£æ¥ resultCode æ¯å¦ä¸º0 |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // è¿éä¸è¦åæå¼å¸¸äºï¼é¿å
æ»å¾ªç¯ |
| | | Console.WriteLine("å¼å¸¸æ¥å£æ¨é失败ï¼" + e.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢åºåºåå表 |
| | | /// </summary> |
| | |
| | | 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); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// padåºåºå®æ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutFinish(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | 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); |
| | | Dt_DeliveryOrder deliveryOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode).Includes(x => x.Details).First(); |
| | | if (deliveryOrder == null) return WebResponseContent.Instance.OK($"åºåºå已宿"); |
| | | content = OutTaskFinish(supplyTask, deliveryOrder); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent OutTaskFinish(Dt_SupplyTask supplyTask, Dt_DeliveryOrder deliveryOrder) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_DeliveryOrderDetail? cabinOrderDetail = deliveryOrder.Details.FirstOrDefault(x => x.Batch_num == supplyTask.BatchNo && x.Goods_no == supplyTask.MaterielCode); |
| | | if (cabinOrderDetail == null) throw new Exception($"åºåºåæç»æªæ¾å°"); |
| | | Dt_MaterielInfo materielInfo = _materielInfoService.Repository.QueryFirst(x => x.MaterielCode == supplyTask.MaterielCode); |
| | | if (materielInfo == null) throw new Exception($"请维æ¤ç©æç¼å·ã{supplyTask.MaterielCode}ãçç©æä¿¡æ¯"); |
| | | cabinOrderDetail.Order_Outqty += supplyTask.StockQuantity; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) throw new Exception($"åºåºæ°éä¸å¯è¶
åºåæ®æ°é"); |
| | | deliveryOrder.OutStatus = "å¼å§"; |
| | | cabinOrderDetail.OotDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Outqty == cabinOrderDetail.Order_qty) cabinOrderDetail.OotDetailStatus = "已宿"; |
| | | |
| | | #region åºå |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.LocationCode == supplyTask.LocationCode); |
| | | if (inventoryInfo == null) throw new Exception($"æªæ¾å°è´§ä½ã{supplyTask.LocationCode}ãçåºåä¿¡æ¯"); |
| | | inventoryInfo.StockQuantity -= supplyTask.StockQuantity; |
| | | inventoryInfo.OutboundQuantity -= supplyTask.StockQuantity; |
| | | #endregion |
| | | Dt_LocationInfo location = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == supplyTask.LocationCode); |
| | | #region è´§ä½ |
| | | if (supplyTask.WarehouseCode != WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | { |
| | | if (location == null) |
| | | return WebResponseContent.Instance.Error($"请维æ¤è´§ä½ç¼å·ã{supplyTask.LocationCode}ãçè´§ä½ä¿¡æ¯"); |
| | | Dt_InventoryInfo inventoryInfo1 = _inventoryInfoService.Repository.QueryFirst(x => x.LocationCode == supplyTask.LocationCode); |
| | | if (inventoryInfo1 == null) location.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | } |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ 妿任å¡ç±»åæ¯è°æ¨åºåºä»»å¡ï¼8ï¼å°±ä¸ä¿®æ¹æ¹æ¬¡åºå |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == |
| | | inventoryInfo.MaterielCode); |
| | | if (supplyTask.TaskType != TaskTypeEnum.AllocatOut.ObjToInt()) |
| | | { |
| | | inventory_Batch.StockQuantity -= supplyTask.StockQuantity; |
| | | inventory_Batch.OutboundQuantity -= supplyTask.StockQuantity; |
| | | } |
| | | #endregion |
| | | supplyTask.TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (inventory_Batch.StockQuantity <= 0) |
| | | _inventory_BatchServices.DeleteData(inventory_Batch); |
| | | else |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | _materielInfoService.UpdateData(materielInfo); |
| | | if (inventoryInfo.StockQuantity <= 0) |
| | | _inventoryInfoService.DeleteData(inventoryInfo); |
| | | else |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | if (location != null) _locationInfoService.UpdateData(location); |
| | | _deliveryOrderDetailServices.UpdateData(cabinOrderDetail); |
| | | _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.äººå·¥å®æ); |
| | | |
| | | #region å¤æè¯¦æ
æ¯å¦å
¨é¨å®æ |
| | | if (!_deliveryOrderDetailServices.Repository.QueryData(x => x.DeliveryOrderId == deliveryOrder.Id && x.OotDetailStatus != "已宿").Any()) |
| | | deliveryOrder.OutStatus = "已宿"; |
| | | BaseDal.UpdateData(deliveryOrder); |
| | | if (supplyTask.WarehouseCode == WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | { |
| | | materielInfo.Business_qty -= supplyTask.StockQuantity; |
| | | if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | } |
| | | #endregion |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent OutTaskFinish(Dt_SupplyTask supplyTask) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_DeliveryOrder? cabinOrder = BaseDal.Db.CopyNew().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.OK($"åºåºå已宿"); |
| | | |
| | | 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(); |
| | | if (cabinOrderDetail == null) return WebResponseContent.Instance.Error($"åºåºåæç»å·²å®æ"); |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | 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 = _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 å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯,åºåºä»»å¡ |
| | | _unitOfWorkManage.BeginTran(); |
| | | //_unitOfWorkManage.BeginTran(); |
| | | |
| | | #region åºåºå |
| | | cabinOrder.OutStatus = "å¼å§"; |
| | |
| | | //_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.CopyNew().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); |
| | |
| | | #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")) |
| | | CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | _unitOfWorkManage.CommitTran(); |
| | | { |
| | | materielInfo.Business_qty -= supplyTask.StockQuantity; |
| | | _materielInfoService.UpdateData(materielInfo); |
| | | if (materielInfo.Business_qty < materielInfo.MinQty) |
| | | CreateAllocatInOut(materielInfo);//åå»ºè°æ¨ä»»å¡ |
| | | } |
| | | //_unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | content.OK(); |
| | | } |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å¹³åºäººå·¥æ£æåºåºå¤çï¼å³äººå·¥æ«ç åºåºæ¶è°ç¨ï¼ |
| | | /// 人工å¨åºåºåä¸ç¹å»å®ææé®å®ç°ä¸æ¥ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <param name="key">id</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 å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #region åºåºå |
| | | cabinOrder.OutStatus = "å¼å§"; |
| | | cabinOrderDetail.OotDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Outqty == cabinOrderDetail.Order_qty) |
| | | 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();//æ¾åºææåºåºåå·ç¸åçåºåºå |
| | | List<Dt_DeliveryOrderDetail> deliveryOrderDetails = new List<Dt_DeliveryOrderDetail>(); |
| | | foreach (var item in deliveryOrders) |
| | | { |
| | | cabinOrderDetail.OotDetailStatus = "已宿"; |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.èªå¨å®æ); |
| | | if (item.Details != null) deliveryOrderDetails.AddRange(item.Details); |
| | | item.Modifier = App.User.UserName; |
| | | item.ModifyDate = DateTime.Now; |
| | | item.Details = null; |
| | | } |
| | | if (deliveryOrder.Out_type == OutOrderTypeEnum.Allocate.ObjToInt().ToString()) |
| | | { |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(deliveryOrderDetails, OperateTypeEnum.äººå·¥å®æ); |
| | | BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.äººå·¥å®æ); |
| | | } |
| | | else |
| | | { |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | 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); |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(deliveryOrderDetails, OperateTypeEnum.äººå·¥å®æ); |
| | | BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.äººå·¥å®æ); |
| | | } |
| | | 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 = "åºåº" |
| | | }; |
| | | _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 |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | content.OK(cabinOrderDetail.Order_Outqty.ToString()); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |