Browse Source

定时同步数据任务 定时开启

master
PoffyZhang 11 months ago
parent
commit
02e1cc1309
3 changed files with 32 additions and 5 deletions
  1. +5
    -5
      kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java
  2. +7
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java
  3. +20
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java

+ 5
- 5
kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java View File

@@ -94,15 +94,15 @@ public abstract class AbstractMatterCacheHelper implements InitializingBean {
.refreshAfterWrite(7, TimeUnit.DAYS) .refreshAfterWrite(7, TimeUnit.DAYS)
.maximumSize(1024 * 100) .maximumSize(1024 * 100)
.build(key -> { .build(key -> {
DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class)
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key)
NdKqZzsfwMattersDeduplicate dup = deduplicateService.getOne(Wrappers.lambdaQuery(NdKqZzsfwMattersDeduplicate.class)
.eq(NdKqZzsfwMattersDeduplicate::getQlName, key)
.last(BizConst.LIMIT_1) .last(BizConst.LIMIT_1)
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl));
if (Objects.isNull(matter)) {
.isNotNull(NdKqZzsfwMattersDeduplicate::getWebapplyurl));
if (Objects.isNull(dup)) {
//查不到直接返回null //查不到直接返回null
return null; return null;
} }
return matter.getWebapplyurl();
return dup.getWebapplyurl();
}); });
mattersDupCache = Caffeine.newBuilder() mattersDupCache = Caffeine.newBuilder()
.refreshAfterWrite(7, TimeUnit.DAYS) .refreshAfterWrite(7, TimeUnit.DAYS)


+ 7
- 0
kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java View File

@@ -58,4 +58,11 @@ public class TaskController {
synTask.synData(); synTask.synData();
return "同步成功"; return "同步成功";
} }

@ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据")
@GetMapping("/syn-menu")
public String synMenuData() throws UnknownHostException {
synTask.synMenu();
return "同步成功";
}
} }

+ 20
- 0
kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java View File

@@ -97,4 +97,24 @@ public class SynTask {
stopWatch.stop(); stopWatch.stop();
log.info("政务数据 ===================== 同步总共耗时 :{} s",stopWatch.getTotalTimeSeconds()); log.info("政务数据 ===================== 同步总共耗时 :{} s",stopWatch.getTotalTimeSeconds());
} }

public void synMenu() {
//2. 事项
List<NdKqZzsfwMenu> menus = menuService.list();
for(NdKqZzsfwMenu menu : menus){
String url = matterCacheHelper.getUrl(menu.getItemName());
log.info("当前缓存的数据 : {},{}",menu.getItemName(),url);
if(StringUtils.isBlank(url)){
menuService.update(Wrappers.lambdaUpdate(NdKqZzsfwMenu.class)
.eq(NdKqZzsfwMenu::getId,menu.getId())
.set(NdKqZzsfwMenu::getWebapplyurl,null)
.set(NdKqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode()));
}else{
menuService.update(Wrappers.lambdaUpdate(NdKqZzsfwMenu.class)
.eq(NdKqZzsfwMenu::getId,menu.getId())
.set(NdKqZzsfwMenu::getWebapplyurl,url)
.set(NdKqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode()));
}
}
}
} }

Loading…
Cancel
Save