From 0e8a7e940569014e33038c4a67b9700b25a276b9 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 14 Aug 2024 15:15:54 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=90=9C=E7=B4=A2=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Organization/Request/GainfoPageRequest.cs | 2 ++ .../Organization/Services/Implements/GainfoService.cs | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) 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)