From d2d07a0d7458ca8f77661dce2f488ad0e3e86702 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 8 Jan 2025 18:36:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A4=96=E5=8C=85=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=83=A8=E9=97=A8=E5=92=8C=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/GainfoService.cs | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 301a80ab..f1159b25 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -89,7 +89,7 @@ public class GainfoService : IGainfoService if (request.SearchType.HasValue) { - GainfoUserTypeEnumType userTypeEnumType = request.SearchType switch + GainfoUserTypeEnumType userType = request.SearchType switch { GainfoSearchEnumType.Internal => GainfoUserTypeEnumType.Normal, GainfoSearchEnumType.Outsource => GainfoUserTypeEnumType.Outsource, @@ -98,27 +98,12 @@ public class GainfoService : IGainfoService null => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()), _ => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()) }; - where = where.And(gainfo => gainfo.Type == userTypeEnumType); + + where = where.And(gainfo => gainfo.Type == userType); } - - if (request.IsSearchAll) - { - where = Expressionable.Create() - .And(where) - .Or(gainfo => SqlFunc.Subqueryable() - .Where(p => p.Code == gainfo.Code - && factories.Contains(p.Destination) - && SqlFunc.DateIsSame(p.BeginDate, today)) - .Any() - ) - .ToExpression(); - } - - ISugarQueryable queryable = request.IsSearchAll ? _dbContext.Queryable().AS("GainfoEntity", "gainfo") - .Where(where) .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) .WhereIF(request.Search.IsPresent(), gainfo => gainfo.Name == request.Search @@ -127,18 +112,24 @@ public class GainfoService : IGainfoService .Select((gainfo, department) => new GainfoPageResponse { DepartmentName = department.Name, - CardType = gainfo.CardType, + CardType = gainfo.CardType }, true) : _gainfoStore.Queryable(request.Status) - .WhereIF(request.SearchType.HasValue == true, where) + .WhereIF(request.SearchType.HasValue, where) .LeftJoin((gainfo, department) => gainfo.DepartmentNo == department.No) .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) + .WhereIF(request.Search.IsPresent() && request.SearchType != GainfoSearchEnumType.Outsource, gainfo => + gainfo.Code == request.Search + || gainfo.IdNo == request.Search + || gainfo.Name.Contains(request.Search)) + .WhereIF(request.Search.IsPresent() && request.SearchType == GainfoSearchEnumType.Outsource, gainfo => + gainfo.Code == request.Search + || gainfo.IdNo == request.Search + || gainfo.Name.Contains(request.Search) + || gainfo.Remark.Contains(request.Search) + || SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code && p.Supplier.Contains(request.Search)).Any()) .OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排 .Select((gainfo, department) => new GainfoPageResponse {