|
|
|
@ -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 |
|
|
|
|
{ |
|
|
|
@ -45,6 +51,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
public override async Task<bool> Update(long Id, EditGhra_StaffGroupInput editModel) |
|
|
|
|
{ |
|
|
|
|
await _StaffGroupDetailServices.Delete(x => x.StaffGroupID == Id); |
|
|
|
|
|
|
|
|
|
editModel.StaffGroupDetail.ForEach(x => |
|
|
|
|
{ |
|
|
|
|
x.StaffGroupID = Id; |
|
|
|
@ -53,6 +60,25 @@ namespace Tiobon.Core.Services |
|
|
|
|
|
|
|
|
|
return await base.Update(Id, editModel); |
|
|
|
|
} |
|
|
|
|
public override async Task<bool> 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<ServiceFormResult<Ghra_StaffGroupDto>> QueryForm(QueryForm body) |
|
|
|
|
{ |
|
|
|
@ -141,11 +167,117 @@ namespace Tiobon.Core.Services |
|
|
|
|
}); |
|
|
|
|
return ServiceResult<object>.OprateSuccess("查询成功!", result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id,JObject FBody) |
|
|
|
|
{ |
|
|
|
|
string LangID = App.User.GetLangId().ToString(); |
|
|
|
|
string BaseDate = FBody["BaseDate"]?.Value<string>() ?? 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' |
|
|
|
|
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<StaffInfoColumn> staffInfoColumns = new List<StaffInfoColumn>(); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string StaffSql = @$"select a.StaffID,a.StaffNo,a.StaffName,
|
|
|
|
|
dbo.FA_StaffInfoRepItemStaffInfo(a.StaffID,null,{LangID},'DeptFullPateName') DeptFullPateName |
|
|
|
|
{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 <= '{BaseDate}' |
|
|
|
|
and (a.OutDate is null or a.OutDate>= '{BaseDate}' ) "
|
|
|
|
|
+ WhereSQL; |
|
|
|
|
|
|
|
|
|
DataTable staffTable = await Db.Ado.GetDataTableAsync(StaffSql); |
|
|
|
|
Dictionary<string, object> result = new Dictionary<string, object>() |
|
|
|
|
{ |
|
|
|
|
["TableColumns"] = staffInfoColumns, |
|
|
|
|
["TableData"] = staffTable |
|
|
|
|
}; |
|
|
|
|
return ServiceResult<Dictionary<string, object>>.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 +293,8 @@ namespace Tiobon.Core.Services |
|
|
|
|
public string ParaDetailName { get; set; } |
|
|
|
|
public string operatorIcon { get; set; } |
|
|
|
|
public string SortNo { get; set; } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|