fix 人脸修改任务生成
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Dlhis.Basic.Device.Request;
|
using Dlhis.Basic.Device.Request;
|
||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Dlhis.Entity.Sys.Enums;
|
using Dlhis.Entity.Sys.Enums;
|
||||||
|
|
||||||
namespace Dlhis.Basic.Device.Services;
|
namespace Dlhis.Basic.Device.Services;
|
||||||
@@ -31,6 +32,15 @@ public interface IDevicePermissionService : IScopeDependency
|
|||||||
Task GenerateDeviceTasksAsync(Func<Task> func, List<string> userNos);
|
Task GenerateDeviceTasksAsync(Func<Task> func, List<string> userNos);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成下发任务(主动生成)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userNo"></param>
|
||||||
|
/// <param name="taskType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task GenerateDeviceTasksAsync(string userNo, DeviceTaskEnumType taskType);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取用户所有设备权限
|
/// 获取用户所有设备权限
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
foreach (var userNo in userNos)
|
foreach (var userNo in userNos)
|
||||||
{
|
{
|
||||||
beforeDic.TryGetValue(userNo, out var beforeCodes);
|
beforeDic.TryGetValue(userNo, out var beforeCodes);
|
||||||
if (beforeCodes == null) beforeCodes = new List<Guid>();
|
beforeCodes ??= new List<Guid>();
|
||||||
|
|
||||||
currentDic.TryGetValue(userNo, out var currentCodes);
|
currentDic.TryGetValue(userNo, out var currentCodes);
|
||||||
if (currentCodes == null) currentCodes = new List<Guid>();
|
currentCodes ??= new List<Guid>();
|
||||||
|
|
||||||
//被删除
|
//被删除
|
||||||
var deletedItems = beforeCodes.Where(x => !currentCodes.Contains(x)).ToList();
|
var deletedItems = beforeCodes.Where(x => !currentCodes.Contains(x)).ToList();
|
||||||
@@ -157,6 +157,40 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task GenerateDeviceTasksAsync(string userNo, DeviceTaskEnumType taskType)
|
||||||
|
{
|
||||||
|
var deviceCodes = await GetAssignDeviceCodesAsync(userNo);
|
||||||
|
if (!deviceCodes.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var deivces = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).ToListAsync();
|
||||||
|
deviceCodes = deivces.Select(x => x.Code).ToList();
|
||||||
|
|
||||||
|
var userInfo = await _dbContext.Queryable<GainfoEntity>()
|
||||||
|
.LeftJoin<DepartmentEntity>((ga, department) => department.No == ga.DepartmentNo)
|
||||||
|
.Where(ga => ga.No == userNo)
|
||||||
|
.Select(ga => new
|
||||||
|
{
|
||||||
|
ga.Code
|
||||||
|
})
|
||||||
|
.SingleAsync();
|
||||||
|
|
||||||
|
|
||||||
|
var tasks = deviceCodes.Select(x => new DeviceTaskEntity
|
||||||
|
{
|
||||||
|
DeviceUniqueNo = deivces.First(item => item.Code == x).UniqueNo,
|
||||||
|
Status = DeviceTaskStatusEnumType.Wait,
|
||||||
|
Type = taskType,
|
||||||
|
UserNo = userNo,
|
||||||
|
Version = 0,
|
||||||
|
UserCode = userInfo.Code,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
await _dbContext.InsertAsync(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取用户所有设备权限
|
/// 获取用户所有设备权限
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class GainfoGroupService : IGainfoGroupService
|
|||||||
var relations = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
var relations = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
||||||
await _dbContext.DeleteReallyAsync(relations);
|
await _dbContext.DeleteReallyAsync(relations);
|
||||||
|
|
||||||
|
request.UserNos = await _dbContext.Queryable<GainfoEntity>().Where(x => request.UserNos.Contains(x.No)).Select(x => x.No).ToListAsync();
|
||||||
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
|
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
|
||||||
{
|
{
|
||||||
GroupCode = request.GroupCode,
|
GroupCode = request.GroupCode,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Threading.Tasks;
|
using Dlhis.Basic.Device.Services;
|
||||||
|
using Dlhis.Basic.Device.Services.Implements;
|
||||||
using Dlhis.Basic.Organization.Request;
|
using Dlhis.Basic.Organization.Request;
|
||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Basic.Enums;
|
using Dlhis.Entity.Basic.Enums;
|
||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Kurisu.AspNetCore.Scope;
|
using Kurisu.AspNetCore.Scope;
|
||||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
@@ -14,8 +16,6 @@ using Kurisu.SqlSugar.Services;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using NetTaste;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||||
|
|
||||||
@@ -24,12 +24,14 @@ public class GainfoService : IGainfoService
|
|||||||
private readonly IGainfoStore _gainfoStore;
|
private readonly IGainfoStore _gainfoStore;
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly ICurrentUser _currentUser;
|
private readonly ICurrentUser _currentUser;
|
||||||
|
private readonly IDevicePermissionService _devicePermissionService;
|
||||||
|
|
||||||
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext, ICurrentUser currentUser)
|
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext, ICurrentUser currentUser, IDevicePermissionService devicePermissionService)
|
||||||
{
|
{
|
||||||
_gainfoStore = gainfoStore;
|
_gainfoStore = gainfoStore;
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_currentUser = currentUser;
|
_currentUser = currentUser;
|
||||||
|
_devicePermissionService = devicePermissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -196,8 +198,6 @@ public class GainfoService : IGainfoService
|
|||||||
|
|
||||||
gainfo.ThrowIfNull("人员档案信息不存在");
|
gainfo.ThrowIfNull("人员档案信息不存在");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await Scoped.Request.Value.CreateAsync(async (sp) =>
|
await Scoped.Request.Value.CreateAsync(async (sp) =>
|
||||||
{
|
{
|
||||||
var configuration = sp.GetService<IConfiguration>();
|
var configuration = sp.GetService<IConfiguration>();
|
||||||
@@ -212,6 +212,9 @@ public class GainfoService : IGainfoService
|
|||||||
dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString;
|
dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString;
|
||||||
var face = await dbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
var face = await dbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
||||||
|
|
||||||
|
//生成任务
|
||||||
|
await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, face == null ? DeviceTaskEnumType.Add : DeviceTaskEnumType.AddAfterDelete);
|
||||||
|
|
||||||
if (face == null)
|
if (face == null)
|
||||||
{
|
{
|
||||||
face = new GainfoFaceEntity
|
face = new GainfoFaceEntity
|
||||||
|
|||||||
Reference in New Issue
Block a user