Commit e61f13b9 by liuyu

2023年04月27 模板重置失败任务

parent 4e6076fd
......@@ -6,7 +6,8 @@ public enum TaskType {
TEMPLATE("template", null),
TEMPLATE_MODIFY("template_modify", null),
TEMPLATE_RESET("template_reset", null),
TEMPLATE_RECORD("template_record", null);
TEMPLATE_RECORD("template_record", null),
TEMPLATE_CLEAR_RETRY("template_clear_retry", null);
final String type;
......
......@@ -3,8 +3,11 @@ package com.zhiwei.middleware.automatic.server.mission;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.middleware.automatic.server.common.GenericAttribute;
import com.zhiwei.middleware.automatic.server.pojo.AutoTask;
import com.zhiwei.middleware.automatic.server.pojo.TemplateTitleVo;
import com.zhiwei.middleware.automatic.server.pojo.enums.TaskType;
import com.zhiwei.middleware.automatic.server.pojo.enums.TemplateStatus;
import com.zhiwei.middleware.automatic.server.redis.RedissonUtil;
import com.zhiwei.middleware.automatic.server.service.TemplateTitleService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.scheduling.annotation.Async;
......@@ -13,6 +16,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Calendar;
import java.util.Map;
@Component
@EnableScheduling
......@@ -26,9 +30,13 @@ public class ScheduledMission {
private final AsyncTask asyncTask;
public ScheduledMission(RedissonUtil redissonUtil, AsyncTask asyncTask) {
private final TemplateTitleService templateTitleService;
public ScheduledMission(RedissonUtil redissonUtil, AsyncTask asyncTask,
TemplateTitleService templateTitleService) {
this.redissonUtil = redissonUtil;
this.asyncTask = asyncTask;
this.templateTitleService = templateTitleService;
}
......@@ -60,6 +68,7 @@ public class ScheduledMission {
long startTime = calendar.getTime().getTime();
long endTime = System.currentTimeMillis();
for (String project : asyncTask.findAllGroup()) {
//模板聚合任务
putTask(project, startTime, endTime);
}
......@@ -84,4 +93,16 @@ public class ScheduledMission {
redissonUtil.putQueue(GenericAttribute.KEY, JSONObject.toJSONString(autoTask));
}
private void putTaskBy(String group) {
Map<String, TemplateTitleVo> project = templateTitleService.getTemplateTitleByProject(group);
for (Map.Entry<String, TemplateTitleVo> entry : project.entrySet()) {
if (entry.getValue().getStatus() == TemplateStatus.重置失败) {
AutoTask autoTask = new AutoTask(TaskType.TEMPLATE_CLEAR_RETRY.getType());
autoTask.getParamSource().put(GenericAttribute.GROUP_PARAM, group);
autoTask.getParamSource().put(GenericAttribute.TEMPLATE_TITLE, entry.getKey());
redissonUtil.putQueue(GenericAttribute.KEY, JSONObject.toJSONString(autoTask));
}
}
}
}
......@@ -67,6 +67,7 @@ public class TaskServiceTemplate implements TaskService {
TYPE_MAP.put(TaskType.TEMPLATE.getType(), Pair.of(TaskType.TEMPLATE, this::runTask));
TYPE_MAP.put(TaskType.TEMPLATE_MODIFY.getType(), Pair.of(TaskType.TEMPLATE_MODIFY, this::templateModify));
TYPE_MAP.put(TaskType.TEMPLATE_RESET.getType(), Pair.of(TaskType.TEMPLATE_RESET, this::templateReset));
TYPE_MAP.put(TaskType.TEMPLATE_CLEAR_RETRY.getType(), Pair.of(TaskType.TEMPLATE_CLEAR_RETRY, this::templateReset));
TYPE_MAP.put(TaskType.TEMPLATE_RECORD.getType(), Pair.of(TaskType.TEMPLATE_RECORD, this::templateRecordClean));
}
......
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