| | |
| | | using WIDESEA_DTO.Base; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.CalcOut; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_DTO.ReturnMES; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundService; |
| | |
| | | private readonly IESSApiService _eSSApiService; |
| | | private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository; |
| | | public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository; |
| | | |
| | | private Dictionary<string, string> stations = new Dictionary<string, string> |
| | | { |
| | |
| | | {"3-1","3-5" }, |
| | | }; |
| | | |
| | | public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository) |
| | | public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _eSSApiService = eSSApiService; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _allocateMaterialInfoRepository = allocateMaterialInfoRepository; |
| | | _inboundOrderDetailRepository = inboundOrderDetailRepository; |
| | | _inboundOrderRepository = inboundOrderRepository; |
| | | } |
| | | |
| | | public WebResponseContent PrintFromData (string barcode) |
| | | { |
| | | var detail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == barcode); |
| | | if(detail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | | } |
| | | |
| | | var inbound = _inboundOrderRepository.QueryFirst(x=>x.Id == detail.OrderId); |
| | | if(inbound == null) |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | | } |
| | | var printFormData = new PrintFromDataDTO { |
| | | materialCode = detail.MaterielCode, |
| | | materialName = detail.MaterielName, |
| | | materialSpec = detail.Unit, |
| | | batchNo = detail.BatchNo, |
| | | pruchaseOrderNo = inbound.UpperOrderNo, |
| | | factoryArea = inbound.FactoryArea, |
| | | suplierCode = detail.SupplyCode, |
| | | quantity = detail.BarcodeQty |
| | | }; |
| | | |
| | | return WebResponseContent.Instance.OK(data:printFormData); |
| | | } |
| | | |
| | | #region åºåºåé
|
| | |
| | | string responseMsg = totalActualAllocate == totalNeedAllocate |
| | | ? "忣任å¡åé
æå" |
| | | : $"忣任å¡åé
宿ï¼å®é
åé
{totalActualAllocate}ï¼éæ±{totalNeedAllocate}ï¼åºåä¸è¶³é¨åæªåé
ï¼"; |
| | | Dt_OutboundOrder outboundOrder1 = _outboundRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == request.OrderNo).Includes(x=>x.Details).First(); |
| | | if(totalActualAllocate == 0 && !outboundOrder1.Details.Any(x=>x.LockQuantity >0)) |
| | | { |
| | | UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.æªå¼å§); |
| | | return WebResponseContent.Instance.Error("åé
åºåæ°é为0ï¼æ æ³åºåº"); |
| | | } |
| | | response.Success = true; |
| | | response.Message = responseMsg; |
| | | response.Tasks = tasks; |
| | |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo); |
| | | if (outboundOrder == null) return false; |
| | | outboundOrder.OrderStatus = status; |
| | | if(outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt()) |
| | | { |
| | | outboundOrder.ReturnToMESStatus = 5; |
| | | } |
| | | _outboundRepository.UpdateData(outboundOrder); |
| | | return true; |
| | | } |
| | |
| | | { |
| | | barcodeQuantity = item.LockQuantity - item.OverOutQuantity; |
| | | allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity); |
| | | if(item.ReturnToMESStatus == 0) |
| | | { |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | else |
| | | { |
| | | item.CurrentDeliveryQty += item.LockQuantity - item.OverOutQuantity; |
| | | } |
| | | item.OverOutQuantity = item.LockQuantity; |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | |
| | | updateDetails.Add(item); |
| | |
| | | response.Success = true; |
| | | response.Message = "åºåºå®æ"; |
| | | response.UpdatedDetails = updateDetails; |
| | | |
| | | |
| | | if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails)) |
| | | { |
| | | Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode; |
| | | |
| | | Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode; |
| | | |
| | | List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x => |
| | | x.OrderNo == request.OrderNo && |
| | | x.MaterielCode == stockInfoDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList(); |
| | | if (stockLockInfos != null && stockLockInfos.Any()) |
| | | { |
| | | _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | } |
| | | |
| | | // æ£æ¥åºåºåæ¯å¦å®æ |
| | | if (CheckOutboundOrderCompleted(request.OrderNo)) |
| | | { |
| | |
| | | { |
| | | barcodeQuantity = item.LockQuantity - item.OverOutQuantity; |
| | | allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity); |
| | | if (item.ReturnToMESStatus == 0) |
| | | { |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | else |
| | | { |
| | | item.CurrentDeliveryQty += item.LockQuantity - item.OverOutQuantity; |
| | | } |
| | | item.OverOutQuantity = item.LockQuantity; |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | |
| | | updateDetails.Add(item); |
| | |
| | | _feedbackMesService.BarcodeFeedback(newBarcode); |
| | | } |
| | | |
| | | if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails.First())) |
| | | if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails)) |
| | | { |
| | | Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode; |
| | | |
| | |
| | | { |
| | | UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.åºåºå®æ.ObjToInt()); |
| | | |
| | | if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt() && outboundOrder.CreateType!=OrderCreateTypeEnum.CreateInSystem.ObjToInt()) |
| | | { |
| | | _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <summary> |
| | | /// æ£æ¥åºåºåæç»æ¯å¦å®æ |
| | | /// </summary> |
| | | public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, Dt_OutboundOrderDetail outboundOrderDetail) |
| | | public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, List<Dt_OutboundOrderDetail> outboundOrderDetails) |
| | | { |
| | | if (string.IsNullOrEmpty(orderNo) || string.IsNullOrEmpty(materialCode) || outboundOrderDetails == null || !outboundOrderDetails.Any()) |
| | | return false; |
| | | |
| | | // æ¥è¯¢ä¸»è®¢åï¼ä¸åå¨ç´æ¥è¿åfalse |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo); |
| | | if (outboundOrder == null) return false; |
| | | |
| | | List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && x.MaterielCode == materialCode && (string.IsNullOrEmpty(outboundOrderDetail.SupplyCode) || x.SupplyCode == outboundOrderDetail.SupplyCode) && (string.IsNullOrEmpty(outboundOrderDetail.WarehouseCode) || x.WarehouseCode == outboundOrderDetail.WarehouseCode)); |
| | | var firstDetail = outboundOrderDetails.FirstOrDefault(); |
| | | string supplyCode = firstDetail.SupplyCode; |
| | | string warehouseCode = firstDetail.WarehouseCode; |
| | | List<int> ids = outboundOrderDetails.Select(x => x.Id).ToList(); |
| | | |
| | | // æ£æ¥æææç»çå·²åºæ°éæ¯å¦é½çäºåæ®æ°é |
| | | List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => |
| | | x.OrderId == outboundOrder.Id |
| | | && x.MaterielCode == materialCode |
| | | && ids.Contains(x.Id) |
| | | && (string.IsNullOrEmpty(supplyCode) || x.SupplyCode == supplyCode) |
| | | && (string.IsNullOrEmpty(warehouseCode) || x.WarehouseCode == warehouseCode) |
| | | ); |
| | | |
| | | if (!details.Any()) return false; |
| | | |
| | | return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty); |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync(); |
| | | |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | return WebResponseContent.Instance.Error("ä»»å¡ä¿¡æ¯å表åå¨è¯¥æççä»»å¡ä¿¡æ¯ï¼ä¸å¯å走空箱ï¼è¯·æ£æ¥ä»»å¡æ¯å¦å®æ"); |
| | | } |
| | | |
| | | if (stock == null) |
| | | { |
| | |
| | | if (stock.Details.Count <= 0) |
| | | { |
| | | stock.PalletType = (int)PalletTypeEnum.Empty; |
| | | stock.StockStatus = (int)StockStatusEmun.ç»çæå; |
| | | stock.StockStatus = (int)StockStatusEmun.å
¥åºç¡®è®¤; |
| | | stock.LocationCode = ""; |
| | | } |
| | | else if (stock.Details.Count > 0) |
| | | { |
| | | Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x => |
| | | x.OrderNo == OrderNo && |
| | | x.StockId == stock.Id && |
| | | x.PalletCode == palletCode); |
| | | |
| | | if (lockInfo != null && lockInfo.SortedQuantity != lockInfo.AssignQuantity) |
| | | { |
| | | return content.Error($"æç{palletCode}åºåæªæ£éå®ä¸å
许ååº"); |
| | | return content.Error($"æç{palletCode}åºåï¼å¨åæ®{lockInfo.OrderNo}éé¢è¿æªæ£é宿ï¼ä¸å
许ååº"); |
| | | } |
| | | stock.StockStatus = (int)StockStatusEmun.ç»çæå; |
| | | stock.StockStatus = (int)StockStatusEmun.å
¥åºç¡®è®¤; |
| | | stock.LocationCode = ""; |
| | | } |
| | | |
| | |
| | | // åé
æ°è´§ä½ |
| | | var newLocation = _locationInfoService.AssignLocation(stock.LocationType); |
| | | |
| | | if(newLocation == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("没æç©ºé²åºä½å¯ååº"); |
| | | } |
| | | |
| | | var newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stations.GetValueOrDefault(station) ?? "", |