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 {