This commit is contained in:
2024-08-22 19:27:05 +08:00
parent 3e8f5da91d
commit db2ba56586
2 changed files with 14 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ using Dlhis.Canteen.Order.Request;
using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Order.Services;
using Dlhis.Entity.Canteen.Entities;
using Kurisu.AspNetCore;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
@@ -23,13 +24,11 @@ public class BalancesController : ControllerBase
{
private readonly IBalanceService _balanceService;
private readonly IHainingBalanceService _hainingBalanceService;
private readonly IServiceProvider _serviceProvider;
public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService, IServiceProvider serviceProvider)
public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService)
{
_balanceService = balanceService;
_hainingBalanceService = hainingBalanceService;
_serviceProvider = serviceProvider;
}
/// <summary>
@@ -210,22 +209,20 @@ public class BalancesController : ControllerBase
}
[HttpPost("recalc1")]
[IgnoreTenant]
[Transactional(IsolationLevel.ReadCommitted)]
[IgnoreTenant]
public async Task ReC5()
{
using (var scope = _serviceProvider.CreateScope())
{
var db = scope.ServiceProvider.GetService<IDbContext>();
var middleService = scope.ServiceProvider.GetService<IMiddleService>();
var others = await db.Queryable<BalanceRecordEntity>().AS("LocalBalanceRecordEntity")
.Where(x => SqlFunc.Subqueryable<BalanceRecordEntity>().Where(p => p.No == x.No).NotAny())
.ToListAsync();
var sp = App.GetServiceProvider();
var db = sp.GetService<IDbContext>();
var middleService = sp.GetService<IMiddleService>();
var others = await db.Queryable<BalanceRecordEntity>().AS("LocalBalanceRecordEntity")
.Where(x => SqlFunc.Subqueryable<BalanceRecordEntity>().Where(p => p.No == x.No).NotAny())
.ToListAsync();
foreach (var item in others)
{
await middleService.MiddleUploadAsync(item);
}
foreach (var item in others)
{
await middleService.MiddleUploadAsync(item);
}
}
}

View File

@@ -1,3 +1,4 @@
using System.Data;
using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Order.Services;
using Dlhis.Entity.Canteen.Entities;
@@ -25,6 +26,7 @@ public class MiddleController : ControllerBase
/// <returns></returns>
[IgnoreTenant]
[HttpPost("upload")]
[Transactional(IsolationLevel.ReadCommitted)]
public async Task<OrderResultResponse> MiddleUpload(BalanceRecordEntity entity)
{
return await _middleService.MiddleUploadAsync(entity);