| | |
| | | using AutoMapper; |
| | | using Dm.filter; |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | |
| | | private readonly IRecordService _recordService; |
| | | private readonly IAllocateService _allocateService; |
| | | private readonly IInvokeMESService _invokeMESService; |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | | private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new() |
| | |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _allocateOrderDetailRepository = allocateOrderDetailRepository; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _materialUnitService = materialUnitService; |
| | | _task_HtyService = task_HtyService; |
| | | } |
| | | |
| | | public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum) |
| | | { |
| | | if (int.TryParse(taskNum, out var newTaskNum)) |
| | | { |
| | | await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task |
| | | { |
| | | TaskStatus = taskStatusEnum.ObjToInt() |
| | | }) |
| | | .Where(it => it.TaskNum == newTaskNum) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.人工å é¤); |
| | | if (!result) |
| | | { |
| | | await Db.Deleteable(task).ExecuteCommandAsync(); |
| | | } |
| | | try |
| | | { |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation($"InboundTaskCompleted AddLocationStatusChangeRecord : {ex.Message} "); |
| | | } |
| | | try |
| | | { |
| | | foreach (var inboundOrder in inboundOrders) |
| | |
| | | }).ToList(); |
| | | allocatefeedmodel.Details = groupedData; |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (feedbackresult != null && feedbackresult.code == 200) |
| | | { |
| | | _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 }) |
| | | .Where(it => it.Id == inboundOrder.Id).ExecuteCommand(); |
| | |
| | | }).ToList(); |
| | | allocatefeedmodel.Details = groupedData; |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (feedbackresult != null && feedbackresult.code == 200) |
| | | { |
| | | _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 }) |
| | | .Where(it => it.Id == inboundOrder.Id).ExecuteCommand(); |
| | |
| | | }).ToList(); |
| | | feedmodel.details = groupedData; |
| | | |
| | | var result = await _invokeMESService.FeedbackInbound(feedmodel); |
| | | if (result != null && result.code == 200) |
| | | var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel); |
| | | if (feedbackresult != null && feedbackresult.code == 200) |
| | | { |
| | | _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 }) |
| | | _inboundOrderService.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 => it.OrderId == inboundOrder.Id).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = feedbackresult.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(); |
| | | } |
| | | } |
| | | } |
| | |
| | | var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo); |
| | | |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.人工å é¤); |
| | | if (!result) |
| | | { |
| | | await Db.Deleteable(task).ExecuteCommandAsync(); |
| | | } |
| | | try |
| | | { |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation($"InEmptyTaskCompleted AddLocationStatusChangeRecord : {ex.Message} "); |
| | | } |
| | | |
| | | if (outboundOrder != null) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); // æ·»å äºå¡ç®¡ç |
| | | |
| | | // æ¥åºå |
| | | Dt_StockInfo stockInfo = await _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(x => x.Details) |
| | |
| | | _logger.LogInformation($"TaskService InPickTaskCompleted: æªæ¾å°è¯¥æçåºåæç»ä¿¡æ¯.{task.TaskNum}"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æçåºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | // æ¥è´§ä½ |
| | | Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfo == null) |
| | |
| | | foreach (var lockInfo in returnLocks) |
| | | { |
| | | lockInfo.Status = (int)OutLockStockStatusEnum.å·²ååº; |
| | | lockInfo.Operator = App.User.UserName; |
| | | } |
| | | |
| | | if (returnLocks.Any()) |
| | |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | } |
| | | |
| | | _locationInfoService.Repository.UpdateData(locationInfo); |
| | | _locationInfoService.Repository.UpdateData(locationInfo); |
| | | |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | |
| | | // å é¤ä»»å¡è®°å½ |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | BaseDal.DeleteData(task); |
| | | //BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | //BaseDal.DeleteData(task); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.人工å é¤); |
| | | if (!result) |
| | | { |
| | | await Db.Deleteable(task).ExecuteCommandAsync(); |
| | | } |
| | | |
| | | // è®°å½è´§ä½ç¶æåæ´ |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord( |
| | | locationInfo, |
| | | beforelocationStatus, |
| | | StockChangeType.Inbound.ObjToInt(), |
| | | "", |
| | | task.TaskNum |
| | | ); |
| | | await RecalculateOrderStatus(task.OrderNo); |
| | | try |
| | | { |
| | | // è®°å½è´§ä½ç¶æåæ´ |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord( |
| | | locationInfo, |
| | | beforelocationStatus, |
| | | StockChangeType.Inbound.ObjToInt(), |
| | | "", |
| | | task.TaskNum |
| | | ); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation($"InPickTaskCompleted AddLocationStatusChangeRecord : {ex.Message} "); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); // æäº¤äºå¡ |
| | | _logger.LogInformation($"æçååºå®æå¤çæå - ä»»å¡å·: {task.TaskNum}, æç: {task.PalletCode}, 订å: {task.OrderNo}"); |
| | | _logger.LogInformation($"æçååºå®æå¤çæå - ä»»å¡å·: {task.TaskNum}, æç: {task.PalletCode}, 订å: {task.OrderNo} è´§ä½ç¶æï¼{locationInfo.LocationStatus}"); |
| | | _ = Task.Run(async () => |
| | | { |
| | | try |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | |
| | | // è·ååå½±åç订åæç»IDï¼å»éï¼ |
| | | var affectedDetailIds = returnLocks |
| | | .Select(x => x.OrderDetailId) |
| | | .Distinct() |
| | | .ToList(); |
| | | //var affectedDetailIds = returnLocks |
| | | // .Select(x => x.OrderDetailId) |
| | | // .Distinct() |
| | | // .ToList(); |
| | | |
| | | if (!affectedDetailIds.Any()) |
| | | { |
| | | _logger.LogInformation($"没æåå½±åç订åæç» - OrderNo: {orderNo}"); |
| | | return; |
| | | } |
| | | //if (!affectedDetailIds.Any()) |
| | | //{ |
| | | // _logger.LogInformation($"没æåå½±åç订åæç» - OrderNo: {orderNo}"); |
| | | // return; |
| | | //} |
| | | |
| | | _logger.LogInformation($"æ´æ°{affectedDetailIds.Count}个åå½±åç订åæç» - OrderNo: {orderNo}"); |
| | | //_logger.LogInformation($"æ´æ°{affectedDetailIds.Count}个åå½±åç订åæç» - OrderNo: {orderNo}"); |
| | | |
| | | foreach (var detailId in affectedDetailIds) |
| | | { |
| | | // éæ°è®¡ç®è¯¥è®¢åæç»çé宿°é |
| | | decimal currentLockQty = await CalculateOrderDetailLockQuantity(detailId); |
| | | //foreach (var detailId in affectedDetailIds) |
| | | //{ |
| | | // // éæ°è®¡ç®è¯¥è®¢åæç»çé宿°é |
| | | // decimal currentLockQty = await CalculateOrderDetailLockQuantity(detailId); |
| | | |
| | | // æ£æ¥æ°æ®ä¸è´æ§ |
| | | if (currentLockQty < 0) |
| | | { |
| | | _logger.LogWarning($"é宿°é计ç®ä¸ºè´å¼ - OrderDetailId: {detailId}, å½åå¼: {currentLockQty}ï¼é置为0"); |
| | | currentLockQty = 0; |
| | | } |
| | | // // æ£æ¥æ°æ®ä¸è´æ§ |
| | | // if (currentLockQty < 0) |
| | | // { |
| | | // _logger.LogWarning($"é宿°é计ç®ä¸ºè´å¼ - OrderDetailId: {detailId}, å½åå¼: {currentLockQty}ï¼é置为0"); |
| | | // currentLockQty = 0; |
| | | // } |
| | | |
| | | // è·å订åæç» |
| | | var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .FirstAsync(x => x.Id == detailId); |
| | | // // è·å订åæç» |
| | | // var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | // .FirstAsync(x => x.Id == detailId); |
| | | |
| | | if (orderDetail == null) |
| | | { |
| | | _logger.LogWarning($"æªæ¾å°è®¢åæç» - OrderDetailId: {detailId}"); |
| | | continue; |
| | | } |
| | | // if (orderDetail == null) |
| | | // { |
| | | // _logger.LogWarning($"æªæ¾å°è®¢åæç» - OrderDetailId: {detailId}"); |
| | | // continue; |
| | | // } |
| | | |
| | | // æ´æ°é宿°é |
| | | if (orderDetail.LockQuantity != currentLockQty) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(it => new Dt_OutboundOrderDetail |
| | | { |
| | | LockQuantity = currentLockQty, |
| | | }) |
| | | .Where(it => it.Id == detailId) |
| | | .ExecuteCommandAsync(); |
| | | // // æ´æ°é宿°é |
| | | // if (orderDetail.LockQuantity != currentLockQty) |
| | | // { |
| | | // await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | // .SetColumns(it => new Dt_OutboundOrderDetail |
| | | // { |
| | | // LockQuantity = currentLockQty, |
| | | // }) |
| | | // .Where(it => it.Id == detailId) |
| | | // .ExecuteCommandAsync(); |
| | | |
| | | _logger.LogInformation($"æ´æ°è®¢åæç»é宿°é - OrderDetailId: {detailId}, " + |
| | | $"æ§å¼: {orderDetail.LockQuantity}, æ°å¼: {currentLockQty}"); |
| | | } |
| | | // _logger.LogInformation($"æ´æ°è®¢åæç»é宿°é - OrderDetailId: {detailId}, " + |
| | | // $"æ§å¼: {orderDetail.LockQuantity}, æ°å¼: {currentLockQty}"); |
| | | // } |
| | | |
| | | // æ´æ°è®¢åæç»ç¶æ |
| | | await UpdateOrderDetailStatus(orderDetail); |
| | | } |
| | | // // æ´æ°è®¢åæç»ç¶æ |
| | | // await UpdateOrderDetailStatus(orderDetail); |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(it => new Dt_OutboundOrderDetail |
| | | { |
| | | OrderDetailStatus = newStatus, |
| | | OrderDetailStatus = newStatus, |
| | | }) |
| | | .Where(it => it.Id == orderDetail.Id) |
| | | .ExecuteCommandAsync(); |
| | |
| | | { |
| | | hasInProgress = true; |
| | | } |
| | | await UpdateOrderDetailStatus(detail); |
| | | } |
| | | |
| | | var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | |
| | | .SetColumns(x => new Dt_OutboundOrder |
| | | { |
| | | OrderStatus = newStatus, |
| | | Operator = App.User.UserName, |
| | | }) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | _logger.LogInformation($"æ´æ°è®¢åç¶æ - OrderNo: {orderNo}, æ§ç¶æ: {outboundOrder.OrderStatus}, æ°ç¶æ: {newStatus}"); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | if (allCompleted && newStatus == (int)OutOrderStatusEnum.åºåºå®æ) |
| | | { |
| | | |
| | | if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt()) |
| | | if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt() || outboundOrder.OrderType == OutOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | { |
| | | var allocate = _allocateService.Repository.QueryData(x => x.UpperOrderNo == outboundOrder.UpperOrderNo).First(); |
| | | var allocatefeedmodel = new AllocateDto |
| | |
| | | MaterialCode = detail.MaterielCode, |
| | | LineNo = detail.lineNo, |
| | | WarehouseCode = detail.WarehouseCode, |
| | | Qty =0, |
| | | Qty = 0, |
| | | Unit = detail.BarcodeUnit, |
| | | Barcodes = new List<BarcodeInfo>() |
| | | }; |
| | |
| | | Barcode = item.CurrentBarcode, |
| | | SupplyCode = item.SupplyCode, |
| | | BatchNo = item.BatchNo, |
| | | Unit = item.BarcodeUnit, |
| | | Unit = detail.BarcodeUnit, |
| | | Qty = 0 |
| | | }; |
| | | // åä½ä¸ä¸è´æ¶è½¬æ¢ |
| | | if (item.BarcodeUnit != item.Unit) |
| | | if (detail.BarcodeUnit != detail.Unit) |
| | | { |
| | | var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, item.Unit, item.BarcodeUnit); |
| | | var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit); |
| | | barModel.Unit = convertResult.Unit; |
| | | barModel.Qty = convertResult.Quantity; |
| | | } |
| | | |
| | | else |
| | | { |
| | | barModel.Qty = item.PickedQty; |
| | | } |
| | | detailModel.Qty += barModel.Qty; |
| | | detailModel.Barcodes.Add(barModel); |
| | | } |
| | | |
| | | |
| | | allocatefeedmodel.Details.Add(detailModel); |
| | | } |
| | | var groupedResult = allocatefeedmodel.Details |
| | | .GroupBy(item => new { item.WarehouseCode, item.MaterialCode, item.Unit, item.LineNo }) |
| | | .Select(group => |
| | | { |
| | | |
| | | var deduplicatedBarcodes = group.SelectMany(x => x.Barcodes) |
| | | .GroupBy(b => b.Barcode) |
| | | .Select(b => new BarcodeInfo |
| | | { |
| | | Barcode = b.Key, |
| | | BatchNo = b.First().BatchNo, |
| | | SupplyCode = b.First().SupplyCode, |
| | | Qty = b.Max(x => x.Qty), |
| | | Unit = b.First().Unit |
| | | }).ToList(); |
| | | return new AllocateDtoDetail |
| | | { |
| | | WarehouseCode = group.Key.WarehouseCode, |
| | | MaterialCode = group.Key.MaterialCode, |
| | | LineNo = group.Key.LineNo, |
| | | Qty = deduplicatedBarcodes.Sum(b => b.Qty), |
| | | Unit = group.Key.Unit, |
| | | Barcodes = deduplicatedBarcodes |
| | | }; |
| | | }).ToList(); |
| | | |
| | | allocatefeedmodel.Details = groupedResult; |
| | | |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(x => new Dt_OutboundOrder |
| | | { |
| | | ReturnToMESStatus = 1, |
| | | }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync(); |
| | | } |
| | | else |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 2) |
| | | .Where(x => x.OrderId == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message }) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | | |
| | | allocatefeedmodel.Details.Add(detailModel); |
| | | } |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(x => new Dt_OutboundOrder |
| | | { |
| | | ReturnToMESStatus = 1, |
| | | Operator = App.User.UserName, |
| | | }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync(); |
| | | } |
| | | } |
| | | else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt()) |
| | |
| | | } |
| | | else |
| | | { |
| | | var feedmodel = new FeedbackOutboundRequestModel |
| | | if (outboundOrder != null && outboundOrder.IsBatch == 0) |
| | | { |
| | | reqCode = Guid.NewGuid().ToString(), |
| | | reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | business_type = outboundOrder.BusinessType, |
| | | factoryArea = outboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = outboundOrder.Operator, |
| | | orderNo = outboundOrder.UpperOrderNo, |
| | | documentsNO = outboundOrder.OrderNo, |
| | | status = outboundOrder.OrderStatus, |
| | | details = new List<FeedbackOutboundDetailsModel>() |
| | | }; |
| | | |
| | | |
| | | foreach (var detail in orderDetails) |
| | | { |
| | | // è·å该æç»å¯¹åºçæ¡ç ä¿¡æ¯ï¼ä»éå®è®°å½ï¼ |
| | | var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == orderNo && |
| | | x.OrderDetailId == detail.Id && |
| | | (x.Status == (int)OutLockStockStatusEnum.æ£é宿 || x.Status == (int)OutLockStockStatusEnum.å·²ååº)) |
| | | .ToListAsync(); |
| | | |
| | | var detailModel = new FeedbackOutboundDetailsModel |
| | | var feedmodel = new FeedbackOutboundRequestModel |
| | | { |
| | | materialCode = detail.MaterielCode, |
| | | lineNo = detail.lineNo, // 注æï¼è¿éå¯è½éè¦è°æ´å段å |
| | | warehouseCode = detail.WarehouseCode, |
| | | qty = 0, |
| | | currentDeliveryQty =0, |
| | | unit = detail.Unit, |
| | | barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>() |
| | | reqCode = Guid.NewGuid().ToString(), |
| | | reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | business_type = outboundOrder.BusinessType, |
| | | factoryArea = outboundOrder.FactoryArea, |
| | | operationType = 1, |
| | | Operator = outboundOrder.Operator, |
| | | orderNo = outboundOrder.UpperOrderNo, |
| | | documentsNO = outboundOrder.OrderNo, |
| | | status = outboundOrder.OrderStatus, |
| | | details = new List<FeedbackOutboundDetailsModel>() |
| | | }; |
| | | foreach (var item in detailLocks) |
| | | foreach (var detail in orderDetails) |
| | | { |
| | | if (item.PickedQty > 0) |
| | | // è·å该æç»å¯¹åºçæ¡ç ä¿¡æ¯ï¼ä»éå®è®°å½ï¼ |
| | | var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == orderNo && |
| | | x.OrderDetailId == detail.Id && |
| | | (x.Status == (int)OutLockStockStatusEnum.æ£é宿 || x.Status == (int)OutLockStockStatusEnum.å·²ååº)) |
| | | .ToListAsync(); |
| | | |
| | | var detailModel = new FeedbackOutboundDetailsModel |
| | | { |
| | | var barModel = new WIDESEA_DTO.Outbound.BarcodesModel |
| | | materialCode = detail.MaterielCode, |
| | | lineNo = detail.lineNo, // 注æï¼è¿éå¯è½éè¦è°æ´å段å |
| | | warehouseCode = detail.WarehouseCode, |
| | | qty = 0, |
| | | currentDeliveryQty = 0, |
| | | unit = detail.Unit, |
| | | barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>() |
| | | }; |
| | | foreach (var item in detailLocks) |
| | | { |
| | | if (item.PickedQty > 0) |
| | | { |
| | | barcode = item.CurrentBarcode, |
| | | supplyCode = item.SupplyCode, |
| | | batchNo = item.BatchNo, |
| | | unit = item.BarcodeUnit, |
| | | qty = item.PickedQty |
| | | }; |
| | | // åä½ä¸ä¸è´æ¶è½¬æ¢ |
| | | if (item.BarcodeUnit != item.Unit) |
| | | { |
| | | var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, item.Unit, item.BarcodeUnit); |
| | | barModel.unit = convertResult.Unit; |
| | | barModel.qty = convertResult.Quantity; |
| | | var barModel = new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | | barcode = item.CurrentBarcode, |
| | | supplyCode = item.SupplyCode, |
| | | batchNo = item.BatchNo, |
| | | unit = item.BarcodeUnit, |
| | | qty = item.PickedQty |
| | | }; |
| | | // åä½ä¸ä¸è´æ¶è½¬æ¢ |
| | | if (detail.BarcodeUnit != detail.Unit) |
| | | { |
| | | var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit); |
| | | barModel.unit = convertResult.Unit; |
| | | barModel.qty = convertResult.Quantity; |
| | | } |
| | | else |
| | | { |
| | | barModel.qty = item.PickedQty; |
| | | } |
| | | detailModel.qty += barModel.qty; |
| | | detailModel.currentDeliveryQty += barModel.qty; |
| | | detailModel.barcodes.Add(barModel); |
| | | } |
| | | |
| | | detailModel.qty += barModel.qty; |
| | | detailModel.currentDeliveryQty += barModel.qty; |
| | | detailModel.barcodes.Add(barModel); |
| | | } |
| | | feedmodel.details.Add(detailModel); |
| | | } |
| | | feedmodel.details.Add(detailModel); |
| | | } |
| | | var result = await _invokeMESService.FeedbackOutbound(feedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderId == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | var groupedResult = feedmodel.details |
| | | .GroupBy(item => new { item.warehouseCode, item.materialCode, item.unit, item.lineNo }) |
| | | .Select(group => |
| | | { |
| | | var deduplicatedBarcodes = group.SelectMany(x => x.barcodes) |
| | | .GroupBy(b => b.barcode) |
| | | .Select(b => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |
| | | barcode = b.Key, |
| | | batchNo = b.First().batchNo, |
| | | supplyCode = b.First().supplyCode, |
| | | qty = b.Max(x => x.qty), |
| | | unit = b.First().unit |
| | | }).ToList(); |
| | | return new FeedbackOutboundDetailsModel |
| | | { |
| | | warehouseCode = group.Key.warehouseCode, |
| | | materialCode = group.Key.materialCode, |
| | | lineNo = group.Key.lineNo, |
| | | qty = deduplicatedBarcodes.Sum(b => b.qty), |
| | | unit = group.Key.unit, |
| | | barcodes = deduplicatedBarcodes |
| | | }; |
| | | }).ToList(); |
| | | |
| | | feedmodel.details = groupedResult; |
| | | |
| | | var result = await _invokeMESService.FeedbackOutbound(feedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderId == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = "" }) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | else |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 2) |
| | | .Where(x => x.OrderId == outboundOrder.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message }) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | } |
| | | else if (outboundOrder != null && outboundOrder.IsBatch == 1) |
| | | { |
| | | await _invokeMESService.BatchOrderFeedbackToMes(new List<string>() { outboundOrder.OrderNo }, 2); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | //_stockRepository.Db.Deleteable(stockInfo).ExecuteCommand(); |
| | | _stockService.StockInfoService.DeleteData(stockInfo); |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.人工å é¤); |
| | | if (!result) |
| | | { |
| | | await Db.Deleteable(task).ExecuteCommandAsync(); |
| | | } |
| | | |
| | | var stockresult = _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | if (!stockresult) |
| | | { |
| | | _stockRepository.Db.Deleteable(stockInfo).ExecuteCommand(); |
| | | } |
| | | _stockService.StockInfoService.DeleteData(stockInfo); |
| | | try |
| | | { |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo?.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError($"TaskService OutEmptyTaskCompleted AddLocationStatusChangeRecord: {ex.Message} "); |
| | | } |
| | | return await Task.FromResult(WebResponseContent.Instance.OK()); |
| | | |
| | | } |