diff --git a/Src/Dlhis.Basic/JinkoSapHttpClientPack.cs b/Src/Dlhis.Basic/JinkoSapHttpClientPack.cs index 8ef2a9a1..1ffa8c86 100644 --- a/Src/Dlhis.Basic/JinkoSapHttpClientPack.cs +++ b/Src/Dlhis.Basic/JinkoSapHttpClientPack.cs @@ -10,7 +10,7 @@ public class JinkoSapHttpClientPack : BaseAppPack { services.AddHttpClient("jinko:sap", (_, httpClient) => { - httpClient.BaseAddress = new Uri($"http://sappipap01.jinkosolar.cn:50100"); + httpClient.BaseAddress = new Uri("http://sappipap01.jinkosolar.cn:50100"); httpClient.Timeout = TimeSpan.FromMinutes(10); const string credentials = "EHS_USER:y3R1hd2h*RICAC"; diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs index 69cef6c5..fff6f9c5 100644 --- a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs +++ b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs @@ -22,8 +22,11 @@ public class GainfoPageRequest : PageDto, IValidatableObject /// 查询类型 GainfoSearchEnumType /// [EnumDataType(typeof(GainfoSearchEnumType))] - public GainfoSearchEnumType SearchType { get; set; } - + public GainfoSearchEnumType? SearchType { get; set; } + + /// + /// 无条件查询所有 + /// public bool IsSearchAll { get; set; } public IEnumerable Validate(ValidationContext validationContext) @@ -38,6 +41,11 @@ public class GainfoPageRequest : PageDto, IValidatableObject }); + if (SearchType == GainfoSearchEnumType.BusinessTrip) + { + SearchType = null; + } + yield break; } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoOutSourceExternalInfoResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoOutSourceExternalInfoResponse.cs index b6c7341f..7076a426 100644 --- a/Src/Dlhis.Basic/Organization/Response/GainfoOutSourceExternalInfoResponse.cs +++ b/Src/Dlhis.Basic/Organization/Response/GainfoOutSourceExternalInfoResponse.cs @@ -7,9 +7,9 @@ namespace Dlhis.Basic.Organization.Response; public class GainfoOutSourceExternalInfoResponse : GainfoOutSourceExternalInfoDto { /// - /// 姓名 + /// 对接人姓名 /// - public string Name { get; set; } + public string SapName { get; set; } /// /// 入职日期 diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoFaceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoFaceService.cs index d52e8d76..bcbdf0d2 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoFaceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoFaceService.cs @@ -106,11 +106,7 @@ public class GainfoFaceService : IGainfoFaceService //ignore } - var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.External) - .Where(x => x.IdNo == request.UserNo) - .SingleAsync(); - - gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.Working) + var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working) .Where(x => x.IdNo == request.UserNo) .SingleAsync(); @@ -272,8 +268,6 @@ public class GainfoFaceService : IGainfoFaceService foreach (var request in requests) { var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Code == request.UserNo).FirstAsync(); - gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.External).Where(x => x.Code == request.UserNo).FirstAsync(); - gainfo.ThrowIfNull("人员档案信息不存在"); var face = await _faceDbContext.Queryable().Where(x => x.UserCode == gainfo.Code).SingleAsync(); diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs index c5343ebb..caf17fd3 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs @@ -103,7 +103,7 @@ public class GainfoOutsourceService : IGainfoOutsourceService Supplier = a.Supplier, SapCode = a.SapCode, SapPhone = a.SapPhone, - Name = c.Name, + SapName = c.Name, EntryDate = b.EntryDate, ResignationDate = b.ResignationDate, Factory = b.Factory diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index af06ba7f..5fdcdaf1 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -70,10 +70,6 @@ public class GainfoService : IGainfoService var where = LinqExpressionExtensions.False(); var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList(); - var role = _currentUser.GetRole(); - var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty; - var isAll = role is "admin" or "tenant-admin"; - if (request.DepartmentSelections.Any()) { foreach (var item in request.DepartmentSelections) @@ -91,6 +87,20 @@ public class GainfoService : IGainfoService where = where.Or(gainfo => factories.Contains(gainfo.Factory)); } + if (request.SearchType.HasValue) + { + GainfoUserTypeEnumType userTypeEnumType = request.SearchType switch + { + GainfoSearchEnumType.Internal => GainfoUserTypeEnumType.Normal, + GainfoSearchEnumType.Outsource => GainfoUserTypeEnumType.Outsource, + GainfoSearchEnumType.BusinessTrip => throw new ArgumentNullException(request.SearchType?.ToString()), + GainfoSearchEnumType.External => GainfoUserTypeEnumType.External, + null => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()), + _ => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()) + }; + where = where.And(x => x.Type == userTypeEnumType); + } + if (request.IsSearchAll) { @@ -122,19 +132,12 @@ public class GainfoService : IGainfoService CardTypeName = type.Display }, true) : _gainfoStore.Queryable(request.Status) - .WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == true, where) .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) .LeftJoin((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod") - .WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory)) - .WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code).NotAny()) - .WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => - SqlFunc.Subqueryable() - .Where(p => p.Code == gainfo.Code) - .WhereIF(!isAll, p => p.SapCode == jinkoCode) - .Any() - ) - .WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo => - SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)).Any()) + .WhereIF(request.SearchType.HasValue == false, gainfo => SqlFunc.Subqueryable() + .Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)) + .Any()) + .WhereIF(request.SearchType.HasValue, where) .WhereIF(request.Search.IsPresent(), gainfo => gainfo.Name.Contains(request.Search) || gainfo.Code == request.Search diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs index f84fdd28..d08f732a 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs @@ -30,11 +30,6 @@ public class GainfoStore : IGainfoStore return _dbContext.Queryable(); } - if (gainfoStatus == GainfoStatusEnumType.External) - { - return _dbContext.Queryable().Where(x => x.Type == GainfoUserTypeEnumType.External); - } - var tableName = typeof(GainfoEntity).GetCustomAttribute()!.TableName; return _dbContext.Queryable().AS(tableName + gainfoStatus); } diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs index b5c60de7..2306e371 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs @@ -364,7 +364,7 @@ public class GainfoUpdateService : IGainfoUpdateService return sapList; } - var needRemove = sapList.Intersect(last, new SapPersonComparer()).ToList(); + var needRemove = sapList.Intersect(last, new SapPersonComparer()); return sapList.Except(needRemove, new SapPersonComparer()).ToList(); } diff --git a/Src/Dlhis.Entity/Basic/Enums/GainfoSearchEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/GainfoSearchEnumType.cs index df1d90d5..35932419 100644 --- a/Src/Dlhis.Entity/Basic/Enums/GainfoSearchEnumType.cs +++ b/Src/Dlhis.Entity/Basic/Enums/GainfoSearchEnumType.cs @@ -21,5 +21,12 @@ public enum GainfoSearchEnumType /// 出差人员 /// [Description("出差人员")] - BusinessTrip = 3 + BusinessTrip = 3, + + + /// + /// 外部人员 + /// + [Description("外部人员")] + External = 4 } \ No newline at end of file diff --git a/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs index 517140ea..7745368d 100644 --- a/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs +++ b/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs @@ -18,11 +18,5 @@ public enum GainfoStatusEnumType /// 离职 /// [Description("离职")] - Leave = 2, - - /// - /// 外部 - /// - [Description("外部")] - External = 3 + Leave = 2 }