80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using Dlhis.Basic.Api;
|
|
using Dlhis.Basic.Api.Request;
|
|
using Dlhis.Entity.Canteen.Entities;
|
|
using Dlhis.Entity.Canteen.Enums;
|
|
using Dlhis.ScheduledTask.Common.Request;
|
|
using Dlhis.ScheduledTask.Common.Services;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
|
|
namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
|
|
|
|
/// <summary>
|
|
/// 调度任务
|
|
/// </summary>
|
|
[Authorize(Roles = "admin")]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class HangfireController : ControllerBase
|
|
{
|
|
private readonly IHangfireService _hangfireService;
|
|
private readonly IDbContext _dbContext;
|
|
|
|
public HangfireController(IHangfireService hangfireService , IDbContext dbContext)
|
|
{
|
|
_hangfireService = hangfireService;
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动获取人员
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpPost("sap/person/no")]
|
|
public async Task PersonManuallySync(SapNoRequest request)
|
|
{
|
|
await _hangfireService.CreateSapPersonSyncBackgroundJobAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动启动人事范围同步
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("sap/werk/no")]
|
|
public async Task WerkManuallySync(SapNoRequest request)
|
|
{
|
|
await _hangfireService.CreateSapWerkSyncBackgroundJobAsync(request);
|
|
}
|
|
|
|
|
|
[HttpPost("assignment-generate")]
|
|
public void GeneratePermissionsAsync(GeneratePermissionIdRequest request)
|
|
{
|
|
_hangfireService.GeneratePermissions(request);
|
|
}
|
|
|
|
|
|
[HttpPost("recalc")]
|
|
public async Task<object> ReCalc()
|
|
{
|
|
// select UserCode,Remark, count(1) count from balancerecord
|
|
// where Status = 'Valid'
|
|
// and TenantId !='1201'
|
|
// and IsDeleted = false
|
|
// group by UserCode,Remark
|
|
// having ifnull(Remark,'')!='' and count > 1 and Remark !='用户取消' and Remark !='正常发放';
|
|
|
|
var ls = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
|
|
.Select(x => new { x.UserCode, x.Remark, count = SqlFunc.AggregateCount(x.Id) })
|
|
.GroupBy(x => new { x.UserCode, x.Remark })
|
|
.Having(x => SqlFunc.IsNull(x.Remark, "") != "" && SqlFunc.AggregateCount(1) > 1 && x.Remark != "用户取消" && x.Remark != "正常发放")
|
|
.ToListAsync();
|
|
|
|
return ls;
|
|
}
|
|
} |