| | |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_IAllocateService; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_ICheckService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEA_Model.Models.Check; |
| | | |
| | | namespace WIDESEA_OutboundService |
| | | { |
| | |
| | | private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository; |
| | | |
| | | private readonly IReCheckOrderService _reCheckOrderService; |
| | | private readonly ILogger<OutboundPickingService> _logger; |
| | | |
| | | 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) : 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) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoService = stockInfoService; |
| | |
| | | _inboundOrderRepository = inboundOrderRepository; |
| | | _inboundOrderDetailService = inboundOrderDetailService; |
| | | _warehouseAreaRepository = warehouseAreaRepository; |
| | | _reCheckOrderService = reCheckOrderService; |
| | | } |
| | | |
| | | |
| | |
| | | var completedLockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(it => it.CurrentBarcode == barcode && |
| | | (it.Status == (int)OutLockStockStatusEnum.æ£é宿 || |
| | | it.Status == (int)OutLockStockStatusEnum.已鿾 || |
| | | it.Status == (int)OutLockStockStatusEnum.å·²åèµ° || |
| | | it.PickedQty >= it.AssignQuantity)).FirstAsync(); |
| | | |
| | | if (completedLockInfo != null) |
| | | throw new Exception($"æ¡ç {barcode}å·²ç»å®æåæ£ï¼ä¸è½éå¤åæ£"); |
| | | { |
| | | string statusMsg = completedLockInfo.Status switch |
| | | { |
| | | (int)OutLockStockStatusEnum.æ£é宿 => "å·²ç»å®æåæ£", |
| | | (int)OutLockStockStatusEnum.已鿾 => "å·²ç»éæ¾", |
| | | (int)OutLockStockStatusEnum.å·²åèµ° => "å·²ç»åèµ°", |
| | | _ => "å·²ç»å®æåæ£" |
| | | }; |
| | | throw new Exception($"æ¡ç {barcode}{statusMsg}ï¼ä¸è½éå¤åæ£"); |
| | | } |
| | | else |
| | | return null; |
| | | } |
| | |
| | | |
| | | private async Task<bool> CanCancelPicking(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail) |
| | | { |
| | | if (lockInfo.Status == (int)OutLockStockStatusEnum.已鿾 || lockInfo.Status == (int)OutLockStockStatusEnum.å·²åèµ°) |
| | | return false; |
| | | // éå®ä¿¡æ¯ç¶ææ£æ¥ |
| | | if (lockInfo.Status != (int)OutLockStockStatusEnum.æ£é宿) |
| | | return false; |
| | | |
| | | ////// åºåç¶ææ£æ¥ |
| | | ////if (stockDetail.Status == StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | //// return false; |
| | | |
| | | |
| | | // å¦ææ¯æå
è®°å½ï¼è¿éè¦æ£æ¥ç¶éå®ä¿¡æ¯ç¶æ |
| | | if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue) |
| | |
| | | var parentLock = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .FirstAsync(x => x.Id == lockInfo.ParentLockId.Value); |
| | | |
| | | if (parentLock == null || parentLock.Status == (int)OutLockStockStatusEnum.ååºä¸) |
| | | if (parentLock == null || parentLock.Status == (int)OutLockStockStatusEnum.ååºä¸ || |
| | | parentLock.Status == (int)OutLockStockStatusEnum.已鿾 || |
| | | parentLock.Status == (int)OutLockStockStatusEnum.å·²åèµ°) |
| | | return false; |
| | | } |
| | | |
| | |
| | | await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>() |
| | | .SetColumns(it => new Dt_OutStockLockInfo |
| | | { |
| | | Status = (int)OutLockStockStatusEnum.已鿾, // éè¦æ°å¢è¿ä¸ªç¶æ |
| | | // ReleaseTime = DateTime.Now, |
| | | Status = (int)OutLockStockStatusEnum.已鿾, |
| | | |
| | | Operator = App.User.UserName |
| | | }) |
| | | .Where(it => lockIds.Contains(it.Id)) |
| | |
| | | |
| | | // å é¤åå§åºåºä»»å¡ |
| | | _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.èªå¨å®æ); |
| | | // await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync(); |
| | | await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync(); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | _logger.LogInformation($"订åç¶ææ´æ° - OrderNo: {orderNo}, æ§ç¶æ: {outboundOrder.OrderStatus}, æ°ç¶æ: {newStatus}"); |
| | | |
| | | // åªææ£å¸¸åæ£å®ææ¶æåMESåé¦ |
| | | if (allCompleted && newStatus == (int)OutOrderStatusEnum.åºåºå®æ) |
| | | { |
| | | await HandleOrderCompletion(outboundOrder, orderNo); |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | | BusinessType = "3", |
| | | BusinessType = "2", |
| | | |
| | | FactoryArea = outboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | |
| | | |
| | | // åªè·åå·²æ£é宿çéå®è®°å½ |
| | | var lists = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == orderNo && x.Status == (int)OutLockStockStatusEnum.æ£é宿) |
| | | .Where(x => x.OrderNo == orderNo && (x.Status == (int)OutLockStockStatusEnum.æ£é宿 || x.Status == (int)OutLockStockStatusEnum.å·²ååº)) |
| | | .ToListAsync(); |
| | | |
| | | var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode }) |
| | | var groupedData = lists.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.Unit, |
| | | qty = group.Sum(x => x.BarcodeQty), |
| | | currentDeliveryQty = group.Sum(x => x.BarcodeQty), |
| | | unit = group.Key.BarcodeUnit, |
| | | barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | | barcode = row.CurrentBarcode, |
| | | supplyCode = row.SupplyCode, |
| | | batchNo = row.BatchNo, |
| | | unit = row.Unit, |
| | | qty = row.PickedQty |
| | | unit = row.BarcodeUnit, |
| | | qty = row.BarcodeQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | |
| | |
| | | _logger.LogInformation($"订å {orderNo} å·²æ 记为åºåºå®æ"); |
| | | |
| | | // åMESåé¦è®¢å宿ï¼å¦æéè¦ï¼ |
| | | await HandleOrderCompletion(outboundOrder, orderNo); |
| | | //await HandleOrderCompletion(outboundOrder, orderNo); |
| | | } |
| | | } |
| | | |
| | |
| | | business_type = outboundOrder.BusinessType, |
| | | factoryArea = outboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = outboundOrder.Operator, |
| | | Operator = App.User.UserName, |
| | | orderNo = outboundOrder.UpperOrderNo, |
| | | documentsNO = outboundOrder.OrderNo, |
| | | status = outboundOrder.OrderStatus, |
| | |
| | | var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == outboundOrder.OrderNo && |
| | | x.OrderDetailId == detail.Id && |
| | | x.Status == (int)OutLockStockStatusEnum.æ£é宿) |
| | | (x.Status == (int)OutLockStockStatusEnum.æ£é宿 || x.Status == (int)OutLockStockStatusEnum.å·²ååº)) |
| | | .ToListAsync(); |
| | | |
| | | var detailModel = new FeedbackOutboundDetailsModel |
| | | { |
| | | materialCode = detail.MaterielCode, |
| | | lineNo = detail.lineNo, // 注æï¼è¿éå¯è½éè¦è°æ´å段å |
| | | warehouseCode = detail.WarehouseCode, |
| | | qty = detail.OverOutQuantity, // 使ç¨è®¢åæç»çå·²åºåºæ°é |
| | | currentDeliveryQty = detail.OverOutQuantity, |
| | | unit = detail.Unit, |
| | | barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | | barcode = lockInfo.CurrentBarcode, |
| | | supplyCode = lockInfo.SupplyCode, |
| | | batchNo = lockInfo.BatchNo, |
| | | unit = lockInfo.Unit, |
| | | qty = lockInfo.PickedQty // æ¡ç 级å«çæ°éä»ç¨éå®è®°å½ |
| | | }).ToList() |
| | | }; |
| | | var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new FeedbackOutboundDetailsModel |
| | | { |
| | | |
| | | feedmodel.details.Add(detailModel); |
| | | materialCode = group.Key.MaterielCode, |
| | | lineNo = group.Key.lineNo, |
| | | warehouseCode = group.Key.WarehouseCode, |
| | | qty = group.Sum(x => x.BarcodeQty), |
| | | currentDeliveryQty = group.Sum(x => x.BarcodeQty), |
| | | 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.BarcodeQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | feedmodel.details.AddRange(groupdata); |
| | | } |
| | | var result = await _invokeMESService.FeedbackOutbound(feedmodel); |
| | | if (result != null && result.code == 200) |
| | |
| | | return content = WebResponseContent.Instance.Error($"ä»åºä¸æ²¡æè¯¥{materielGroupDTO.WarehouseType}ç¼å·ã"); |
| | | } |
| | | |
| | | |
| | | if (materielGroupDTO.orderTypes == InOrderTypeEnum.ReCheck.ObjToInt()) |
| | | { |
| | | var dborder = _reCheckOrderService.Db.Queryable<Dt_ReCheckOrder>().First(x => x.OrderNo == materielGroupDTO.OrderNo); |
| | | if (dborder != null && dborder.SignSeq == 0) |
| | | { |
| | | return content.Error("åªææ¿å°éæ£ç»ææè½å
¥åºï¼"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æ²¡ææ¾å°éæ£åæ®æ°æ®ã"); |
| | | } |
| | | } |
| | | // Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo); |
| | | |
| | | var dbinboundOrderDetails = Db.Queryable<Dt_PickingRecord>().Where(x => x.OrderNo == materielGroupDTO.OrderNo && !x.IsCancelled && x.Barcode == materielGroupDTO.Barcodes).ToList(); |
| | |
| | | InboundOrderNo = dbinboundOrderDetails.First()?.OrderNo, |
| | | UpperOrderNo = dbinboundOrderDetails.First()?.OrderNo, |
| | | SupplierId = dbinboundOrderDetails.First()?.SupplyCode, |
| | | OrderType = InOrderTypeEnum.InternalAllocat.ObjToInt(), |
| | | OrderType = materielGroupDTO.orderTypes, |
| | | |
| | | BusinessType = InOrderTypeEnum.InternalAllocat.ObjToInt().ToString(), |
| | | BusinessType = materielGroupDTO.orderTypes.ToString(), |
| | | |
| | | FactoryArea = dbinboundOrderDetails.First()?.FactoryArea, |
| | | Remark = "", |
| | |
| | | } |
| | | else |
| | | { |
| | | dt_InboundOrder = new Dt_InboundOrder { Details = new List<Dt_InboundOrderDetail>() }; |
| | | dt_InboundOrder = new Dt_InboundOrder { Details = new List<Dt_InboundOrderDetail>() }; |
| | | inboindId = dbinbound.Id; |
| | | } |
| | | |