From b94f0b8aa85df442748eb4c88e61cb4c962ed46f Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 30 十二月 2025 09:19:15 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundQueryService.cs |  105 +++++++++++++++++++++++--
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs |   27 ------
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs      |   77 +++++++++++++++----
 3 files changed, 156 insertions(+), 53 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundQueryService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundQueryService.cs"
index 494e6d2..6f2ee51 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundQueryService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundQueryService.cs"
@@ -26,26 +26,111 @@
             }
         }
 
+        //public WebResponseContent QueryPickingTasks(string palletCode, string orderNo)
+        //{
+        //    try
+        //    {
+        //        Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+
+        //        var outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
+
+        //        bool isMatMixed = false;
+        //        if (stockInfo != null)
+        //        {
+        //            isMatMixed = stockInfo.Details.GroupBy(x => new
+        //            {
+        //                x.MaterielCode,
+        //                x.MaterielName,
+        //                x.BatchNo,
+        //                x.SupplyCode,
+        //                x.WarehouseCode
+        //            }).Count() > 1;
+        //        }
+
+
+        //        List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo);
+        //        return WebResponseContent.Instance.OK(data: new { outStockLockInfos, stockInfo, isMatMixed });
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        return WebResponseContent.Instance.Error(ex.Message);
+        //    }
+        //}
+
         public WebResponseContent QueryPickingTasks(string palletCode, string orderNo)
         {
             try
             {
-                Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+                Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>()
+                    .Where(x => x.PalletCode == palletCode)
+                    .Includes(x => x.Details)
+                    .First();
+
+                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository
+                    .QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo);
+
                 bool isMatMixed = false;
-                if (stockInfo != null)
+                if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Any())
                 {
-                    isMatMixed = stockInfo.Details.GroupBy(x => new
+                    if (outStockLockInfos.FirstOrDefault() != null)
                     {
-                        x.MaterielCode,
-                        x.MaterielName,
-                        x.BatchNo,
-                        x.SupplyCode,
-                        x.WarehouseCode
-                    }).Count() > 1;
+                        bool includeBatchNo = !string.IsNullOrEmpty(outStockLockInfos.FirstOrDefault().BatchNo);
+                        bool includeSupplyCode = !string.IsNullOrEmpty(outStockLockInfos.FirstOrDefault().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;
+                        }
+                    }
+                    else
+                    {
+                        isMatMixed = stockInfo.Details.GroupBy(x => new
+                        {
+                            x.MaterielCode,
+                            x.MaterielName,
+                            x.WarehouseCode
+                        }).Count() > 1;
+                    }
                 }
 
+                
 
-                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo);
                 return WebResponseContent.Instance.OK(data: new { outStockLockInfos, stockInfo, isMatMixed });
             }
             catch (Exception ex)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 4d53ab6..53bfd2c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -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)
@@ -919,6 +903,67 @@
                     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);
+                }
+
                 // 鎵惧嚭宸插垎閰嶇殑璁㈠崟鏄庣粏Id
                 List<int> detailIds = new List<int>();
                 string[] ids = lockInfo.OrderDetailIds.Split(",");
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 474ff58..901532d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -88,33 +88,6 @@
 
                     _unitOfWorkManage.CommitTran();
 
-                    //TaskModel esstask = new TaskModel()
-                    //{
-                    //    taskType = "carry",
-                    //    taskGroupCode = "",
-                    //    groupPriority = 0,
-                    //    tasks = new List<TasksType>
-                    //    {
-                    //            new()
-                    //            {
-                    //                taskCode=task.TaskNum.ToString(),
-                    //                taskPriority=0,
-                    //                taskDescribe=new TaskDescribeType
-                    //                {
-                    //                    containerCode=stockInfo.PalletCode,
-                    //                    containerType= "CT_KUBOT_STANDARD",
-                    //                    fromLocationCode=stockInfo.LocationCode??"",
-                    //                    toStationCode="",
-                    //                    toLocationCode="1-2",
-                    //                    deadline=0,
-                    //                    storageTag=""
-                    //                }
-                    //            }
-                    //    }
-                    //};
-                    //var result = await _eSSApiService.CreateTaskAsync(esstask);
-
-                    //_logger.LogInformation("鍒涘缓浠诲姟PalletOutboundTask 杩斿洖:  " + result);
                 }
                 return content.OK("绌烘墭鍑哄簱鎴愬姛!");
             }

--
Gitblit v1.9.3