diff --git a/Model/Tiobon.Web.pdm b/Model/Tiobon.Web.pdm index 242619aa..12ac48c9 100644 --- a/Model/Tiobon.Web.pdm +++ b/Model/Tiobon.Web.pdm @@ -1,5 +1,5 @@ - + @@ -120972,11 +120972,11 @@ LABL 0 Arial Unicode MS,8,N Result 1722403195 Administrator -1722403297 +1723284867 Administrator 结果 -nvarchar(256) -256 +nvarchar(2000) +2000 2D5BA3A4-EFBB-4770-AFD6-9B40D4C4F2B6 diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index ebf1e9e9..1602c014 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -4087,7 +4087,7 @@ - 必选修规则 (Dto.Base) + Ghre_StudyRule (Dto.Base) diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_StudyRule.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_StudyRule.Dto.Base.cs index 3d2a7bf7..e735eb74 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_StudyRule.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_StudyRule.Dto.Base.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2024/7/19 15:24:17 SimonHsiao 初版 +*V0.01 2024/8/10 18:11:53 SimonHsiao 初版 * * Copyright(c) 2024 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -21,7 +21,7 @@ namespace Tiobon.Core.Model.Models { /// - /// 必选修规则 (Dto.Base) + /// Ghre_StudyRule (Dto.Base) /// public class Ghre_StudyRuleBase { @@ -51,27 +51,32 @@ namespace Tiobon.Core.Model.Models /// /// 厂区 /// - public int? ZoneId { get; set; } + [Display(Name = "ZoneId"), Description("厂区"), MaxLength(2000, ErrorMessage = "厂区 不能超过 2000 个字符")] + public string ZoneId { get; set; } /// /// 部门 /// - public int? DeptId { get; set; } + [Display(Name = "DeptId"), Description("部门"), MaxLength(2000, ErrorMessage = "部门 不能超过 2000 个字符")] + public string DeptId { get; set; } /// /// 职称 /// - public int? TitleId { get; set; } + [Display(Name = "TitleId"), Description("职称"), MaxLength(2000, ErrorMessage = "职称 不能超过 2000 个字符")] + public string TitleId { get; set; } /// /// 职等 /// - public int? GradeId { get; set; } + [Display(Name = "GradeId"), Description("职等"), MaxLength(2000, ErrorMessage = "职等 不能超过 2000 个字符")] + public string GradeId { get; set; } /// /// 岗位 /// - public int? JobId { get; set; } + [Display(Name = "JobId"), Description("岗位"), MaxLength(2000, ErrorMessage = "岗位 不能超过 2000 个字符")] + public string JobId { get; set; } /// /// 年度 @@ -93,7 +98,7 @@ namespace Tiobon.Core.Model.Models /// /// 结果 /// - [Display(Name = "Result"), Description("结果"), MaxLength(2000, ErrorMessage = "结果 不能超过 256 个字符")] + [Display(Name = "Result"), Description("结果"), MaxLength(256, ErrorMessage = "结果 不能超过 256 个字符")] public string Result { get; set; } /// diff --git a/Tiobon.Core.Model/Edit/Ghre/Ghre_StudyRule.Dto.EditInput.cs b/Tiobon.Core.Model/Edit/Ghre/Ghre_StudyRule.Dto.EditInput.cs index 0c316f33..c9f971ac 100644 --- a/Tiobon.Core.Model/Edit/Ghre/Ghre_StudyRule.Dto.EditInput.cs +++ b/Tiobon.Core.Model/Edit/Ghre/Ghre_StudyRule.Dto.EditInput.cs @@ -23,4 +23,18 @@ namespace Tiobon.Core.Model.Models; public class EditGhre_StudyRuleInput : Ghre_StudyRuleBase { public List Staffs { get; set; } + + public List ZoneIds { get; set; } + + + public List DeptIds { get; set; } + + + public List TitleIds { get; set; } + + + public List GradeIds { get; set; } + + + public List JobIds { get; set; } } diff --git a/Tiobon.Core.Model/Insert/Ghre/Ghre_StudyRule.Dto.InsertInput.cs b/Tiobon.Core.Model/Insert/Ghre/Ghre_StudyRule.Dto.InsertInput.cs index e432acdf..ba800f06 100644 --- a/Tiobon.Core.Model/Insert/Ghre/Ghre_StudyRule.Dto.InsertInput.cs +++ b/Tiobon.Core.Model/Insert/Ghre/Ghre_StudyRule.Dto.InsertInput.cs @@ -23,4 +23,18 @@ namespace Tiobon.Core.Model.Models; public class InsertGhre_StudyRuleInput : Ghre_StudyRuleBase { public List Staffs { get; set; } + + public List ZoneIds { get; set; } + + + public List DeptIds { get; set; } + + + public List TitleIds { get; set; } + + + public List GradeIds { get; set; } + + + public List JobIds { get; set; } } diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_StudyRule.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_StudyRule.cs index c4bf9730..812f3c07 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_StudyRule.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_StudyRule.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2024/7/19 15:24:17 SimonHsiao 初版 +*V0.01 2024/8/10 18:11:53 SimonHsiao 初版 * * Copyright(c) 2024 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -53,27 +53,32 @@ namespace Tiobon.Core.Model.Models /// /// 厂区 /// - public int? ZoneId { get; set; } + [Display(Name = "ZoneId"), Description("厂区"), MaxLength(2000, ErrorMessage = "厂区 不能超过 2000 个字符")] + public string ZoneId { get; set; } /// /// 部门 /// - public int? DeptId { get; set; } + [Display(Name = "DeptId"), Description("部门"), MaxLength(2000, ErrorMessage = "部门 不能超过 2000 个字符")] + public string DeptId { get; set; } /// /// 职称 /// - public int? TitleId { get; set; } + [Display(Name = "TitleId"), Description("职称"), MaxLength(2000, ErrorMessage = "职称 不能超过 2000 个字符")] + public string TitleId { get; set; } /// /// 职等 /// - public int? GradeId { get; set; } + [Display(Name = "GradeId"), Description("职等"), MaxLength(2000, ErrorMessage = "职等 不能超过 2000 个字符")] + public string GradeId { get; set; } /// /// 岗位 /// - public int? JobId { get; set; } + [Display(Name = "JobId"), Description("岗位"), MaxLength(2000, ErrorMessage = "岗位 不能超过 2000 个字符")] + public string JobId { get; set; } /// /// 年度 diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRule.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRule.Dto.View.cs index c1d61292..3cba3942 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRule.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRule.Dto.View.cs @@ -45,4 +45,20 @@ public class Ghre_StudyRuleDto : Ghre_StudyRule public string StaffNames { get; set; } public List Staffs { get; set; } + + + public List ZoneIds { get; set; } = new List(); + + + public List DeptIds { get; set; } = new List(); + + + public List TitleIds { get; set; } = new List(); + + + public List GradeIds { get; set; } = new List(); + + + public List JobIds { get; set; } = new List(); + } diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index 437d19bb..1b3030bc 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -14,6 +14,8 @@ using SqlSugar; using MathNet.Numerics.Distributions; using MongoDB.Driver.Linq; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; +using System.Data; +using System.Collections.Generic; namespace Tiobon.Core.Services; @@ -49,9 +51,9 @@ public class Ghre_StudyRuleServices : BaseServices x.Id).ToList(); var staffs = await _ghre_StudyRuleStaffServices.Query(x => x.StudyRuleId != null && ids.Contains(x.StudyRuleId.Value)); - entitys.ForEach(x => + var zoneIds = new List(); + var deptIds = new List(); + var titleIds = new List(); + var gradeIds = new List(); + var jobIds = new List(); + entitys.ForEach(rule => { - x.StaffNames = string.Join(",", staffs.Where(o => o.StudyRuleId == x.Id).Select(o => o.StaffName)); + rule.StaffNames = string.Join(",", staffs.Where(o => o.StudyRuleId == rule.Id).Select(o => o.StaffName)); + + if (!rule.ZoneId.IsNull()) + rule.ZoneIds = JsonHelper.JsonToObj>(rule.ZoneId); + if (!rule.DeptId.IsNull()) + rule.DeptIds = JsonHelper.JsonToObj>(rule.DeptId); + if (!rule.TitleId.IsNull()) + rule.TitleIds = JsonHelper.JsonToObj>(rule.TitleId); + if (!rule.GradeId.IsNull()) + rule.GradeIds = JsonHelper.JsonToObj>(rule.GradeId); + if (!rule.JobId.IsNull()) + rule.JobIds = JsonHelper.JsonToObj>(rule.JobId); + + if (rule.ZoneIds.Any()) + zoneIds.AddRange(rule.ZoneIds); + + if (rule.DeptIds.Any()) + deptIds.AddRange(rule.DeptIds); + + if (rule.TitleIds.Any()) + titleIds.AddRange(rule.TitleIds); + + if (rule.GradeIds.Any()) + gradeIds.AddRange(rule.GradeIds); + + if (rule.JobIds.Any()) + jobIds.AddRange(rule.JobIds); }); + return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); } @@ -125,6 +159,18 @@ public class Ghre_StudyRuleServices : BaseServices Add(InsertGhre_StudyRuleInput entity) { + + if (!entity.ZoneIds.IsNull() && entity.ZoneIds.Any()) + entity.ZoneId = JsonHelper.ObjToJson(entity.ZoneIds); + if (!entity.DeptIds.IsNull() && entity.DeptIds.Any()) + entity.DeptId = JsonHelper.ObjToJson(entity.DeptIds); + if (!entity.TitleIds.IsNull() && entity.TitleIds.Any()) + entity.TitleId = JsonHelper.ObjToJson(entity.TitleIds); + if (!entity.GradeIds.IsNull() && entity.GradeIds.Any()) + entity.GradeId = JsonHelper.ObjToJson(entity.GradeIds); + if (!entity.JobIds.IsNull() && entity.JobIds.Any()) + entity.JobId = JsonHelper.ObjToJson(entity.JobIds); + var result = await base.Add(entity); if (entity.Staffs != null && entity.Staffs.Any()) @@ -147,15 +193,27 @@ public class Ghre_StudyRuleServices : BaseServices Update(long Id, EditGhre_StudyRuleInput editModel) + public override async Task Update(long Id, EditGhre_StudyRuleInput entity) { - var result = await base.Update(Id, editModel); + + if (!entity.ZoneIds.IsNull() && entity.ZoneIds.Any()) + entity.ZoneId = JsonHelper.ObjToJson(entity.ZoneIds); + if (!entity.DeptIds.IsNull() && entity.DeptIds.Any()) + entity.DeptId = JsonHelper.ObjToJson(entity.DeptIds); + if (!entity.TitleIds.IsNull() && entity.TitleIds.Any()) + entity.TitleId = JsonHelper.ObjToJson(entity.TitleIds); + if (!entity.GradeIds.IsNull() && entity.GradeIds.Any()) + entity.GradeId = JsonHelper.ObjToJson(entity.GradeIds); + if (!entity.JobIds.IsNull() && entity.JobIds.Any()) + entity.JobId = JsonHelper.ObjToJson(entity.JobIds); + + var result = await base.Update(Id, entity); await _ghre_StudyRuleStaffServices.Delete(x => x.StudyRuleId == Id); - if (editModel.Staffs != null && editModel.Staffs.Any()) + if (!entity.IsNull() && entity.Staffs.Any()) { - var insertStaffs = editModel.Staffs.Select(x => new InsertGhre_StudyRuleStaffInput + var insertStaffs = entity.Staffs.Select(x => new InsertGhre_StudyRuleStaffInput { StaffId = x, StudyRuleId = Id @@ -183,9 +241,19 @@ public class Ghre_StudyRuleServices : BaseServices x.StudyRuleId != null && x.StudyRuleId == result.result.DT_TableDataT1[0].Id); var DT_TableDataT1 = result.result.DT_TableDataT1; - DT_TableDataT1.ForEach(t => + DT_TableDataT1.ForEach(rule => { - t.Staffs = staffs.Where(x => x.StaffId != null).Select(x => x.StaffId.Value).ToList(); + rule.Staffs = staffs.Where(x => x.StaffId != null).Select(x => x.StaffId.Value).ToList(); + if (!rule.ZoneId.IsNull()) + rule.ZoneIds = JsonHelper.JsonToObj>(rule.ZoneId); + if (!rule.DeptId.IsNull()) + rule.DeptIds = JsonHelper.JsonToObj>(rule.DeptId); + if (!rule.TitleId.IsNull()) + rule.TitleIds = JsonHelper.JsonToObj>(rule.TitleId); + if (!rule.GradeId.IsNull()) + rule.GradeIds = JsonHelper.JsonToObj>(rule.GradeId); + if (!rule.JobId.IsNull()) + rule.JobIds = JsonHelper.JsonToObj>(rule.JobId); }); result.result.DT_TableDataT1 = DT_TableDataT1; @@ -201,6 +269,22 @@ public class Ghre_StudyRuleServices : BaseServices().FirstAsync(x => x.Id == ruleId); + var ZoneIds = new List(); + var DeptIds = new List(); + var TitleIds = new List(); + var GradeIds = new List(); + var JobIds = new List(); + if (!rule.ZoneId.IsNull()) + ZoneIds = JsonHelper.JsonToObj>(rule.ZoneId); + if (!rule.DeptId.IsNull()) + DeptIds = JsonHelper.JsonToObj>(rule.DeptId); + if (!rule.TitleId.IsNull()) + TitleIds = JsonHelper.JsonToObj>(rule.TitleId); + if (!rule.GradeId.IsNull()) + GradeIds = JsonHelper.JsonToObj>(rule.GradeId); + if (!rule.JobId.IsNull()) + JobIds = JsonHelper.JsonToObj>(rule.JobId); + var ruleStaffs = await Db.Queryable().Where(x => x.StudyRuleId == ruleId).ToListAsync(); await Db.Updateable().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1) @@ -211,13 +295,12 @@ public class Ghre_StudyRuleServices : BaseServices() .Where(x => x.OutDate == null || (x.OutDate != null && x.Indate != null && x.Indate.Value.Date <= DateTime.Now.Date && x.Indate.Value.Date >= DateTime.Now.Date)) - .WhereIF(!rule.ZoneId.IsNull(), x => x.ZoneID == rule.ZoneId) - .WhereIF(!rule.DeptId.IsNull(), x => x.DeptID == rule.DeptId) - .WhereIF(!rule.TitleId.IsNull(), x => x.TitleID == rule.TitleId) - .WhereIF(!rule.GradeId.IsNull(), x => x.GradeID == rule.GradeId) - .WhereIF(!rule.JobId.IsNull(), x => x.JobID == rule.JobId) + .WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID)) + .WhereIF(DeptIds.Any(), x => DeptIds.Contains(x.DeptID)) + .WhereIF(TitleIds.Any(), x => TitleIds.Contains(x.TitleID)) + .WhereIF(GradeIds.Any(), x => GradeIds.Contains(x.GradeID)) + .WhereIF(JobIds.Any(), x => JobIds.Contains(x.JobID)) .WhereIF(!ruleStaffIds.IsNull() && ruleStaffIds.Any(), x => ruleStaffIds.Contains(x.StaffID)) - .WhereIF(!rule.GradeId.IsNull(), x => x.GradeID == rule.GradeId) .ToListAsync(); if (!staffs.IsNull()) diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index ebf1e9e9..1602c014 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -4087,7 +4087,7 @@ - 必选修规则 (Dto.Base) + Ghre_StudyRule (Dto.Base)