| | |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicService; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEA_Model.Models.Check; |
| | |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository; |
| | | private readonly IReCheckOrderService _reCheckOrderService; |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | 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, IReCheckOrderService reCheckOrderService) : 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) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoService = stockInfoService; |
| | |
| | | _inboundOrderDetailService = inboundOrderDetailService; |
| | | _warehouseAreaRepository = warehouseAreaRepository; |
| | | _reCheckOrderService = reCheckOrderService; |
| | | _task_HtyService = task_HtyService; |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | { |
| | | // è·åææ°ç订åæç»æ°æ®ï¼å¸¦éï¼ |
| | | var currentOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .With(SqlWith.RowLock) |
| | | //.With(SqlWith.RowLock) |
| | | .FirstAsync(x => x.Id == orderDetailId); |
| | | |
| | | decimal newOverOutQuantity = currentOrderDetail.OverOutQuantity - cancelQty; |
| | |
| | | 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)) |
| | |
| | | WarehouseId = originalTask.WarehouseId |
| | | |
| | | }; |
| | | // ä¿åååºä»»å¡ |
| | | await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync(); |
| | | try |
| | | { |
| | | // ä¿åååºä»»å¡ |
| | | var insertcount = await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync(); |
| | | if (insertcount <= 0) |
| | | { |
| | | throw new Exception("å建任å¡å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation($"CreateReturnTaskAndHandleESS å建任å¡å¤±è´¥: {orderNo} ï¼ {palletCode}"); |
| | | throw new Exception("å建任å¡å¤±è´¥ï¼"); |
| | | } |
| | | var targetAddress = originalTask.TargetAddress; |
| | | |
| | | // å é¤åå§åºåºä»»å¡ |
| | | _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.èªå¨å®æ); |
| | | await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync(); |
| | | |
| | | // _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.èªå¨å®æ); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.人工å é¤); |
| | | if (!result) |
| | | { |
| | | await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync(); |
| | | } |
| | | |
| | | |
| | | // ç» ESS åéæµå¨ä¿¡å·ååå»ºä»»å¡ |
| | |
| | | |
| | | _logger.LogInformation($"订åç¶ææ´æ° - OrderNo: {orderNo}, æ§ç¶æ: {outboundOrder.OrderStatus}, æ°ç¶æ: {newStatus}"); |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | .Where(x => x.OrderNo == orderNo && 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 AllocateDtoDetail |
| | | { |
| | | MaterialCode = group.Key.MaterielCode, |
| | |
| | | WarehouseCode = group.Key.WarehouseCode, |
| | | Qty = group.Sum(x => x.PickedQty), |
| | | |
| | | Unit = group.Key.Unit, |
| | | Unit = group.Key.BarcodeUnit, |
| | | Barcodes = group.Select(row => new BarcodeInfo |
| | | { |
| | | Barcode = row.CurrentBarcode, |
| | | SupplyCode = row.SupplyCode, |
| | | BatchNo = row.BatchNo, |
| | | Unit = row.Unit, |
| | | Unit = row.BarcodeUnit, |
| | | Qty = row.PickedQty |
| | | }).ToList() |
| | | |
| | |
| | | materialCode = group.Key.MaterielCode, |
| | | lineNo = group.Key.lineNo, |
| | | warehouseCode = group.Key.WarehouseCode, |
| | | qty = group.Sum(x => x.BarcodeQty), |
| | | currentDeliveryQty = group.Sum(x => x.BarcodeQty), |
| | | qty = group.Sum(x => x.PickedQty), |
| | | currentDeliveryQty = group.Sum(x => x.PickedQty), |
| | | unit = group.Key.BarcodeUnit, |
| | | barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | |
| | | supplyCode = row.SupplyCode, |
| | | batchNo = row.BatchNo, |
| | | unit = row.BarcodeUnit, |
| | | qty = row.BarcodeQty |
| | | qty = row.PickedQty |
| | | }).ToList() |
| | | }).ToList(); |
| | | |
| | |
| | | { |
| | | // 1. å é¤åºåæ°é为0çæç»è®°å½ |
| | | var deleteDetailCount = await _stockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockId && x.StockQuantity == 0 && (x.Status == StockStatusEmun.åºåºå®æ.ObjToInt() || x.Status == |
| | | StockStatusEmun.å
¥åºå®æ.ObjToInt())) |
| | | .Where(x => x.StockId == stockId && x.StockQuantity == 0) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _stockInfoService.Db.Deleteable<Dt_StockInfo>() |
| | |
| | | StockId = 0, |
| | | OrderQuantity = outboundOrderDetail.OrderQuantity, |
| | | AssignQuantity = outboundOrderDetail.OverOutQuantity, |
| | | PickedQty = 0, |
| | | PickedQty = outboundOrderDetail.NoStockOutQty, |
| | | LocationCode = "空", |
| | | PalletCode = "空", |
| | | TaskNum = 0, |
| | | Status = (int)OutLockStockStatusEnum.æ£é宿, |
| | | Unit = outboundOrderDetail.Unit, |
| | | SupplyCode = outboundOrderDetail.SupplyCode?? "æ ", |
| | | SupplyCode = outboundOrderDetail.SupplyCode ?? "æ ", |
| | | OrderType = outboundOrder.OrderType, |
| | | CurrentBarcode = inboundOrderDetail.Barcode, |
| | | IsSplitted = 1, |
| | | Operator = App.User.UserName, |
| | | lineNo= outboundOrderDetail.lineNo, |
| | | lineNo = outboundOrderDetail.lineNo, |
| | | WarehouseCode = outboundOrderDetail.WarehouseCode ?? "æ ", |
| | | BarcodeQty=outboundOrderDetail.NoStockOutQty, |
| | | BarcodeUnit =outboundOrderDetail.BarcodeUnit, |
| | | BarcodeQty = outboundOrderDetail.NoStockOutQty, |
| | | BarcodeUnit = outboundOrderDetail.BarcodeUnit, |
| | | BatchNo = outboundOrderDetail.BatchNo |
| | | }; |
| | | _outStockLockInfoService.AddData(newLockInfo); |
| | |
| | | .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand(); |
| | | } |
| | | //åºåºåä¼ MES |
| | | |
| | | 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 = outboundOrder.OrderNo, |
| | | status = outboundOrder.OrderStatus, |
| | | details = new List<FeedbackOutboundDetailsModel>() |
| | | }; |
| | | { |
| | | 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 outboundOrder.Details) |
| | | { |
| | | // è·å该æç»å¯¹åºçæ¡ç ä¿¡æ¯ï¼ä»éå®è®°å½ï¼ |
| | |
| | | .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.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(); |
| | | .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); |
| | | } |
| | | var result = await _invokeMESService.FeedbackOutbound(outfeedmodel); |
| | |
| | | { |
| | | return content.Error("åªææ¿å°éæ£ç»ææè½å
¥åºï¼"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æ²¡ææ¾å°éæ£åæ®æ°æ®ã"); |
| | | } |
| | | |
| | | |
| | | } |
| | | // Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo); |
| | | |
| | |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | var inboindId = 0; Dt_InboundOrder dt_InboundOrder = null; |
| | | var dbinbound = _inboundOrderRepository.QueryData(x => x.InboundOrderNo == dbinboundOrderDetails.First().OrderNo).First(); |
| | | var orderno = dbinboundOrderDetails.First().OrderNo; |
| | | var dbinbound = _inboundOrderRepository.QueryData(x => x.InboundOrderNo == orderno).FirstOrDefault(); |
| | | if (dbinbound == null) |
| | | { |
| | | dt_InboundOrder = new Dt_InboundOrder |
| | |
| | | FactoryArea = item.FactoryArea, |
| | | Status = 0, |
| | | OrderNo = item.OrderNo, |
| | | BusinessType = InOrderTypeEnum.InternalAllocat.ObjToInt().ToString() |
| | | BusinessType = materielGroupDTO.orderTypes.ToString() |
| | | |
| | | }); |
| | | item.WarehouseCode = item.WarehouseCode; |