pan
3 天以前 02aefe4bc6808cce80964fcd939762e43828a312
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -297,9 +297,16 @@
            {
                await Db.Deleteable(task).ExecuteCommandAsync();
            }
            _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
            try
            {
                _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)
@@ -568,8 +575,14 @@
                {
                    await Db.Deleteable(task).ExecuteCommandAsync();
                }
                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
                try
                {
                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation($"InEmptyTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
                }
                if (outboundOrder != null)
                {
@@ -683,16 +696,23 @@
                {
                    await Db.Deleteable(task).ExecuteCommandAsync();
                }
                // è®°å½•货位状态变更
                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
                    locationInfo,
                    beforelocationStatus,
                    StockChangeType.Inbound.ObjToInt(),
                    "",
                    task.TaskNum
                );
                await RecalculateOrderStatus(task.OrderNo);
                await RecalculateOrderStatus(task.OrderNo);
                try
                {
                    // è®°å½•货位状态变更
                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
                        locationInfo,
                        beforelocationStatus,
                        StockChangeType.Inbound.ObjToInt(),
                        "",
                        task.TaskNum
                    );
                }
                catch (Exception ex)
                {
                    _logger.LogInformation($"InPickTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
                }
                _logger.LogInformation($"托盘回库完成处理成功 - ä»»åŠ¡å·: {task.TaskNum}, æ‰˜ç›˜: {task.PalletCode}, è®¢å•: {task.OrderNo}");
                _ = Task.Run(async () =>
@@ -737,8 +757,8 @@
        {
            try
            {
                // èŽ·å–å—å½±å“çš„è®¢å•æ˜Žç»†ID(去重)
                //var affectedDetailIds = returnLocks
                //    .Select(x => x.OrderDetailId)
@@ -979,7 +999,7 @@
                    _logger.LogInformation($"更新订单状态 - OrderNo: {orderNo}, æ—§çŠ¶æ€: {outboundOrder.OrderStatus}, æ–°çŠ¶æ€: {newStatus}");
                }
            }
            catch (Exception ex)
            {
@@ -1115,7 +1135,34 @@
                                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)
@@ -1202,6 +1249,32 @@
                                }
                                feedmodel.details.Add(detailModel);
                            }
                            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)
@@ -1284,8 +1357,14 @@
                    _stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
                }
                _stockService.StockInfoService.DeleteData(stockInfo);
                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
                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());
            }