From 0472e43a5483cb393950871786e2be3f8419d73b Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Sun, 29 Sep 2024 16:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B2=E5=B8=88=E7=AD=89=E7=BA=A7=E5=BC=82?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Tiobon.Web.pdm | 25 ++- .../Ghre/Ghre_TeacherChangeController.cs | 50 ++++++ Tiobon.Core.Api/Tiobon.Core.Model.xml | 2 +- Tiobon.Core.Api/Tiobon.Core.xml | 8 + Tiobon.Core.Common/Helper/DateTimeHelper.cs | 4 +- .../Ghre/IGhre_TeacherChangeServices.cs | 6 + .../Base/Ghre/Ghre_TeacherChange.Dto.Base.cs | 3 +- .../Models/Ghre/Ghre_TeacherChange.cs | 5 +- .../View/Ghre/Ghre_TeacherChange.Dto.View.cs | 6 + Tiobon.Core.Services/CommonServices.cs | 4 + .../Ghre/Ghre_TeacherChangeServices.cs | 155 ++++++++++++++++-- Tiobon.Core/Tiobon.Core.Model.xml | 2 +- Tiobon.Core/Tiobon.Core.xml | 8 + 13 files changed, 240 insertions(+), 38 deletions(-) diff --git a/Model/Tiobon.Web.pdm b/Model/Tiobon.Web.pdm index 3a86019b..87392e80 100644 --- a/Model/Tiobon.Web.pdm +++ b/Model/Tiobon.Web.pdm @@ -1,5 +1,5 @@ - + @@ -105075,7 +105075,7 @@ Shadow=0 1714101292 1727336781 (1800, 1438) -((-21934,18603), (-11734,21512)) +((-21934,18603), (-11734,21562)) ((-21934,18828),(-11734,18828)) 2 1 @@ -105135,7 +105135,7 @@ Shadow=0 1714109221 1717481025 -((-11857,-7040), (-1057,-5479)) +((-11857,-7040), (-1057,-5518)) ((-1057,-6815),(-11857,-6815)) 2 1 @@ -105256,7 +105256,7 @@ Shadow=0 1717481682 1727336872 (0, 1739) -((-21750,-6964), (-11729,-3753)) +((-21750,-6964), (-11729,-3703)) ((-21750,-6739),(-11729,-6739)) 2 1 @@ -105276,7 +105276,7 @@ Shadow=0 1717726229 1719381754 -((-42298,11400), (-39374,18375)) +((-42299,11400), (-39375,18375)) ((-40837,11400),(-40837,18375)) 2 1 @@ -105296,7 +105296,7 @@ Shadow=0 1719381914 1719381932 -((-40875,18075), (-30150,19634)) +((-40875,18075), (-30150,19596)) ((-30150,18300),(-40875,18300)) 2 1 @@ -105317,7 +105317,7 @@ Shadow=0 1719468257 1727336864 (300, 1650) -((-40800,11175), (-30700,14296)) +((-40800,11175), (-30700,14346)) ((-30700,11400),(-40800,11400)) 2 1 @@ -105358,7 +105358,7 @@ Shadow=0 1721280189 1727336851 (-150, 2039) -((12000,-14850), (21750,-11339)) +((12000,-14850), (21750,-11289)) ((12000,-14625),(21750,-14625)) 2 1 @@ -105379,7 +105379,7 @@ Shadow=0 1721372603 1727336854 (-75, 1889) -((21750,-14925), (32550,-11564)) +((21750,-14925), (32550,-11514)) ((32550,-14700),(21750,-14700)) 2 1 @@ -105419,7 +105419,7 @@ Shadow=0 1727335554 1727335611 -((-51600,11212), (-40800,12771)) +((-51600,11212), (-40800,12733)) ((-51600,11437),(-40800,11437)) 2 1 @@ -124943,11 +124943,10 @@ LABL 0 Arial Unicode MS,8,N OriginChangeDate 1727337543 Administrator -1727337672 +1727428742 Administrator 原调动日期 -nvarchar(32) -32 +datetime 2FD9DA9A-8BC0-4A85-BA0F-5C7FBBB65C5E diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_TeacherChangeController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_TeacherChangeController.cs index fafb7e0a..3627fba2 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_TeacherChangeController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_TeacherChangeController.cs @@ -11,4 +11,54 @@ public class Ghre_TeacherChangeController : BaseController> QueryDisabled([FromBody] QueryBody body) + { + return await _service.QueryFilterPage(body, null, false); + } + #endregion + + #region 查询 + /// + /// 根据条件查询数据 + /// + /// 条件 + /// status + /// + [HttpPost, Route("QueryList/{status}")] + public async Task> QueryByStatus([FromBody] QueryBody body, string status) + { + if (status == "Active") + return await _service.QueryFilterPage(body, $"(Status ='{status}' OR (WorkID IS NOT NULL AND WorkState IN (0,1)))"); + else if (status == "Disable") + return await _service.QueryFilterPage(body, null, false); + else + return await _service.QueryFilterPage(body, $"Status ='{status}' AND WorkID IS NULL"); + } + #endregion + + #region 状态修改 + [HttpPost("UpdateStatus/{status}")] + public async Task UpdateStatus(string status, [FromBody] InsertGhre_TeacherChangeInput input) + { + return await _service.UpdateStatus(input, status); + } + #endregion + + #region 新增 + [HttpPost("Insert/{status}")] + public async Task> InsertByStatus([FromBody] InsertGhre_TeacherChangeInput insertModel, string status) + { + return await _service.InsertByStatus(insertModel, status); + } + #endregion + + #region 查询 + [HttpPost("QueryLast/{teacherId}")] + public async Task> QueryLast(int teacherId) + { + return await _service.QueryLast(teacherId); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index e4a56674..06df0c48 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -13319,7 +13319,7 @@ 原调动日期 - + diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 03aa5ddc..e2eff31f 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1115,6 +1115,14 @@ 培训讲师异动(Controller) + + + 根据条件查询数据 + + 条件 + status + + Ghre_Teacher(Controller) diff --git a/Tiobon.Core.Common/Helper/DateTimeHelper.cs b/Tiobon.Core.Common/Helper/DateTimeHelper.cs index 895ac314..95d6d2d3 100644 --- a/Tiobon.Core.Common/Helper/DateTimeHelper.cs +++ b/Tiobon.Core.Common/Helper/DateTimeHelper.cs @@ -1,7 +1,7 @@ namespace Tiobon.Core.Common.Helper; public class DateTimeHelper -{ +{ public static string FriendlyDate(DateTime? date) { if (!date.HasValue) return string.Empty; @@ -148,6 +148,8 @@ public class DateTimeHelper /// public static string ConvertToDayString(object dateTime) { + if (dateTime is null) + return ""; if (string.IsNullOrEmpty(Convert.ToString(dateTime))) { return ""; diff --git a/Tiobon.Core.IServices/Ghre/IGhre_TeacherChangeServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_TeacherChangeServices.cs index 98632cdd..68117d5a 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_TeacherChangeServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_TeacherChangeServices.cs @@ -1,4 +1,5 @@ using Tiobon.Core.IServices.BASE; +using Tiobon.Core.Model; using Tiobon.Core.Model.Models; namespace Tiobon.Core.IServices @@ -8,5 +9,10 @@ namespace Tiobon.Core.IServices /// public interface IGhre_TeacherChangeServices :IBaseServices { + Task UpdateStatus(InsertGhre_TeacherChangeInput input, string status); + + Task> InsertByStatus(InsertGhre_TeacherChangeInput insertModel, string status); + + Task> QueryLast(int teacherId); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_TeacherChange.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_TeacherChange.Dto.Base.cs index a07295d3..669ba335 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_TeacherChange.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_TeacherChange.Dto.Base.cs @@ -52,8 +52,7 @@ namespace Tiobon.Core.Model.Models /// /// 原调动日期 /// - [Display(Name = "OriginChangeDate"), Description("原调动日期"), MaxLength(32, ErrorMessage = "原调动日期 不能超过 32 个字符")] - public string OriginChangeDate { get; set; } + public DateTime? OriginChangeDate { get; set; } /// /// 调动日期 diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_TeacherChange.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_TeacherChange.cs index 5c41dc64..b4ccfbdd 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_TeacherChange.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_TeacherChange.cs @@ -53,9 +53,8 @@ namespace Tiobon.Core.Model.Models /// /// 原调动日期 - /// - [Display(Name = "OriginChangeDate"), Description("原调动日期"), MaxLength(32, ErrorMessage = "原调动日期 不能超过 32 个字符")] - public string OriginChangeDate { get; set; } + /// + public DateTime? OriginChangeDate { get; set; } /// /// 调动日期 diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_TeacherChange.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_TeacherChange.Dto.View.cs index 77fd67c6..dae2357b 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_TeacherChange.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_TeacherChange.Dto.View.cs @@ -35,9 +35,15 @@ public class Ghre_TeacherChangeDto : Ghre_TeacherChange public string TeacherTypeLabel { get; set; } + public string OriginTeacherLevelLabel { get; set; } public string TeacherLevelLabel { get; set; } public string DeptOrSchoolName { get; set; } + public string GenderLabel { get; set; } + public string ChangeTypeLabel { get; set; } + public string OriginChangeTypeLabel { get; set; } + public string OriginChangeDate1 { get; set; } + public string ChangeDate1 { get; set; } public List TeacherAttachments { get; set; } } diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 99225c37..19ce73e0 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1130,6 +1130,7 @@ public partial class CommonServices : BaseServices>, ICommon case "F_Training_Demand_ToDo": case "F_TeacherManageTemporary": + case "F_TeacherChangeManageTemporary": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); @@ -1182,6 +1183,8 @@ public partial class CommonServices : BaseServices>, ICommon case "F_Training_Demand_VoidQuery": case "F_TeacherManage": case "F_TeacherManageActive": + case "F_TeacherChangeManage": + case "F_TeacherChangeManageActive": case "F_TeacherDisabled": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } @@ -1192,6 +1195,7 @@ 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_TeacherChangeManageWaitConfirm": case "F_TeacherManageWaitConfirm": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs b/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs index a06bedf6..b7d0e816 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs @@ -5,12 +5,12 @@ using Tiobon.Core.Services.BASE; using Tiobon.Core.IRepository.Base; using Tiobon.Core.Common.Caches; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json.Linq; using static Tiobon.Core.Model.Consts; using Tiobon.Core.Common.UserManager; using Tiobon.Core.Common; using Tiobon.Core.Model; using AgileObjects.AgileMapper; +using Tiobon.Core.Common.Helper; namespace Tiobon.Core.Services; @@ -22,20 +22,49 @@ public class Ghre_TeacherChangeServices : BaseServices _dal; private IGhre_AttachmentServices _ghre_AttachmentServices; private IGhre_TeacherChangeAttachmentServices _ghre_TeacherChangeAttachmentServices; + private IGhre_TeacherAttachmentServices _ghre_TeacherAttachmentServices; public Ghre_TeacherChangeServices(ICaching caching, IGhre_AttachmentServices ghre_AttachmentServices, - IGhre_TeacherChangeAttachmentServices ghre_TeacherChangeAttachmentServices, IBaseRepository dal) + IGhre_TeacherChangeAttachmentServices ghre_TeacherChangeAttachmentServices, + IGhre_TeacherAttachmentServices ghre_TeacherAttachmentServices, + IBaseRepository dal) { this._dal = dal; base.BaseDal = dal; base._caching = caching; _ghre_AttachmentServices = ghre_AttachmentServices; _ghre_TeacherChangeAttachmentServices = ghre_TeacherChangeAttachmentServices; + _ghre_TeacherAttachmentServices = ghre_TeacherAttachmentServices; } public override async Task> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { var result = await base.QueryFilterPage(filter, condition, IsEnable); + + var data = result.result.DT_TableDataT1; + + var schoolIds = data.Where(x => x.SchoolId != null).Select(x => x.SchoolId.Value).Distinct().ToList(); + var deptIDs = data.Where(x => x.DeptID != null).Select(x => x.DeptID).Distinct().ToList(); + var teacherIds = data.Where(x => x.TeacherId != null).Select(x => x.TeacherId).Distinct().ToList(); + + var depts = await Db.Queryable().Where(x => deptIDs.Contains(x.DeptID)).Select(x => new { x.DeptID, x.DeptName }).ToListAsync(); + var schools = await Db.Queryable().Where(x => schoolIds.Contains(x.Id)).Select(x => new { x.Id, x.SchoolName }).ToListAsync(); + var teachers = await Db.Queryable().Where(x => teacherIds.Contains(x.Id)).Select(x => new { x.Id, TeacherName = x.TeacherName + " (" + x.TeacherNo + ")" }).ToListAsync(); + + data.ForEach(async x => + { + x.TeacherTypeLabel = await GetParaLabel("TrainingTeacherType", x.TeacherType); + x.TeacherLevelLabel = await GetParaLabel("TrainingTeacherLevel", x.TeacherLevel); + x.OriginTeacherLevelLabel = await GetParaLabel("TrainingTeacherLevel", x.OriginTeacherLevel); + x.ChangeTypeLabel = await GetParaLabel("TrainingTeacherChangeType", x.ChangeType); + x.OriginChangeTypeLabel = await GetParaLabel("TrainingTeacherChangeType", x.OriginChangeType); + x.DeptOrSchoolName = x.TeacherType == "Out" ? schools.FirstOrDefault(o => o.Id == x.SchoolId)?.SchoolName : depts.FirstOrDefault(o => o.DeptID == x.DeptID)?.DeptName; + x.TeacherName = teachers.FirstOrDefault(o => o.Id == x.TeacherId)?.TeacherName; + x.OriginChangeDate1 = DateTimeHelper.ConvertToDayString(x.OriginChangeDate); + x.ChangeDate1 = DateTimeHelper.ConvertToDayString(x.ChangeDate); + }); + + result.result.DT_TableDataT1 = data; return result; } @@ -63,22 +92,15 @@ public class Ghre_TeacherChangeServices : BaseServices Add(InsertGhre_TeacherChangeInput entity) { + #region 校验 当天是否能发起 + if (await Db.Queryable().AnyAsync(x => x.TeacherId == entity.TeacherId && ((x.Status == "Wait") || (x.Status != "Wait" && x.WorkState != 2)))) + throw new Exception("讲师当天只能发起一笔有效异动!"); + #endregion - if (entity.TeacherType == "In") - { - entity.SchoolId = null; - var staff = await Db.Queryable().FirstAsync(x => x.StaffID == entity.StaffId); - if (staff != null) - { - entity.TeacherNo = staff.StaffNo; - entity.TeacherName = staff.StaffName; - } - } - else - { - entity.DeptID = null; - entity.StaffId = null; - } + var teacher = await Db.Queryable().FirstAsync(x => x.Id == entity.TeacherId); + + entity.SchoolId = teacher.SchoolId; + entity.DeptID = teacher.DeptID; var id = await base.Add(entity); var sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_TeacherChange WHERE Id !='{id}'"; @@ -104,6 +126,7 @@ public class Ghre_TeacherChangeServices : BaseServices 0; if (data.Success) + { data.Data = id; + #region 状态是Wait 直接会写至主数据 + if (status == "Wait") + { + var teacher = Mapper.Map(insertModel).ToANew(); + teacher.Id = insertModel.TeacherId.Value; + await Db.Updateable(teacher).UpdateColumns(it => new { it.TeacherLevel, it.Price, it.SkillPoints }).ExecuteCommandAsync(); + + var teacherAttachmentIds = await Db.Queryable().Where(x => x.TeacherId == insertModel.TeacherId).Select(x => x.Id).ToListAsync(); + if (teacherAttachmentIds.Any()) + await Db.Updateable() + .SetColumns(it => new Ghre_TeacherAttachment() + { + IsEnable = 0 + }) + .Where(it => teacherAttachmentIds.Contains(it.Id)) + .ExecuteCommandAsync(); + + if (insertModel.TeacherAttachments != null && insertModel.TeacherAttachments.Any()) + { + for (int i = 0; i < insertModel.TeacherAttachments.Count; i++) + { + var insert = Mapper.Map(insertModel.TeacherAttachments[i]).ToANew(); ; + insert.TeacherId = teacher.Id; + var teacherAttachmentId = await _ghre_TeacherAttachmentServices.Add(insert); + if (insertModel.TeacherAttachments[i].Attachments != null && insertModel.TeacherAttachments[i].Attachments.Any()) + for (int j = 0; j < insertModel.TeacherAttachments[i].Attachments.Count; j++) + { + var attachment = await Db.Queryable().FirstAsync(x => x.RelativePath == insert.Attachments[j].RelativePath); + attachment.TableName = teacherAttachmentId.ToString(); + await Db.Insertable(attachment).ExecuteReturnSnowflakeIdAsync(); + } + } + } + } + #endregion + } else return ServiceResult.OprateFailed("发布成功!"); @@ -201,4 +261,65 @@ public class Ghre_TeacherChangeServices : BaseServices> QueryLast(int teacherId) + { + var change = new Ghre_TeacherChangeDto(); + var change1 = await Db.Queryable().OrderByDescending(x => x.CreateTime).FirstAsync(x => x.TeacherId == teacherId && (x.Status == "Active" || x.Status == "Wait")); + if (change1 != null) + { + change = Mapper.Map(change1).ToANew(); + change.OriginChangeDate = change.ChangeDate; + change.OriginChangeType = change.ChangeType; + change.OriginPrice = change.Price; + change.OriginSkillPoints = change.SkillPoints; + change.OriginTeacherLevel = change.TeacherLevel; + + change.ChangeDate = null; + change.ChangeType = null; + change.Price = null; + change.SkillPoints = null; + change.TeacherLevel = null; + change.RemarkSz = null; + change.DeptOrSchoolName = change.TeacherType == "Out" ? (await Db.Queryable().FirstAsync(o => o.Id == change.SchoolId))?.SchoolName : (await Db.Queryable().FirstAsync(o => o.DeptID == change.DeptID))?.DeptName; + + var teacherAttachments = await Db.Queryable().Where(x => x.TeacherChangeId == change.Id).ToListAsync(); + + change.TeacherAttachments = Mapper.Map(teacherAttachments).ToANew>(); + var ids1 = teacherAttachments.Select(x => x.Id.ToString()).ToList(); + var attachments = await _ghre_AttachmentServices.QueryDto(x => ids1.Contains(x.TableName)); + change.TeacherAttachments.ForEach(x => + { + x.Attachments = attachments.Where(o => o.TableName == x.Id.ToString()).ToList(); + }); + } + else + { + var teacher = await Db.Queryable().FirstAsync(x => x.Id == teacherId); + if (teacher != null) + { + change.TeacherType = teacher.TeacherType; + change.OriginTeacherLevel = teacher.TeacherLevel; + change.OriginPrice = teacher.Price; + change.OriginSkillPoints = teacher.SkillPoints; + change.SchoolId = teacher.SchoolId; + change.DeptID = teacher.DeptID; + change.DeptOrSchoolName = change.OriginTeacherLevel == "Out" ? (await Db.Queryable().FirstAsync(o => o.Id == change.SchoolId))?.SchoolName : (await Db.Queryable().FirstAsync(o => o.DeptID == change.DeptID))?.DeptName; + change.PhotoUrl = teacher.PhotoUrl; + + var teacherAttachments = await Db.Queryable().Where(x => x.TeacherId == teacher.Id).ToListAsync(); + + change.TeacherAttachments = Mapper.Map(teacherAttachments).ToANew>(); + var ids1 = teacherAttachments.Select(x => x.Id.ToString()).ToList(); + var attachments = await _ghre_AttachmentServices.QueryDto(x => ids1.Contains(x.TableName)); + change.TeacherAttachments.ForEach(x => + { + x.Attachments = attachments.Where(o => o.TableName == x.Id.ToString()).ToList(); + }); + } + } + return ServiceResult.OprateSuccess("执行成功!", change); + + } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index e4a56674..06df0c48 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -13319,7 +13319,7 @@ 原调动日期 - + diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 03aa5ddc..e2eff31f 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1115,6 +1115,14 @@ 培训讲师异动(Controller) + + + 根据条件查询数据 + + 条件 + status + + Ghre_Teacher(Controller)