feat 照片上传sap

This commit is contained in:
2024-07-17 16:48:30 +08:00
parent aeda215b38
commit a5a6c7a515
13 changed files with 160 additions and 87 deletions

View File

@@ -1,14 +1,9 @@
using Dlhis.Basic.Api.Request;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Dlhis.ScheduledTask.TaskAssignment.Request;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
@@ -52,61 +47,10 @@ public class HangfireController : ControllerBase
await _hangfireService.CreateSapWerkSyncBackgroundJobAsync(request);
}
[HttpPost("assignment-generate")]
public void GeneratePermissionsAsync(GeneratePermissionIdRequest request)
[AllowAnonymous]
[HttpPost("sap/face")]
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
{
_hangfireService.GeneratePermissions(request);
}
[IgnoreTenant]
[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<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();
foreach (var row in ls)
{
var data = await _dbContext.Queryable<BalanceRecordEntity>()
.Where(x => x.UserCode == row.UserCode)
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.MealSupplement)
.Where(x => x.Remark == row.Remark)
.ToListAsync();
if (data.Count <= 1)
{
continue;
}
var f = data.First();
var others = data.Where(x => x.Id != f.Id).ToList();
others.ForEach(x => x.Status = BalanceRecordStatusEnumType.Obsolute);
await _dbContext.UpdateAsync(others);
var sum = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.UserCode == f.UserCode)
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
.SumAsync(x => x.Amount);
var mealInfo = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == f.UserCode).SingleAsync();
await _dbContext.Updateable<GainfoMealEntity>()
.SetColumns(x => x.Balance == sum)
.SetColumns(x => x.Version == x.Version + 1)
.SetColumns(x => x.ModifiedTime == DateTime.Now)
.Where(x => x.UserCode == f.UserCode && x.Version == mealInfo.Version)
.ExecuteCommandAsync();
}
await _hangfireService.FaceUploadToSapAsync(request);
}
}