feat 出差人员筛选,移除无用代码

This commit is contained in:
2024-07-04 17:53:53 +08:00
parent 218027ffd4
commit cae9035e4a
12 changed files with 52 additions and 104 deletions

View File

@@ -4,6 +4,7 @@ using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Device.Enums;
using Dlhis.Entity.Visitor.Entity;
using Dlhis.Scheduled.Api;
using Dlhis.Scheduled.Api.Request;
using Dlhis.Sys.Api;
@@ -57,8 +58,6 @@ public class GainfoService : IGainfoService
/// <returns></returns>
public async Task<Pagination<GainfoPageResponse>> GetPageAsync(GainfoPageRequest request)
{
var currentTenantId = _currentUser.GetStringTenantId();
//根据组织架构搜索档案
var where = LinqExpressionExtensions.False<GainfoEntity>();
foreach (var item in request.DepartmentSelections)
@@ -69,11 +68,16 @@ public class GainfoService : IGainfoService
: where.Or(gainfo => gainfo.Factory == item.Tenant);
}
//获取所有厂区
var factories = request.DepartmentSelections.Select(x => x.Tenant);
var today = DateTime.Today;
var page = await _gainfoStore.Queryable(request.Status)
.WhereIF(request.DepartmentSelections?.Any() == true, where)
.WhereIF(request.DepartmentSelections?.Any() != true, gainfo => gainfo.Factory == currentTenantId)
.WhereIF(request.IsOutsource.HasValue && request.IsOutsource.Value, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(x => x.Code == gainfo.Code).Any())
.WhereIF(request.IsOutsource.HasValue && !request.IsOutsource.Value, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(x => x.Code == gainfo.Code).NotAny())
.WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == true, where)
.WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(x => x.Code == gainfo.Code).NotAny())
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(x => x.Code == gainfo.Code).Any())
.WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo =>
SqlFunc.Subqueryable<BusinessTripEntity>().Where(x => x.Code == gainfo.Code && factories.Contains(x.Destination) && SqlFunc.DateIsSame(x.BeginDate, today)).Any())
.WhereIF(request.Search.IsPresent(), gainfo =>
gainfo.Name.Contains(request.Search)
|| gainfo.Code == request.Search