fix 处理离职下发问题
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Api.Dtos;
|
||||
using Dlhis.Basic.Api.Request;
|
||||
using Kurisu.Core.Result;
|
||||
using Kurisu.RemoteCall.Attributes;
|
||||
|
||||
@@ -10,4 +11,8 @@ public interface IBusinessPlacePermissionsApi
|
||||
[Auth]
|
||||
[Get("/api/businessplacepermissions/my")]
|
||||
Task<DefaultApiResult<List<BusinessPlaceDto>>> GetMyAsync();
|
||||
|
||||
[Auth]
|
||||
[Post("/api/gainfoPermissions/reset")]
|
||||
Task<DefaultApiResult> ResetAsync(GainfoPermissionResetRequest request);
|
||||
}
|
||||
|
||||
11
Src/Dlhis.Basic.Api/Request/GainfoPermissionResetRequest.cs
Normal file
11
Src/Dlhis.Basic.Api/Request/GainfoPermissionResetRequest.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Dlhis.Basic.Api.Request;
|
||||
|
||||
public class GainfoPermissionResetRequest
|
||||
{
|
||||
public string UserNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是离职
|
||||
/// </summary>
|
||||
public bool IsLeave { get; set; }
|
||||
}
|
||||
@@ -72,7 +72,6 @@ public class GainfoPermissionsController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = "admin,tenant-admin")]
|
||||
[HttpPost("reset")]
|
||||
[IgnoreTenant]
|
||||
public async Task ResetPermissionsAsync(GainfoPermissionResetRequest request)
|
||||
|
||||
@@ -217,6 +217,7 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
|
||||
var tasks = devices.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
UserId = gainfo.Id,
|
||||
CancellationId = 0,
|
||||
Version = 0,
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
|
||||
@@ -18,6 +18,12 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public DeviceTaskEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户id
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户档案号
|
||||
/// </summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Comparers;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Dlhis.Basic.Api.Dtos;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
@@ -17,6 +18,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger<GainfoUpdateService> _logger;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IBusinessPlacePermissionsApi _businessPlacePermissionsApi;
|
||||
private readonly IDevicePermissionApi _devicePermissionApi;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
|
||||
@@ -27,6 +29,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
||||
public GainfoUpdateService(IDbContext dbContext,
|
||||
ILogger<GainfoUpdateService> logger,
|
||||
ITenantApi tenantApi,
|
||||
IBusinessPlacePermissionsApi businessPlacePermissionsApi,
|
||||
IDevicePermissionApi devicePermissionApi,
|
||||
IJinkoSapService jinkoSapService)
|
||||
{
|
||||
@@ -34,6 +37,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
||||
_dbContext.Client.QueryFilter.Clear();
|
||||
_logger = logger;
|
||||
_tenantApi = tenantApi;
|
||||
_businessPlacePermissionsApi = businessPlacePermissionsApi;
|
||||
_devicePermissionApi = devicePermissionApi;
|
||||
_jinkoSapService = jinkoSapService;
|
||||
}
|
||||
@@ -334,8 +338,22 @@ public class GainfoUpdateService : IGainfoUpdateService
|
||||
}
|
||||
else
|
||||
{
|
||||
//离职
|
||||
if (gainfo != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _businessPlacePermissionsApi.ResetAsync(new Basic.Api.Request.GainfoPermissionResetRequest
|
||||
{
|
||||
IsLeave = true,
|
||||
UserNo = gainfo.No
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "离职任务生成失败:{message}", ex.Message);
|
||||
}
|
||||
|
||||
//先写入离职表
|
||||
gainfo.IdentityUserId = (int)gainfo.Id;
|
||||
gainfo.Id = 0;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class AssignmentService : IAssignmentService
|
||||
.OrderBy(deviceTask => deviceTask.CreateTime)
|
||||
.Select((deviceTask, deivce, deivceTamplate, ga, department) => new
|
||||
{
|
||||
UserId = SqlFunc.IsNull(ga.Id, 0),
|
||||
UserId = SqlFunc.IsNull(deviceTask.UserId, ga.Id),
|
||||
TaskId = deviceTask.Id,
|
||||
deviceTask.Type,
|
||||
deviceTask.DeviceUniqueNo,
|
||||
|
||||
Reference in New Issue
Block a user