fix 优化档案查询
This commit is contained in:
@@ -4,19 +4,17 @@ using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Scope;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Options;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
@@ -57,10 +55,22 @@ public class GainfoService : IGainfoService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<GainfoPageResponse>> GetPageAsync(GainfoPageRequest request)
|
||||
{
|
||||
request.DepartmentNos = await GetRecursionDepartmentNosAsync(request.DepartmentNos);
|
||||
var currentTenantId = _currentUser.GetStringTenantId();
|
||||
|
||||
//根据组织架构搜索档案
|
||||
Expression<Func<GainfoEntity, bool>> where = LinqExpressionExtension.False<GainfoEntity>();
|
||||
foreach (var item in request.DepartmentSelections)
|
||||
{
|
||||
var depts = await GetRecursionDepartmentNosAsync(item.DepartmentNos);
|
||||
if (depts.Any())
|
||||
where = where.Or(gainfo => gainfo.Factory == item.Tenant && depts.Contains(gainfo.DepartmentNo));
|
||||
else
|
||||
where = where.Or(gainfo => gainfo.Factory == item.Tenant);
|
||||
}
|
||||
|
||||
var page = await _gainfoStore.Queryable(request.Status)
|
||||
.WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
|
||||
.WhereIF(request.DepartmentSelections.IsPresent(), where)
|
||||
.WhereIF(request.DepartmentSelections.IsEmpty(), gainfo => gainfo.Factory == currentTenantId)
|
||||
.WhereIF(request.Search.IsPresent(), gainfo =>
|
||||
gainfo.Name.Contains(request.Search)
|
||||
|| gainfo.Code.Contains(request.Search)
|
||||
@@ -574,13 +584,10 @@ public class GainfoService : IGainfoService
|
||||
void RecursionGetNext(string currentCode, List<DepartmentEntity> departments, List<string> result)
|
||||
{
|
||||
var next = departments.Where(x => x.PNo == currentCode).ToList();
|
||||
foreach (var item in next)
|
||||
{
|
||||
result.Add(item.No);
|
||||
}
|
||||
|
||||
foreach (var item in next)
|
||||
{
|
||||
result.Add(item.No);
|
||||
RecursionGetNext(item.No, departments, result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user