fix 消费明细支持多选营业点/餐补部门名称处理

This commit is contained in:
2024-09-24 22:53:25 +08:00
parent 17e494f5c8
commit 9775052ab2
4 changed files with 24 additions and 21 deletions

View File

@@ -78,6 +78,12 @@ public class MealSupplementRecordResponse
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 部门号
/// </summary>
public string DepartmentNo { get; set; }
/// <summary>
/// 部门名称
/// </summary>

View File

@@ -4,6 +4,7 @@ using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.Sys.Api;
using Dlhis.Sys.Api.Response;
using Kurisu.AspNetCore.Authentication.Abstractions;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
@@ -31,18 +32,18 @@ public class MealSupplementRecordService : IMealSupplementRecordService
{
var queryable = _dbContext.Queryable<MealSupplementRecordEntity>()
.LeftJoin<GainfoEntity>((x, ga) => x.Code == ga.Code)
.LeftJoin<DepartmentEntity>((x, ga, department) => ga.DepartmentNo == department.No)
.LeftJoin<GainfoLeaveEntity>((x, ga, gaLeave) => gaLeave.Code == x.Code)
.WhereIF(request.Status.HasValue, x => x.Status == request.Status)
.WhereIF(request.Sync.HasValue, x => x.Sync == request.Sync)
.WhereIF(request.Workplace.IsPresent(), x => x.Workplace == request.Workplace)
.WhereIF(request.Factory.IsPresent(), x => x.Factory == request.Factory)
.WhereIF(request.DepartmentNo.IsPresent(), (x, ga) => ga.DepartmentNo == request.DepartmentNo)
.WhereIF(request.DepartmentNo.IsPresent(), (x, ga, gaLeave) => ga.DepartmentNo == request.DepartmentNo || gaLeave.DepartmentNo == request.DepartmentNo)
.WhereIF(request.Werks.IsPresent(), (x, ga) => ga.Werks == request.Werks)
.WhereIF(request.DateTimePeriod.HasValue(), x => x.Date >= request.DateTimePeriod.Start && x.Date <= request.DateTimePeriod.End)
.WhereIF(request.Search.IsPresent(), (x, ga) => x.Code == request.Search || ga.Name == request.Search);
var page = await queryable
.Select((x, ga, department) => new MealSupplementRecordResponse
.Select((x, ga, gaLeave) => new MealSupplementRecordResponse
{
Amount = x.Amount,
Code = x.Code,
@@ -52,32 +53,37 @@ public class MealSupplementRecordService : IMealSupplementRecordService
Status = x.Status,
Sync = x.Sync,
UniqueId = x.UniqueId,
UserName = ga.Name,
UserName = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.Name), gaLeave.Name, ga.Name),
Workplace = x.Workplace,
DepartmentNo = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.DepartmentNo), gaLeave.DepartmentNo, ga.DepartmentNo),
Factory = x.Factory,
CreateTime = x.CreateTime,
DepartmentName = department.Name,
Werks = ga.Werks
})
.ToPageListAsync(request);
var departmentNos = page.Data.Select(x => x.DepartmentNo).Distinct().ToList();
var departmentInfos = await _dbContext.Queryable<DepartmentEntity>().Where(x => departmentNos.Contains(x.No)).Select(x => new { x.No, x.Name }).ToListAsync();
var tenants = new List<TenantResponse>();
try
{
var tenantsResult = await _tenantApi.GetTenantsInternalAsync();
var tenants = tenantsResult.Data;
page.Data.ForEach(item =>
{
item.Workplace = tenants.FirstOrDefault(x => x.Code == item.Workplace)?.Name;
item.Factory = tenants.FirstOrDefault(x => x.Code == item.Factory)?.Name;
});
tenants = tenantsResult.Data;
}
catch (Exception)
{
//ignore
}
page.Data.ForEach(item =>
{
item.Workplace = tenants.FirstOrDefault(x => x.Code == item.Workplace)?.Name;
item.Factory = tenants.FirstOrDefault(x => x.Code == item.Factory)?.Name;
item.DepartmentName = departmentInfos.FirstOrDefault(x => x.No == item.DepartmentNo)?.Name;
});
return new MealSupplementRecordSummaryResponse
{

View File

@@ -4,8 +4,4 @@ namespace Dlhis.Canteen.Order.Request;
public class BalanceRecordAnalysisRequest : SummaryCommonDto
{
/// <summary>
/// 营业点
/// </summary>
public Guid? BusinessPlaceCode { get; set; }
}

View File

@@ -26,11 +26,6 @@ public class BalanceSummaryService : IBalanceSummaryService
public async Task<BalanceRecordAnalysisSummaryResponse> BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request)
{
if (request.BusinessPlaceCode.HasValue)
{
request.BusinessPlaceCodes = new List<Guid> { request.BusinessPlaceCode.Value };
}
var queryable = GetQueryable(request);
var list = await queryable.ToListAsync();