fix 提醒厂区不匹配的人员
This commit is contained in:
@@ -76,11 +76,21 @@ public class WorkGridService : IWorkGridService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task SaveAsync(List<WorkGridSaveRequest> requests)
|
public async Task SaveAsync(List<WorkGridSaveRequest> requests)
|
||||||
{
|
{
|
||||||
|
var factory = _currentUser.GetStringTenantId();
|
||||||
|
|
||||||
var insertGrids = new List<string>();
|
var insertGrids = new List<string>();
|
||||||
var updateGrids = new List<string>();
|
var updateGrids = new List<string>();
|
||||||
|
|
||||||
var leaderUserCodes = requests.Select(x => x.LeaderUserCode).Distinct().ToList();
|
var leaderUserCodes = requests.Select(x => x.LeaderUserCode).Distinct().ToList();
|
||||||
var existsUserCodes = await _dbContext.Queryable<GainfoEntity>().Where(x => leaderUserCodes.Contains(x.Code)).Select(x => x.Code).ToListAsync();
|
var existsUserInfos = await _dbContext.Queryable<GainfoEntity>()
|
||||||
|
.Where(x => leaderUserCodes.Contains(x.Code))
|
||||||
|
.Select(x => new { x.Code, x.Factory })
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var excludeCodes = existsUserInfos.Where(x => x.Factory != factory).Select(x => x.Code).ToList();
|
||||||
|
excludeCodes.ThrowIfExists($"工号:{excludeCodes.Join(",")}不属于当前厂区");
|
||||||
|
|
||||||
|
var existsUserCodes = existsUserInfos.Select(x => x.Code).ToList();
|
||||||
var notExistsUserCodes = leaderUserCodes.Except(existsUserCodes).ToList();
|
var notExistsUserCodes = leaderUserCodes.Except(existsUserCodes).ToList();
|
||||||
notExistsUserCodes.ThrowIfExists($"工号:{notExistsUserCodes.Join(",")}不存在");
|
notExistsUserCodes.ThrowIfExists($"工号:{notExistsUserCodes.Join(",")}不存在");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user