fix 调试大华设备对接

This commit is contained in:
2024-01-24 20:46:55 +08:00
parent a36ff46722
commit 51c80a242e
19 changed files with 368 additions and 74 deletions

View File

@@ -106,6 +106,30 @@ public class AssignmentService : IAssignmentService
return new List<DeviceTaskToDeviceByDeviceResponse>();
}
Dictionary<string, DateTime?> deviceUploadInfos = null;
if (data.Any(x => x.Type == DeviceTaskEnumType.UploadRecord))
{
var deviceNos = data.Select(x => x.DeviceUniqueNo).Distinct();
deviceUploadInfos = new Dictionary<string, DateTime?>(deviceNos.Count());
var logInfos = await _dbContext.Queryable<DeviceUploadLogEntity>().Select(it => new
{
Index2 = SqlFunc.RowNumber(SqlFunc.Desc(it.Id), it.DeviceUniqueNo),
it.DeviceUniqueNo,
it.RaiseDateTime
})
.MergeTable()
.Where(it => it.Index2 == 1)
.ToListAsync();
foreach (var item in deviceNos)
{
var logInfo = logInfos.FirstOrDefault(x => x.DeviceUniqueNo == item);
deviceUploadInfos.Add(item, logInfo?.RaiseDateTime);
}
}
//申请新的请求域
return Scoped.Request.Value.Create((sp) =>
{
var faceUrlOptions = sp.GetService<IOptions<FaceUrlOptions>>().Value;
@@ -137,9 +161,9 @@ public class AssignmentService : IAssignmentService
Tasks = x.AsEnumerable().Select(item =>
{
var key = $"face:{item.UserCode}";
var token = item.Type == DeviceTaskEnumType.Add
? timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit))
: string.Empty;
var token = item.Type == DeviceTaskEnumType.Delete
? string.Empty
: timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit));
var dto = new TaskCombineDto
{
@@ -162,11 +186,11 @@ public class AssignmentService : IAssignmentService
UserName = item.UserName,
DepartmentNo = item.DepartmentNo,
DepartmentName = item.DepartmentName,
CardNo = item.Type == DeviceTaskEnumType.Add ? item.CardNo : string.Empty,
Face = item.Type == DeviceTaskEnumType.Add ? faceUrlOptions.Url + token : string.Empty,//下发才附带照片信息
CardNo = item.Type == DeviceTaskEnumType.Delete ? string.Empty : item.CardNo,
Face = item.Type == DeviceTaskEnumType.Delete ? string.Empty : faceUrlOptions.Url + token,//下发才附带照片信息
ValidDatePeriod = new DatePeriod
{
Start = DateOnly.FromDateTime(DateTime.Now),
Start = DateOnly.FromDateTime(DateTime.Now.AddDays(-1)),
End = DateOnly.FromDateTime(DateTime.Now.AddYears(20)),
},
TimePeriods = new List<int> { 1 },
@@ -181,15 +205,23 @@ public class AssignmentService : IAssignmentService
dto.Info = new TimePeriodToDeviceResponse
{
Id = 1,
TimePeriod = new TimePeriod
Name = "小白领",
Enable = true,
Sections = new List<TimePeriodWeekDaySection>()
{
Start = TimeOnly.Parse("08:00:00"),
End = TimeOnly.Parse("17:30:00"),
},
Weeks = new List<DayOfWeek>
{
DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
},
new TimePeriodWeekDaySection()
{
DayOfWeek= DayOfWeek.Monday,
TimePeriods = new List<TimePeriod>()
{
new TimePeriod
{
Start = TimeOnly.Parse("08:00:00"),
End = TimeOnly.Parse("17:30:00"),
},
}
}
}
};
}
break;
@@ -205,16 +237,30 @@ public class AssignmentService : IAssignmentService
{
new ScheduleDto
{
Name = "国庆节",
Name = "国庆节",
DateTimePeriod = new DateTimePeriod
{
Start = new DateTime(2024,10,1), End = new DateTime(2024,10,7)
Start = new DateTime(2024,10,1),
End = new DateTime(2024,10,7)
}
}
}
};
}
break;
case DeviceTaskEnumType.UploadRecord:
{
dto.Info = new UploadRecordToDeviceResponse
{
DateTimePeriod = new DateTimePeriod
{
Start = deviceUploadInfos[d] ?? DateTime.Now,
End = DateTime.Now.AddDays(1)
}
};
}
break;
default:
break;
}