diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs index 899a8369..162af652 100644 --- a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs +++ b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs @@ -24,6 +24,8 @@ public class GainfoPageRequest : PageDto, IValidatableObject [EnumDataType(typeof(GainfoSearchEnumType))] public GainfoSearchEnumType SearchType { get; set; } + public bool IsSearchAll { get; set; } + public IEnumerable Validate(ValidationContext validationContext) { DepartmentSelections.ForEach(d => diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 0b881111..6bdda56c 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -82,10 +82,11 @@ public class GainfoService : IGainfoService .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).Any()) - .WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo => + .WhereIF(request.IsSearchAll && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory)) + .WhereIF(!request.IsSearchAll && request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory)) + .WhereIF(!request.IsSearchAll && request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code).NotAny()) + .WhereIF(!request.IsSearchAll && request.SearchType == GainfoSearchEnumType.Outsource, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code).Any()) + .WhereIF(!request.IsSearchAll && 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.Search.IsPresent(), gainfo => gainfo.Name.Contains(request.Search)