diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 5fdcdaf1..2093245e 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -131,24 +131,43 @@ public class GainfoService : IGainfoService CardType = gainfo.CardType, CardTypeName = type.Display }, true) - : _gainfoStore.Queryable(request.Status) - .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) - .LeftJoin((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod") - .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 - || gainfo.IdNo == request.Search) - .OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排 - .Select((gainfo, department, type) => new GainfoPageResponse - { - DepartmentName = department.Name, - CardType = gainfo.CardType, - CardTypeName = type.Display - }, true); + : request.Status == GainfoStatusEnumType.Working + ? _dbContext.Queryable() + .WhereIF(request.SearchType.HasValue, where) + .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) + .LeftJoin((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod") + .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.Search.IsPresent(), gainfo => + gainfo.Name.Contains(request.Search) + || gainfo.Code == request.Search + || gainfo.IdNo == request.Search) + .OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排 + .Select((gainfo, department, type) => new GainfoPageResponse + { + DepartmentName = department.Name, + CardType = gainfo.CardType, + CardTypeName = type.Display + }, true) + : _dbContext.Queryable().AS("GainfoLeave") + .WhereIF(request.SearchType.HasValue, where) + .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) + .LeftJoin((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod") + .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.Search.IsPresent(), gainfo => + gainfo.Name.Contains(request.Search) + || gainfo.Code == request.Search + || gainfo.IdNo == request.Search) + .OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排 + .Select((gainfo, department, type) => new GainfoPageResponse + { + DepartmentName = department.Name, + CardType = gainfo.CardType, + CardTypeName = type.Display + }, true); var page = await queryable.ToPageListAsync(request); diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs index d08f732a..ebcfdc0a 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs @@ -25,10 +25,7 @@ public class GainfoStore : IGainfoStore /// public ISugarQueryable Queryable(GainfoStatusEnumType? gainfoStatus) { - if (gainfoStatus is null or GainfoStatusEnumType.Working) - { - return _dbContext.Queryable(); - } + gainfoStatus ??= GainfoStatusEnumType.Working; var tableName = typeof(GainfoEntity).GetCustomAttribute()!.TableName; return _dbContext.Queryable().AS(tableName + gainfoStatus);