fix 离职就餐人员查询优化

This commit is contained in:
2024-07-11 10:46:22 +08:00
parent fb40af4f1f
commit 42ed53cdaa

View File

@@ -38,7 +38,7 @@ public class GainfoMealService : IGainfoMealService
|| gainfo.Name.Contains(request.Search)
|| gainfoLeave.Name.Contains(request.Search))
.Where((meal, gainfo, gainfoLeave) => gainfo.Factory == tenantId || gainfoLeave.Factory == tenantId)
.WhereIF(request.IsLeave, (meal, gainfo, gainfoLeave) => SqlFunc.IsNullOrEmpty(gainfo.No))
.WhereIF(request.IsLeave, (meal, gainfo, gainfoLeave) => SqlFunc.Subqueryable<GainfoLeaveEntity>().Where(x => x.Code == meal.UserCode).Any())
.Select((meal, gainfo, gainfoLeave, dept1, dept2) => new GainfoMealResponse
{
Balance = meal.Balance,
@@ -122,7 +122,7 @@ public class GainfoMealService : IGainfoMealService
.SetColumns(x => x.Version == x.Version + 1)
.Where(x => x.UserCode == request.BeforeCode) //不需要判断version
.ExecuteCommandAsync();
//转移到现有人员
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == request.NowCode).SingleAsync();
gainfo.ThrowIfNull("目标人员不存在");