fix 通行记录数据上报处理
This commit is contained in:
@@ -33,6 +33,11 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceUniqueNos.Contains(x.UniqueNo)).ToListAsync();
|
||||
var existsDeviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
|
||||
|
||||
var userCodes = requests.Where(x => x.UserUniqueNo.IsPresent()).Select(x => x.UserUniqueNo).Distinct().ToList();
|
||||
var gainfo1 = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Type }).ToListAsync();
|
||||
var gainfo2 = await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave").Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Type }).ToListAsync();
|
||||
var gainfos = gainfo1.Concat(gainfo2).DistinctBy(x => x.Code).ToList();
|
||||
|
||||
var inserts = new List<DeviceUploadLogEntity>();
|
||||
foreach (var request in requests.Where(x => existsDeviceUniqueNos.Contains(x.DeviceUniqueNo)))
|
||||
{
|
||||
@@ -60,20 +65,20 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
|
||||
inserts.Add(new DeviceUploadLogEntity
|
||||
{
|
||||
DeviceCode = device.Code,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
UserUniqueNo = request.UserUniqueNo,
|
||||
UserType = gainfos.FirstOrDefault(x => x.Code == request.UserUniqueNo)?.Type,
|
||||
RaiseDateTime = request.RaiseDateTime,
|
||||
SerialNo = request.SerialNo,
|
||||
SerialNo = request.SerialNo ?? string.Empty,
|
||||
Type = device.Type == DeviceTypeEnumType.Attendance
|
||||
? DeviceUploadLogTypeEnumType.Attendance
|
||||
: device.Type == DeviceTypeEnumType.Door && device.AsAttendance
|
||||
? DeviceUploadLogTypeEnumType.Attendance
|
||||
: DeviceUploadLogTypeEnumType.Door,
|
||||
|
||||
: DeviceUploadLogTypeEnumType.Door,
|
||||
NeedUpload = device.Type == DeviceTypeEnumType.Attendance || (device.Type == DeviceTypeEnumType.Door && device.AsAttendance),
|
||||
TenantId = device.TenantId,
|
||||
Status = request.Status ?? true,
|
||||
CreatedBy = 1,
|
||||
ModifiedBy = 1,
|
||||
ModifiedBy = 1
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user