Commit 878bfaf0 by shentao

Merge branch 'release' into 'master'

Release

See merge request !99
parents d07d2734 5ea958f0
......@@ -9,7 +9,8 @@ public enum TaskType {
TEMPLATE_RECORD("template_record", null, "模板特征值清除记录任务"),
TEMPLATE_CLEAR_RETRY("template_clear_retry", null, "模板重置模板重试任务"),
TEMPLATE_LOST_RESET("template_lost_reset", null, "过期重置模板清除任务"),
TEMPLATE_DAY_CLEAR("template_day_clear", null, "模板每日清除任务");
TEMPLATE_DAY_CLEAR("template_day_clear", null, "模板每日清除任务"),
TEMPLATE_LOST_REMOVE("template_lost_remove", null, "过期模板清除任务");
final String type;
......
......@@ -88,6 +88,8 @@ public class ScheduledMission {
AutoTask autoTask = new AutoTask(TaskType.TEMPLATE_DAY_CLEAR.getType(), project, startTime, endTime);
log.info("任务类型:{},项目:{},开始时间:{},结束时间:{}已创建", autoTask.getType(), autoTask.getGroup(),startTime, endTime);
TaskManager.getInstance().putTask(autoTask);
// 过期模板删除
TaskManager.getInstance().putTask(new AutoTask(TaskType.TEMPLATE_LOST_REMOVE.getType(), project));
}
} catch (Exception e) {
log.error("模板每日清除任务构建失败", e);
......
......@@ -20,6 +20,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Service
......@@ -27,6 +28,9 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
private static final Logger log = LogManager.getLogger(TemplateTitleServiceImpl.class);
private static final Pattern SYMBOL_PATTERN = Pattern
.compile("[\\p{P}+~$`^=丨|<>~`$^+=|<>¥×\\s\u200B\u200C\u200D\u00A0\u0020\u3000]");
private final RedissonUtil redissonUtil;
private final TemplateRecordDao templateRecordDao;
......@@ -138,6 +142,7 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
res.put("errorMessage", "该项目组未有聚合集");
return res;
}
title = filterSymbol(title);
TemplateTitleVo titleVo = null;
double similarity = 0.0;
for (Map.Entry<String, TemplateTitleVo> entry : templateTitleVoMap.entrySet()) {
......@@ -190,4 +195,17 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
}
return Tools.restoreTMap(mapValue, TemplateTitleVo.class);
}
/**
* 过滤掉标题里面的标点符号
*
* @param title 标题
* @return 去除特殊符号后的标题
*/
private String filterSymbol(String title) {
if (null != title) {
return SYMBOL_PATTERN.matcher(title).replaceAll("");
}
return null;
}
}
......@@ -32,6 +32,6 @@ public class TaskPoolConfig {
@Bean("templateExecutor")
public ThreadPoolExecutorTimeout templateExecutor() {
return new ThreadPoolExecutorTimeout(1000L * 60 * 30, 32, 32,10000L,
TimeUnit.MILLISECONDS, 400, "模板任务线程池");
TimeUnit.MILLISECONDS, 1000, "模板任务线程池");
}
}
......@@ -95,4 +95,10 @@ public interface TemplateTitleService {
* @param templateTitleVo 模板
*/
void transferTemplate(String group, TemplateTitleVo templateTitleVo);
/**
* 过期模板清除
* @param group 项目
*/
void lostTemplateRemove(String group);
}
......@@ -188,6 +188,7 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
public void transferTemplate(String group, TemplateTitleVo templateTitleVo) {
String lockKey = Tools.assembleKey(GenericAttribute.LOCK, templateTitleVo.getTemplateTitle());
try {
redissonUtil.tryLock(lockKey, 5, 5);
templateTitleVo.setDaySum(0L);
redissonUtil.setMapValue(Tools.assembleKey(GenericAttribute.REDIS_MAP_LOSE_KEY, group), templateTitleVo.getTemplateTitle(), JSONObject.toJSONString(templateTitleVo));
redissonUtil.removeMapValue(Tools.assembleKey(GenericAttribute.REDIS_MAP_KEY, group), templateTitleVo.getTemplateTitle());
......@@ -198,6 +199,19 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
}
}
@Override
public void lostTemplateRemove(String group) {
List<String> removeKey = new ArrayList<>();
for (Map.Entry<String, TemplateTitleVo> entry : getTemplateTitleByProjectLost(group).entrySet()) {
if (entry.getValue().getStatus().equals(TemplateStatus.待删除)) {
removeKey.add(entry.getKey());
}
}
for (String key : removeKey) {
redissonUtil.removeMapValue(Tools.assembleKey(GenericAttribute.REDIS_MAP_LOSE_KEY, group), key);
}
}
private void setTemplateValue(String group, String title, TemplateTitleVo templateTitleVo, String fixTag, Long daySum) {
String lockKey = Tools.assembleKey(GenericAttribute.LOCK, title);
try {
......
......@@ -170,7 +170,7 @@ public class TaskServiceCommon extends BaseTaskTypePair<TaskServiceCommon.TaskCo
try {
entry.getValue().setDaySum(0L);
} catch (Exception e) {
log.error("模板初始化失败:{},", entry, e);
log.debug("模板初始化失败:{},", entry, e);
removeKey.add(entry.getKey());
}
}
......
......@@ -74,6 +74,7 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
taskCache(TaskType.TEMPLATE_RECORD, this::templateRecordClean);
taskCache(TaskType.TEMPLATE_LOST_RESET, this::templateLost);
taskCache(TaskType.TEMPLATE_DAY_CLEAR, this::templateDayClear);
taskCache(TaskType.TEMPLATE_LOST_REMOVE, this::templateLostRemove);
}
@Override
......@@ -166,6 +167,10 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
autoTask.getParamSource().getLong(GenericAttribute.START_PARAM), autoTask.getParamSource().getLong(GenericAttribute.END_PARAM));
}
private void templateLostRemove(AutoTask autoTask) {
templateTitleService.lostTemplateRemove(autoTask.getGroup());
}
/**
* 查询该项目 指定时间范围的数据
* @param mgroup 项目
......
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