新增执行大屏报表存储过程

parent 8b109903
...@@ -189,7 +189,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -189,7 +189,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
/// <summary> /// <summary>
/// 上传文件 /// 上传文件
/// </summary> /// </summary>
/// <param name="form"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
[Route("ImportExtraction/{allotId}")] [Route("ImportExtraction/{allotId}")]
[HttpPost] [HttpPost]
...@@ -244,7 +244,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -244,7 +244,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
var allot = _allotService.GetAllot(request.ID); var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path)) if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件"); throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
var email = _claim.GetUserClaim(JwtClaimTypes.Mail);
if (allot.States == (int)AllotStates.Wait) if (allot.States == (int)AllotStates.Wait)
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成"); return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
...@@ -252,7 +251,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -252,7 +251,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate); _allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
if (_evn.IsEnvironment("Localhost")) if (_evn.IsEnvironment("Localhost"))
{ {
_allotService.Generate(allot, email); _allotService.Generate(allot);
} }
else else
{ {
...@@ -263,7 +262,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -263,7 +262,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
{ {
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>(); var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.Generate(allot, email); scopedServices.Generate(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token); await Task.Delay(TimeSpan.FromSeconds(5), token);
} }
}); });
...@@ -274,6 +273,34 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -274,6 +273,34 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email)); ////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email));
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
/// <summary>
/// 绩效生成报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("genreport")]
[HttpPost]
public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromBody] AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
var states = new[] { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed, (int)AllotStates.GenerateAccomplish };
if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.GenerateReport(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
return new ApiResponse(ResponseType.OK);
}
/* /*
[Route("recalculation")] [Route("recalculation")]
[HttpPost] [HttpPost]
...@@ -284,7 +311,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request) ...@@ -284,7 +311,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
*/ */
/// <summary> /// <summary>
/// 重新计算院领导绩效 /// 重新计算院领导绩效
/// </summary> /// </summary>
......
...@@ -49,9 +49,9 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeo ...@@ -49,9 +49,9 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeo
return context.Database.GetDbConnection().Query<T>(sql, param, commandTimeout: commandTimeout); return context.Database.GetDbConnection().Query<T>(sql, param, commandTimeout: commandTimeout);
} }
public int Execute(string sql, object param) public int Execute(string sql, object param, int? commandTimeout = null)
{ {
return context.Database.GetDbConnection().Execute(sql, param); return context.Database.GetDbConnection().Execute(sql, param, commandTimeout: commandTimeout);
} }
public bool Add(TEntity entity) public bool Add(TEntity entity)
......
...@@ -303,7 +303,7 @@ public per_allot UpdateAllotShowFormula(int allotId) ...@@ -303,7 +303,7 @@ public per_allot UpdateAllotShowFormula(int allotId)
/// </summary> /// </summary>
/// <param name="allot"></param> /// <param name="allot"></param>
/// <param name="user"></param> /// <param name="user"></param>
public void Generate(per_allot allot, string mail) public void Generate(per_allot allot)
{ {
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
try try
...@@ -441,7 +441,7 @@ public void Generate(per_allot allot, string mail) ...@@ -441,7 +441,7 @@ public void Generate(per_allot allot, string mail)
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate); UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID); perforCofdirectorRepository.SupplementaryData(allot.ID);
logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
//var res = reportService.ImportData(allot); //var res = reportService.ImportData(allot);
//var flag = reportService.UpdateData(allot); //var flag = reportService.UpdateData(allot);
//logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true);
...@@ -465,6 +465,15 @@ public void Generate(per_allot allot, string mail) ...@@ -465,6 +465,15 @@ public void Generate(per_allot allot, string mail)
} }
/// <summary> /// <summary>
/// 绩效生成报表
/// </summary>
/// <param name="allot"></param>
public void GenerateReport(per_allot allot)
{
reportService.ExecProc("call proc_report_performance(@hospitalid, @year, @month);", new { allot.HospitalId, allot.Year, allot.Month });
}
/// <summary>
/// 重新计算院领导绩效 /// 重新计算院领导绩效
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
......
...@@ -395,7 +395,7 @@ public void ExecProc(string execsql, object param) ...@@ -395,7 +395,7 @@ public void ExecProc(string execsql, object param)
{ {
try try
{ {
perforPerallotRepository.Execute(execsql, param); perforPerallotRepository.Execute(execsql, param, 60 * 60);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment