fix 恢复数据代码
This commit is contained in:
@@ -89,6 +89,14 @@ public class GainfoOutsourceController : ControllerBase
|
||||
await _gainfoOutSourceService.AutoResignAsync();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("recover")]
|
||||
[IgnoreTenant]
|
||||
public async Task RecoverAsync()
|
||||
{
|
||||
await _gainfoOutSourceService.RecoverAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取外包白名单分页数据
|
||||
/// </summary>
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface IGainfoOutsourceService : IScopeDependency
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task AutoResignAsync();
|
||||
|
||||
Task RecoverAsync();
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Kurisu.AspNetCore.Cache;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Mapster;
|
||||
@@ -211,6 +210,35 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task RecoverAsync()
|
||||
{
|
||||
var gainfoLeaves = await _dbContext.Queryable<GainfoLeaveEntity>()
|
||||
.Where(x => x.Type == GainfoUserTypeEnumType.Outsource)
|
||||
.Where(x => x.Remark == "1000天无通行记录")
|
||||
.Where(x => SqlFunc.Subqueryable<GainfoEntity>().Where(p => p.No == x.No || p.IdNo == x.IdNo).NotAny())
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var gainfoLeave in gainfoLeaves)
|
||||
{
|
||||
await _dbContext.Client.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var gainfo = gainfoLeave.Adapt<GainfoEntity>();
|
||||
gainfo.Id = gainfo.IdentityUserId;
|
||||
await _dbContext.InsertAsync(gainfo);
|
||||
await _dbContext.DeleteReallyAsync(gainfoLeave);
|
||||
|
||||
await _dbContext.Client.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "恢复外包人员失败:{userNo}", gainfoLeave.No);
|
||||
await _dbContext.Client.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<DateOnly> GetDaysUntilToday(DateTime begin)
|
||||
{
|
||||
var start = DateOnly.FromDateTime(begin.Date);
|
||||
|
||||
Reference in New Issue
Block a user