parent
2a5ed5f6fb
commit
5cbc8e22ba
|
@ -7,10 +7,7 @@ package net.northking.cctp.executePlan.db.dao;
|
|||
import net.northking.cctp.common.http.QueryByPage;
|
||||
import net.northking.cctp.executePlan.db.entity.AtuPlanTask;
|
||||
import net.northking.cctp.executePlan.db.mapper.AtuPlanTaskMapper;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskExtendDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskPageDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskQueryDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuTaskSendBugDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.*;
|
||||
import net.northking.cctp.executePlan.pub.dto.ScriptFirstExecutionDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -132,4 +129,6 @@ public interface AtuPlanTaskDao extends AtuPlanTaskMapper
|
|||
AtuPlanTaskExtendDto queryTaskExtendById(String id);
|
||||
|
||||
List<AtuPlanTask> queryWaitTimeoutTask(@Param("waitTimeout") Integer waitTimeout);
|
||||
|
||||
List<ScriptStatusStatistic> countTaskStatus(AtuPlanTask task);
|
||||
}
|
||||
|
|
|
@ -6,16 +6,16 @@ package net.northking.cctp.executePlan.db.impl;
|
|||
|
||||
import net.northking.cctp.common.db.BasicDao;
|
||||
import net.northking.cctp.common.db.PaginationService;
|
||||
import net.northking.cctp.common.exception.PlatformRuntimeException;
|
||||
import net.northking.cctp.common.http.QueryByPage;
|
||||
import net.northking.cctp.executePlan.db.dao.AtuPlanTaskDao;
|
||||
import net.northking.cctp.executePlan.db.entity.AtuPlanTask;
|
||||
import net.northking.cctp.executePlan.db.service.AtuPlanTaskService;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskExtendDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskPageDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskQueryDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuTaskSendBugDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.*;
|
||||
import net.northking.cctp.executePlan.exception.ExecPlanError;
|
||||
import net.northking.cctp.executePlan.pub.dto.ScriptFirstExecutionDTO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -183,6 +183,20 @@ private static final Logger logger = LoggerFactory.getLogger(AtuPlanTaskServiceI
|
|||
return atuPlanTaskDao.queryWaitTimeoutTask(waitTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定批次下分组查询脚本下任务的执行状态结果
|
||||
*
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ScriptStatusStatistic> countTaskStatus(AtuPlanTask task) {
|
||||
if (task == null || StringUtils.isBlank(task.getBatchId())) {
|
||||
throw new PlatformRuntimeException(ExecPlanError.EMPTY_BATCH_ID);
|
||||
}
|
||||
return this.atuPlanTaskDao.countTaskStatus(task);
|
||||
}
|
||||
|
||||
// ---- The End by Generator ----//
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ package net.northking.cctp.executePlan.db.service;
|
|||
import net.northking.cctp.common.db.BasicService;
|
||||
import net.northking.cctp.common.http.QueryByPage;
|
||||
import net.northking.cctp.executePlan.db.entity.AtuPlanTask;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskExtendDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskPageDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuPlanTaskQueryDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.AtuTaskSendBugDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.*;
|
||||
import net.northking.cctp.executePlan.pub.dto.ScriptFirstExecutionDTO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
@ -136,4 +133,11 @@ public interface AtuPlanTaskService extends BasicService<AtuPlanTask>
|
|||
AtuPlanTaskExtendDto queryTaskExtendById(String taskId);
|
||||
|
||||
List<AtuPlanTask> queryWaitTimeoutTask(Integer waitTimeout);
|
||||
|
||||
/**
|
||||
* 统计指定批次下分组查询脚本下任务的执行状态结果
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
List<ScriptStatusStatistic> countTaskStatus(AtuPlanTask task);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ public enum ExecPlanError implements PlatformError {
|
|||
|
||||
PARSE_DATE_ERROR("格式化日期出错,请检查参数"),
|
||||
|
||||
EMPTY_BATCH_ID("批次id不能为空"),
|
||||
|
||||
GET_FILE_FAIL("获取文件失败"),
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.northking.cctp.executePlan.db.entity.*;
|
|||
import net.northking.cctp.executePlan.db.service.*;
|
||||
import net.northking.cctp.executePlan.dto.planBatch.*;
|
||||
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanRunDto;
|
||||
import net.northking.cctp.executePlan.dto.planTask.ScriptStatusStatistic;
|
||||
import net.northking.cctp.executePlan.enums.MobilePlatformEnum;
|
||||
import net.northking.cctp.executePlan.feign.PublicFeignClient;
|
||||
import net.northking.cctp.executePlan.utils.MinioPathUtils;
|
||||
|
@ -134,6 +135,8 @@ public class PlanBatchTaskDataUpdateJob {
|
|||
Map<Object, Object> entries = redisTemplate.opsForHash().entries(key);
|
||||
if (CollUtil.isEmpty(entries)) {
|
||||
logger.info("缓存[" + key + "]中无统计数据");
|
||||
// 没有统计数据,删掉key
|
||||
redisTemplate.delete(key);
|
||||
return;
|
||||
}
|
||||
String batchId = key.substring(key.lastIndexOf(":") + 1);
|
||||
|
@ -150,7 +153,21 @@ public class PlanBatchTaskDataUpdateJob {
|
|||
if (ObjectUtil.isNotNull(runningStatusObj)) {
|
||||
runningTotal = Integer.parseInt(runningStatusObj.toString());
|
||||
}
|
||||
// TODO: 判断有没有负数、总数是否相等
|
||||
// TODO: 判断有没有数据是否合法、如果存在问题,重新获取数据库进行统计刷新
|
||||
if (waitTotal < 0 || runningTotal < 0) { // 重新统计
|
||||
AtuPlanTask taskQ = new AtuPlanTask();
|
||||
taskQ.setBatchId(batchId);
|
||||
List<ScriptStatusStatistic> resultList = planTaskService.countTaskStatus(taskQ);
|
||||
for (ScriptStatusStatistic result : resultList) {
|
||||
Set<String> statusSet = result.getStatusSet();
|
||||
if (!statusSet.isEmpty()) {
|
||||
// 状态集合不为空,根据状态设置脚本的结果状态
|
||||
|
||||
} else {
|
||||
// todo: 如果是空,如何处理
|
||||
}
|
||||
}
|
||||
}
|
||||
// 失败的数据
|
||||
// 脚本超时的
|
||||
if (waitTotal != 0 || runningTotal != 0) {
|
||||
|
@ -191,7 +208,7 @@ public class PlanBatchTaskDataUpdateJob {
|
|||
if (ObjectUtil.isNotNull(cancelStatusObj)) {
|
||||
cancelTotal = Integer.parseInt(cancelStatusObj.toString());
|
||||
}
|
||||
// TODO: 统计库表数据进行更新,而不是通过缓存
|
||||
// TODO: 如果等待中和执行中都没有,都为0,统计库表数据进行更新,而不是通过缓存
|
||||
// 更新批次表
|
||||
AtuPlanBatch planBatch = new AtuPlanBatch();
|
||||
planBatch.setId(batchId);
|
||||
|
@ -710,4 +727,9 @@ public class PlanBatchTaskDataUpdateJob {
|
|||
// 绑定脚本
|
||||
planScriptLinkService.insertByBatch(scriptLinkList);
|
||||
}
|
||||
|
||||
private String scriptStatus(Set<String> statusSet) {
|
||||
if (statusSet == null || statusSet.isEmpty()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,4 +366,24 @@
|
|||
<select id="queryAllFailIdList" resultType="java.lang.String">
|
||||
select id from <include refid="Table_Name"/> where batch_id = #{batchId} and status in ("3", "4", "6")
|
||||
</select>
|
||||
|
||||
<resultMap id="taskStatusMap" type="net.northking.cctp.executePlan.dto.planTask.ScriptStatusStatistic">
|
||||
<!-- 脚本id -->
|
||||
<result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
|
||||
<!-- 状态字符串 -->
|
||||
<result column="task_status" jdbcType="VARCHAR" property="statusString"/>
|
||||
<!-- 任务数量 -->
|
||||
<result column="total" jdbcType="INTEGER" property="total" />
|
||||
</resultMap>
|
||||
|
||||
<select id="countTaskStatus" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanTask" resultMap="taskStatusMap">
|
||||
SELECT
|
||||
script_id,
|
||||
group_concat(status) as task_status,
|
||||
count(*) as total
|
||||
FROM <include refid="Table_Name" />
|
||||
WHERE
|
||||
batch_id = #{task.batchId,jdbcType=VARCHAR}
|
||||
GROUP BY script_id
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue