From 0a146328e2442404b09b1d482c6f0ba95e8167af Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 23 May 2025 18:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=AE=A1=E5=88=92=E8=BE=BE?= =?UTF-8?q?=E6=88=90=E7=8E=87=E6=8A=A5=E8=A1=A8=E6=9F=A5=E8=AF=A2=5F?= =?UTF-8?q?=E5=AE=9D=E8=BF=9E=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_PlanServices.cs | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index 99a9ab8a..47616247 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -807,17 +807,63 @@ public class Ghre_PlanServices : BaseServices() + .Where(x => x.Year == dt.Value.Year && x.DeptId == deptId && x.Month.Contains($"\"{dt.Value.Month}\"")) + .CountAsync(); + + if (courseCount > 0) + { + var planIds = await Db.Queryable() + .Where(x => x.Year == dt.Value.Year && x.DeptId == deptId && x.Month.Contains($"\"{dt.Value.Month}\"")) + .Select(x => x.Id).ToListAsync(); + + for (int i = 0; i < planIds.Count; i++) + { + var submitCount1 = await Db.Queryable() + .Where(x => x.PlanId != null && x.PlanId.Contains(planIds[i].ObjToString())).CountAsync(); + submitCount = submitCount + submitCount1; + } + } data.Add(new CompletionRateBLT { - Month = formatted + Month = formatted, + SubmitCount = submitCount, + CourseCount = courseCount }); } } else { + int submitCount = 0; + var courseCount = 0; + for (DateTime? dt = startTime; dt <= endTime; dt = dt.Value.AddMonths(1)) + { + string formatted = dt.Value.ToString("yyyy-MM"); + var courseCount1 = await Db.Queryable() + .Where(x => x.Year == dt.Value.Year && x.DeptId == deptId && x.Month.Contains($"\"{dt.Value.Month}\"")) + .CountAsync(); + courseCount = courseCount + courseCount1; + + if (courseCount > 0) + { + var planIds = await Db.Queryable() + .Where(x => x.Year == dt.Value.Year && x.DeptId == deptId && x.Month.Contains($"\"{dt.Value.Month}\"")) + .Select(x => x.Id).ToListAsync(); + + for (int i = 0; i < planIds.Count; i++) + { + var submitCount1 = await Db.Queryable() + .Where(x => x.PlanId != null && x.PlanId.Contains(planIds[i].ObjToString())).CountAsync(); + submitCount = submitCount + submitCount1; + } + } + } data.Add(new CompletionRateBLT { - Month = $"{startTime.Value.ToString("yyyy-MM")}~{endTime.Value.ToString("yyyy-MM")}" + Month = $"{startTime.Value.ToString("yyyy-MM")}~{endTime.Value.ToString("yyyy-MM")}", + SubmitCount = submitCount, + CourseCount = courseCount }); } @@ -830,6 +876,10 @@ public class Ghre_PlanServices : BaseServices 0 && data[i].SubmitCount > 0) + data[i].CompletionRate = data[i].SubmitCount / data[i].CourseCount; + + data[i].CompletionRate1 = $"{data[i].CompletionRate}%"; //var examCount = await Db.Queryable() // .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) // .CountAsync();