From 1a338f9fa39d2ad113ec2b1a6141e64e0707751d Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 4 Jun 2024 12:22:16 +0800 Subject: [PATCH] =?UTF-8?q?test=20=E6=B5=8B=E8=AF=95=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HangfireController.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs index 22b92c7e..bf4e742d 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs @@ -1,9 +1,13 @@ 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; @@ -16,10 +20,12 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Controllers; public class HangfireController : ControllerBase { private readonly IHangfireService _hangfireService; + private readonly IDbContext _dbContext; - public HangfireController(IHangfireService hangfireService) + public HangfireController(IHangfireService hangfireService , IDbContext dbContext) { _hangfireService = hangfireService; + _dbContext = dbContext; } /// @@ -51,4 +57,24 @@ public class HangfireController : ControllerBase { _hangfireService.GeneratePermissions(request); } + + + [HttpPost("recalc")] + public async Task 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().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; + } } \ No newline at end of file