Commit d70ef16c by lcx

开启自定义提取、强制刷新报表

parent 6799bf4a
...@@ -263,17 +263,17 @@ public ApiResponse GenerateAsync([CustomizeValidator(RuleSet = "Delete"), FromBo ...@@ -263,17 +263,17 @@ public ApiResponse GenerateAsync([CustomizeValidator(RuleSet = "Delete"), FromBo
//} //}
//else //else
//{ //{
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => _backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{ {
using (var scope = _serviceScopeFactory.CreateScope()) var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
{ scopedServices.Generate(allot);
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>(); await Task.Delay(TimeSpan.FromSeconds(5), token);
scopedServices.Generate(allot); }
await Task.Delay(TimeSpan.FromSeconds(5), token); });
}
}); //_publishEndpoint.Publish(allot).Wait();
//_publishEndpoint.Publish(allot).Wait();
//} //}
_logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage"); _logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
...@@ -297,7 +297,15 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -297,7 +297,15 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB
if (null == allot || !states.Contains(allot.States)) if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。"); throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
//_publishEndpoint.Publish(allot).Wait(); _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, "统计报表数据任务开始"); return new ApiResponse(ResponseType.OK, "统计报表数据任务开始");
} }
......
...@@ -20,6 +20,7 @@ public class ModExtractController : Controller ...@@ -20,6 +20,7 @@ public class ModExtractController : Controller
private readonly AllotService _allotService; private readonly AllotService _allotService;
private readonly CustomExtractService _extractService; private readonly CustomExtractService _extractService;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
private readonly IHubNotificationQueue _notificationQueue; private readonly IHubNotificationQueue _notificationQueue;
public ModExtractController( public ModExtractController(
...@@ -27,12 +28,14 @@ public class ModExtractController : Controller ...@@ -27,12 +28,14 @@ public class ModExtractController : Controller
AllotService allotService, AllotService allotService,
CustomExtractService extractService, CustomExtractService extractService,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
IBackgroundTaskQueue backgroundTaskQueue,
IHubNotificationQueue notificationQueue) IHubNotificationQueue notificationQueue)
{ {
_claim = claim; _claim = claim;
_allotService = allotService; _allotService = allotService;
_extractService = extractService; _extractService = extractService;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_backgroundTaskQueue = backgroundTaskQueue;
_notificationQueue = notificationQueue; _notificationQueue = notificationQueue;
} }
...@@ -43,27 +46,27 @@ public ApiResponse CustomExtract(int allotId) ...@@ -43,27 +46,27 @@ public ApiResponse CustomExtract(int allotId)
if (!_extractService.CheckConfigScript(userId, allotId)) if (!_extractService.CheckConfigScript(userId, allotId))
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。"); return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
//_backgroundTaskQueue.QueueBackgroundWorkItem(async token => _backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
//{ {
// using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
// { {
// var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>(); var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
// var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>(); var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
// var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>(); var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
// if (scopedServices.ExtractData(userId, allotId, out string resultFilePath)) if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
// { {
// scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath); scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
// scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId))); scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
// } }
// else else
// { {
// scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR))); scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
// } }
// await Task.Delay(TimeSpan.FromSeconds(5), token); await Task.Delay(TimeSpan.FromSeconds(5), token);
// } }
//}); });
_notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行"))); _notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
......
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