fix 优化出差任务生成
This commit is contained in:
@@ -10,4 +10,8 @@
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Request\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Dlhis.Basic.Api.Request;
|
||||
|
||||
public class GainfoPermissionResetRequest
|
||||
{
|
||||
public string UserNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是离职
|
||||
/// </summary>
|
||||
public bool IsLeave { get; set; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Request;
|
||||
|
||||
public class GainfoPermissionResetRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 档案号
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string UserNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是离职
|
||||
/// </summary>
|
||||
public bool IsLeave { get; set; }
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Places.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
@@ -16,5 +17,5 @@ public interface IGainfoPermissionService : IScopeDependency
|
||||
|
||||
Task<List<DeviceGroupTreeResponse>> GetAssignGroupAsync(string userNo);
|
||||
|
||||
Task ResetPermissionsAsync(GainfoPermissionResetRequest request);
|
||||
Task ResetPermissionsAsync(string userNo, DeviceTaskEnumType type);
|
||||
}
|
||||
@@ -143,25 +143,31 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
}
|
||||
|
||||
|
||||
public async Task ResetPermissionsAsync(GainfoPermissionResetRequest request)
|
||||
public async Task ResetPermissionsAsync(string userNo, DeviceTaskEnumType type)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.Where(x => x.No == userNo)
|
||||
.SingleAsync();
|
||||
|
||||
if (gainfo == null && request.IsLeave)
|
||||
|
||||
var msg = gainfo == null ? "不存在职数据" : string.Empty;
|
||||
|
||||
//如果找不到就为离职人员
|
||||
if (gainfo == null)
|
||||
{
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.Where(x => x.No == userNo)
|
||||
.SingleAsync();
|
||||
|
||||
if (gainfo != null)
|
||||
{
|
||||
gainfo.Id = gainfo.IdentityUserId;
|
||||
}
|
||||
|
||||
msg += gainfo == null ? "并且不存在离职数据" : string.Empty;
|
||||
}
|
||||
|
||||
gainfo.ThrowIfNull("档案数据不存在");
|
||||
gainfo.ThrowIfNull($"档案数据有误:{msg}");
|
||||
|
||||
//获取人员的设备权限
|
||||
var deviceCodes = await _devicePermissionService.GetAssignDeviceCodesAsync(gainfo!.Code);
|
||||
@@ -173,10 +179,8 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
Version = 0,
|
||||
UserNo = request.UserNo,
|
||||
Type = request.IsLeave
|
||||
? DeviceTaskEnumType.Delete
|
||||
: DeviceTaskEnumType.Add,
|
||||
UserNo = userNo,
|
||||
Type = type,
|
||||
DeviceType = x.Type,
|
||||
TenantId = x.TenantId,
|
||||
Priority = 10,
|
||||
|
||||
@@ -252,11 +252,6 @@ public class GainfoService : IGainfoService
|
||||
(outsource == null).ThrowIfTrue("非外包人员不可手动离职");
|
||||
}
|
||||
|
||||
await _gainfoPermissionService.ResetPermissionsAsync(new GainfoPermissionResetRequest
|
||||
{
|
||||
UserNo = gainfo.No,
|
||||
IsLeave = true
|
||||
});
|
||||
|
||||
//先写入离职表
|
||||
gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id
|
||||
@@ -271,6 +266,8 @@ public class GainfoService : IGainfoService
|
||||
|
||||
gainfo.Id = gainfo.IdentityUserId;
|
||||
await _dbContext.DeleteReallyAsync(gainfo);
|
||||
|
||||
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Delete);
|
||||
}
|
||||
|
||||
public async Task SetSecurityWhiteAsync(string userCode)
|
||||
|
||||
@@ -18,17 +18,17 @@ public class SapBusinessTripService : ISapBusinessTripService
|
||||
{
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||
private readonly ILogger<SapBusinessTripService> _logger;
|
||||
|
||||
public SapBusinessTripService(IJinkoJipApi jinkoJipApi,
|
||||
IDbContext dbContext,
|
||||
IDevicePermissionService devicePermissionService,
|
||||
IGainfoPermissionService gainfoPermissionService,
|
||||
ILogger<SapBusinessTripService> logger)
|
||||
{
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
_dbContext = dbContext;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_gainfoPermissionService = gainfoPermissionService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ public class SapBusinessTripService : ISapBusinessTripService
|
||||
{
|
||||
todayTripInfo.Status = BusinessTripStatusEnumType.Generated;
|
||||
await _dbContext.UpdateAsync(todayTripInfo);
|
||||
continue;
|
||||
|
||||
//下发
|
||||
}
|
||||
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
if (yesterdayTripInfo != null)
|
||||
{
|
||||
//todayTripInfo == null
|
||||
yesterdayTripInfo.Status = BusinessTripStatusEnumType.Deleted;
|
||||
await _dbContext.Updateable<DevicePermissionEntity>()
|
||||
.SetColumns(x => x.IsDeleted == true)
|
||||
@@ -113,25 +113,40 @@ public class SapBusinessTripService : ISapBusinessTripService
|
||||
.Where(x => x.Type == tripGroup.Type)
|
||||
.Where(x => x.TenantId == factory)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
await _dbContext.UpdateAsync(yesterdayTripInfo);
|
||||
|
||||
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Delete);
|
||||
}
|
||||
|
||||
if (yesterdayTripInfo == null)
|
||||
{
|
||||
todayTripInfo.Status = BusinessTripStatusEnumType.Generated;
|
||||
//todayTripInfo != null
|
||||
if (!await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.AssignType == AssignTypeEnumType.User)
|
||||
.Where(x => x.AssignValue == gainfo.No)
|
||||
.Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group)
|
||||
.Where(x => x.UniqueValue == tripGroup.Code)
|
||||
.Where(x => x.Type == tripGroup.Type)
|
||||
.Where(x => x.TenantId == factory)
|
||||
.AnyAsync())
|
||||
{
|
||||
await _dbContext.InsertAsync(new DevicePermissionEntity
|
||||
{
|
||||
AssignType = AssignTypeEnumType.User,
|
||||
AssignValue = gainfo.No,
|
||||
UniqueType = DeviceAssignmentTypeEnumType.Group,
|
||||
UniqueValue = tripGroup.Code,
|
||||
TenantId = factory,
|
||||
Type = tripGroup.Type,
|
||||
IsDeleted = false
|
||||
TenantId = factory
|
||||
});
|
||||
await _dbContext.UpdateAsync(todayTripInfo);
|
||||
}
|
||||
}, new List<string> { gainfo.No });
|
||||
|
||||
todayTripInfo.Status = BusinessTripStatusEnumType.Generated;
|
||||
await _dbContext.UpdateAsync(todayTripInfo);
|
||||
|
||||
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Add);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user