|
|
@@ -68,6 +68,16 @@ public class ScheduledTaskService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private boolean hasMasterConfigured(String masterName) {
|
|
|
+ if (!mastersCache.isEmpty() ) {
|
|
|
+ for (Master master : mastersCache) {
|
|
|
+ if (master.getMa_user().equalsIgnoreCase(masterName))
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查找任务配置(按账套、模块)
|
|
|
*
|
|
|
@@ -75,6 +85,10 @@ public class ScheduledTaskService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<MasterTaskConfigEntity> getTaskConfigs(final MasterTaskConfigId configId, final String module, final String role) {
|
|
|
+ // 指定账套在查询时发现没有配置,主动刷一次
|
|
|
+ if (StringUtils.hasText(configId.getMasterName()) && !hasMasterConfigured(configId.getMasterName())) {
|
|
|
+ refreshConfigs();
|
|
|
+ }
|
|
|
return masterTaskConfigRepository.findAll(new Specification<MasterTaskConfigEntity>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<MasterTaskConfigEntity> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
@@ -180,7 +194,7 @@ public class ScheduledTaskService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Scheduled(cron = "0 */5 * * * *")
|
|
|
- public void refreshConfigs() throws Exception{
|
|
|
+ public synchronized void refreshConfigs() {
|
|
|
List<Master> masters = masterService.getMasters();
|
|
|
if (!CollectionUtils.isEmpty(masters)) {
|
|
|
if (CollectionUtils.isEmpty(mastersCache) || !masters.equals(mastersCache)) {
|