From a54ca1178977d0b1ba493a365241624bbc781b5b Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Sat, 12 Oct 2024 13:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E6=8B=9B?= =?UTF-8?q?=E8=81=98=E6=A8=A1=E6=9D=BF=E7=B1=BB=E5=88=AB=E6=A0=8F=E4=BD=8D?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghrh/Ghrh_ResumeTemplateController.cs | 26 +- Tiobon.Core.Api/Tiobon.Core.xml | 15 + .../Ghrh/IGhrh_ResumeTemplateServices.cs | 5 + .../Extend/ResumeTemplateColumnMove.cs | 8 + .../Extend/ResumeTemplateGroupColumn.cs | 12 + .../Ghrh/Ghrh_ResumeTemplateServices.cs | 522 ++++++++++++++++++ 6 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateColumnMove.cs create mode 100644 Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs diff --git a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeTemplateController.cs b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeTemplateController.cs index 4811b73e..4809ff38 100644 --- a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeTemplateController.cs +++ b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeTemplateController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using Tiobon.Core.Model.ViewModels.Extend; + +namespace Tiobon.Core.Api.Controllers; /// /// 简历模板(Controller) @@ -44,4 +46,26 @@ public class Ghrh_ResumeTemplateController : BaseController PhotoSwitch(long id, int? photoType) => await _service.PhotoSwitch(id, photoType); #endregion + + #region 模板栏位异动 + /// + /// 模板栏位异动 + /// + /// + /// + /// + [HttpPost("ColumnMove/{id}")] + public async Task ColumnMove(long id, [FromBody] List columns) => await _service.ColumnMove(id, columns); + #endregion + + #region 获取分组数据 + /// + /// 获取分组数据 + /// + /// + /// + [HttpPost("QueryTemplateColumn")] + public async Task>> QueryTemplateColumn([FromBody] QueryForm filter) => await _service.QueryTemplateColumn(filter); + + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 91590af9..188d1f1f 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1169,6 +1169,21 @@ + + + 模板栏位异动 + + + + + + + + 获取分组数据 + + + + Ghro_Dept(Controller) diff --git a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeTemplateServices.cs b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeTemplateServices.cs index b47cf5c0..7b5c54a8 100644 --- a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeTemplateServices.cs +++ b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeTemplateServices.cs @@ -2,6 +2,7 @@ using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; using Tiobon.Core.Model.Models; +using Tiobon.Core.Model.ViewModels.Extend; namespace Tiobon.Core.IServices { @@ -15,5 +16,9 @@ namespace Tiobon.Core.IServices Task>> QueryGroup(QueryForm filter); Task PhotoSwitch(long id, int? photoType); + + Task ColumnMove(long id, List columns); + + Task>> QueryTemplateColumn(QueryForm filter); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateColumnMove.cs b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateColumnMove.cs new file mode 100644 index 00000000..d059939c --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateColumnMove.cs @@ -0,0 +1,8 @@ +namespace Tiobon.Core.Model.ViewModels.Extend; + +public class ResumeTemplateColumnMove +{ + public int DisplayType { get; set; } + public int SortNo { get; set; } + public long StaffInfoColumnID { get; set; } +} diff --git a/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs new file mode 100644 index 00000000..c31ee377 --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs @@ -0,0 +1,12 @@ +namespace Tiobon.Core.Model.ViewModels.Extend; + +public class ResumeTemplateGroupColumn +{ + public long ResumeInfoColumnID { get; set; } + public string ResumeInfoColumnName { get; set; } + public int SortNo { get; set; } + public int IsBuildIn { get; set; } + public int IsRequired { get; set; } + public int Removable { get; set; } + public int DisplayType { get; set; } +} diff --git a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeTemplateServices.cs b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeTemplateServices.cs index 9a92dcef..1d24cea2 100644 --- a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeTemplateServices.cs +++ b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeTemplateServices.cs @@ -7,6 +7,7 @@ using Tiobon.Core.Common.Caches; using Tiobon.Core.Model; using Tiobon.Core.Common; using Tiobon.Core.Common.Helper; +using Tiobon.Core.Model.ViewModels.Extend; namespace Tiobon.Core.Services; @@ -182,4 +183,525 @@ public class Ghrh_ResumeTemplateServices : BaseServices ColumnMove(long id, List columns) + { + var sql = $@"DECLARE @id INT = {id} + + DECLARE @jsonParam NVARCHAR (MAX) = '{JsonHelper.ObjToJson(columns)}' + DECLARE @menuName NVARCHAR (1000) = 'F_RecruitmentTemplate' + + UPDATE a -- 移动栏位 + SET a.SortNo = b.SortNo, a.IsDisplay = b.DisplayType + FROM Ghrh_ResumeTemplateInfoGroupColumn a, + (SELECT ResumeInfoColumnID, DisplayType, SortNo + FROM OPENJSON (@jsonParam) WITH (ResumeInfoColumnID INT, + DisplayType INT, + SortNo INT)) b + WHERE a.ResumeTemplateInfoGroupID = @id + AND a.IsEnable = 1 + AND a.ResumeInfoColumnID = b.ResumeInfoColumnID + AND b.DisplayType IN (0, 1) + + -- 如果之前的栏位是 从 作废里面(未发布)--> 可选或者已选, 则需要修改 ResumeInfoColumn + UPDATE Ghrh_ResumeInfoColumn + SET IsRelease = 1 + WHERE ID IN + (SELECT ResumeInfoColumnID + FROM OPENJSON (@jsonParam) WITH (ResumeInfoColumnID INT, + DisplayType INT, + SortNo INT) + WHERE DisplayType IN (0, 1)) + AND IsRelease = 0 + + DELETE FROM + Ghrh_ResumeTemplateInfoGroupColumn -- 作废项目 + WHERE ResumeTemplateInfoGroupID = @id + AND IsEnable = 1 + AND ResumeInfoColumnID IN + (SELECT ResumeInfoColumnID + FROM OPENJSON (@jsonParam) WITH (ResumeInfoColumnID INT, + DisplayType INT, + SortNo INT) + WHERE DisplayType = -1) + + -- 新增栏位 + INSERT INTO Ghrh_ResumeTemplateInfoGroupColumn (ResumeTemplateInfoGroupId, + ResumeTemplateId, + TemplateType, + ResumeInfoGroupId, + GroupType, + ResumeInfoColumnID, + IsRequired, + Editable, + InitValue, + IsDisplay, + SortNo, + RowNum, + ColNum) + SELECT a.Id ResumeTemplateInfoGroupId, + ResumeTemplateId, + a.TemplateType, + a.ResumeInfoGroupId, + a.GroupType, + c.ID ResumeInfoColumnID, + c.IsRequired, + c.Editable, + c.InitValue, + b.DisplayType, + b.SortNo, + 1, + 1 + FROM Ghrh_ResumeTemplateInfoGroup a, + (SELECT ResumeInfoColumnID, DisplayType, SortNo + FROM OPENJSON (@jsonParam) WITH (ResumeInfoColumnID INT, + DisplayType INT, + SortNo INT)) b, + Ghrh_ResumeInfoColumn c + WHERE a.Id = @id + AND b.ResumeInfoColumnID = c.ID + AND b.DisplayType IN (0, 1) + AND c.IsEnable = 1 + AND b.ResumeInfoColumnID NOT IN + (SELECT ResumeInfoColumnID + FROM Ghrh_ResumeTemplateInfoGroupColumn + WHERE ResumeTemplateInfoGroupId = @id AND IsEnable = 1) + + -- micro 2022-08-05 add 模板自动更新 栏位设定 Ghrs_PageSettingQuery + DECLARE + @FResumeMenuName NVARCHAR (1000) = 'F_Resume~', + @FResumeGroupType NVARCHAR (100) + SELECT @FResumeMenuName = + @FResumeMenuName + CONVERT (NVARCHAR (100), ResumeTemplateId), + @FResumeGroupType = GroupType + FROM Ghrh_ResumeTemplateInfoGroup + WHERE Id = @id + + IF @FResumeGroupType IN ('Base', + 'Education', + 'Family', + 'Contract', + 'WorkExp', + 'Training', + 'Licence') + BEGIN + IF @FResumeGroupType = 'Education' + SET @FResumeMenuName = 'F_ResumeEduBG' + + IF @FResumeGroupType = 'Contract' + SET @FResumeMenuName = 'F_ResumeContract' + + IF @FResumeGroupType = 'Family' + SET @FResumeMenuName = 'F_ResumeSocialRelation' + + IF @FResumeGroupType = 'WorkExp' + SET @FResumeMenuName = 'F_ResumeWorkExp' + + IF @FResumeGroupType = 'Training' + SET @FResumeMenuName = 'F_ResumeTraining' + + IF @FResumeGroupType = 'Licence' + SET @FResumeMenuName = 'F_ResumeLicence' + + -- 更新后的栏位设定写入临时表 + IF OBJECT_ID ('tempdb.[dbo].[#TempPageSettingQuery]') IS NOT NULL + DROP TABLE [dbo].[#TempPageSettingQuery] + + --insert into Ghrs_PageSettingQuery(PageNo,ColumnGroup,elementType,field,label,Meky,multipleSelect,dataType,required,palceholder, + -- dataSourceType,dataSource,sortable,sortOrder,defaultHidden,filterable,width,align,fixed,editable, + -- searchable,searchRequired,searchColumnSeq,isPrimaryKey,SortNo,searchCanOperator) + SELECT @FResumeMenuName + PageNo, + '' + ColumnGroup, + b.ColumnType + elementType, + b.ResumeInfoColumnNo + field, + b.ResumeInfoColumnName + label, + b.MKey + Meky, + NULL + multipleSelect, + b.DataType + dataType, + CASE WHEN a.IsRequired = 1 THEN 'true' ELSE 'false' END + required, + NULL + palceholder, + CASE + WHEN b.ColumnType IN ('OrgTreeSelect', 'ApiSelect') + THEN + 'dict' + ELSE + '' + END + dataSourceType, + dbo.FS_GetdataSourceBySet ('', b.DataSourceType, b.DataSource) + dataSource, + 'true' + sortable, + NULL + sortOrder, + CASE WHEN b.isPrimaryKey = 1 THEN 'true' ELSE 'false' END + defaultHidden, + NULL + filterable, + '100' + width, + 'left' + align, + NULL + fixed, + 'false' + editable, + 'false' + searchable, + 'false' + searchRequired, + '' + searchColumnSeq, + CASE WHEN b.isPrimaryKey = 1 THEN 'true' ELSE 'false' END + isPrimaryKey, + a.SortNo, + CONVERT (NVARCHAR (1000), '') + searchCanOperator, + 0 + PageSettingQueryID + INTO dbo.[#TempPageSettingQuery] + FROM Ghrh_ResumeTemplateInfoGroupColumn a, Ghrh_ResumeInfoColumn b --Ghrs_PageSettingQuery + WHERE a.ResumeInfoColumnID = b.ID + AND a.ResumeTemplateInfoGroupId = @id + AND b.IsEnable = 1 + AND grouptype = @FResumeGroupType + AND (b.isPrimaryKey = 1 OR a.IsEnable = 1 AND IsDisPlay = 1) + ORDER BY a.SortNo + + -- Group Type 的特别处理 + IF @FResumeGroupType = 'Base' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'ResumeNo' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'ResumeName' + + -- 判断生成 照片是否显示 + INSERT INTO [#TempPageSettingQuery] (PageNo, + ColumnGroup, + elementType, + field, + label, + Meky, + multipleSelect, + dataType, + required, + palceholder, + dataSourceType, + dataSource, + sortable, + sortOrder, + defaultHidden, + filterable, + width, + align, + fixed, + editable, + searchable, + searchRequired, + searchColumnSeq, + isPrimaryKey, + SortNo, + searchCanOperator, + PageSettingQueryID) + SELECT @FResumeMenuName, + '', + 'Avatar', + 'PhotoUrl', + '照片', + 'F_User_UserPhotoUrl', + '', + 'string', + '', + '', + '', + '', + '', + '', + 'false', + NULL, + '120', + '', + '', + 'true', + '', + '', + '', + '', + 1, + '', + 0 + END + + IF @FResumeGroupType = 'Education' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'SchoolName' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'DeptName' + END + + IF @FResumeGroupType = 'Family' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'RelationName' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Equal,NotEqual,EqualAny,NotEqualAny' + WHERE field = 'RelationType' + END + + IF @FResumeGroupType = 'Contract' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'ContractNo' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Equal,NotEqual,EqualAny,NotEqualAny' + WHERE field = 'ContractType' + END + + IF @FResumeGroupType = 'WorkExp' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'CompanyName' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'DeptName' + END + + IF @FResumeGroupType = 'Training' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'CourseName' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'TrainingOrgName' + END + + IF @FResumeGroupType = 'Licence' + BEGIN + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 1, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'LicenceName' + + UPDATE dbo.[#TempPageSettingQuery] + SET searchable = 'true', + searchColumnSeq = 2, + searchCanOperator = 'Include,Equal,NotEqual,NotInclude' + WHERE field = 'LicenceNo' + END + + + -- 修改临时表的 PageSettingQueryID + UPDATE a + SET a.PageSettingQueryID = b.PageSettingQueryID + FROM dbo.[#TempPageSettingQuery] a, Ghrs_PageSettingQuery b + WHERE a.PageNo = b.PageNo AND a.field = b.field AND b.IsEnable = 1 + + -- 删除 Ghrs_PageSettingQuery 中本次取消的栏位 + UPDATE Ghrs_PageSettingQuery + SET IsEnable = 0, UpdateProg = @menuName + WHERE NOT EXISTS + (SELECT 1 + FROM dbo.[#TempPageSettingQuery] a + WHERE a.PageSettingQueryID = + Ghrs_PageSettingQuery.PageSettingQueryID) + AND PageNo = @FResumeMenuName + AND elementType ! = 'FnKey' + AND field NOT IN ('CreateTime', + 'UpdateTime', + 'CreateBy', + 'UpdateBy', + 'ResumeJobStatus') + AND CreateProg = @menuName + + -- 删除自定义栏位 Ghrs_UserPageSettingQueryColumn 中本次取消的栏位 + UPDATE Ghrs_UserPageSettingQueryColumn + SET IsEnable = 0 + WHERE NOT EXISTS + (SELECT 1 + FROM Ghrs_PageSettingQuery a + WHERE a.PageSettingQueryID = + Ghrs_UserPageSettingQueryColumn.PageSettingQueryID) + AND IsEnable = 1 + AND CreateProg = @FResumeMenuName + AND EXISTS + (SELECT 1 + FROM Ghrs_PageSettingQuery a + WHERE a.PageSettingQueryID = + Ghrs_UserPageSettingQueryColumn.PageSettingQueryID + AND a.elementType ! = 'FnKey') + + -- 修改栏位 + UPDATE a + SET a.label = b.label, + a.Meky = b.Meky, + a.required = b.required, + a.elementType = b.elementType, + a.dataType = b.dataType, + a.dataSourceType = b.dataSourceType, + a.dataSource = b.dataSource, + --a.sortable=b.sortable, + a.defaultHidden = + CASE + WHEN a.field = 'ResumeID' THEN 'true' + ELSE b.defaultHidden + END, + -- a.filterable=b.filterable,a.width=b.width,a.align=b.align,a.fixed=b.fixed, + a.editable = b.editable, + --a.searchable=b.searchable,a.searchRequired=b.searchRequired,a.searchColumnSeq=b.searchColumnSeq, + a.isPrimaryKey = b.isPrimaryKey, + a.SortNo = b.SortNo, + -- a.searchCanOperator=b.searchCanOperator, + a.UpdateProg = @menuName, + a.CreateProg = @menuName + FROM Ghrs_PageSettingQuery a, dbo.[#TempPageSettingQuery] b + WHERE a.PageSettingQueryID = b.PageSettingQueryID + + -- 新增本次设定的栏位 + INSERT INTO Ghrs_PageSettingQuery (PageNo, + ColumnGroup, + elementType, + field, + label, + Meky, + multipleSelect, + dataType, + required, + palceholder, + dataSourceType, + dataSource, + sortable, + sortOrder, + defaultHidden, + filterable, + width, + align, + fixed, + editable, + searchable, + searchRequired, + searchColumnSeq, + isPrimaryKey, + SortNo, + searchCanOperator, + UpdateProg, + CreateProg) + SELECT PageNo, + ColumnGroup, + elementType, + field, + label, + Meky, + multipleSelect, + dataType, + required, + palceholder, + dataSourceType, + dataSource, + sortable, + sortOrder, + defaultHidden, + filterable, + width, + align, + fixed, + editable, + searchable, + searchRequired, + searchColumnSeq, + isPrimaryKey, + SortNo, + searchCanOperator, + @menuName, + @menuName + FROM dbo.[#TempPageSettingQuery] + WHERE isnull (PageSettingQueryID, 0) = 0 + END"; + var result = await Db.Ado.ExecuteCommandAsync(sql); + return ServiceResult.OprateSuccess(); + } + #endregion + + + #region 获取分组数据 + public async Task>> QueryTemplateColumn(QueryForm filter) + { + var sql = @$"DECLARE @ResumeInfoGroupId INT = 0 + DECLARE @ID INT = {filter.id} + SELECT @ResumeInfoGroupId = ResumeInfoGroupId + FROM Ghrh_ResumeTemplateInfoGroup + WHERE ID = @ID + + SELECT b.ID ResumeInfoColumnID, + b.ResumeInfoColumnName, + a.SortNo, + b.IsBuildIn, + isnull (a.IsRequired, b.IsRequired) IsRequired, + 1 Removable, -- 是否可以从 已选中移除 + CASE WHEN b.IsRelease = 0 THEN -1 ELSE isnull (a.IsDisplay, 0) END DisplayType -- 判断是 1;已选择 0:可选择 -1: 未发布的栏位 + FROM Ghrh_ResumeInfoColumn b + LEFT JOIN Ghrh_ResumeTemplateInfoGroupColumn a + ON a.ResumeTemplateInfoGroupID = @ID + AND a.IsEnable = 1 + AND a.ResumeInfoColumnID = b.ID + WHERE b.IsEnable = 1 AND b.ResumeInfoGroupId = @ResumeInfoGroupId + ORDER BY a.SortNo"; + + var entitys = await Db.Ado.SqlQueryAsync(sql); + + return ServiceResult>.OprateSuccess("查询成功!", entitys); + + } + #endregion } \ No newline at end of file