fix 修复网格解散的情况
This commit is contained in:
@@ -17,6 +17,7 @@ using Kurisu.AspNetCore.Authentication.Abstractions;
|
|||||||
using Kurisu.AspNetCore.Cache;
|
using Kurisu.AspNetCore.Cache;
|
||||||
using Kurisu.AspNetCore.CustomClass;
|
using Kurisu.AspNetCore.CustomClass;
|
||||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -72,7 +73,12 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
.Where(x => factories.Contains(x.TenantId))
|
.Where(x => factories.Contains(x.TenantId))
|
||||||
.Select(x => new
|
.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();
|
.ToListAsync();
|
||||||
|
|
||||||
@@ -83,11 +89,14 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
.Where(x => x.Date >= min && x.Date <= max && userCodes2.Contains(x.UserCode))
|
.Where(x => x.Date >= min && x.Date <= max && userCodes2.Contains(x.UserCode))
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
x.UserCode, x.WorkGridCode, x.Date, x.PeriodType
|
x.UserCode,
|
||||||
|
x.WorkGridCode,
|
||||||
|
x.Date,
|
||||||
|
x.PeriodType
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.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 workGridUsers = await _dbContext.Queryable<WorkGridUserEntity>().Where(x => userCodes2.Contains(x.UserCode)).ToListAsync();
|
||||||
|
|
||||||
var inserts = new List<DeviceUploadLogEntity>();
|
var inserts = new List<DeviceUploadLogEntity>();
|
||||||
@@ -132,13 +141,16 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
var currentWorkGridTimePeriods = workGridTimePeriods.Where(x => x.TenantId == device.TenantId).ToList();
|
var currentWorkGridTimePeriods = workGridTimePeriods.Where(x => x.TenantId == device.TenantId).ToList();
|
||||||
var currentWorkGridSchedules = workGridSchedules.Where(x => x.UserCode == request.UserUniqueNo).ToList();
|
var currentWorkGridSchedules = workGridSchedules.Where(x => x.UserCode == request.UserUniqueNo).ToList();
|
||||||
var currentWorkGridUser = workGridUsers.FirstOrDefault(x => x.UserCode == request.UserUniqueNo); //可能被删除,但还存在当天的排班
|
var currentWorkGridUser = workGridUsers.FirstOrDefault(x => x.UserCode == request.UserUniqueNo); //可能被删除,但还存在当天的排班
|
||||||
|
|
||||||
if (needUpload && currentWorkGridTimePeriods.Any() && (currentWorkGridUser != null || currentWorkGridSchedules.Any()))
|
if (needUpload && currentWorkGridTimePeriods.Any() && (currentWorkGridUser != null || currentWorkGridSchedules.Any()))
|
||||||
{
|
{
|
||||||
workGridInfo.TimeSetting = currentWorkGridTimePeriods.Select(x => new
|
workGridInfo.TimeSetting = currentWorkGridTimePeriods.Select(x => new
|
||||||
{
|
{
|
||||||
Type = x.Type.GetDescription(),
|
Type = x.Type.GetDescription(),
|
||||||
x.Before, x.Start,
|
x.Before,
|
||||||
x.End, x.After,
|
x.Start,
|
||||||
|
x.End,
|
||||||
|
x.After,
|
||||||
x.TenantId
|
x.TenantId
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
@@ -279,6 +291,19 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
await _dbContext.InsertAsync(inserts);
|
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)
|
private async Task<Dictionary<Guid, EFenceEntity>> GetDeviceCodeInEFencesAsync(List<Guid> deviceCodes)
|
||||||
{
|
{
|
||||||
@@ -314,7 +339,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
_logger.LogInformation("MCB未开启, userCode:{userCode} directionType:{directionType}", userCode, directionType);
|
_logger.LogInformation("MCB未开启, userCode:{userCode} directionType:{directionType}", userCode, directionType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var room = await _dbContext.Queryable<DormitoryRoomEntity>().Where(x => x.RoomId == roomInfo.RoomId).SingleAsync();
|
var room = await _dbContext.Queryable<DormitoryRoomEntity>().Where(x => x.RoomId == roomInfo.RoomId).SingleAsync();
|
||||||
if (room == null)
|
if (room == null)
|
||||||
{
|
{
|
||||||
@@ -334,13 +359,13 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
await _dbContext.InsertAsync(room);
|
await _dbContext.InsertAsync(room);
|
||||||
|
|
||||||
var personEntities = roomInfo.Persons.Select(x => new DormitoryRoomPersonEntity
|
var personEntities = roomInfo.Persons.Select(x => new DormitoryRoomPersonEntity
|
||||||
{
|
{
|
||||||
RoomId = roomInfo.RoomId,
|
RoomId = roomInfo.RoomId,
|
||||||
UserCode = x.UserCode,
|
UserCode = x.UserCode,
|
||||||
UserName = x.UserName,
|
UserName = x.UserName,
|
||||||
In = true,
|
In = true,
|
||||||
IsDeleted = false
|
IsDeleted = false
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
await _dbContext.InsertAsync(personEntities);
|
await _dbContext.InsertAsync(personEntities);
|
||||||
|
|||||||
Reference in New Issue
Block a user