From 851d7e66f2ef75d9efde7eb4f1516d21c05be688 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 28 Mar 2025 11:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=9B=E5=B0=BE=E5=9F=B9=E8=AE=AD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=8A=A5=E8=A1=A8=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Services/CommonServices.cs | 121 ++++++++++++++++++ .../Ghre/Ghre_PlanServices.cs | 76 ++++++++++- Tiobon.Core/Tiobon.Core.xml | 7 + 3 files changed, 201 insertions(+), 3 deletions(-) diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 0f1a93db..488a3b0a 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -2247,6 +2247,127 @@ public partial class CommonServices : BaseServices>, ICommon toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); if (toolbar != null) toolbar.fnKey = "TBD4YN"; + break; + case "F_UshioTrainPlanReport": + + config = await Db.Queryable().Where(x => x.ConfigCode == "ESS_Recruit_Year_Human_Start_Month").FirstAsync(); + startMonth = config != null ? config.ConfigValue.ObjToInt() : 1; + months = new List(); + numbers = new(); + for (int i = 1; i <= 12; i++) + { + if (i < 10) + months.Add("0" + i); + else + months.Add(i.ObjToString()); + numbers.Add(i); + } + curentYear = DateTime.Now.Year; + curentMonth = DateTime.Now.Month; + // 指定要打头的数字 + startNumber = startMonth; + + + if (curentMonth < startMonth) + curentYear--; + // 创建一个新的列表用于存储重新排序后的结果 + reorderedNumbers = new(); + + sort = result.JM_TableColumnT1.TableColumn.Where(x => x.field == "M1").SingleOrDefault()?.SortNo ?? 5; + name1 = "计划年月"; + result.JM_TableColumnT1.TableColumn?.ForEach(x => + { + + for (int i = 1; i < 13; i++) + { + if (x.label.Contains(i.ObjToString())) + { + if(x.label== $"实际合计人天{i}" || x.label == $"进展率{i}") + { + x.label = x.label.Replace($"实际合计人天{i}", "实际合计人天"); + x.label = x.label.Replace($"进展率{i}", "进展率"); + + } + x.GroupName = i + "月"; + } + } + if (x.field == "Year") + x.searchColumnDefaultValue = curentYear; + }); + + // 找到指定数字的索引 + index1 = numbers.IndexOf(startNumber); + if (index1 != -1) + { + // 从指定数字开始,按照循环顺序添加数字 + for (int i = 0; i < numbers.Count; i++) + { + int currentIndex = (index1 + i) % numbers.Count; + reorderedNumbers.Add(numbers[currentIndex]); + } + + foreach (var num in reorderedNumbers) + { + result.JM_TableColumnT1.TableColumn?.ForEach(x => + { + if (x.label.ObjToInt() == num) + { + x.SortNo = sort; + x.label = curentYear + "-" + x.label; + } + }); + if (num == 12) + curentYear++; + sort++; + } + } + result.JM_TableColumnT1.TableColumn = result.JM_TableColumnT1.TableColumn.OrderBy(x => x.SortNo).ToList(); + + if (param.menuName == "F_UshioTrainPlan_WaitConfirm" || param.menuName == "F_TrainPlan_WaitConfirm") + { + + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBDDoReject", + fnTitle = await QueryLangValue("F_Training_Demand_ToConfirm_Reject", param.langId, "拒绝"), + fnType = "table", + icon = "ess-icon-reject", + position = "left" + }); + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBDDoAgree", + fnTitle = await QueryLangValue("F_Training_Demand_ToConfirm_Agree", param.langId, "同意"), + fnType = "table", + icon = "ess-icon-approval", + position = "left" + }); + } + else if (param.menuName == "F_UshioTrainPlan_Temporary" || param.menuName == "F_TrainPlan_Temporary") + { + sql = $@"SELECT A.RoleId, B.RoleNo, B.RoleName + FROM Ghrs_UserRole A LEFT JOIN Ghrs_Role B ON A.RoleId = B.RoleId + WHERE A.UserID = {App.User.ID} + AND A.IsEnable = 1 + AND B.IsEnable = 1 + AND B.RoleNo = 'F_TrainPlanTransferToConfirmed'"; + toolbarRoles = DbAccess.QueryList(sql); + if (toolbarRoles != null && toolbarRoles.Any()) + { + index = result.JM_PageControlT1.Toolbar.FindIndex(x => x.fnKey == "NewYN"); + result.JM_PageControlT1.Toolbar.Insert(index + 1, new Toolbar() + { + display = true, + fnKey = "TBDToConfirm", + fnTitle = await QueryLangValue("F_ManReqMaintenTemporary_TransferToConfirmed", param.langId, "转入待确认"), + fnType = "table", + icon = "ghr-icon-user-wait", + position = "left" + }); + } + } break; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index 4ea1b1cb..10b94e83 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -257,20 +257,90 @@ public class Ghre_PlanServices : BaseServices new { q.Id, q.PlanId, q.ExamDate }) .Select(m => new { m.PlanId, ExamDate = m.ExamDate.Value, Count = SqlFunc.AggregateCount(m.Id) }) .ToListAsync(); - + studyRecordGroup1 = studyRecordGroup1.Where(x => x.ExamDate.Year == year).ToList(); var data = Mapper.Map(result.result.DT_TableDataT1).ToANew>(); data.ForEach(d => { - d.M1_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Year == year && x.ExamDate.Month == 1).Sum(x => x.Count); + d.M1_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 1).Sum(x => x.Count); if (d.M1_Count > 0 && d.TrainNum > 0) d.M1_CompletionRate = d.M1_Count / d.TrainNum; + d.M2_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 2).Sum(x => x.Count); + if (d.M2_Count > 0 && d.TrainNum > 0) + d.M2_CompletionRate = d.M2_Count / d.TrainNum; + + d.M3_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 3).Sum(x => x.Count); + if (d.M3_Count > 0 && d.TrainNum > 0) + d.M3_CompletionRate = d.M3_Count / d.TrainNum; + + d.M4_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 4).Sum(x => x.Count); + if (d.M4_Count > 0 && d.TrainNum > 0) + d.M4_CompletionRate = d.M4_Count / d.TrainNum; + + d.M5_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 5).Sum(x => x.Count); + if (d.M5_Count > 0 && d.TrainNum > 0) + d.M5_CompletionRate = d.M5_Count / d.TrainNum; + + d.M6_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 6).Sum(x => x.Count); + if (d.M6_Count > 0 && d.TrainNum > 0) + d.M6_CompletionRate = d.M6_Count / d.TrainNum; + + d.M7_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 7).Sum(x => x.Count); + if (d.M7_Count > 0 && d.TrainNum > 0) + d.M7_CompletionRate = d.M7_Count / d.TrainNum; + + d.M8_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 8).Sum(x => x.Count); + if (d.M8_Count > 0 && d.TrainNum > 0) + d.M8_CompletionRate = d.M8_Count / d.TrainNum; + + d.M9_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 9).Sum(x => x.Count); + if (d.M9_Count > 0 && d.TrainNum > 0) + d.M9_CompletionRate = d.M9_Count / d.TrainNum; + + d.M10_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 10).Sum(x => x.Count); + if (d.M10_Count > 0 && d.TrainNum > 0) + d.M10_CompletionRate = d.M10_Count / d.TrainNum; + + d.M11_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 11).Sum(x => x.Count); + if (d.M11_Count > 0 && d.TrainNum > 0) + d.M11_CompletionRate = d.M11_Count / d.TrainNum; + + d.M12_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Month == 12).Sum(x => x.Count); + if (d.M12_Count > 0 && d.TrainNum > 0) + d.M12_CompletionRate = d.M12_Count / d.TrainNum; + }); - return new ServicePageResult(filter.pageNum, result.result.DT_TablePageInfoT1.TotalCount, filter.pageSize, data); + ModuleParam param = new ModuleParam() + { + langId = filter.langId, + menuName = filter.menuName + }; + var module = await _commonServices.GetModuleInfoAsync(param); + var result1 = new ServicePageResult(filter.pageNum, result.result.DT_TablePageInfoT1.TotalCount, filter.pageSize, data); + result1.result.JM_TableColumnT1 = module.Data.JM_TableColumnT1; + + var yearField = module.Data.JM_TableColumnT1.TableColumn.Where(x => x.field == "Year").SingleOrDefault(); + if (year != yearField?.searchColumnDefaultValue.ObjToInt()) + { + + result1.result.JM_TableColumnT1.TableColumn?.ForEach(x => + { + if (x.GroupName == "计划年月") + { + + int month = x.field.Replace("M", null).Replace("_F", null).ObjToInt(); + x.label = year + "-" + (month < 10 ? "0" + month : month); + if (month == 12) + year++; + } + }); + } + + return result1; } diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 0f44f739..ad991fe6 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1202,6 +1202,13 @@ status + + + 根据条件查询数据 + + 条件 + + 题目答案(Controller)