heshaofeng
2026-01-06 b13d3d2c634df625dcaa74371f1d36a8376851b4
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs
@@ -549,7 +549,7 @@
        private List<Dt_StockInfo> BuildStockQueryWithInfo(MaterielOutboundCalculationDTO materielCalc, string factoryArea)
        {
            // åŸºç¡€æŸ¥è¯¢æ¡ä»¶ï¼šç‰©æ–™ç¼–号、批次号(如果提供)、库存数量>0
            ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0);
            ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0 && (x.Status == (int)StockStatusEmun.入库完成 || x.Status == (int)StockStatusEmun.手动解锁));
            // æ ¹æ®æ¡ä»¶æ·»åŠ ä¾›åº”å•†ç¼–å·åŒ¹é…ï¼ˆä¸ä¸ºç©ºæ—¶æ‰éœ€è¦åŒ¹é…ï¼‰
            if (!string.IsNullOrEmpty(materielCalc.SupplyCode))
@@ -878,22 +878,6 @@
                    return WebResponseContent.Instance.Error(response.Message);
                }
                bool isMatMixed = stockInfo.Details.GroupBy(x => new
                {
                    x.MaterielCode,
                    x.MaterielName,
                    x.BatchNo,
                    x.SupplyCode,
                    x.WarehouseCode
                }).Count() > 1;
                if (isMatMixed)
                {
                    response.Success = false;
                    response.Message = $"混料托盘 {request.PalletCode} ä¸èƒ½æ•´ç®±å‡ºåº“";
                    return WebResponseContent.Instance.Error(response.Message);
                }
                // 2. æŸ¥æ‰¾å‡ºåº“单信息
                Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(o => o.OrderNo == request.OrderNo);
                if (outboundOrder == null)
@@ -916,6 +900,67 @@
                {
                    response.Success = false;
                    response.Message = $"该库存没有分配出库量,托盘号:{request.PalletCode}";
                    return WebResponseContent.Instance.Error(response.Message);
                }
                //bool isMatMixed = stockInfo.Details.GroupBy(x => new
                //{
                //    x.MaterielCode,
                //    x.MaterielName,
                //    x.BatchNo,
                //    x.SupplyCode,
                //    x.WarehouseCode
                //}).Count() > 1;
                bool isMatMixed = false;
                bool includeBatchNo = !string.IsNullOrEmpty(lockInfo.BatchNo);
                bool includeSupplyCode = !string.IsNullOrEmpty(lockInfo.SupplyCode);
                if (includeBatchNo && includeSupplyCode)
                {
                    isMatMixed = stockInfo.Details.GroupBy(x => new
                    {
                        x.MaterielCode,
                        x.MaterielName,
                        x.BatchNo,
                        x.SupplyCode,
                        x.WarehouseCode
                    }).Count() > 1;
                }
                else if (includeBatchNo && !includeSupplyCode)
                {
                    isMatMixed = stockInfo.Details.GroupBy(x => new
                    {
                        x.MaterielCode,
                        x.MaterielName,
                        x.BatchNo,
                        x.WarehouseCode
                    }).Count() > 1;
                }
                else if (!includeBatchNo && includeSupplyCode)
                {
                    isMatMixed = stockInfo.Details.GroupBy(x => new
                    {
                        x.MaterielCode,
                        x.MaterielName,
                        x.SupplyCode,
                        x.WarehouseCode
                    }).Count() > 1;
                }
                else
                {
                    isMatMixed = stockInfo.Details.GroupBy(x => new
                    {
                        x.MaterielCode,
                        x.MaterielName,
                        x.WarehouseCode
                    }).Count() > 1;
                }
                if (isMatMixed)
                {
                    response.Success = false;
                    response.Message = $"混料托盘 {request.PalletCode} ä¸èƒ½æ•´ç®±å‡ºåº“";
                    return WebResponseContent.Instance.Error(response.Message);
                }
@@ -1435,7 +1480,7 @@
                        List<Barcodes> barcodesList = new List<Barcodes>();
                        Barcodes barcodes = new Barcodes
                        {
                            Barcode = request.Barcode,
                            Barcode = isUnpacked ? newBarcode : stockDetail?.Barcode,
                            Qty = barcodeQuantity,
                            SupplyCode = stockDetail?.SupplyCode ?? "",
                            BatchNo = stockDetail?.BatchNo ?? "",
@@ -1920,13 +1965,13 @@
                var newTask = new Dt_Task()
                {
                    CurrentAddress = stations[station],
                    CurrentAddress = stations.GetValueOrDefault(station) ?? "",
                    Grade = 0,
                    PalletCode = palletCode,
                    NextAddress = "",
                    OrderNo = OrderNo,
                    Roadway = newLocation.RoadwayNo,
                    SourceAddress = stations[station],
                    SourceAddress = stations.GetValueOrDefault(station) ?? "",
                    TargetAddress = newLocation.LocationCode,
                    TaskStatus = (int)TaskStatusEnum.New,
                    TaskType = stock.Details.Count > 0 ? (int)TaskTypeEnum.InPick : (int)TaskTypeEnum.InEmpty,
@@ -1936,11 +1981,11 @@
                _stockInfoRepository.UpdateData(stock);
                _taskRepository.AddData(newTask);
                //var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
                //{
                //    slotCode = movestations[station],
                //    containerCode = palletCode
                //});
                var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
                {
                    slotCode = movestations[station],
                    containerCode = palletCode
                });
                return content.OK();
            }