fix 修复网格解散的情况
This commit is contained in:
@@ -17,6 +17,7 @@ using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.Cache;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using SqlSugar;
|
||||
@@ -72,7 +73,12 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
.Where(x => factories.Contains(x.TenantId))
|
||||
.Select(x => new
|
||||
{
|
||||
x.Type, x.Start, x.End, x.Before, x.After, x.TenantId
|
||||
x.Type,
|
||||
x.Start,
|
||||
x.End,
|
||||
x.Before,
|
||||
x.After,
|
||||
x.TenantId
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
@@ -83,11 +89,14 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
.Where(x => x.Date >= min && x.Date <= max && userCodes2.Contains(x.UserCode))
|
||||
.Select(x => new
|
||||
{
|
||||
x.UserCode, x.WorkGridCode, x.Date, x.PeriodType
|
||||
x.UserCode,
|
||||
x.WorkGridCode,
|
||||
x.Date,
|
||||
x.PeriodType
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var workGrids = await _dbContext.Queryable<WorkGridEntity>().ToListAsync();
|
||||
var workGrids = await GetAllWorkGridAsync();
|
||||
var workGridUsers = await _dbContext.Queryable<WorkGridUserEntity>().Where(x => userCodes2.Contains(x.UserCode)).ToListAsync();
|
||||
|
||||
var inserts = new List<DeviceUploadLogEntity>();
|
||||
@@ -132,13 +141,16 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
var currentWorkGridTimePeriods = workGridTimePeriods.Where(x => x.TenantId == device.TenantId).ToList();
|
||||
var currentWorkGridSchedules = workGridSchedules.Where(x => x.UserCode == request.UserUniqueNo).ToList();
|
||||
var currentWorkGridUser = workGridUsers.FirstOrDefault(x => x.UserCode == request.UserUniqueNo); //可能被删除,但还存在当天的排班
|
||||
|
||||
if (needUpload && currentWorkGridTimePeriods.Any() && (currentWorkGridUser != null || currentWorkGridSchedules.Any()))
|
||||
{
|
||||
workGridInfo.TimeSetting = currentWorkGridTimePeriods.Select(x => new
|
||||
{
|
||||
Type = x.Type.GetDescription(),
|
||||
x.Before, x.Start,
|
||||
x.End, x.After,
|
||||
x.Before,
|
||||
x.Start,
|
||||
x.End,
|
||||
x.After,
|
||||
x.TenantId
|
||||
}).ToList();
|
||||
|
||||
@@ -279,6 +291,19 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
await _dbContext.InsertAsync(inserts);
|
||||
}
|
||||
|
||||
private async Task<List<WorkGridEntity>> GetAllWorkGridAsync()
|
||||
{
|
||||
_dbContext.Client.QueryFilter.ClearAndBackup<ISoftDeleted>();
|
||||
try
|
||||
{
|
||||
return await _dbContext.Queryable<WorkGridEntity>().ToListAsync();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbContext.Client.QueryFilter.Restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task<Dictionary<Guid, EFenceEntity>> GetDeviceCodeInEFencesAsync(List<Guid> deviceCodes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user