From bc9bcb7bc34669d907431d83d3d07aff6ffcbe6d Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 11 Sep 2024 10:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/Ghre/Ghre_Request.Dto.View.cs | 18 +++++ Tiobon.Core.Services/BASE/BaseServices.cs | 4 +- .../Ghre/Ghre_RequestServices.cs | 71 +++++++++++++++++-- 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs index c0317ceb..dacde2eb 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs @@ -32,4 +32,22 @@ public class Ghre_RequestDto : Ghre_Request /// public string UpdateDataInfo { get; set; } public List TrainStaffIds { get; set; } + + + public string CourseSourceLabel { get; set; } + + public string RequestSourceLabel { get; set; } + + public string DeptName { get; set; } + public string TrainClassLabel { get; set; } + public string TrainLevelLabel { get; set; } + + public string InOrOutLabel { get; set; } + + public string TeacherClassLabel { get; set; } + + public string SponsorName { get; set; } + public string TrainStaffNames { get; set; } + } + diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 6fe79413..f5858c6f 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -1237,13 +1237,11 @@ public class BaseServices : IBaseServ /// 栏位名 /// 前缀 /// - public async Task GenerateContinuousSequence(string tableCode, string columnCode, string prefixTemp) + public async Task GenerateContinuousSequence(string tableCode, string columnCode, string prefixTemp, int length = 7, int tempLength = 6) { try { string result = string.Empty; - int length = 7; - int tempLength = 6; int sequence; #region 查询 diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs index 8b3b5efe..01ce69f5 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs @@ -5,11 +5,12 @@ using Tiobon.Core.Services.BASE; using Tiobon.Core.IRepository.Base; using Tiobon.Core.Common.Caches; using Microsoft.AspNetCore.Http; -using static Tiobon.Core.Model.Consts; using Tiobon.Core.Common.UserManager; using Tiobon.Core.Model; using Tiobon.Core.Common.Helper; using Tiobon.Core.Common; +using Newtonsoft.Json.Linq; +using System.Collections.Generic; namespace Tiobon.Core.Services; @@ -26,23 +27,79 @@ public class Ghre_RequestServices : BaseServices> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) + { + + var result = await base.QueryFilterPage(filter, condition, IsEnable); + var courseIds = result.result.DT_TableDataT1.Where(x => x.CourseId != null).Select(x => x.CourseId).Distinct().ToList(); + var courses = await Db.Queryable().Where(x => courseIds.Contains(x.Id)).ToListAsync(); + var deptIds = result.result.DT_TableDataT1.Where(x => x.DeptId != null).Select(x => x.DeptId).Distinct().ToList(); + var depts = await Db.Queryable().Where(x => deptIds.Contains(x.DeptID)).ToListAsync(); + + var sponsorIds = result.result.DT_TableDataT1.Where(x => x.SponsorId != null).Select(x => x.SponsorId).Distinct().ToList(); + + + + result.result.DT_TableDataT1.ForEach(x => + { + string trainStaffId = x.TrainStaffId; + if (!string.IsNullOrWhiteSpace(trainStaffId)) + { + x.TrainStaffIds = JsonHelper.JsonToObj>(trainStaffId); + var TrainStaffIds = JsonHelper.JsonToObj>(trainStaffId); + sponsorIds.AddRange(TrainStaffIds); + } + + + }); + sponsorIds = sponsorIds.Distinct().ToList(); + var staffs = await Db.Queryable().Where(x => sponsorIds.Contains(x.StaffID)).ToListAsync(); + result.result.DT_TableDataT1.ForEach(async x => + { + x.CourseSourceLabel = await GetParaLabel("TrainingRequestCourseSource", x.CourseSource); + x.RequestSourceLabel = await GetParaLabel("TrainingRequestRequestSource", x.RequestSource); + x.TrainClassLabel = await GetParaLabel("TrainingRequestTrainClass", x.TrainClass); + x.TrainLevelLabel = await GetParaLabel("TrainingRequestTrainLevel", x.TrainLevel); + x.InOrOutLabel = await GetParaLabel("CourseInOrOut", x.InOrOut); + x.TeacherClassLabel = await GetParaLabel("TrainingTeacherType", x.InOrOut); + + if (x.CourseId != null) + x.CourseName = courses.Where(o => x.CourseId == o.Id).FirstOrDefault()?.CourseName; + + if (x.DeptId != null) + x.DeptName = depts.Where(o => x.DeptId == o.DeptID).FirstOrDefault()?.DeptName; + + if (x.SponsorId != null) + x.SponsorName = staffs.Where(o => x.SponsorId == o.StaffID).FirstOrDefault()?.StaffName; + if (x.TrainStaffIds.IsNotEmptyOrNull()) + x.TrainStaffNames = string.Join("、", staffs.Where(o => x.TrainStaffIds.Contains(o.StaffID)).Select(o => o.StaffName)); + }); + return result; + + } + public override async Task Add(InsertGhre_RequestInput entity) { entity.SponsorId = GetStaffId(); - entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); + if (entity.TrainStaffIds.IsNotEmptyOrNull()) + entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); + entity.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R"); return await base.Add(entity); } public override async Task Update(long Id, EditGhre_RequestInput entity) { - entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); + if (entity.TrainStaffIds.IsNotEmptyOrNull()) + entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); + else entity.TrainStaffId = null; return await base.Update(Id, entity, null, ["Status"]); } public async Task> InsertByStatus(InsertGhre_RequestInput insertModel, string status) { var data = ServiceResult.OprateSuccess("新增成功", 0); insertModel.Status = status; - var id = await base.Add(insertModel); + var id = await Add(insertModel); data.Success = id > 0; if (data.Success) @@ -56,9 +113,9 @@ public class Ghre_RequestServices : BaseServices> QueryForm(QueryForm body) { var result = await base.QueryForm(body); - string examPaperId = result.result.DT_TableDataT1[0].TrainStaffId; - if (!string.IsNullOrWhiteSpace(examPaperId)) - result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj>(examPaperId); + string trainStaffId = result.result.DT_TableDataT1[0].TrainStaffId; + if (!string.IsNullOrWhiteSpace(trainStaffId)) + result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj>(trainStaffId); return result; }