From d13e6e7d5df05ba244971d2fabb788ccb0f5c12a Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期二, 27 一月 2026 15:12:10 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/JiAnLiKu

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs |  319 ++++++++++++++++++++++-------------------------------
 1 files changed, 133 insertions(+), 186 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
index e6ddda7..93ba00b 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -47,7 +47,7 @@
                 if (stockInfo != null)
                 {
                     Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
-                    if (locationInfo==null)
+                    if (locationInfo == null)
                     {
                         throw new Exception("鏈壘鍒板嚭搴撳簱浣�");
                     }
@@ -116,7 +116,7 @@
                             }
                             tasks.Add(task);
                         }
-                        
+
                     }
                 }
 
@@ -152,7 +152,16 @@
             List<Dt_LocationInfo>? locationInfos = null;
             //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
             {
-                (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+                Dt_OutboundOrder dt_OutboundOrder = _outboundService.OutboundOrderService.Repository.QueryData(x => x.Id == outboundOrderDetails.First().OrderId).First();
+                (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = new();
+                if (dt_OutboundOrder.OutWareHouse.Contains("DW") || dt_OutboundOrder.OutWareHouse.Contains("YS"))
+                {
+                   result = _outboundService.OutboundOrderDetailService.DWANDYSAssignStockOutbound(outboundOrderDetails);
+                }
+                else
+                {
+                   result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+                }
                 if (result.Item1 != null && result.Item1.Count > 0)
                 {
                     Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
@@ -163,15 +172,29 @@
                         (int)OrderTypeEnum.鍙嶆嫞鍑哄簱鍗� => TaskTypeEnum.ReverseOut,
                         _ => new TaskTypeEnum()
                     };
-                    tasks = GetTasks(result.Item1,typeEnum);
+                    tasks = GetTasks(result.Item1, typeEnum);
                     tasks.ForEach(x =>
                     {
                         x.OrderNo = outboundOrder.OrderNo;
                     });
-                    result.Item2.ForEach(x =>
+                    if (dt_OutboundOrder.OutWareHouse.Contains("DW") || dt_OutboundOrder.OutWareHouse.Contains("YS"))
                     {
-                        x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
-                    });
+                        result.Item2.ForEach(x =>
+                        {
+                            if (x.LockQuantity == x.OrderQuantity)
+                            {
+                                x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                            }
+                        });
+                    }
+                    else
+                    {
+                        result.Item2.ForEach(x =>
+                        {
+                            x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                        });
+                    }
+
                     result.Item3.ForEach(x =>
                     {
 
@@ -288,181 +311,90 @@
                 }
                 if (warehouse.WarehouseCode.Contains("CP"))
                 {
-                    Dt_NewOutboundOrder newOutboundOrder = BaseDal.Db.Queryable<Dt_NewOutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO.No).Includes(x => x.Details).First();
+
                     Dt_Production production1 = new Dt_Production();
-                    if (newOutboundOrder != null)
+                    OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
+                    orderAddDTO1.OrderNo = orderAddDTO.No;
+                    orderAddDTO1.UpperOrderNo = orderAddDTO.No;
+                    orderAddDTO1.OutWareHouse = orderAddDTO.OutWareHouse;
+                    orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode ?? "宸ュ崟鍙戞枡";
+                    orderAddDTO1.InoutType = orderAddDTO.OrderType ?? InoutTypeEnum.WorkFeed.ToString();
+                    orderAddDTO1.OrderType = orderAddDTO.InoutType;
+                    orderAddDTO1.System = orderAddDTO.System;
+                    IEnumerable<int> inOrderTypes = Enum.GetValues<OrderTypeEmun>().Cast<int>();
+                    orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
+                    #region 楠岃瘉鏁版嵁
+                    (bool, string, object?) result = CheckOutboundOrderAddData(orderAddDTO1);
+                    if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+                    #endregion
+                    Dt_NewOutboundOrder inboundOrder = _mapper.Map<Dt_NewOutboundOrder>(orderAddDTO1);
+                    inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
+                    inboundOrder.Creater = "WMS";
+                    inboundOrder.CreateDate = DateTime.Now;
+                    inboundOrder.CreateType = CreateType.UpperSystemPush.ObjToInt();
+                    _unitOfWorkManage.BeginTran();
+                    bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+
+                    foreach (var item in orderAddDTO1.Details)
                     {
-                        if (newOutboundOrder.OutWareHouse != warehouse.WarehouseCode)
+                        if (string.IsNullOrWhiteSpace(item.Remark))
                         {
-                            return WebResponseContent.Instance.Error($"浠撳簱涓嶄竴鑷�");
+                            continue;
                         }
-                        else
+                        string[] remarkEntries = item.Remark.Split(
+                            new[] { ';' },
+                            StringSplitOptions.RemoveEmptyEntries
+                        );
+
+                        foreach (var entry in remarkEntries)
                         {
-                            OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
-                            orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
-                            var details = orderAddDTO1.Details.FirstOrDefault();
-                            Dt_NewOutboundOrderDetail outboundOrderDetail = new Dt_NewOutboundOrderDetail()
-                            {
-                                LPNNo = details.LPNNo,
-                                BatchNo = details.BatchNo,
-                                MaterielCode = details.MaterielCode,
-                                MaterielName = details.MaterielName,
-                                MaterieSpec = details.MaterieSpec,
-                                OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
-                                OrderQuantity = details.OrderQuantity,
-                                LinId = details.LinId,
-                                OrderId = newOutboundOrder.Id,
-                                Creater = "WMS",
-                                CreateDate = DateTime.Now,
-                                Remark = details.Remark,
-                                SupplierBatch = details.SupplierBatch,
-                                OrinalLocation=details.OrinalLocation,
-                            };
-                            _newOutboundOrderDetailRepository.AddData(outboundOrderDetail);
-                            foreach (var item in orderAddDTO1.Details)
-                            {
-                                if (string.IsNullOrWhiteSpace(item.Remark))
-                                {
-                                    continue;
-                                }
-                                string[] remarkEntries = item.Remark.Split(
-                                    new[] { ';' },
-                                    StringSplitOptions.RemoveEmptyEntries
-                                );
-
-                                foreach (var entry in remarkEntries)
-                                {
-                                    string[] keyValuePairs = entry.Split(
-                                        new[] { ',' },
-                                        StringSplitOptions.RemoveEmptyEntries
-                                    );
-
-                                    foreach (var kvp in keyValuePairs)
-                                    {
-                                        int colonIndex = kvp.IndexOf(':');
-                                        if (colonIndex <= 0 || colonIndex >= kvp.Length - 1)
-                                        {
-                                            continue;
-                                        }
-
-                                        string key = kvp.Substring(0, colonIndex).Trim();
-                                        string value = kvp.Substring(colonIndex + 1).Trim();
-
-                                        switch (key)
-                                        {
-                                            case "鍒堕�犲崟鍙�":
-                                                production1.ProductionNo = value;
-                                                break;
-                                            case "鍒堕�犻儴浠�":
-                                                production1.ManufacturingCo = value;
-                                                break;
-                                            case "鍑哄簱鏁伴噺":
-                                                if (decimal.TryParse(value, out decimal outQuantity))
-                                                {
-                                                    production1.OutQuantity = outQuantity;
-                                                }
-                                                else
-                                                {
-                                                    Console.WriteLine($"鍑哄簱鏁伴噺鏍煎紡閿欒锛歿value}锛堝簲涓烘暟鍊硷紝濡�14.0000锛�");
-                                                }
-                                                break;
-                                            default:
-                                                Console.WriteLine($"鏈煡閿悕锛歿key}锛堝搴斿�硷細{value}锛岃烦杩囪閿�煎锛�");
-                                                break;
-                                        }
-
-                                    }
-                                    production1.Creater = "WMS";
-                                    production1.OrderId = outboundOrderDetail.Id;
-                                    _productionRepository.AddData(production1);
-                                }
-                            }
-                        }
-                    }
-                    else
-                    {
-                        OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
-                        orderAddDTO1.OrderNo = orderAddDTO.No;
-                        orderAddDTO1.UpperOrderNo = orderAddDTO.No;
-                        orderAddDTO1.OutWareHouse = orderAddDTO.OutWareHouse;
-                        orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode ?? "宸ュ崟鍙戞枡";
-                        orderAddDTO1.InoutType = orderAddDTO.OrderType ?? InoutTypeEnum.WorkFeed.ToString();
-                        orderAddDTO1.OrderType = orderAddDTO.InoutType;
-                        orderAddDTO1.System = orderAddDTO.System;
-                        IEnumerable<int> inOrderTypes = Enum.GetValues<OrderTypeEmun>().Cast<int>();
-                        orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
-                        #region 楠岃瘉鏁版嵁
-                        (bool, string, object?) result = CheckOutboundOrderAddData(orderAddDTO1);
-                        if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
-                        #endregion
-                        Dt_NewOutboundOrder inboundOrder = _mapper.Map<Dt_NewOutboundOrder>(orderAddDTO1);
-                        inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
-                        inboundOrder.Creater = "WMS";
-                        inboundOrder.CreateDate = DateTime.Now;
-                        inboundOrder.CreateType = CreateType.UpperSystemPush.ObjToInt();
-                        _unitOfWorkManage.BeginTran();
-                        bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
-
-                        foreach (var item in orderAddDTO1.Details)
-                        {
-                            if (string.IsNullOrWhiteSpace(item.Remark))
-                            {
-                                continue;
-                            }
-                            string[] remarkEntries = item.Remark.Split(
-                                new[] { ';' },
+                            string[] keyValuePairs = entry.Split(
+                                new[] { ',' },
                                 StringSplitOptions.RemoveEmptyEntries
                             );
 
-                            foreach (var entry in remarkEntries)
+                            foreach (var kvp in keyValuePairs)
                             {
-                                string[] keyValuePairs = entry.Split(
-                                    new[] { ',' },
-                                    StringSplitOptions.RemoveEmptyEntries
-                                );
-
-                                foreach (var kvp in keyValuePairs)
+                                int colonIndex = kvp.IndexOf(':');
+                                if (colonIndex <= 0 || colonIndex >= kvp.Length - 1)
                                 {
-                                    int colonIndex = kvp.IndexOf(':');
-                                    if (colonIndex <= 0 || colonIndex >= kvp.Length - 1)
-                                    {
-                                        continue;
-                                    }
-
-                                    string key = kvp.Substring(0, colonIndex).Trim();
-                                    string value = kvp.Substring(colonIndex + 1).Trim();
-
-                                    switch (key)
-                                    {
-                                        case "鍒堕�犲崟鍙�":
-                                            production1.ProductionNo = value;
-                                            break;
-                                        case "鍒堕�犻儴浠�":
-                                            production1.ManufacturingCo = value;
-                                            break;
-                                        case "鍑哄簱鏁伴噺":
-                                            if (decimal.TryParse(value, out decimal outQuantity))
-                                            {
-                                                production1.OutQuantity = outQuantity;
-                                            }
-                                            else
-                                            {
-                                                Console.WriteLine($"鍑哄簱鏁伴噺鏍煎紡閿欒锛歿value}锛堝簲涓烘暟鍊硷紝濡�14.0000锛�");
-                                            }
-                                            break;
-                                        default:
-                                            Console.WriteLine($"鏈煡閿悕锛歿key}锛堝搴斿�硷細{value}锛岃烦杩囪閿�煎锛�");
-                                            break;
-                                    }
-
+                                    continue;
                                 }
-                                production1.Creater = "WMS";
-                                production1.OrderId = inboundOrder.Details.FirstOrDefault().Id;
-                                _productionRepository.AddData(production1);
+
+                                string key = kvp.Substring(0, colonIndex).Trim();
+                                string value = kvp.Substring(colonIndex + 1).Trim();
+
+                                switch (key)
+                                {
+                                    case "鍒堕�犲崟鍙�":
+                                        production1.ProductionNo = value;
+                                        break;
+                                    case "鍒堕�犻儴浠�":
+                                        production1.ManufacturingCo = value;
+                                        break;
+                                    case "鍑哄簱鏁伴噺":
+                                        if (decimal.TryParse(value, out decimal outQuantity))
+                                        {
+                                            production1.OutQuantity = outQuantity;
+                                        }
+                                        else
+                                        {
+                                            Console.WriteLine($"鍑哄簱鏁伴噺鏍煎紡閿欒锛歿value}锛堝簲涓烘暟鍊硷紝濡�14.0000锛�");
+                                        }
+                                        break;
+                                    default:
+                                        Console.WriteLine($"鏈煡閿悕锛歿key}锛堝搴斿�硷細{value}锛岃烦杩囪閿�煎锛�");
+                                        break;
+                                }
+
                             }
+                            production1.Creater = "WMS";
+                            production1.OrderId = inboundOrder.Details.FirstOrDefault().Id;
+                            _productionRepository.AddData(production1);
                         }
-                        _unitOfWorkManage.CommitTran();
                     }
+                    _unitOfWorkManage.CommitTran();
+
                 }
                 else
                 {
@@ -676,23 +608,25 @@
                 inboundOrder.OrderType = OutOrderTypeEnum.OutInventory.ObjToInt();
                 inboundOrder.Creater = "WMS";
                 inboundOrder.CreateDate = DateTime.Now;
-
-                Dt_OutboundOrder oldOutboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderAddDTO1.OrderNo).Includes(x => x.Details).First();
-                Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == oldOutboundOrder.Id);
                 List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>();
-                StockSelectViewDTO stockSelectViewDTO = new()
+                foreach (var item in inboundOrder.Details)
                 {
-                    OrderNo = orderAddDTO1.OrderNo,
-                    MaterielCode = outboundOrderDetail.MaterielCode,
-                    MaterielName = outboundOrderDetail.MaterielName,
-                    UseableQuantity = outboundOrderDetail.OrderQuantity,
-                    BatchNo = outboundOrderDetail.BatchNo,
-                    LinId = outboundOrderDetail.LinId,
-                };
+
+                    StockSelectViewDTO stockSelectViewDTO = new()
+                    {
+                        OrderNo = orderAddDTO1.OrderNo,
+                        MaterielCode = item.MaterielCode,
+                        MaterielName = item.MaterielName,
+                        UseableQuantity = item.OrderQuantity,
+                        BatchNo = item.BatchNo,
+                        LinId = item.LinId,
+                    };
+                    stockSelectViews.Add(stockSelectViewDTO);
+                }
                 _unitOfWorkManage.BeginTran();
                 bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
-                stockSelectViews.Add(stockSelectViewDTO);
-                GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews);
+
+                GenerateOutboundTasks(inboundOrder.Id, stockSelectViews);
                 _unitOfWorkManage.CommitTran();
                 content = WebResponseContent.Instance.OK();
             }
@@ -825,7 +759,7 @@
                 }
                 _unitOfWorkManage.CommitTran();
                 //灏嗕换鍔℃帹閫佸埌WCS
-               
+
                 if (tasks.FirstOrDefault().Roadway.Contains("SC01_BC"))
                 {
                     PushTasksToWCS(tasks);
@@ -1006,7 +940,7 @@
                 foreach (int key in keys)
                 {
 
-                    (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
+                   (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
                     if (result.Item2 != null && result.Item2.Count > 0)
                     {
                         stockInfos.AddRange(result.Item2);
@@ -1017,17 +951,30 @@
                     }
                     if (result.Item4 != null && result.Item4.Count > 0)
                     {
-                        outStockLockInfos.AddRange(result.Item4);
+                        outStockLockInfos.AddRange(result.Item4); 
                     }
                     if (result.Item5 != null && result.Item5.Count > 0)
                     {
-                        locationInfos.AddRange(result.Item5);
+                        if(result.Item5.Any(x => x.RoadwayNo.Contains("DW")) || result.Item5.Any(x => x.RoadwayNo.Contains("YS")))
+                        {
+                            locationInfos.AddRange(result.Item5.DistinctBy(x => x.LocationCode));
+
+                        }
+                        else
+                        {
+                            locationInfos.AddRange(result.Item5);
+
+                        }
+
                     }
                     if (result.Item1 != null && result.Item1.Count > 0)
                     {
                         tasks.AddRange(result.Item1);
                     }
-
+                    if(locationInfos.First().RoadwayNo.Contains("DW") || locationInfos.First().RoadwayNo.Contains("YS"))
+                    {
+                        break;
+                    }
 
                 }
 

--
Gitblit v1.9.3