From 647e772011336829e2867f22c3d60f80e4e0393f Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 5 Mar 2025 10:07:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=89=9B=E5=B0=BE=E3=80=91=E5=9F=B9?= =?UTF-8?q?=E8=AE=AD=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_UshioPlanController.cs | 36 ++++++ Tiobon.Core.Api/Tiobon.Core.xml | 8 ++ .../Ghre/IGhre_UshioPlanServices.cs | 7 +- .../Base/Ghre/Ghre_UshioPlan.Dto.Base.cs | 2 + .../Ghre/Ghre_UshioPlan.Dto.InsertInput.cs | 2 + .../View/Ghre/Ghre_UshioPlan.Dto.View.cs | 6 + .../Ghre/Ghre_UshioPlanServices.cs | 115 +++++++++++++++++- 7 files changed, 174 insertions(+), 2 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_UshioPlanController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_UshioPlanController.cs index 01bc59a7..5f671333 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_UshioPlanController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_UshioPlanController.cs @@ -11,4 +11,40 @@ public class Ghre_UshioPlanController : BaseController + /// 根据条件查询数据 + /// + /// 条件 + /// status + /// + [HttpPost, Route("QueryList/{status}")] + public async Task> QueryByStatus([FromBody] QueryBody body, string status) + { + if (status == "Active") + return await _service.QueryFilterPage(body, $"(Status ='Active' OR Status ='Wait')"); + else if (status == "Disable") + return await _service.QueryFilterPage(body, null, false); + else + return await _service.QueryFilterPage(body, $"Status ='{status}'"); + } + #endregion + + #region 状态修改 + [HttpPost("UpdateStatus/{status}")] + public async Task UpdateStatus(string status, [FromBody] InsertGhre_UshioPlanInput input) + { + return await _service.UpdateStatus(input, status); + } + #endregion + + #region 新增 + [HttpPost("Insert/{status}")] + public async Task> InsertByStatus([FromBody] InsertGhre_UshioPlanInput insertModel, string status) + { + return await _service.InsertByStatus(insertModel, status); + } + #endregion + } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index cdd002d5..8270da1f 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1401,6 +1401,14 @@ 【牛尾】培训计划(Controller) + + + 根据条件查询数据 + + 条件 + status + + 面试评估设定(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_UshioPlanServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_UshioPlanServices.cs index b5b7613a..697671f5 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_UshioPlanServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_UshioPlanServices.cs @@ -1,8 +1,13 @@ -namespace Tiobon.Core.IServices; +using Tiobon.Core.Model; + +namespace Tiobon.Core.IServices; /// /// 【牛尾】培训计划(自定义服务接口) /// public interface IGhre_UshioPlanServices : IBaseServices { + Task> InsertByStatus(InsertGhre_UshioPlanInput insertModel, string status); + + Task UpdateStatus(InsertGhre_UshioPlanInput input, string status); } \ No newline at end of file diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_UshioPlan.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_UshioPlan.Dto.Base.cs index 4dba9e69..4805d85f 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_UshioPlan.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_UshioPlan.Dto.Base.cs @@ -189,4 +189,6 @@ public class Ghre_UshioPlanBase /// 预留字段12 /// public int? ReverseI2 { get; set; } + + public List StaffId { get; set; } } diff --git a/Tiobon.Core.Model/Insert/Ghre/Ghre_UshioPlan.Dto.InsertInput.cs b/Tiobon.Core.Model/Insert/Ghre/Ghre_UshioPlan.Dto.InsertInput.cs index c924854b..90f9668c 100644 --- a/Tiobon.Core.Model/Insert/Ghre/Ghre_UshioPlan.Dto.InsertInput.cs +++ b/Tiobon.Core.Model/Insert/Ghre/Ghre_UshioPlan.Dto.InsertInput.cs @@ -23,4 +23,6 @@ namespace Tiobon.Core.Model.Models; /// public class InsertGhre_UshioPlanInput : Ghre_UshioPlanBase { + public List Ids { get; set; } + public string Reason { get; set; } } diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_UshioPlan.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_UshioPlan.Dto.View.cs index 1546a508..21e7bc6d 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_UshioPlan.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_UshioPlan.Dto.View.cs @@ -31,4 +31,10 @@ public class Ghre_UshioPlanDto : Ghre_UshioPlan /// 修改信息 /// public string UpdateDataInfo { get; set; } + + public string StaffNames { get; set; } + public string DeptName { get; set; } + public string SchoolName { get; set; } + + public List StaffId { get; set; } } diff --git a/Tiobon.Core.Services/Ghre/Ghre_UshioPlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_UshioPlanServices.cs index 7c43c2fc..76160cc5 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_UshioPlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_UshioPlanServices.cs @@ -1,4 +1,7 @@ -namespace Tiobon.Core.Services; +using static Tiobon.Core.Model.Consts; +using Tiobon.Core.Common.DB.Dapper.Extensions; + +namespace Tiobon.Core.Services; /// /// 【牛尾】培训计划 (服务) @@ -12,4 +15,114 @@ public class Ghre_UshioPlanServices : BaseServices> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) + { + + var result = await base.QueryFilterPage(filter, condition, IsEnable); + var DT_TableDataT1 = result.result.DT_TableDataT1; + + var deptIds = DT_TableDataT1.Select(x => x.DeptId).Distinct().ToList(); + var courseIds = DT_TableDataT1.Select(x => x.CourseId).Distinct().ToList(); + var staffIds = new List(); + for (int i = 0; i < DT_TableDataT1.Count; i++) + { + if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull()) + staffIds.AddRange(JsonHelper.JsonToObj>(DT_TableDataT1[i].StaffIds)); + DT_TableDataT1[i].TrainCategory = await GetParaLabel("TrainingCategory", DT_TableDataT1[i].TrainCategory); + DT_TableDataT1[i].Month = await GetParaLabel("MonthSelect", DT_TableDataT1[i].Month); + } + staffIds = staffIds.Distinct().ToList(); + var staffs = await Db.Queryable().Where(x => staffIds.Contains(x.StaffID)).ToListAsync(); + var depts = await Db.Queryable().Where(x => deptIds.Contains(x.DeptID)).ToListAsync(); + var courses = await Db.Queryable().Where(x => courseIds.Contains(x.Id)).ToListAsync(); + + + for (int i = 0; i < DT_TableDataT1.Count; i++) + { + if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull()) + { + var staffIds1 = JsonHelper.JsonToObj>(DT_TableDataT1[i].StaffIds); + if (staffIds1.Any()) + DT_TableDataT1[i].StaffNames = string.Join("、", staffs.Where(x => staffIds1.Contains(x.StaffID)).Select(x => x.StaffName)); + } + + DT_TableDataT1[i].CourseName = courses.Where(x => x.Id == DT_TableDataT1[i].CourseId).Select(x => x.CourseName).FirstOrDefault(); + DT_TableDataT1[i].DeptName = depts.Where(x => x.DeptID == DT_TableDataT1[i].DeptId).Select(x => x.DeptName).FirstOrDefault(); + } + return result; + } + + + + public override async Task Add(InsertGhre_UshioPlanInput entity) + { + if (entity.StaffId != null) + entity.StaffIds = JsonHelper.ObjToJson(entity.StaffId); + var result = await base.Add(entity); + + return result; + } + + public override async Task Update(long Id, EditGhre_UshioPlanInput editModel) + { + if (editModel.StaffId != null) + editModel.StaffIds = JsonHelper.ObjToJson(editModel.StaffId); + + var result = await base.Update(Id, editModel, null, ["Status"]); + return result; + } + + public override async Task> QueryForm(QueryForm body) + { + var result = await base.QueryForm(body); + string StaffIds = result.result.DT_TableDataT1[0].StaffIds; + if (!string.IsNullOrWhiteSpace(StaffIds)) + result.result.DT_TableDataT1[0].StaffId = JsonConvert.DeserializeObject>(StaffIds); + return result; + } + public async Task> InsertByStatus(InsertGhre_UshioPlanInput insertModel, string status) + { + + if (insertModel.StaffId != null) + insertModel.StaffIds = JsonHelper.ObjToJson(insertModel.StaffId); + var data = ServiceResult.OprateSuccess("新增成功", 0); + insertModel.Status = status; + var id = await Add(insertModel); + + data.Success = id > 0; + if (data.Success) + data.Data = id; + else + return ServiceResult.OprateFailed("失败!"); + + return data; + } + + public async Task UpdateStatus(InsertGhre_UshioPlanInput input, string status) + { + + HttpRequest request = UserContext.Context.Request; + var api = request.Path.ObjToString().TrimEnd('/').ToLower(); + var ip = GetUserIp(UserContext.Context); + + var entities = new List(); + foreach (var id in input.Ids) + { + if (!BaseDal.Any(id)) + continue; + + var entity = await BaseDal.QueryById(id); + + entity.UpdateIP = ip; + entity.UpdateProg = api; + entity.Status = status; + entities.Add(entity); + } + + var result = await BaseDal.Update(entities); + return ServiceResult.OprateSuccess("执行成功!"); + + } } \ No newline at end of file