From d26cee116654afc71a1981843651cd6ca125e032 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 14 Aug 2024 15:20:24 +0800 Subject: [PATCH] fix search --- .../Organization/Services/Implements/GainfoService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 6bdda56c..57065f80 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -79,10 +79,13 @@ public class GainfoService : IGainfoService var today = DateTime.Today; var query = _gainfoStore.Queryable(request.Status) - .WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == true, where) + .WhereIF(!request.IsSearchAll && request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == true, where) + .WhereIF(request.IsSearchAll && 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.IsSearchAll && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory)) + .WhereIF(request.IsSearchAll, gainfo => + SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)).Any()) .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())