Commit f0eef863 by liuyu

2023年05/23 模板聚合日志添加,esIndex修复

parent 9de8be65
...@@ -127,9 +127,10 @@ public class TemplateTitleVo implements Serializable { ...@@ -127,9 +127,10 @@ public class TemplateTitleVo implements Serializable {
} }
public void accSum(long markSum, long daySum) { public void accSum(long markSum, long daySum) {
this.markSum = markSum + this.daySum; // daySum就不需要更新
if (this.daySum != 0) { if (this.daySum != 0) {
this.daySum += daySum; this.daySum += daySum;
this.markSum = markSum + this.daySum;
} }
} }
} }
...@@ -32,6 +32,6 @@ public class TaskPoolConfig { ...@@ -32,6 +32,6 @@ public class TaskPoolConfig {
@Bean("templateExecutor") @Bean("templateExecutor")
public ThreadPoolExecutorTimeout templateExecutor() { public ThreadPoolExecutorTimeout templateExecutor() {
return new ThreadPoolExecutorTimeout(1000L * 60 * 30, 32, 32,10000L, return new ThreadPoolExecutorTimeout(1000L * 60 * 30, 32, 32,10000L,
TimeUnit.MILLISECONDS, 200, "模板任务线程池"); TimeUnit.MILLISECONDS, 400, "模板任务线程池");
} }
} }
...@@ -189,12 +189,17 @@ public class TemplateTitleServiceImpl implements TemplateTitleService { ...@@ -189,12 +189,17 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
if (Objects.isNull(titleVo)) { if (Objects.isNull(titleVo)) {
return; return;
} }
// templateTitleVo,fixTag 必定只有一个有值
// 当传入的模板为空,表示不需要修改模板
if (Objects.isNull(templateTitleVo)) { if (Objects.isNull(templateTitleVo)) {
templateTitleVo = titleVo; templateTitleVo = titleVo;
} }
// 标签为null表示需要更新模板
if (Objects.isNull(fixTag)) { if (Objects.isNull(fixTag)) {
// templateTitleVo.daySum = 0 代表清空day模板,场景:大聚合时清空daySum。daySum != 0代表更新数值,场景:自动标注数值统计
templateTitleVo.accSum(titleVo.getMarkSum(), titleVo.getDaySum()); templateTitleVo.accSum(titleVo.getMarkSum(), titleVo.getDaySum());
} else { } else {
// 修改标签
String oldTag = templateTitleVo.getMtag(); String oldTag = templateTitleVo.getMtag();
templateTitleVo.setMtag(fixTag); templateTitleVo.setMtag(fixTag);
log.info("修改模板标签成功: group:{} templateTitle:{} oldTag:{} fixTag:{}", group, title, oldTag, log.info("修改模板标签成功: group:{} templateTitle:{} oldTag:{} fixTag:{}", group, title, oldTag,
......
...@@ -84,15 +84,18 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta ...@@ -84,15 +84,18 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TaskTemplateFunctional pair = getPairValue(autoTask.getType()); TaskTemplateFunctional pair = getPairValue(autoTask.getType());
pair.template(autoTask); pair.template(autoTask);
// log.info("{}结束, 项目:{},开始时间:{},结束时间:{},耗时:{}", getPairKey(autoTask.getType()).getMessage(), autoTask.getGroup(), Long startTime = autoTask.getParamSource().getLong(GenericAttribute.START_PARAM);
// Tools.TIME_FORMAT.format(autoTask.getParamSource().getLong(GenericAttribute.START_PARAM)), if (Objects.nonNull(startTime)) {
// Tools.TIME_FORMAT.format(autoTask.getParamSource().getLong(GenericAttribute.START_PARAM)), System.currentTimeMillis() - now); log.info("{}结束, 项目:{},开始时间:{},结束时间:{},耗时:{}", getPairKey(autoTask.getType()).getMessage(), autoTask.getGroup(),
Tools.TIME_FORMAT.format(startTime),
Tools.TIME_FORMAT.format(startTime), System.currentTimeMillis() - now);
}
}, autoTask)); }, autoTask));
} }
@Override @Override
public void executorStatus() { public void executorStatus() {
log.info(executorLog, "模板聚合",executor.getActiveCount(), executor.getQueue().size()); log.info(executorLog, "模板聚合", executor.getActiveCount(), executor.getQueue().size());
} }
/** /**
...@@ -176,7 +179,7 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta ...@@ -176,7 +179,7 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
sourceBuilder.query(boolQueryBuilder).size(10000) sourceBuilder.query(boolQueryBuilder).size(10000)
.fetchSource(new String[] { "ind_full_text", "mtime", "mtag", "mperson", "url","id"}, null); .fetchSource(new String[] { "ind_full_text", "mtime", "mtag", "mperson", "url","id"}, null);
return esDao.afterSearch(esIndexes.getIndexes(Index.mark.name()).toArray(new String[]{}), sourceBuilder, 1000).stream().map(SearchHit::getSourceAsMap).collect(Collectors.toList()); return esDao.afterSearch(esIndexes.getIndexes(Index.mark2.name()).toArray(new String[]{}), sourceBuilder, 1000).stream().map(SearchHit::getSourceAsMap).collect(Collectors.toList());
} }
/** /**
...@@ -197,7 +200,7 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta ...@@ -197,7 +200,7 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
} }
long updateTime = templateTitleVo.getUpdateTime().getTime(); long updateTime = templateTitleVo.getUpdateTime().getTime();
// 移除7天有效期外的数据 // 移除7天有效期外的数据
if (System.currentTimeMillis() - updateTime > ONE_DAY * 7 * 1000) { if (System.currentTimeMillis() - updateTime > ONE_DAY * 1000) {
log.info("{}-移除过期模板标题:{},最后更新时间:{}", group, title, updateTime); log.info("{}-移除过期模板标题:{},最后更新时间:{}", group, title, updateTime);
templateTitleService.deleteTemplate(group, title); templateTitleService.deleteTemplate(group, title);
return false; return false;
......
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