From 0e42f871905f207658d822fcbe29aeb57b2156af Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周三, 21 5月 2025 16:18:01 +0800
Subject: [PATCH] 修复查询bug

---
 PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs |  163 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 160 insertions(+), 3 deletions(-)

diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs
index d3853a7..9e1ae40 100644
--- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs
+++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs
@@ -24,6 +24,7 @@
 using NPOI.SS.Formula.Functions;
 using CMS.Plugin.PipeLineLems.Application.Implements;
 using CmsQueryExtensions.Entitys;
+using CMS.Plugin.PipeLineLems.Domain.WorkTask;
 
 namespace CMS.Plugin.PipeLineLems.ProjectService
 {
@@ -35,7 +36,6 @@
         private IServiceProvider _serviceProvider;
         private readonly ILogger<PipeLineLemsProjectService> _logger;
         private readonly IVariableDataCache _variableDataCache;
-
 
         /// <summary>
         /// 鍙橀噺鏈嶅姟
@@ -94,6 +94,8 @@
                 { "鍒囧壊杩涚珯淇″彿", "鍒囧壊杩涚珯淇″彿(鎻忚堪)" },
 
                 { "瑁呴厤瀹屽伐淇″彿", "瑁呴厤瀹屽伐淇″彿(鎻忚堪)" },
+                { "鐒婃帴瀹屽伐淇″彿", "鐒婃帴瀹屽伐淇″彿(鎻忚堪)" },
+                { "娉曞叞鍐茬爜瀹屽伐淇″彿", "娉曞叞鍐茬爜瀹屽伐淇″彿(鎻忚堪)" },
             };
 
             // 鍒涘缓閫氶亾鐩戝惉
@@ -279,6 +281,42 @@
                         });
                     }
                 }
+
+                if (changed.Name == "鐒婃帴瀹屽伐淇″彿")
+                {
+                    if (changed.New?.Value.SafeString().ToBool() == true)
+                    {
+                        _ = Task.Run(async () =>
+                        {
+                            await HanlderFor鐒婃帴瀹屽伐淇″彿Async();
+                        });
+                    }
+                    else
+                    {
+                        _ = Task.Run(async () =>
+                        {
+                            await HanlderFor瀹屽伐淇″彿WhenFalseAsync("鐒婃帴");
+                        });
+                    }
+                }
+
+                if (changed.Name == "娉曞叞鍐茬爜瀹屽伐淇″彿")
+                {
+                    if (changed.New?.Value.SafeString().ToBool() == true)
+                    {
+                        _ = Task.Run(async () =>
+                        {
+                            await HanlderFor娉曞叞鍐茬爜瀹屽伐淇″彿Async();
+                        });
+                    }
+                    else
+                    {
+                        _ = Task.Run(async () =>
+                        {
+                            await HanlderFor瀹屽伐淇″彿WhenFalseAsync("娉曞叞鍐茬爜");
+                        });
+                    }
+                }
             }
         }
 
@@ -446,7 +484,9 @@
         {
 
             var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>();
+            var workTaskAppService = _serviceProvider.GetRequiredService<IWorkTaskAppService>();
             var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>();
+            var workTaskRepository = _serviceProvider.GetRequiredService<IWorkTaskRepository>();
             var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>();
 
             using var scope = _serviceProvider.CreateScope();
@@ -473,6 +513,10 @@
                     if (callMaterialOrder == null) return;//缁撴潫
 
 
+                    //鏍规嵁鍘熸枡鏍囪瘑瀵绘壘 浣滀笟璁″垝
+                    var workTaskList = await workTaskAppService.GetListByFilterAsync(x => x.DataIdentifier == callMaterialOrder.DataIdentifier);
+                    if (workTaskList?.Count == 0) return;//缁撴潫
+                                                         //鏇存柊涓虹敓浜т腑 
 
                     //鏍规嵁鍘熸枡鏍囪瘑瀵绘壘 浣滀笟璁″垝
                     var workPlanList = await workPlanAppService.GetListByFilterAsync(x => x.DataIdentifier == callMaterialOrder.DataIdentifier);
@@ -488,6 +532,13 @@
                     };
                     var ret = _variableService.WriteValueAsync(keyValuePairs_productID);
 
+                    //鏇存柊 浠诲姟 涓虹敓浜т腑 
+                    var new_workTaskList = workTaskList.Where(x => x.ProcessRouteNumber == "鍒囧壊").ToList();
+                    foreach (var item in new_workTaskList)
+                    {
+                        item.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鐢熶骇涓�;
+                    }
+                    await workTaskRepository.UpdateManyAsync(new_workTaskList);
 
                     //鏇存柊涓虹敓浜т腑 
                     var new_workPlanList = workPlanList.Where(x => x.ProcessRouteNumber == "鍒囧壊").ToList();
@@ -718,7 +769,9 @@
         {
 
             var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>();
+            var workTaskAppService = _serviceProvider.GetRequiredService<IWorkTaskAppService>();
             var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>();
+            var workTaskRepository = _serviceProvider.GetRequiredService<IWorkTaskRepository>();
             var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>();
 
             using var scope = _serviceProvider.CreateScope();
@@ -744,7 +797,26 @@
                     callMaterialOrder = await callMaterialOrderAppService.GetSingleByFilterAsync(x => x.WmsTaskNo == myTaskNo);
                     if (callMaterialOrder == null) return;//缁撴潫
 
+                    //鏍规嵁鍘熸枡鏍囪瘑瀵绘壘 浣滀笟璁″垝
+                    var workTaskList = await workTaskAppService.GetListByFilterAsync(x => x.DataIdentifier == callMaterialOrder.DataIdentifier);
+                    if (workTaskList?.Count == 0) return;//缁撴潫
 
+                    var new_workTaskList = workTaskList.Where(x => x.ProcessName == "鍒囧壊宸ュ簭").ToList();
+                    //鏇存柊涓虹敓浜т腑 
+                    foreach (var item in new_workTaskList)
+                    {
+                        item.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鐢熶骇涓�;
+                        item.Remark = "鏇存柊鐢熶骇涓�";
+                    }
+                    await workTaskRepository.UpdateManyAsync(new_workTaskList);
+
+                    var new_workTaskList_printCode = workTaskList.Where(x => x.ProcessName == "鎵撶爜宸ュ簭").ToList();
+                    foreach (var item in new_workTaskList_printCode)
+                    {
+                        item.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.宸插畬鎴�;
+                        item.Remark = "鏇存柊宸插畬鎴�";
+                    }
+                    await workTaskRepository.UpdateManyAsync(new_workTaskList_printCode);
 
                     //鏍规嵁鍘熸枡鏍囪瘑瀵绘壘 浣滀笟璁″垝
                     var workPlanList = await workPlanAppService.GetListByFilterAsync(x => x.DataIdentifier == callMaterialOrder.DataIdentifier);
@@ -759,6 +831,8 @@
                         { "CMS鍙嶉璇锋眰鐢熸垚鍒囧壊浜у搧鐮佷俊鍙风粨鏋�", true},
                     };
                     var ret = _variableService.WriteValueAsync(keyValuePairs_productID);
+
+
 
                     var new_workPlanList = workPlanList.Where(x => x.ProcessRouteNumber == "瑁呴厤").ToList();
                     //鏇存柊涓虹敓浜т腑 
@@ -836,12 +910,95 @@
                     {
                         UserAccount = userName.Content.Value.SafeString().ToString()
                     };
-                    sharedService.CompleteAssemblyProcess(_serviceProvider, new Application.Contracts.Dtos.WorkPlan.CompleteAssemblyProcessInput() { PipeSpecCode = myPipeSpecCode, ProcessName="瑁呴厤宸ュ簭" }, myCurrentUser);
+                    await sharedService.CompleteAssemblyProcess(_serviceProvider, new Application.Contracts.Dtos.WorkPlan.CompleteAssemblyProcessInput() { PipeSpecCode = myPipeSpecCode, ProcessName = "瑁呴厤宸ュ簭" }, myCurrentUser);
 
                 }
-                catch (Exception)
+                catch (Exception ex)
                 {
+                    _logger.LogException(ex, LogLevel.Error);
+                }
+            }
+        }
 
+        /// <summary>
+        /// 鐒婃帴瀹屽伐淇″彿=true鏃�
+        /// </summary>
+        /// <returns></returns>
+        private async Task HanlderFor鐒婃帴瀹屽伐淇″彿Async()
+        {
+
+            var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>();
+            var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>();
+            var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>();
+
+            var pipeSpecCode = await _variableService.ReadValueAsync("鐒婃帴绠℃缂栫爜");
+
+            if (string.IsNullOrEmpty(pipeSpecCode?.Content?.Value.SafeString().ToString()))
+            {
+
+            }
+            else
+            {
+
+
+
+                var myPipeSpecCode = pipeSpecCode.Content.Value.SafeString().ToString();
+                CallMaterialOrder callMaterialOrder = null;
+                try
+                {
+                    var sharedService = _serviceProvider.GetRequiredService<SharedService>();
+                    var userName = await _variableService.ReadValueAsync("鐒婃帴浜�");
+                    MyCurrentUser myCurrentUser = new MyCurrentUser()
+                    {
+                        UserAccount = userName.Content.Value.SafeString().ToString()
+                    };
+                    await sharedService.CompleteAssemblyProcess(_serviceProvider, new Application.Contracts.Dtos.WorkPlan.CompleteAssemblyProcessInput() { PipeSpecCode = myPipeSpecCode, ProcessName = "鐒婃帴宸ュ簭" }, myCurrentUser);
+
+                }
+                catch (Exception ex)
+                {
+                    _logger.LogException(ex, LogLevel.Error);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 娉曞叞鍐茬爜瀹屽伐淇″彿=true鏃�
+        /// </summary>
+        /// <returns></returns>
+        private async Task HanlderFor娉曞叞鍐茬爜瀹屽伐淇″彿Async()
+        {
+
+            var txt = "娉曞叞鍐茬爜";
+            var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>();
+            var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>();
+            var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>();
+
+            var pipeSpecCode = await _variableService.ReadValueAsync($"{txt}绠℃缂栫爜");
+
+            if (string.IsNullOrEmpty(pipeSpecCode?.Content?.Value.SafeString().ToString()))
+            {
+
+            }
+            else
+            {
+                var myPipeSpecCode = pipeSpecCode.Content.Value.SafeString().ToString();
+                CallMaterialOrder callMaterialOrder = null;
+                try
+                {
+                    var sharedService = _serviceProvider.GetRequiredService<SharedService>();
+                    var userName = await _variableService.ReadValueAsync($"{txt}浜�");
+                    MyCurrentUser myCurrentUser = new MyCurrentUser()
+                    {
+                        UserAccount = userName.Content.Value.SafeString().ToString()
+                    };
+                    await sharedService.SendFlangeCode_CompleteAssemblyProcess(_serviceProvider, new Application.Contracts.Dtos.WorkPlan.CompleteAssemblyProcessInput()
+                    { PipeSpecCode = myPipeSpecCode, ProcessName = $"{txt}宸ュ簭" }, myCurrentUser);
+
+                }
+                catch (Exception ex)
+                {
+                    _logger.LogException(ex, LogLevel.Error);
                 }
             }
         }

--
Gitblit v1.9.3