fix 优化出差任务生成

This commit is contained in:
2024-12-06 12:59:37 +08:00
parent 9764740030
commit 6514401a3c
7 changed files with 57 additions and 64 deletions

View File

@@ -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,