From 4f1a9bf3506904a1955b7d01dfd57a3c359771e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A4=E5=85=B0?= Date: Tue, 6 May 2025 14:04:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BE=A4=E7=BB=84=E5=B8=A6=E5=87=BA?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghra/Ghra_StaffGroupController.cs | 4 +- Tiobon.Core.Api/Tiobon.Core.xml | 2 +- .../Ghra/IGhra_StaffGroupServices.cs | 1 + .../Models/Ghra/Ghra_StaffGroupDetail.cs | 2 +- .../Ghra/Ghra_StaffGroupServices.cs | 115 +++++++++++++++++- 5 files changed, 119 insertions(+), 5 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs index b4819bfd..9d5c4e11 100644 --- a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs +++ b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs @@ -17,5 +17,7 @@ public class Ghra_StaffGroupController : BaseController /// [HttpPost, Route("GetStaffInfoColumnData")] - public async Task> GetStaffInfoColumnData(string Stage) => await _service.GetStaffInfoColumnData(); + public async Task> GetStaffInfoColumnData() => await _service.GetStaffInfoColumnData(); + [HttpPost, Route("GetStaffGroupInfoByID/{Id}")] + public async Task>> GetStaffGroupInfoByID(long Id, string BaseDate) => await _service.GetStaffGroupInfoByID(Id,BaseDate); } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 752767ce..a1409683 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -688,7 +688,7 @@ 人员群组(Controller) - + 获取配置 diff --git a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs index a567b2ba..f01ed104 100644 --- a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs +++ b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs @@ -10,5 +10,6 @@ namespace Tiobon.Core.IServices public interface IGhra_StaffGroupServices :IBaseServices { Task> GetStaffInfoColumnData(); + Task>> GetStaffGroupInfoByID(long Id, string BaseDate); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/Models/Ghra/Ghra_StaffGroupDetail.cs b/Tiobon.Core.Model/Models/Ghra/Ghra_StaffGroupDetail.cs index 8da0322d..da3fa793 100644 --- a/Tiobon.Core.Model/Models/Ghra/Ghra_StaffGroupDetail.cs +++ b/Tiobon.Core.Model/Models/Ghra/Ghra_StaffGroupDetail.cs @@ -49,7 +49,7 @@ namespace Tiobon.Core.Model.Models /// 字段所选值 /// [Display(Name = "FieldValue"), Description("字段所选值"), MaxLength(-1, ErrorMessage = "字段所选值 不能超过 -1 个字符")] - public object FieldValue { get; set; } + public object FieldValue { get; set; } /// /// 备注 diff --git a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs index 9b9659e9..2e83c39c 100644 --- a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs +++ b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs @@ -8,6 +8,12 @@ using System.Collections.Generic; using MySqlX.XDevAPI.Relational; using Microsoft.EntityFrameworkCore.Metadata.Internal; using NPOI.POIFS.NIO; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; +using MySqlX.XDevAPI.Common; +using System.Text; +using Microsoft.AspNetCore.Identity; +using System.Linq; +using Amazon.Runtime.Internal.Transform; namespace Tiobon.Core.Services { @@ -141,11 +147,115 @@ namespace Tiobon.Core.Services }); return ServiceResult.OprateSuccess("查询成功!", result); } - + + public async Task>> GetStaffGroupInfoByID(long Id,string BaseDate) + { + string LangID = App.User.GetLangId().ToString(); + if (LangID == "0") LangID = "1"; + string sql = @$"select case when Operator not in ('IsNull','NotNull') then iif(IsChangeColumn = 1,'b.','a.')+StaffField + + case when Operator = 'Equal' + then ' = '+' '''+ISNULL(FieldValue,'')+''' ' + when Operator = 'NotEqual' + then ' != '+' '''+ISNULL(FieldValue,'')+''' ' + when Operator = 'Include' + then ' like '+' ''%'+ISNULL(FieldValue,'')+'%'' ' + when Operator = 'NotInclude' + then ' not like ' +' ''%'+ISNULL(FieldValue,'')+'%'' ' + when Operator = 'EqualAny' and ISJSON(FieldValue) =1 + then ' in '+'(select value from openjson('''+ISNULL(FieldValue,'')+'''))' + when Operator = 'NotEqualAny' and ISJSON(FieldValue) =1 + then ' not in ' +'(select value from openjson('''+ISNULL(FieldValue,'')+'''))' + when Operator = 'Greater' + then ' > ' +' '''+ISNULL(FieldValue,'')+''' ' + when Operator = 'GreaterOrEqual' + then ' >= ' +' '''+ISNULL(FieldValue,'')+''' ' + when Operator = 'Less' + then ' < ' +' '''+ISNULL(FieldValue,'')+''' ' + when Operator = 'LessOrEqual' + then ' <= ' +' '''+ISNULL(FieldValue,'')+''' ' + end + else + ISNULL('+StaffField+','') + iif(IsChangeColumn = 1,'b.','a.')+ + case when Operator = 'IsNull' + then ' = '''' ' + when Operator = 'NotNull' + then ' != '''' ' + end + end WhereStr, + case when b.DataSourceType='ParaDetailNo' then + '(select dbo.FLangKeyToValue(MKey,'+ convert(nvarchar(10), {LangID})+',ParaDetailName) from Ghrs_ParaDetail kk where kk.ParaMasterId='+b.DataSource+' and IsEnable=1 and ParaDetailNo=a.'+b.ColumnName+') ' + when b.DataSourceType='ParaDetail' then + '(select dbo.FLangKeyToValue(MKey,'+ convert(nvarchar(10), {LangID})+',ParaDetailName) from Ghrs_ParaDetail kk where kk.ParaDetailId=a.'+b.ColumnName+') ' + when b.DataSourceType='OrgTreeWithoutPriv' then + '(select dbo.FS_CommonLangName(''Ghro_Dept'',kk.DeptID, kk.DeptName,'+convert(nvarchar(100),{LangID})+') from Ghro_Dept kk where kk.DeptID=a.'+b.ColumnName+') ' + when b.DataSourceType='OrgTreeWithPriv' then + '(select dbo.FS_CommonLangName(''Ghro_Dept'',kk.DeptID, kk.DeptName,'+convert(nvarchar(100),{LangID})+') from Ghro_Dept kk where kk.DeptID=a.'+b.ColumnName+') ' + when b.DataSourceType='StaffWithoutPriv' and b.ColumnName!='StaffID' then + '(select [dbo].[FA_StaffLangName](kk.StaffID,kk.StaffName,kk.StaffEname,'+ convert(nvarchar(10), {LangID})+') StaffName from Ghra_Staff kk where kk.StaffID=a.'+b.ColumnName+') ' + when b.DataSourceType='StaffWithPriv' and b.ColumnName!='StaffID' then + '(select [dbo].[FA_StaffLangName](kk.StaffID,kk.StaffName,kk.StaffEname,'+ convert(nvarchar(10), {LangID})+') StaffName from Ghra_Staff kk where kk.StaffID=a.'+b.ColumnName+') ' + when b.ColumnType in ('Switch','CheckBox') then '(select convert(nvarchar(10), iif(convert(nvarchar(100),a.'+b.ColumnName+') in (''1'',''true''),'''+[dbo].[FLangKeyToValue]('GHR_Common_000195',{LangID},'是' )+''','''+[dbo].[FLangKeyToValue]('GHR_Common_000196',{LangID},'否' )+''') ) )' + when b.DataSourceType='CommonList' then + '('+ (select replace(replace(SqlIDToName,'{{@LangID}}',Convert(nvarchar(10),{LangID})),'{{@KeyWords}}','a.'+b.ColumnName) from Ghrs_ListCommonSql where ListCommonSqlID=b.DataSource )+') ' + else '' end + + b.ColumnName SqlStr + ,ColumnName ColumnNo + ,dbo.FLangKeyToValue(MKey,{LangID},StaffInfoColumnName) ColumnName + ,b.SortNo + from Ghra_StaffGroupDetail a inner join Ghra_StaffInfoColumn b on a.StaffField=b.StaffInfoColumnNo + where a.IsEnable = 1 + and b.IsEnable = 1 + and b.StaffInfoGroupId = 1 + and b.IsRelease = 1 + and StaffGroupID = '{Id}' + order by b.SortNo"; + + DataTable dt = await Db.Ado.GetDataTableAsync(sql); + string WhereSQL = string.Empty; + string SqlStr = string.Empty; + + List staffInfoColumns = new List(); + staffInfoColumns.Add(new StaffInfoColumn() { StaffInfoColumnNo = "StaffID", StaffInfoColumnName = "ID",isHidden=true }); + staffInfoColumns.Add(new StaffInfoColumn() { StaffInfoColumnNo = "StaffNo", StaffInfoColumnName = "工号" }); + staffInfoColumns.Add(new StaffInfoColumn() { StaffInfoColumnNo = "StaffName", StaffInfoColumnName = "姓名" }); + staffInfoColumns.Add(new StaffInfoColumn() { StaffInfoColumnNo = "DeptFullPateName", StaffInfoColumnName = "全部门" }); + foreach (DataRow dr in dt.Rows) + { + WhereSQL += " and "+dr["WhereStr"].ToString(); + + StaffInfoColumn staffInfo = new StaffInfoColumn(); + staffInfo.StaffInfoColumnNo = dr["ColumnNo"].ToString(); + staffInfo.StaffInfoColumnName = dr["ColumnName"].ToString(); + +; if ( !staffInfoColumns.Any(x => x.StaffInfoColumnNo == dr["ColumnNo"].ToString())) + { + staffInfoColumns.Add(staffInfo); + SqlStr += ","+dr["SqlStr"].ToString()+ $" [{dr["ColumnNo"].ToString()}] "; + } + } + + string StaffSql = @$"select a.StaffID,a.StaffNo,a.StaffName, + dbo.FA_StaffInfoRepItemStaffInfo(a.StaffID,null,{LangID},'DeptFullPateName') DeptFullPateName + from Ghra_Staff a inner join (select * from Ghra_StaffChange where IsEnable=1 and ChangeDate= [dbo].[FLatestStaffChangeDate](StaffID,{(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")}) )b + on a.StaffID = b.StaffID + where a.IsEnable=1 + and a.InDate <= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} + and (a.OutDate is null or a.OutDate>= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} ) " + + WhereSQL; + + DataTable staffTable = await Db.Ado.GetDataTableAsync(StaffSql); + Dictionary result = new Dictionary() + { + ["TableColumns"] = staffInfoColumns, + ["TableData"] = staffTable + }; + return ServiceResult>.OprateSuccess("查询成功!", result); + } public class StaffInfoColumn() { public string StaffInfoColumnNo { get; set; } public string StaffInfoColumnName { get; set; } + public bool isHidden { get; set; } = false; public string elementType { get; set; } public string dataType { get; set; } public string dataSourceType { get; set; } @@ -161,7 +271,8 @@ namespace Tiobon.Core.Services public string ParaDetailName { get; set; } public string operatorIcon { get; set; } public string SortNo { get; set; } - } + } + } From 9a0a87f326044145922c00e37ce5d0c68c25a84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A4=E5=85=B0?= Date: Tue, 6 May 2025 14:48:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BE=A4=E7=BB=84=E4=BD=9C=E5=BA=9F?= =?UTF-8?q?=E6=97=B6=E5=90=8C=E6=AD=A5=E4=BD=9C=E5=BA=9F=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghra/Ghra_StaffGroupController.cs | 6 ++-- .../Ghra/IGhra_StaffGroupServices.cs | 5 +-- .../Ghra/Ghra_StaffGroupServices.cs | 32 ++++++++++++++++--- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs index 9d5c4e11..6b3e8192 100644 --- a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs +++ b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using Newtonsoft.Json.Linq; + +namespace Tiobon.Core.Api.Controllers; /// /// 人员群组(Controller) @@ -19,5 +21,5 @@ public class Ghra_StaffGroupController : BaseController> GetStaffInfoColumnData() => await _service.GetStaffInfoColumnData(); [HttpPost, Route("GetStaffGroupInfoByID/{Id}")] - public async Task>> GetStaffGroupInfoByID(long Id, string BaseDate) => await _service.GetStaffGroupInfoByID(Id,BaseDate); + public async Task>> GetStaffGroupInfoByID(long Id, [FromBody] JObject FBody) => await _service.GetStaffGroupInfoByID(Id, FBody); } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs index f01ed104..bddd0c9d 100644 --- a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs +++ b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs @@ -1,4 +1,5 @@ -using Tiobon.Core.IServices.BASE; +using Newtonsoft.Json.Linq; +using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; using Tiobon.Core.Model.Models; @@ -10,6 +11,6 @@ namespace Tiobon.Core.IServices public interface IGhra_StaffGroupServices :IBaseServices { Task> GetStaffInfoColumnData(); - Task>> GetStaffGroupInfoByID(long Id, string BaseDate); + Task>> GetStaffGroupInfoByID(long Id, JObject FBody); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs index 2e83c39c..08dc3b38 100644 --- a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs +++ b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs @@ -51,6 +51,7 @@ namespace Tiobon.Core.Services public override async Task Update(long Id, EditGhra_StaffGroupInput editModel) { await _StaffGroupDetailServices.Delete(x => x.StaffGroupID == Id); + editModel.StaffGroupDetail.ForEach(x => { x.StaffGroupID = Id; @@ -59,6 +60,25 @@ namespace Tiobon.Core.Services return await base.Update(Id, editModel); } + public override async Task DeleteById1(object id) + { + var entity = await BaseDal.QueryById(id); + BasePoco ent = entity as BasePoco; + ent.IsEnable = 0; + HttpRequest request = UserContext.Context.Request; + var api = request.Path.ObjToString().TrimEnd('/').ToLower(); + var ip = GetUserIp(UserContext.Context); + string sql = @$"update Ghra_StaffGroupDetail + set IsEnable=0, + UpdateBy={App.User.ID.ToString()}, + UpdateIP={ip}, + UpdateProg={api}, + UpdateTime=GETDATE() + where StaffGroupID={id.ToString()} + and IsEnable= 1"; + + return await BaseDal.Update(entity); + } public override async Task> QueryForm(QueryForm body) { @@ -148,9 +168,10 @@ namespace Tiobon.Core.Services return ServiceResult.OprateSuccess("查询成功!", result); } - public async Task>> GetStaffGroupInfoByID(long Id,string BaseDate) + public async Task>> GetStaffGroupInfoByID(long Id,JObject FBody) { string LangID = App.User.GetLangId().ToString(); + string BaseDate = FBody["BaseDate"]?.Value() ?? DateTime.Now.ToString("yyyy-MM-dd"); if (LangID == "0") LangID = "1"; string sql = @$"select case when Operator not in ('IsNull','NotNull') then iif(IsChangeColumn = 1,'b.','a.')+StaffField + case when Operator = 'Equal' @@ -230,17 +251,18 @@ namespace Tiobon.Core.Services ; if ( !staffInfoColumns.Any(x => x.StaffInfoColumnNo == dr["ColumnNo"].ToString())) { staffInfoColumns.Add(staffInfo); - SqlStr += ","+dr["SqlStr"].ToString()+ $" [{dr["ColumnNo"].ToString()}] "; + SqlStr += ","+dr["SqlStr"].ToString(); } } string StaffSql = @$"select a.StaffID,a.StaffNo,a.StaffName, dbo.FA_StaffInfoRepItemStaffInfo(a.StaffID,null,{LangID},'DeptFullPateName') DeptFullPateName - from Ghra_Staff a inner join (select * from Ghra_StaffChange where IsEnable=1 and ChangeDate= [dbo].[FLatestStaffChangeDate](StaffID,{(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")}) )b + {SqlStr} + from Ghra_Staff a inner join (select * from Ghra_StaffChange where IsEnable=1 and ChangeDate= [dbo].[FLatestStaffChangeDate](StaffID,'{BaseDate}') )b on a.StaffID = b.StaffID where a.IsEnable=1 - and a.InDate <= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} - and (a.OutDate is null or a.OutDate>= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} ) " + and a.InDate <= '{BaseDate}' + and (a.OutDate is null or a.OutDate>= '{BaseDate}' ) " + WhereSQL; DataTable staffTable = await Db.Ado.GetDataTableAsync(StaffSql);