From b513ce3a4527e998da66c6f179a279472c7262a8 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 18 十一月 2025 10:59:46 +0800
Subject: [PATCH] 代码更新优化

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs |  106 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 83 insertions(+), 23 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 8a462a4..d06a1c4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -137,13 +137,13 @@
                         task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                         _unitOfWorkManage.BeginTran();
                         proStockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
-                        _stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(proStockInfo,App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                        _stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(proStockInfo,App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         if (proStockInfo.proStockInfoDetails!=null && proStockInfo.proStockInfoDetails.Count>0)
                         {
-                            _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(proStockInfo.proStockInfoDetails, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                            _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(proStockInfo.proStockInfoDetails, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         }
                         _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, proStockInfo.PalletType, LocationStatusEnum.Free, proStockInfo.WarehouseId);
-                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         _unitOfWorkManage.CommitTran();
                     }
                     else
@@ -180,7 +180,7 @@
                         else
                         {
                             stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
-                            _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                            _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         }
                         if (outStockLockInfos!=null && outStockLockInfos.Count>0)
                         {
@@ -189,9 +189,10 @@
                                 x.Status=OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
                             });
                             _outboundRepository.OutStockLockInfoRepository.UpdateData(outStockLockInfos);
+                            _outboundService.OutLineViewService.SaveLineView(outStockLockInfos);
                         }
                         _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
-                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         _unitOfWorkManage.CommitTran();
                     }
                     else
@@ -257,7 +258,7 @@
         /// </summary>
         /// <param name="stockInfos"></param>
         /// <returns></returns>
-        public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos,List<Dt_OutStockLockInfo> outStockLockInfos, TaskTypeEnum taskType)
+        public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos,List<Dt_OutStockLockInfo> outStockLockInfos, TaskTypeEnum taskType=new TaskTypeEnum())
         {
             List<Dt_Task> tasks = new List<Dt_Task>();
             for (int i = 0; i < stockInfos.Count; i++)
@@ -620,10 +621,12 @@
             {
                 //鑾峰彇浠诲姟
                 tasks = GetTasks(result.Item1, TaskTypeEnum.OldYLOutbound);
-                
                 result.Item2.ForEach(x =>
                 {
-                    x.OutSGOrderDetailStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
+                    if (result.Item3.FirstOrDefault(t=>t.OrderDetailId==x.Id)!=null)
+                    {
+                        x.OutSGOrderDetailStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
+                    }
                 });
                 result.Item3.ForEach(x =>
                 {
@@ -656,7 +659,7 @@
                 {
                     tasks.ForEach(x =>
                     {
-                        string orderNos = string.Join(",", outStockLockInfos.Where(x => x.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct());
+                        string orderNos = string.Join(",", outStockLockInfos.Where(t => t.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct());
                         x.OrderNo = orderNos;
                     });
                 }
@@ -667,11 +670,7 @@
                     {
                         x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
                     });
-                    outboundOrderDetails.ForEach(x =>
-                    {
-                        x.OutSGOrderDetailStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
-                    });
-                    List<Dt_OutSGOrder> outSGOrders = _outboundRepository.OutSGOrderRepository.QueryData(x => outboundOrderDetails.Select(x=>x.OutSGOrderId).Distinct().Contains(x.Id));
+                    List<Dt_OutSGOrder> outSGOrders = _outboundRepository.OutSGOrderRepository.QueryData(x => outStockLockInfos.Select(x=>x.OrderNo).Distinct().Contains(x.OrderId));
                     if (outSGOrders.Count<=0)
                     {
                         throw new Exception("鏈壘鍒板崟鎹俊鎭�");
@@ -704,16 +703,79 @@
         /// </summary>
         /// <param name="bSTPickInfoDTO"></param>
         /// <returns></returns>
-        public WebResponseContent ReceivePicking(BSTPickInfoDTO bSTPickInfoDTO)
+        public WebResponseContent ReceivePicking(List<BSTPickInfoDTO> bSTPickInfoDTOs)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
+                //鏂板
+                List<BSTPickInfoDTO> bSTPickInfosAdd = bSTPickInfoDTOs.Where(x => x.Way == 1).ToList();
+                //鑾峰彇鏂板鏄庣粏棰嗘枡
+                List<PaperMattakeDetailItem>? paperMattakeDetailItemsAdd = null;
+                //淇敼
+                List<BSTPickInfoDTO> bSTPickInfosUp = bSTPickInfoDTOs.Where(x => x.Way == 2).ToList();
+                //鑾峰彇鏂板鏄庣粏棰嗘枡
+                List<PaperMattakeDetailItem>? paperMattakeDetailItemsUp = null;
+                if (bSTPickInfosAdd != null && bSTPickInfosAdd.Count > 0)
+                {
+                    paperMattakeDetailItemsAdd = bSTPickInfosAdd.SelectMany(x => x.PaperMattakeDetails).ToList();
+                }
+                if (bSTPickInfosUp != null && bSTPickInfosUp.Count > 0)
+                {
+                    paperMattakeDetailItemsUp = bSTPickInfosUp.SelectMany(x => x.PaperMattakeDetails).ToList();
+                }
                 //鑾峰彇鎵�鏈夊緟棰嗘枡鐨勫嚭搴撹鎯�
-                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x=>x.OrderType==OutOrderTypeEnum.OutSGPick.ObjToInt());
+                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.OrderType == OutOrderTypeEnum.OutSGPick.ObjToInt() && x.Status==OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
+                #region 棰嗘枡閫昏緫
+                if (paperMattakeDetailItemsAdd != null && paperMattakeDetailItemsAdd.Count > 0)
+                {
+                    foreach (var item in paperMattakeDetailItemsAdd)
+                    {
+                        //鑾峰彇瀵瑰簲鐨�
+                    }
+                }
+                
+                if (paperMattakeDetailItemsUp != null && paperMattakeDetailItemsUp.Count > 0)
+                {
+                    foreach (var item in paperMattakeDetailItemsUp)
+                    {
+                        
+                    }
+
+                }
+                #endregion
             }
             catch (Exception ex)
             {
+                _unitOfWorkManage.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// 鍒涘缓鐢熺鎵嬪姩鍑哄簱
+        /// </summary>
+        /// <param name="ids"></param>
+        /// <returns></returns>
+        public WebResponseContent CreateSGManualTasks(List<int> ids)
+        {
+            WebResponseContent content=new WebResponseContent();
+            try
+            {
+                //鑾峰彇鎵�鏈夋槑缁�
+                List<Dt_OutSGOrder> outSGOrders = BaseDal.Db.Queryable<Dt_OutSGOrder>().Where(x=>ids.Contains(x.Id)).Includes(x=>x.Details).ToList();
+                List<Dt_OutSGOrderDetail> outSGOrderDetails = outSGOrders.SelectMany(x=>x.Details.Where(t=>t.OutSGOrderDetailStatus==OutOrderStatusEnum.鏈紑濮�.ObjToInt())).ToList();
+                List<int> ints = outSGOrderDetails.Select(x => x.Id).ToList();
+                int[] reseponse = new int[ints.Count];
+                for (int i = 0; i < ints.Count; i++)
+                {
+                    reseponse[i] = ints[i];
+                }
+                content = CreateSGOutboundTasks(reseponse);
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
                 content.Error(ex.Message);
             }
             return content;
@@ -735,22 +797,21 @@
                 {
                     return content.Error("棰嗘枡璁″垝浼犲叆淇℃伅涓虹┖");
                 }
-                outMESOrderDTOs.Select(x => x.OutDetailId);
                 List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData();
                 OutMESOrderDTO? CheckGradeCode = outMESOrderDTOs.FirstOrDefault(x => !GradeCodes.Contains(x.GradeCode));
                 if (CheckGradeCode != null)
                 {
-                    return content.Error($"棰嗘枡璁″垝搴撳尯{nameof(OutMESOrderDTO.GradeCode)}:{CheckGradeCode.GradeCode}涓嶅瓨鍦�");
+                    return content.Error($"棰嗘枡璁″垝绛夌骇{nameof(OutMESOrderDTO.GradeCode)}:{CheckGradeCode.GradeCode}涓嶅瓨鍦�");
                 }
                 OutMESOrderDTO? CheckOutDetailId = outMESOrderDTOs.FirstOrDefault(x => x.OutDetailId <= 0);
                 if (CheckOutDetailId != null)
                 {
-                    return content.Error($"棰嗘枡璁″垝{nameof(OutMESOrderDTO.OutDetailId)}:{CheckOutDetailId.ProductOrderNo}闇�瑕佸ぇ浜�0");
+                    return content.Error($"棰嗘枡璁″垝ID:{CheckOutDetailId.OutDetailId}闇�澶т簬0");
                 }
                 OutMESOrderDTO? CheckReqQuantity = outMESOrderDTOs.FirstOrDefault(x => x.ReqQuantity <= 0);
                 if (CheckReqQuantity != null)
                 {
-                    return content.Error($"棰嗘枡璁″垝{nameof(OutMESOrderDTO.ReqQuantity)}:{CheckReqQuantity.ProductOrderNo}闇�瑕佸ぇ浜�0");
+                    return content.Error($"棰嗘枡璁″垝ID:{CheckReqQuantity.OutDetailId},{CheckReqQuantity.ProductOrderNo}鐗╂枡闇�姹傞渶瑕佸ぇ浜�0");
                 }
                 //鑾峰彇鎵�鏈夌墿鏂欎俊鎭�
                 List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt());
@@ -782,10 +843,9 @@
                     item.MakeArea = makeCenterInfo.MakeArea;
                     item.WarehouseId = materielInfo.WarehouseId;
                 }
-
                 
                 _unitOfWorkManage.BeginTran();
-
+                //鎿嶄綔鏁版嵁锛屽苟鍒嗛厤闇�姹傚簱瀛�
                 _outboundRepository.OutMESOrderRepository.AddData(AddoutMESOrders);
                 List<Dt_OutMESOrder> mESOrders = _outboundRepository.OutMESOrderRepository.QueryData(x => AddoutMESOrders.Select(x => x.OutDetailId).Contains(x.OutDetailId));
                 List<Dt_Task> tasks = new List<Dt_Task>();
@@ -799,7 +859,7 @@
                     if (result.Item1 != null && result.Item1.Count > 0)
                     {
                         //鍒涘缓浠诲姟
-                        tasks = GetTasks(result.Item1, result.Item3, TaskTypeEnum.PrintYLOutbound);
+                        tasks = GetTasks(result.Item1, result.Item3);
                         result.Item2.ForEach(x =>
                         {
                             OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();

--
Gitblit v1.9.3