From de77a7796e13eb921309cb54fababc87ccca26a4 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Sat, 2 Nov 2024 17:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8F=B0=E5=8F=B0=E8=B4=A6=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=90=E4=BB=BB=E5=8A=A1=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskPlat/Method/TaskManageService.cs | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs index e1373729..6399e0b9 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -2140,8 +2140,6 @@ namespace DS.WMS.Core.TaskPlat.Method var userId = long.Parse(user.UserId); DataResult> result = new(); - List taskIdList = []; // 查询结果中的任务主键列表 - List<(long taskId, int count)?> childTaskData = []; // 查询结果中任务的子任务列表 try { @@ -2780,7 +2778,7 @@ namespace DS.WMS.Core.TaskPlat.Method .LeftJoin((t, a, s) => t.OUT_BS_NO == s.Id); await SetCondition(queryable, whereList, taskType, taskStatLevel, querySearch.OtherQueryCondition, user); - + ISugarQueryable queryableTemp = queryable.Select((t, a, s) => new { PK_ID = t.Id.SelectAll(), @@ -2814,24 +2812,6 @@ namespace DS.WMS.Core.TaskPlat.Method #endif result = await queryableTemp.ToQueryPageAsync(querySearch.PageCondition); - if (result.Data?.Count > 0) - { - taskIdList = result.Data.Select(x => (long)x.Id).ToList(); - - // 查询子任务 - var childTaskTotalQueryable = tenantDb.Queryable().Where(x => taskIdList.Contains(x.ParentTaskId) && x.IsChild == true) - .GroupBy(x => new { x.ParentTaskId }) - .Select(x => new - { - ParentTaskId = x.ParentTaskId, - Count = SqlFunc.AggregateCount(x.ParentTaskId) - }); -#if DEBUG - var sql1 = childTaskTotalQueryable.ToSqlString(); -#endif - var childTaskTotal = await childTaskTotalQueryable.ToListAsync(); - childTaskData = childTaskTotal.Select(x => new ValueTuple?((x.ParentTaskId, x.Count))).ToList(); - } return result; } @@ -2841,6 +2821,8 @@ namespace DS.WMS.Core.TaskPlat.Method { if (result.Data?.Count > 0) { + List taskIdList = result.Data.Select(x => (long)x.Id).ToList(); // 查询结果中的任务主键列表 + // 查询任务接收人列表 var allRecvUserList = await tenantDb.Queryable() .Where(x => taskIdList.Contains(x.TaskId)) @@ -2854,6 +2836,19 @@ namespace DS.WMS.Core.TaskPlat.Method RecvUserStatusTime = x.StatusTime }).ToListAsync(); + // 查询子任务 + var childTaskTotalQueryable = tenantDb.Queryable().Where(x => taskIdList.Contains(x.ParentTaskId) && x.IsChild == true) + .GroupBy(x => new { x.ParentTaskId }) + .Select(x => new + { + ParentTaskId = x.ParentTaskId, + Count = SqlFunc.AggregateCount(x.ParentTaskId) + }); +#if DEBUG + var sql1 = childTaskTotalQueryable.ToSqlString(); +#endif + var childTaskTotal = await childTaskTotalQueryable.ToListAsync(); + // 一些特殊处理 foreach (var item in result.Data) { @@ -2915,7 +2910,7 @@ namespace DS.WMS.Core.TaskPlat.Method } // 4.赋值子任务数量 - item.ChildTaskCount = childTaskData.FirstOrDefault(x => x.Value.taskId == taskId)?.count ?? 0; + item.ChildTaskCount = childTaskTotal.FirstOrDefault(x => x.ParentTaskId == taskId)?.Count ?? 0; } } }