fix 优化批量处理逻辑
This commit is contained in:
@@ -45,17 +45,7 @@ public class GainfoCardsController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _gainfoCardService.GetChangeRecordsAsync(userNo);
|
return await _gainfoCardService.GetChangeRecordsAsync(userNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取卡类型
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("cardTypes")]
|
|
||||||
public async Task<List<KeyValueDto<string, string>>> GetCardTypesAsync()
|
|
||||||
{
|
|
||||||
return await _gainfoCardService.GetCardTypesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑卡类型
|
/// 编辑卡类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -63,7 +53,6 @@ public class GainfoCardsController : ControllerBase
|
|||||||
[HttpPost("cardType")]
|
[HttpPost("cardType")]
|
||||||
public async Task EditCardTypeAsync(GainfoCardEditRequest request)
|
public async Task EditCardTypeAsync(GainfoCardEditRequest request)
|
||||||
{
|
{
|
||||||
//string code, int typeId
|
await _gainfoCardService.EditCardTypeAsync(request.UserCodes, request.CardType);
|
||||||
await _gainfoCardService.EditCardTypeAsync(request.UserCode, request.CardType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ public class GainfoCardEditRequest
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工号
|
/// 工号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required(ErrorMessage = "工号不能为空")]
|
[MinLength(1, ErrorMessage = "工号不能为空")]
|
||||||
public string UserCode { get; set; }
|
public List<string> UserCodes { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 卡类型
|
/// 卡类型
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Dlhis.Basic.Organization.Request;
|
using Dlhis.Basic.Organization.Request;
|
||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Kurisu.AspNetCore.CustomClass;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services;
|
namespace Dlhis.Basic.Organization.Services;
|
||||||
|
|
||||||
@@ -20,17 +19,11 @@ public interface IGainfoCardService : IScopeDependency
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<ChangeCardResponse>> GetChangeRecordsAsync(string userNo);
|
Task<List<ChangeCardResponse>> GetChangeRecordsAsync(string userNo);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取卡类型
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<List<KeyValueDto<string, string>>> GetCardTypesAsync();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑卡类型
|
/// 编辑卡类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="userCodes"></param>
|
||||||
/// <param name="typeId"></param>
|
/// <param name="typeId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task EditCardTypeAsync(string code, int typeId);
|
Task EditCardTypeAsync(List<string> userCodes, int typeId);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ 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.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Kurisu.AspNetCore.CustomClass;
|
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -14,17 +13,17 @@ public class GainfoCardService : IGainfoCardService
|
|||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly IGainfoStore _gainfoStore;
|
private readonly IGainfoStore _gainfoStore;
|
||||||
private readonly IDevicePermissionService _devicePermissionService;
|
private readonly IDevicePermissionAnalyzeService _devicePermissionAnalyzeService;
|
||||||
private readonly IGainfoPermissionService _gainfoPermissionService;
|
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||||
|
|
||||||
public GainfoCardService(IDbContext dbContext,
|
public GainfoCardService(IDbContext dbContext,
|
||||||
IGainfoStore gainfoStore,
|
IGainfoStore gainfoStore,
|
||||||
IDevicePermissionService devicePermissionService,
|
IDevicePermissionAnalyzeService devicePermissionAnalyzeService,
|
||||||
IGainfoPermissionService gainfoPermissionService)
|
IGainfoPermissionService gainfoPermissionService)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_gainfoStore = gainfoStore;
|
_gainfoStore = gainfoStore;
|
||||||
_devicePermissionService = devicePermissionService;
|
_devicePermissionAnalyzeService = devicePermissionAnalyzeService;
|
||||||
_gainfoPermissionService = gainfoPermissionService;
|
_gainfoPermissionService = gainfoPermissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,36 +56,28 @@ public class GainfoCardService : IGainfoCardService
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<KeyValueDto<string, string>>> GetCardTypesAsync()
|
|
||||||
|
public async Task EditCardTypeAsync(List<string> userCodes, int typeId)
|
||||||
{
|
{
|
||||||
var r = new List<KeyValueDto<string, string>>
|
var gainfos = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).ToListAsync();
|
||||||
|
(gainfos.Count == userCodes.Count).ThrowIfFalse("人员不存在");
|
||||||
|
|
||||||
|
var result = await _devicePermissionAnalyzeService.GetUserAssignDeviceCodesWithTypeInTenantAsync(gainfos.Select(x => x.No).ToList());
|
||||||
|
foreach (var gainfo in gainfos)
|
||||||
{
|
{
|
||||||
new()
|
var userNo = gainfo.No;
|
||||||
{
|
var myDeviceCodes = result[userNo].SelectMany(x => x.AssignTypes.SelectMany(p => p.Codes)).Distinct().ToList();
|
||||||
Key = "行政卡", Value = "2"
|
|
||||||
},
|
|
||||||
new()
|
|
||||||
{
|
|
||||||
Key = "车间卡", Value = "3"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return await Task.FromResult(r);
|
var deviceCodes = await _dbContext.Queryable<DeviceEntity>()
|
||||||
}
|
.Where(x => myDeviceCodes.Contains(x.Code))
|
||||||
|
.Where(x => x.EnableTimePeriod)
|
||||||
|
.Select(x => x.Code)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
public async Task EditCardTypeAsync(string code, int typeId)
|
await _gainfoPermissionService.ResetPermissionsAsync(userNo, DeviceTaskEnumType.Update, deviceCodes, "卡类型编辑下发");
|
||||||
{
|
gainfo.CardType = typeId;
|
||||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
|
}
|
||||||
gainfo.ThrowIfNull("人员不存在");
|
|
||||||
gainfo.CardType = typeId;
|
|
||||||
|
|
||||||
var myDeviceCodes = await _devicePermissionService.GetUserDeviceCodesByNoAsync(gainfo.No);
|
await _dbContext.UpdateAsync(gainfos);
|
||||||
var deviceCodes = await _dbContext.Queryable<DeviceEntity>()
|
|
||||||
.Where(x => myDeviceCodes.Contains(x.Code))
|
|
||||||
.Where(x => x.EnableTimePeriod)
|
|
||||||
.Select(x => x.Code)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Update, deviceCodes, "卡类型编辑下发");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户档案号
|
/// 用户档案号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
public string UserNo { get; set; }
|
public string UserNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -262,8 +262,6 @@ public class AssignmentService : IAssignmentService
|
|||||||
.WhereIF(request.Brand.IsPresent(), (deviceTask, device, deviceTemplate) => deviceTemplate.Brand == request.Brand)
|
.WhereIF(request.Brand.IsPresent(), (deviceTask, device, deviceTemplate) => deviceTemplate.Brand == request.Brand)
|
||||||
.Where((deviceTask, device, deviceTemplate, ga, gaLeave, department, deviceRegistry) =>
|
.Where((deviceTask, device, deviceTemplate, ga, gaLeave, department, deviceRegistry) =>
|
||||||
device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) > DateTime.Now)
|
device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) > DateTime.Now)
|
||||||
#if !DEBUG
|
|
||||||
#endif
|
|
||||||
.OrderBy(deviceTask => new { deviceTask.CreateTime, Priority = SqlFunc.Desc(deviceTask.Priority) })
|
.OrderBy(deviceTask => new { deviceTask.CreateTime, Priority = SqlFunc.Desc(deviceTask.Priority) })
|
||||||
.Select((deviceTask, device, deviceTemplate, ga, gaLeave, department) => new TaskDto
|
.Select((deviceTask, device, deviceTemplate, ga, gaLeave, department) => new TaskDto
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user