fix 增加redis缓存优化速度
This commit is contained in:
@@ -14,6 +14,7 @@ using SqlSugar;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.AspNetCore;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
|
||||
|
||||
@@ -52,7 +53,7 @@ public class AssignmentService : IAssignmentService
|
||||
deivceTamplate.Brand,
|
||||
FuncStr = deivce.Funcs.ToString(),
|
||||
deviceTask.UserNo,
|
||||
deviceTask.UserCode,
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
ga.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
@@ -282,25 +283,21 @@ public class AssignmentService : IAssignmentService
|
||||
{
|
||||
var task = await _dbContext.Queryable<DeviceTaskEntity>().Where(x => x.Id == taskId).FirstAsync();
|
||||
task.ThrowIfNull("该任务不存在");
|
||||
|
||||
(task.Status != DeviceTaskStatusEnumType.Process).ThrowIfTrue($"设备任务下发状态需为{DeviceTaskStatusEnumType.Process.GetDescription()}");
|
||||
|
||||
return Scoped.Request.Value.Create((sp) =>
|
||||
{
|
||||
var faceUrlOptions = sp.GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var dataProtectionProvider = sp.GetService<IDataProtectionProvider>();
|
||||
var faceUrlOptions = App.GetServiceProvider(true).GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var dataProtectionProvider = App.GetServiceProvider(true).GetService<IDataProtectionProvider>();
|
||||
|
||||
var timeLimitedDataProtector = dataProtectionProvider
|
||||
.CreateProtector("down:face")
|
||||
.ToTimeLimitedDataProtector();
|
||||
var timeLimitedDataProtector = dataProtectionProvider
|
||||
.CreateProtector("down:face")
|
||||
.ToTimeLimitedDataProtector();
|
||||
|
||||
var userCode = task.UserCode;
|
||||
var userCode = await _dbContext.Queryable<GainfoEntity>().Where(x => x.No == task.UserNo).Select(x => x.Code).SingleAsync();
|
||||
|
||||
var key = $"face:{userCode}";
|
||||
var token = timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit));
|
||||
var key = $"face:{userCode}";
|
||||
var token = timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit));
|
||||
|
||||
return faceUrlOptions.Url + token;
|
||||
});
|
||||
return faceUrlOptions.Url + token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
|
||||
|
||||
@@ -33,14 +29,13 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|
||||
Status = deviceTask.Status,
|
||||
UserNo = deviceTask.UserNo,
|
||||
UserName = ga.Name,
|
||||
UserCode = deviceTask.UserCode,
|
||||
UserCode = ga.Code,
|
||||
Type = deviceTask.Type,
|
||||
LastUpdateTime = deviceTask.ModifiedTime
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user