任务开始前检查配置

parent 8b007359
...@@ -18,6 +18,7 @@ public class ModExtractController : Controller ...@@ -18,6 +18,7 @@ public class ModExtractController : Controller
{ {
private readonly ClaimService _claim; private readonly ClaimService _claim;
private readonly AllotService _allotService; private readonly AllotService _allotService;
private readonly CustomExtractService _extractService;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IHubNotificationQueue _notificationQueue; private readonly IHubNotificationQueue _notificationQueue;
private readonly IBackgroundTaskQueue _backgroundTaskQueue; private readonly IBackgroundTaskQueue _backgroundTaskQueue;
...@@ -25,12 +26,14 @@ public class ModExtractController : Controller ...@@ -25,12 +26,14 @@ public class ModExtractController : Controller
public ModExtractController( public ModExtractController(
ClaimService claim, ClaimService claim,
AllotService allotService, AllotService allotService,
CustomExtractService extractService,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
IHubNotificationQueue notificationQueue, IHubNotificationQueue notificationQueue,
IBackgroundTaskQueue backgroundTaskQueue) IBackgroundTaskQueue backgroundTaskQueue)
{ {
_claim = claim; _claim = claim;
_allotService = allotService; _allotService = allotService;
_extractService = extractService;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_notificationQueue = notificationQueue; _notificationQueue = notificationQueue;
_backgroundTaskQueue = backgroundTaskQueue; _backgroundTaskQueue = backgroundTaskQueue;
...@@ -40,6 +43,9 @@ public class ModExtractController : Controller ...@@ -40,6 +43,9 @@ public class ModExtractController : Controller
public ApiResponse CustomExtract(int allotId) public ApiResponse CustomExtract(int allotId)
{ {
var userId = _claim.GetUserId(); var userId = _claim.GetUserId();
if (!_extractService.CheckConfigScript(userId, allotId))
return new ApiResponse(ResponseType.Fail, "配置信息错误");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => _backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{ {
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
......
...@@ -43,6 +43,19 @@ public class CustomExtractService : IAutoInjection ...@@ -43,6 +43,19 @@ public class CustomExtractService : IAutoInjection
_perforHospitalconfigRepository = perforHospitalconfigRepository; _perforHospitalconfigRepository = perforHospitalconfigRepository;
_perforcustscriptRepository = perforcustscriptRepository; _perforcustscriptRepository = perforcustscriptRepository;
} }
public bool CheckConfigScript(int userId, int allotId)
{
var allot = _perallotRepository.GetEntity(w => w.ID == allotId)
?? throw new PerformanceException("绩效ID无效");
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
scripts = (IsSecondAdmin(userId))
? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList();
return scripts?.Count() > 0;
}
public bool ExtractData(int userId, int allotId, out string resultFilePath) public bool ExtractData(int userId, int allotId, out string resultFilePath)
{ {
...@@ -59,7 +72,7 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath) ...@@ -59,7 +72,7 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
? scripts?.Where(w => w.IsSecondAllot == 1).ToList() ? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList(); : scripts?.Where(w => w.IsOnceAllot == 1).ToList();
if (scripts == null && scripts.Count > 0) if (scripts == null || scripts.Count == 0)
{ {
result = false; result = false;
return result; return result;
......
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