| | |
| | | using MailKit.Search; |
| | | using Microsoft.Extensions.Logging; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using Newtonsoft.Json.Serialization; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using WIDESEA_BasicService; |
| | | using WIDESEA_Common.CommonEnum; |
| | |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_DTO.ReturnMES; |
| | | using WIDESEA_IAllocateService; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_ICheckService; |
| | |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEA_Model.Models.Check; |
| | | using WIDESEA_Model.Models.Outbound; |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | | using WIDESEA_BasicService.MESOperation; |
| | | using WIDESEA_Core.Util; |
| | | using WIDESEA_DTO.Allocate; |
| | | |
| | | namespace WIDESEA_OutboundService |
| | | { |
| | |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | private readonly ILogger<OutboundPickingService> _logger; |
| | | private readonly IRepository<Dt_InterfaceLog> _interfaceLog; |
| | | private readonly IInboundService _inboundService; |
| | | private readonly IFeedbackMesService _feedbackMesService; |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | private readonly IRepository<Dt_MesReturnRecord> _mesReturnRecord; |
| | | |
| | | private Dictionary<string, string> stations = new Dictionary<string, string> |
| | | { |
| | |
| | | public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, |
| | | IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, |
| | | IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, |
| | | IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService, IRepository<Dt_InterfaceLog> interfaceLog) : base(BaseDal) |
| | | IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService, IRepository<Dt_InterfaceLog> interfaceLog, IInboundService inboundService, IFeedbackMesService feedbackMesService, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoService = stockInfoService; |
| | |
| | | _reCheckOrderService = reCheckOrderService; |
| | | _task_HtyService = task_HtyService; |
| | | _interfaceLog = interfaceLog; |
| | | _inboundService = inboundService; |
| | | _feedbackMesService = feedbackMesService; |
| | | _httpClientHelper = httpClientHelper; |
| | | _mesReturnRecord = mesReturnRecord; |
| | | |
| | | } |
| | | |
| | | #endregion |
| | |
| | | return WebResponseContent.Instance.OK("æå", data: InOderCodes); |
| | | } |
| | | |
| | | public WebResponseContent GetAvailablePickingOrders() |
| | | public WebResponseContent GetAvailablePickingOrders(string outOrder) |
| | | { |
| | | List<Dt_OutboundOrder> outOders = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderStatus != OutOrderStatusEnum.åºåºå®æ.ObjToInt()).ToList(); |
| | | |
| | | List<string> outOderCodes = outOders.Select(x => x.UpperOrderNo).ToList(); |
| | | return WebResponseContent.Instance.OK("æå", data: outOderCodes); |
| | | Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == outOrder && x.OrderStatus != OutOrderStatusEnum.åºåºå®æ.ObjToInt()).Includes(x=>x.Details).First(); |
| | | if(outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°æ»¡è¶³åºåºæ¡ä»¶çåºåºå"); |
| | | } |
| | | //å
æ¸
ç©ºåæ®èæåºå
¥åºæ°éè¿è¡è®¡ç® |
| | | foreach (var item in outboundOrder.Details) |
| | | { |
| | | item.NoStockOutQty = 0; |
| | | item.documentsNO = ""; |
| | | } |
| | | _outboundOrderDetailService.UpdateData(outboundOrder.Details); |
| | | return WebResponseContent.Instance.OK("æå"); |
| | | |
| | | } |
| | | public WebResponseContent BarcodeValidate(NoStockOutModel noStockOut) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°éè´åï¼{noStockOut.inOder}"); |
| | | } |
| | | var matchedDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == noStockOut.barCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | if (matchedDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨éè´å {noStockOut.inOder} 䏿ªæ¾å°æ¡ç 为 {noStockOut.barCode} çæç»ã"); |
| | | } |
| | | matchedDetail.NoStockOutQty = 0; |
| | | |
| | | Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOut.outOder && x.OrderStatus != OutOrderStatusEnum.åºåºå®æ.ObjToInt()).Includes(x => x.Details).First(); |
| | | if (outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºåï¼{noStockOut.inOder}"); |
| | | } |
| | | var matchedCode = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == matchedDetail.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | //åå¨å
¥åºåæ®æç»ä¿¡æ¯ |
| | | var detailLists = new List<Dt_InboundOrderDetail>(); |
| | | |
| | | var matchedDetail = inboundOrder.Details.FirstOrDefault(detail => |
| | | detail.Barcode == noStockOut.barCode && |
| | | detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | if (matchedDetail == null) |
| | | { |
| | | matchedDetail = inboundOrder.Details.FirstOrDefault(detail => |
| | | detail.OutBoxbarcodes == noStockOut.barCode && |
| | | detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | if (matchedDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨éè´å {noStockOut.inOder} 䏿ªæ¾å°æ¡ç 为 {noStockOut.barCode} çæç»ã"); |
| | | } |
| | | else |
| | | { |
| | | |
| | | // æ·»å ææéå®æç¶æçæç»æ¡ç |
| | | foreach (var detail in inboundOrder.Details) |
| | | { |
| | | if (detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() && |
| | | !string.IsNullOrEmpty(detail.Barcode)) |
| | | { |
| | | detailLists.Add(detail); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!string.IsNullOrEmpty(noStockOut.barCode)) |
| | | { |
| | | detailLists.Add(matchedDetail); |
| | | } |
| | | } |
| | | |
| | | var outDetails = new List<Dt_OutboundOrderDetail>(); |
| | | |
| | | foreach (var item in detailLists) |
| | | { |
| | | item.NoStockOutQty = 0; |
| | | |
| | | var matchedCode = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == item.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() && (detail.OrderQuantity-detail.LockQuantity-detail.MoveQty-detail.NoStockOutQty)>0); |
| | | |
| | | if (matchedCode == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä¸ç{matchedDetail.MaterielCode} 对åºçç©æã"); |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä¸ç{item.MaterielCode} 对åºçç©æã"); |
| | | } |
| | | matchedCode.NoStockOutQty = 0; |
| | | if (!matchedCode.BatchNo.IsNullOrEmpty() && matchedCode.BatchNo != "") |
| | | { |
| | | var matcheBatch = outboundOrder.Details.FirstOrDefault(detail => detail.BatchNo == item.BatchNo); |
| | | if (matcheBatch == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åæ¹æ¬¡ä¸ç{item.BatchNo} 对åºçç©æã"); |
| | | } |
| | | } |
| | | if (!matchedCode.SupplyCode.IsNullOrEmpty() && matchedCode.SupplyCode != "") |
| | | { |
| | | var matcheBatch = outboundOrder.Details.FirstOrDefault(detail => detail.SupplyCode == item.SupplyCode); |
| | | if (matcheBatch == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä¾åºåä¸ç{item.SupplyCode} 对åºçç©æã"); |
| | | } |
| | | } |
| | | if (!outboundOrder.FactoryArea.IsNullOrEmpty() && outboundOrder.FactoryArea != "" && !inboundOrder.FactoryArea.IsNullOrEmpty() && inboundOrder.FactoryArea != "") |
| | | { |
| | | if (inboundOrder.FactoryArea != outboundOrder.FactoryArea) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æ¡ç {item.Barcode}对åºçåæ®ååºä¸åºåºåæ®ä¸ä¸è´ï¼ä¸å
许åºåºã"); |
| | | } |
| | | } |
| | | if (!matchedCode.WarehouseCode.IsNullOrEmpty() && matchedCode.WarehouseCode != "") |
| | | { |
| | | var matcheBatch = outboundOrder.Details.FirstOrDefault(detail => detail.WarehouseCode == item.WarehouseCode); |
| | | if (matcheBatch == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä»åºä¸ä¸è´ï¼å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä»åºä¸ç{item.WarehouseCode} 对åºçç©æã"); |
| | | } |
| | | } |
| | | |
| | | //å©ä½å
¥åºæ°éå³èæåºå
¥åºå©ä½å¯åºæ°é |
| | | decimal outQuantity = matchedDetail.OrderQuantity - matchedDetail.ReceiptQuantity; |
| | | decimal outQuantity = item.OrderQuantity - item.ReceiptQuantity; |
| | | if (outQuantity == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该éè´åä¸çæ¡ç 对åºçå¯åºæ°é为0"); |
| | | } |
| | | if (matchedCode.OrderQuantity < outQuantity) |
| | | if (matchedCode.OrderQuantity - matchedCode.LockQuantity - matchedCode.MoveQty - matchedCode.NoStockOutQty < outQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该éè´åä¸çæ¡ç 对åºçå¯åºæ°éè¶
åºåºåºååºåºæ°é{matchedDetail.OrderQuantity - matchedCode.OrderQuantity},䏿»¡è¶³æ´å
åºåº"); |
| | | return WebResponseContent.Instance.Error($"该éè´åä¸çæ¡ç 对åºçå¯åºæ°éè¶
åºåºåºååºåºæ°é{item.OrderQuantity - (matchedCode.OrderQuantity - matchedCode.LockQuantity - matchedCode.MoveQty)},䏿»¡è¶³æ´å
åºåº"); |
| | | } |
| | | //åæ®åºåºé宿°é |
| | | matchedDetail.NoStockOutQty += outQuantity; |
| | | item.NoStockOutQty += outQuantity; |
| | | matchedCode.NoStockOutQty += outQuantity; |
| | | |
| | | if ((matchedCode.LockQuantity + matchedCode.NoStockOutQty) > matchedCode.OrderQuantity) |
| | | //åä¼ MESåæ° |
| | | List<Barcodes> barcodesList = new List<Barcodes>(); |
| | | Barcodes barcodes = new Barcodes |
| | | { |
| | | return WebResponseContent.Instance.Error($"åºåºåæç»æ°é溢åº{matchedCode.LockQuantity - matchedCode.OrderQuantity}"); |
| | | Barcode = item.Barcode, |
| | | Qty = item.BarcodeQty, |
| | | SupplyCode = item?.SupplyCode ?? "", |
| | | BatchNo = item?.BatchNo ?? "", |
| | | Unit = item?.Unit ?? "" |
| | | }; |
| | | if (!string.IsNullOrEmpty(matchedCode.documentsNO)) |
| | | { |
| | | barcodesList = JsonConvert.DeserializeObject<List<Barcodes>>(matchedCode.documentsNO) ?? new List<Barcodes>(); |
| | | } |
| | | matchedDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); |
| | | matchedCode.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt(); |
| | | barcodesList.Add(barcodes); |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | matchedCode.documentsNO = JsonConvert.SerializeObject(barcodesList, settings); |
| | | |
| | | |
| | | if ((matchedCode.LockQuantity + matchedCode.NoStockOutQty+matchedCode.MoveQty) > matchedCode.OrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"åºåºåæç»æ°é溢åº{matchedCode.OrderQuantity - matchedCode.LockQuantity-matchedCode.NoStockOutQty-matchedCode.MoveQty}"); |
| | | } |
| | | item.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); |
| | | |
| | | outDetails.Add(matchedCode); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inboundOrderDetailService.UpdateData(matchedDetail); |
| | | _outboundOrderDetailService.UpdateData(matchedCode); |
| | | _inboundOrderDetailService.UpdateData(detailLists); |
| | | _outboundOrderDetailService.UpdateData(outDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | return WebResponseContent.Instance.OK("æå",data:detailLists); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºåï¼{noStockOut.inOder}"); |
| | | } |
| | | var matchedCode = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == matchedDetail.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | // æ¤éåä¼ MESåæ° |
| | | List<Barcodes> barcodesList = new List<Barcodes>(); |
| | | Barcodes barcodes = new Barcodes |
| | | { |
| | | Barcode = matchedDetail.Barcode, |
| | | Qty = matchedDetail.BarcodeQty, |
| | | SupplyCode = matchedDetail?.SupplyCode ?? "", |
| | | BatchNo = matchedDetail?.BatchNo ?? "", |
| | | Unit = matchedDetail?.Unit ?? "" |
| | | }; |
| | | var matchedCode = outboundOrder.Details.FirstOrDefault(detail => |
| | | detail.documentsNO.Contains(barcodes.Barcode) && |
| | | detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() |
| | | ); |
| | | |
| | | if (matchedCode == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä¸ç{matchedDetail.MaterielCode} 对åºçç©æã"); |
| | | } |
| | | matchedCode.NoStockOutQty = 0; |
| | | |
| | | if (!string.IsNullOrEmpty(matchedCode.documentsNO)) |
| | | { |
| | | barcodesList = JsonConvert.DeserializeObject<List<Barcodes>>(matchedCode.documentsNO) ?? new List<Barcodes>(); |
| | | } |
| | | barcodesList.RemoveAll(b => |
| | | string.Equals(b.Barcode, barcodes.Barcode, StringComparison.OrdinalIgnoreCase) |
| | | ); |
| | | |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | matchedCode.documentsNO = JsonConvert.SerializeObject(barcodesList, settings); |
| | | |
| | | matchedCode.NoStockOutQty -= matchedDetail.OrderQuantity; |
| | | if (matchedCode.LockQuantity == 0 && matchedCode.OverOutQuantity == 0) |
| | | { |
| | | matchedCode.OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(); |
| | |
| | | { |
| | | try |
| | | { |
| | | Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.InOderSubmit && x.OrderStatus != InOrderStatusEnum.å
¥åºå®æ.ObjToInt()).Includes(x => x.Details).First(); |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°éè´åï¼{noStockOutSubmit.InOderSubmit}"); |
| | | } |
| | | Dt_OutboundOrder outboundOrder = _inboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.OutOderSubmit && x.OrderStatus != OutOrderStatusEnum.åºåºå®æ.ObjToInt()).Includes(x => x.Details).First(); |
| | | if (outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºåï¼{noStockOutSubmit.OutOderSubmit}"); |
| | | } |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | foreach (var BarCode in noStockOutSubmit.BarCodeSubmit) |
| | | { |
| | | var inboundOrderDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == BarCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | if (inboundOrderDetail == null) |
| | | Dictionary<int, List<string>> orderIdBarCodeDict = new Dictionary<int, List<string>>(); |
| | | |
| | | List<Dt_InboundOrderDetail> updateInboundDetails = new List<Dt_InboundOrderDetail>(); |
| | | |
| | | Dictionary<int, Dt_InboundOrder> updateInboundOrders = new Dictionary<int, Dt_InboundOrder>(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | List<Dt_InboundOrderDetail> allInboundDetails = _inboundOrderDetailService.Db |
| | | .Queryable<Dt_InboundOrderDetail>() |
| | | .Where(detail => noStockOutSubmit.BarCodeSubmit.Contains(detail.Barcode) |
| | | && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) |
| | | .ToList(); |
| | | |
| | | var detailGroupByOrderId = allInboundDetails.GroupBy(d => d.OrderId).ToList(); |
| | | foreach (var group in detailGroupByOrderId) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨éè´å {noStockOutSubmit.InOderSubmit} 䏿ªæ¾å°æ¡ç 为 {BarCode} çæç»ã"); |
| | | int orderId = group.Key; |
| | | List<Dt_InboundOrderDetail> groupDetails = group.ToList(); |
| | | List<string> groupBarCodes = groupDetails.Select(d => d.Barcode).ToList(); |
| | | |
| | | |
| | | orderIdBarCodeDict[orderId] = groupBarCodes; |
| | | |
| | | foreach (var detail in groupDetails) |
| | | { |
| | | detail.ReceiptQuantity = detail.NoStockOutQty; |
| | | detail.OverInQuantity = detail.NoStockOutQty; |
| | | |
| | | if (detail.OrderQuantity == detail.OverInQuantity) |
| | | { |
| | | detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | var outboundOrderDetail = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == inboundOrderDetail.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()); |
| | | |
| | | if (outboundOrderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å¨åºåºåçç©æç¼ç 䏿ªæ¾å°ä¸éè´åä¸ç{inboundOrderDetail.MaterielCode} 对åºçç©æã"); |
| | | updateInboundDetails.Add(detail); |
| | | } |
| | | inboundOrderDetail.ReceiptQuantity += inboundOrderDetail.NoStockOutQty; |
| | | inboundOrderDetail.OverInQuantity = inboundOrderDetail.ReceiptQuantity; |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | inboundOrderDetails.Add(inboundOrderDetail); |
| | | |
| | | outboundOrderDetail.LockQuantity += outboundOrderDetail.NoStockOutQty; |
| | | outboundOrderDetail.OverOutQuantity = outboundOrderDetail.LockQuantity; |
| | | if (outboundOrderDetail.OrderQuantity == outboundOrderDetail.OverOutQuantity) |
| | | if (!updateInboundOrders.ContainsKey(orderId)) |
| | | { |
| | | outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db |
| | | .Queryable<Dt_InboundOrder>() |
| | | .Where(x => x.Id == orderId) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåID为 {orderId} çåæ®"); |
| | | } |
| | | outboundOrderDetails.Add(outboundOrderDetail); |
| | | |
| | | var newLockInfo = new Dt_OutStockLockInfo |
| | | // 夿æ´åæ¯å¦å
¨é¨å®æ |
| | | int totalDetailCount = inboundOrder.Details.Count(); |
| | | int beforeDetailCount = inboundOrder.Details.Where(x => x.OrderId == orderId && x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | .Count(); |
| | | int finishedDetailCount = updateInboundDetails |
| | | .Where(x => x.OrderId == orderId && x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | .Count(); |
| | | |
| | | inboundOrder.OrderStatus = totalDetailCount == finishedDetailCount+beforeDetailCount |
| | | ? InOrderStatusEnum.å
¥åºå®æ.ObjToInt() |
| | | : InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | |
| | | updateInboundOrders[orderId] = inboundOrder; |
| | | } |
| | | } |
| | | |
| | | // 6. æ¹éæ´æ°æç»å主åï¼æ¹éæä½æåæ§è½ï¼ |
| | | if (updateInboundDetails.Any()) |
| | | { |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | OrderDetailId = outboundOrderDetail.Id, |
| | | OutboundBatchNo = outboundOrderDetail.BatchNo, |
| | | MaterielCode = outboundOrderDetail.MaterielCode, |
| | | MaterielName = outboundOrderDetail.MaterielName, |
| | | StockId = 0, |
| | | OrderQuantity = outboundOrderDetail.OrderQuantity, |
| | | AssignQuantity = outboundOrderDetail.OverOutQuantity, |
| | | PickedQty = outboundOrderDetail.NoStockOutQty, |
| | | LocationCode = "空", |
| | | PalletCode = "空", |
| | | TaskNum = 0, |
| | | Status = (int)OutLockStockStatusEnum.æ£é宿, |
| | | Unit = outboundOrderDetail.Unit, |
| | | SupplyCode = outboundOrderDetail.SupplyCode ?? "æ ", |
| | | OrderType = outboundOrder.OrderType, |
| | | CurrentBarcode = inboundOrderDetail.Barcode, |
| | | IsSplitted = 1, |
| | | Operator = App.User.UserName, |
| | | lineNo = outboundOrderDetail.lineNo, |
| | | WarehouseCode = outboundOrderDetail.WarehouseCode ?? "æ ", |
| | | BarcodeQty = outboundOrderDetail.BarcodeQty, |
| | | BarcodeUnit = outboundOrderDetail.BarcodeUnit, |
| | | BatchNo = outboundOrderDetail.BatchNo |
| | | foreach (var detail in updateInboundDetails) |
| | | { |
| | | _inboundOrderDetailService.UpdateData(detail); |
| | | } |
| | | |
| | | } |
| | | if (updateInboundOrders.Any()) |
| | | { |
| | | foreach (var order in updateInboundOrders.Values) |
| | | { |
| | | _inboundOrderRepository.UpdateData(order); |
| | | } |
| | | } |
| | | |
| | | // 7. 循ç¯åç»ç»æï¼è°ç¨MESåä¼ æ¹æ³ï¼æå
¥åºååç»åä¼ ï¼ |
| | | foreach (var kvp in orderIdBarCodeDict) |
| | | { |
| | | int orderId = kvp.Key; |
| | | List<string> barCodeList = kvp.Value; |
| | | //å
¥åºåä¼ MES |
| | | NoStockOutBatchInOrderFeedbackToMes(orderId, barCodeList); |
| | | |
| | | } |
| | | |
| | | //åªå¯¹åºåºæ¡ç çåºåºåæç»è¿è¡è®¡ç®åä¼ |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetail = outboundOrder.Details |
| | | .Where(x => !string.IsNullOrWhiteSpace(x.documentsNO) |
| | | && noStockOutSubmit.BarCodeSubmit.Any(barcode => |
| | | x.documentsNO.IndexOf(barcode, StringComparison.OrdinalIgnoreCase) >= 0)) |
| | | .ToList(); |
| | | |
| | | foreach (var item in outboundOrderDetail) |
| | | { |
| | | item.LockQuantity = item.NoStockOutQty; |
| | | item.OverOutQuantity = item.NoStockOutQty; |
| | | //æ·»å åä¼ MESåæ° |
| | | List<Barcodes> barcodesList = new List<Barcodes>(); |
| | | List<Barcodes> documentsNOList = new List<Barcodes>(); |
| | | if (!string.IsNullOrEmpty(item.ReturnJsonData)) |
| | | { |
| | | barcodesList = JsonConvert.DeserializeObject<List<Barcodes>>(item.documentsNO) ?? new List<Barcodes>(); |
| | | } |
| | | if (!string.IsNullOrEmpty(item.documentsNO) && item.documentsNO!="") |
| | | { |
| | | documentsNOList = JsonConvert.DeserializeObject<List<Barcodes>>(item.documentsNO) ?? new List<Barcodes>(); |
| | | } |
| | | foreach (var documentsNO in documentsNOList) |
| | | { |
| | | barcodesList.Add(documentsNO); |
| | | } |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | _outStockLockInfoService.AddData(newLockInfo); |
| | | item.ReturnJsonData = JsonConvert.SerializeObject(barcodesList, settings); |
| | | |
| | | outboundOrderDetails.Add(item); |
| | | } |
| | | //夿å
¥åºåæ®æç»æ¯å¦å
¨é¨æ¯å®æç¶æ |
| | | int e = inboundOrder.Details.Count(); |
| | | int w = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | bool inoderOver = inboundOrder.Details.Count() == inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | if (inoderOver) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | } |
| | | //夿åºåºåæ®æç»æ¯å¦å
¨é¨æ¯å®æç¶æ |
| | | bool outOderOver = outboundOrder.Details.Count() == outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | if (outOderOver) |
| | | |
| | | _outboundOrderDetailService.UpdateData(outboundOrderDetails); |
| | | |
| | | // æ£æ¥åºåºåæ¯å¦å®æ |
| | | if (CheckOutboundOrderCompleted(outboundOrder.OrderNo)) |
| | | { |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | } |
| | | //æ°æ®å¤ç |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inboundOrderDetailService.UpdateData(inboundOrderDetails); |
| | | _outboundOrderDetailService.UpdateData(outboundOrderDetails); |
| | | _inboundOrderRepository.UpdateData(inboundOrder); |
| | | _outboundOrderService.UpdateData(outboundOrder); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | //å
¥åºåä¼ MES |
| | | var infeedmodel = new FeedbackInboundRequestModel |
| | | { |
| | | reqCode = Guid.NewGuid().ToString(), |
| | | reqTime = DateTime.Now.ToString(), |
| | | business_type = inboundOrder.BusinessType, |
| | | factoryArea = inboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = App.User.UserName, |
| | | orderNo = inboundOrder.UpperOrderNo, |
| | | status = inboundOrder.OrderStatus, |
| | | details = new List<FeedbackInboundDetailsModel>() |
| | | |
| | | }; |
| | | |
| | | var groupedData = inboundOrderDetails.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new FeedbackInboundDetailsModel |
| | | { |
| | | materialCode = group.Key.MaterielCode, |
| | | supplyCode = group.Key.SupplyCode, |
| | | batchNo = group.Key.BatchNo, |
| | | lineNo = group.Key.lineNo, |
| | | warehouseCode = group.Key.WarehouseCode, |
| | | qty = group.Sum(x => x.BarcodeQty), |
| | | // warehouseCode= "1072", |
| | | unit = group.Key.BarcodeUnit, |
| | | barcodes = group.Select(row => new FeedbackBarcodesModel |
| | | { |
| | | barcode = row.Barcode, |
| | | qty = row.BarcodeQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | infeedmodel.details = groupedData; |
| | | |
| | | var result1 = await _invokeMESService.FeedbackInbound(infeedmodel); |
| | | if (result1 != null && result1.code == 200) |
| | | { |
| | | var orderIds = inboundOrderDetails.Select(x => x.Id).Distinct().ToList(); |
| | | if (inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1, Remark = "" }) |
| | | .Where(it => it.Id == inboundOrder.Id).ExecuteCommand(); |
| | | } |
| | | _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 }) |
| | | .Where(it => orderIds.Contains(it.Id)).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = result1.message }) |
| | | .Where(it => it.Id == inboundOrder.Id).ExecuteCommand(); |
| | | _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 }) |
| | | .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand(); |
| | | } |
| | | //åºåºåä¼ MES |
| | | _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo); |
| | | |
| | | var documentNo = UniqueValueGenerator.Generate(); |
| | | |
| | | var outfeedmodel = new FeedbackOutboundRequestModel |
| | | { |
| | | reqCode = Guid.NewGuid().ToString(), |
| | | reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | business_type = outboundOrder.BusinessType, |
| | | factoryArea = outboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = App.User.UserName, |
| | | orderNo = outboundOrder.UpperOrderNo, |
| | | documentsNO = documentNo, |
| | | status = outboundOrder.OrderStatus, |
| | | details = new List<FeedbackOutboundDetailsModel>() |
| | | }; |
| | | foreach (var detail in outboundOrderDetails) |
| | | { |
| | | // è·å该æç»å¯¹åºçæ¡ç ä¿¡æ¯ï¼ä»éå®è®°å½ï¼ |
| | | var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == outboundOrder.UpperOrderNo && |
| | | x.OrderDetailId == detail.Id && |
| | | (x.Status == (int)OutLockStockStatusEnum.æ£é宿 || x.Status == (int)OutLockStockStatusEnum.å·²ååº)) |
| | | .ToListAsync(); |
| | | |
| | | var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new FeedbackOutboundDetailsModel |
| | | { |
| | | |
| | | materialCode = group.Key.MaterielCode, |
| | | lineNo = group.Key.lineNo, |
| | | warehouseCode = group.Key.WarehouseCode, |
| | | qty = group.Sum(x => x.PickedQty), |
| | | currentDeliveryQty = group.Sum(x => x.PickedQty), |
| | | unit = group.Key.BarcodeUnit, |
| | | barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | | barcode = lockInfo.CurrentBarcode, |
| | | supplyCode = lockInfo.SupplyCode, |
| | | batchNo = lockInfo.BatchNo, |
| | | unit = lockInfo.BarcodeUnit, |
| | | qty = lockInfo.PickedQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | outfeedmodel.details.AddRange(groupdata); |
| | | |
| | | _outStockLockInfoService.DeleteData(detailLocks); |
| | | } |
| | | //åå¨åä¼ åæ°ï¼ä¿è¯å¼å¸¸æå¨åä¼ |
| | | Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog |
| | | { |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | DocumentNo = documentNo, |
| | | OrderType = "èæåºå
¥åº", |
| | | Content = outfeedmodel.ToJson(), |
| | | ReturnToMESStatus = 0, |
| | | IsDeleted = false |
| | | }; |
| | | _interfaceLog.AddData(interfaceLog); |
| | | |
| | | var result = await _invokeMESService.FeedbackOutbound(outfeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | var orderIds = outboundOrderDetails.Select(x => x.Id).Distinct().ToList(); |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => orderIds.Contains(x.Id)) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 1, Remark = "" }) |
| | | .Where(x => x.Id == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _interfaceLog.Db.Updateable<Dt_InterfaceLog>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.DocumentNo == documentNo) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | else |
| | | { |
| | | var uporderIds = outboundOrderDetails.Select(x => x.Id).Distinct().ToList(); |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 2) |
| | | .Where(x => uporderIds.Contains(x.Id)) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message }) |
| | | .Where(x => x.Id == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _interfaceLog.Db.Updateable<Dt_InterfaceLog>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 2) |
| | | .Where(x => x.DocumentNo == documentNo) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public WebResponseContent NoStockOutBatchInOrderFeedbackToMes(int id,List<string> barCodeList) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>() |
| | | .Where(x => x.Id == id) |
| | | .First(); |
| | | |
| | | List<Dt_MesReturnRecord> returnRecords = _mesReturnRecord.QueryData(x => x.OrderNo == inboundOrder.InboundOrderNo && x.OrderId == inboundOrder.Id && x.ReturnStatus == 2); |
| | | foreach (var item in returnRecords) |
| | | { |
| | | HttpResponseResult<MesResponseDTO> httpResponse = _httpClientHelper.Post<MesResponseDTO>(item.ApiUrl, item.RequestData); |
| | | item.ReturnCount += 1; |
| | | bool success = httpResponse.IsSuccess && httpResponse.Data.Code == "200"; |
| | | item.ReturnStatus = success ? 1 : 2; |
| | | item.HttpStatusCode = httpResponse.StatusCode.ObjToInt(); |
| | | item.LastReturnTime = DateTime.Now; |
| | | item.ResponseData = httpResponse.Content; |
| | | item.SuccessTime = httpResponse.IsSuccess ? DateTime.Now : null; |
| | | |
| | | //List<Dt_InboundOrderDetail> details=new List<Dt_InboundOrderDetail>(); |
| | | //foreach (var y in item.DetailsId.Split(',')) |
| | | //{ |
| | | // details.Add( _inboundOrderDetailRepository.QueryFirst(x => x.Id == Convert.ToInt32(y))); |
| | | //} |
| | | } |
| | | _mesReturnRecord.UpdateData(returnRecords); |
| | | |
| | | var inboundOrderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus == (int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0) |
| | | .ToList(); |
| | | |
| | | var detail = inboundOrderDetail.Where(x => barCodeList.Contains(x.Barcode)).ToList(); |
| | | |
| | | if (inboundOrder.OrderType == (int)InOrderTypeEnum.AllocatInbound)//è°æ¨å
¥åº |
| | | { |
| | | var allocate = _inboundOrderRepository.Db.Queryable<Dt_AllocateOrder>().Where(x => x.OrderNo == inboundOrder.InboundOrderNo).First(); |
| | | var allocatefeedmodel = new AllocateDto |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | | BusinessType = "3", |
| | | FactoryArea = inboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | Operator = inboundOrder.Operator, |
| | | OrderNo = inboundOrder.UpperOrderNo, |
| | | fromWarehouse = allocate?.FromWarehouse ?? "", |
| | | toWarehouse = allocate?.ToWarehouse ?? "", |
| | | Details = NoStockOutGetAllocateDtoDetails(detail) |
| | | }; |
| | | |
| | | if (allocatefeedmodel.Details.Count <= 0) |
| | | { |
| | | throw new Exception("æªæ¾å°éè¦åä¼ çæ°æ®"); |
| | | } |
| | | |
| | | var response = NoStockOutresponseModel(inboundOrder, 3, null, allocatefeedmodel); |
| | | |
| | | if (response != null && response.IsSuccess) |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 }); |
| | | } |
| | | else |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 }); |
| | | return content.Error("åä¼ MES失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var feedmodel = new FeedbackInboundRequestModel |
| | | { |
| | | reqCode = Guid.NewGuid().ToString(), |
| | | reqTime = DateTime.Now.ToString(), |
| | | business_type = inboundOrder.BusinessType, |
| | | factoryArea = inboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = inboundOrder.Operator, |
| | | orderNo = inboundOrder.UpperOrderNo, |
| | | status = inboundOrder.OrderStatus, |
| | | details = NoStockOutFeedbackInboundDetailsModelDto(detail) |
| | | }; |
| | | |
| | | if (feedmodel.details.Count <= 0) |
| | | { |
| | | throw new Exception("æªæ¾å°éè¦åä¼ çæ°æ®"); |
| | | } |
| | | var response = NoStockOutresponseModel(inboundOrder, 3, feedmodel); |
| | | |
| | | if (response != null && response.IsSuccess) |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 }); |
| | | } |
| | | else |
| | | { |
| | | _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 }); |
| | | return content.Error("åä¼ MES失败"); |
| | | } |
| | | } |
| | | |
| | | return content.OK("åä¼ MESæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public List<AllocateDtoDetail> NoStockOutGetAllocateDtoDetails(List<Dt_InboundOrderDetail> inboundOrderDetails) |
| | | { |
| | | var groupedData = inboundOrderDetails.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new AllocateDtoDetail |
| | | { |
| | | MaterialCode = group.Key.MaterielCode, |
| | | LineNo = group.Key.lineNo, |
| | | WarehouseCode = group.Key.WarehouseCode, |
| | | Qty = group.Sum(x => x.BarcodeQty), |
| | | Unit = group.Key.BarcodeUnit, |
| | | Barcodes = group.Select(row => new BarcodeInfo |
| | | { |
| | | Barcode = row.Barcode, |
| | | Qty = row.BarcodeQty, |
| | | BatchNo = row.BatchNo, |
| | | SupplyCode = row.SupplyCode, |
| | | Unit = row.BarcodeUnit |
| | | }).ToList() |
| | | }).ToList(); |
| | | return groupedData; |
| | | } |
| | | public List<FeedbackInboundDetailsModel> NoStockOutFeedbackInboundDetailsModelDto(List<Dt_InboundOrderDetail> inboundOrderDetails) |
| | | { |
| | | var groupedData = inboundOrderDetails.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new FeedbackInboundDetailsModel |
| | | { |
| | | materialCode = group.Key.MaterielCode, |
| | | lineNo = group.Key.lineNo, |
| | | warehouseCode = group.Key.WarehouseCode, |
| | | qty = group.Sum(x => x.BarcodeQty), |
| | | unit = group.Key.BarcodeUnit, |
| | | barcodes = group.Select(row => new FeedbackBarcodesModel |
| | | { |
| | | barcode = row.Barcode, |
| | | qty = row.BarcodeQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | return groupedData; |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponseDTO> NoStockOutresponseModel(Dt_InboundOrder order, int InterfaceType, FeedbackInboundRequestModel model = null, AllocateDto allocateDto = null) |
| | | { |
| | | HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>(); |
| | | string reqCode = Guid.NewGuid().ToString(); |
| | | string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | string requestData = string.Empty; |
| | | string apiUrl = string.Empty; |
| | | if (model != null) |
| | | { |
| | | apiUrl = AppSettings.GetValue("AldMaterialWarehousing"); |
| | | httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, model.Serialize()); |
| | | requestData = model.Serialize(); |
| | | } |
| | | else |
| | | { |
| | | apiUrl = AppSettings.GetValue("AldAllocationOperation"); |
| | | httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, allocateDto.Serialize()); |
| | | requestData = allocateDto.Serialize(); |
| | | } |
| | | httpResponseResult.ApiUrl = apiUrl; |
| | | bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data.Code == "200"; |
| | | string message = "æå"; |
| | | if (!isSuccess) |
| | | { |
| | | if (!httpResponseResult.IsSuccess) |
| | | { |
| | | message = $"MESæ¥å£è¿åé误ï¼HTTP代ç ï¼{httpResponseResult.StatusCode}ï¼ä¿¡æ¯ï¼{httpResponseResult.ErrorMessage}"; |
| | | } |
| | | else if (httpResponseResult?.Data?.Code != "200") |
| | | { |
| | | message = $"è°ç¨MESæ¥å£å¤±è´¥ï¼ä»£ç ï¼{httpResponseResult?.Data?.Code}ï¼ä¿¡æ¯ï¼{httpResponseResult?.Data?.Message}"; |
| | | } |
| | | } |
| | | Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord() |
| | | { |
| | | ApiUrl = httpResponseResult.ApiUrl, |
| | | InterfaceType = InterfaceType, |
| | | OrderId = order.Id, |
| | | OrderNo = order.InboundOrderNo, |
| | | RequestCode = reqCode, |
| | | RequestData = requestData, |
| | | FailureReason = message, |
| | | LastReturnTime = DateTime.Now, |
| | | HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(), |
| | | ResponseData = httpResponseResult.Content, |
| | | ReturnType = 0, |
| | | ReturnCount = 1, |
| | | ReturnStatus = httpResponseResult.IsSuccess ? 1 : 2, |
| | | SuccessTime = httpResponseResult.IsSuccess ? DateTime.Now : null |
| | | }; |
| | | _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand(); |
| | | |
| | | return httpResponseResult; |
| | | } |
| | | public bool CheckOutboundOrderCompleted(string orderNo) |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderNo).First(); |
| | | if (outboundOrder == null) return false; |
| | | |
| | | List<Dt_OutboundOrderDetail> details = _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.OrderId == outboundOrder.Id).ToList(); |
| | | |
| | | // æ£æ¥æææç»çå·²åºæ°éæ¯å¦é½çäºåæ®æ°é |
| | | return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty); |
| | | } |
| | | |
| | | public WebResponseContent GetPurchaseOrderByBarcode(string barcode) |
| | | { |
| | | try |
| | |
| | | Dt_InboundOrderDetail inboundOrderDetail = _stockInfoDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.Barcode == barcode && x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()).First(); |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | inboundOrderDetail = _stockInfoDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OutBoxbarcodes == barcode && x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()).First(); |
| | | |
| | | if(inboundOrderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æ¡ç {barcode}çå
¥åºæç»æè
æç»ç¶æå·²å
¥æºä»å®æ"); |
| | | } |
| | | } |
| | | Dt_InboundOrder inboundOrder = _inboundOrderRepository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId && x.OrderStatus != InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | if (inboundOrder == null) |
| | | { |