Commit aec307f9 by guo_minglei@163.com

统计数据接口返回

parent 84f12afb
...@@ -16,7 +16,6 @@ import com.byit.mapper.*; ...@@ -16,7 +16,6 @@ import com.byit.mapper.*;
import com.byit.model.JobTaskRunLog; import com.byit.model.JobTaskRunLog;
import com.byit.model.RunRecording; import com.byit.model.RunRecording;
import com.byit.model.*; import com.byit.model.*;
import com.byit.model.po.StatusPO;
import com.byit.model.vo.RunRecordingVo; import com.byit.model.vo.RunRecordingVo;
import com.byit.service.ApiFlowService; import com.byit.service.ApiFlowService;
import com.byit.util.ApiFlowDagCheck; import com.byit.util.ApiFlowDagCheck;
...@@ -82,6 +81,9 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -82,6 +81,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
private WaitingTaskMapper waitingTaskMapper; private WaitingTaskMapper waitingTaskMapper;
@Resource @Resource
private FlowStatusSnapshootMapper flowStatusSnapshootMapper;
@Resource
private CurrentUserUtils currentUserUtils; private CurrentUserUtils currentUserUtils;
private void parseParam(String param, DeleteDto deletDto){ private void parseParam(String param, DeleteDto deletDto){
...@@ -726,13 +728,37 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -726,13 +728,37 @@ public class ApiFlowServiceImpl implements ApiFlowService {
} }
} }
List<StatusPO> runRecordingList = runRecordingMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList); StatisticData flowStatisticData = runRecordingMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
List<StatusPO> runLogList = jobTaskRunLogMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList); StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
StatisticData nodeDate = new StatisticData(); List<FlowStatusSnapshoot> flowStatusSnapshootList = flowStatusSnapshootMapper.findByTime(startTime, endTime);
runLogList.forEach(statusPO -> {
Map<String, StatisticData> collectMap = new HashMap<>();
flowStatusSnapshootList.forEach(flowStatusSnapshoot -> {
String key = flowStatusSnapshoot.getDay() + " " + flowStatusSnapshoot.getHour();
StatisticData statisticData = collectMap.get(key);
if (null == statisticData){
statisticData = new StatisticData();
statisticData.setUnstart(flowStatusSnapshoot.getUnstartNode());
statisticData.setRunIng(flowStatusSnapshoot.getRuningNode());
statisticData.setSuccess(flowStatusSnapshoot.getSuccessNode());
statisticData.setFail(flowStatusSnapshoot.getFailNode());
statisticData.setKill(flowStatusSnapshoot.getKillNode());
collectMap.put(key, statisticData);
}else {
statisticData.setUnstart(statisticData.getUnstart() + flowStatusSnapshoot.getUnstartNode());
statisticData.setRunIng(statisticData.getRunIng() + flowStatusSnapshoot.getRuningNode());
statisticData.setSuccess(statisticData.getSuccess() + flowStatusSnapshoot.getSuccessNode());
statisticData.setFail(statisticData.getFail() + flowStatusSnapshoot.getFailNode());
statisticData.setKill(statisticData.getKill() + flowStatusSnapshoot.getKillNode());
collectMap.put(key, statisticData);
}
}); });
return null;
CollectData collectData = new CollectData();
collectData.setFlowData(flowStatisticData);
collectData.setNodeData(nodeStatisticData);
collectData.setCollectMap(collectMap);
return collectData;
} }
public static void main(String[] args) throws ParseException { public static void main(String[] args) throws ParseException {
......
...@@ -38,4 +38,12 @@ public interface FlowStatusSnapshootMapper { ...@@ -38,4 +38,12 @@ public interface FlowStatusSnapshootMapper {
* @return * @return
*/ */
int deleteOutSnapShoot(Long outTime); int deleteOutSnapShoot(Long outTime);
/**
* 根据时间范围查询
* @param startTime
* @param endTime
* @return
*/
List<FlowStatusSnapshoot> findByTime(Long startTime, Long endTime);
} }
\ No newline at end of file
...@@ -3,7 +3,6 @@ package com.byit.mapper; ...@@ -3,7 +3,6 @@ package com.byit.mapper;
import com.byit.dto.plugin.StatisticData; import com.byit.dto.plugin.StatisticData;
import com.byit.model.JobTaskRunLog; import com.byit.model.JobTaskRunLog;
import com.byit.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.po.StatusPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -120,7 +119,7 @@ public interface JobTaskRunLogMapper { ...@@ -120,7 +119,7 @@ public interface JobTaskRunLogMapper {
* @param flowIdList * @param flowIdList
* @return * @return
*/ */
List<StatusPO> findStatusByStartAndEndTime(@Param("startTime")Long startTime, StatisticData findStatusByStartAndEndTime(@Param("startTime")Long startTime,
@Param("endTime")Long endTime, @Param("endTime")Long endTime,
@Param("flowIdList")List<Integer> flowIdList); @Param("flowIdList")List<Integer> flowIdList);
......
package com.byit.mapper; package com.byit.mapper;
import com.byit.dto.plugin.StatisticData;
import com.byit.model.RunRecording; import com.byit.model.RunRecording;
import com.byit.model.po.StatusPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -166,9 +166,9 @@ public interface RunRecordingMapper { ...@@ -166,9 +166,9 @@ public interface RunRecordingMapper {
* @param flowIdList * @param flowIdList
* @return * @return
*/ */
List<StatusPO> findStatusByStartAndEndTime(@Param("startTime")Long startTime, StatisticData findStatusByStartAndEndTime(@Param("startTime")Long startTime,
@Param("endTime")Long endTime, @Param("endTime")Long endTime,
@Param("flowIdList")List<Integer> flowIdList); @Param("flowIdList")List<Integer> flowIdList);
RunRecording findMaxByFlowId(@Param("flowId")Integer flowId); RunRecording findMaxByFlowId(@Param("flowId")Integer flowId);
} }
\ No newline at end of file
package com.byit.model.po;
import lombok.Data;
/**
* @Description
* @Author guo_m
* @Date 2020-04-01
*/
@Data
public class StatusPO {
private Integer flowId;
private Integer nodeId;
private Integer status;
private Long startTime;
}
package com.byit.thread.helper; package com.byit.thread.helper;
import com.alibaba.fastjson.JSON;
import com.byit.dto.plugin.StatisticData; import com.byit.dto.plugin.StatisticData;
import com.byit.mapper.FlowMapper; import com.byit.mapper.FlowMapper;
import com.byit.mapper.FlowStatusSnapshootMapper; import com.byit.mapper.FlowStatusSnapshootMapper;
......
...@@ -198,6 +198,13 @@ ...@@ -198,6 +198,13 @@
from flow_status_snapshoot from flow_status_snapshoot
where 'day' = #{date} and `hour` = #{hour} where 'day' = #{date} and `hour` = #{hour}
</select> </select>
<select id="findByTime" resultType="com.byit.model.FlowStatusSnapshoot">
select
<include refid="Base_Column_List" />
from flow_status_snapshoot
where snapshoot_time &gt;= ${startDate}
and snapshoot_time &lt;= ${endDate}
</select>
<delete id="deleteOutSnapShoot" parameterType="java.lang.Long"> <delete id="deleteOutSnapShoot" parameterType="java.lang.Long">
delete from flow_status_snapshoot delete from flow_status_snapshoot
where snapshoot_time = #{outTime,jdbcType=BIGINT} where snapshoot_time = #{outTime,jdbcType=BIGINT}
......
...@@ -121,20 +121,13 @@ ...@@ -121,20 +121,13 @@
from job_task_run_log from job_task_run_log
where log_id = #{logId,jdbcType=INTEGER} where log_id = #{logId,jdbcType=INTEGER}
</select> </select>
<select id="findStatusByStartAndEndTime" resultType="com.byit.model.po.StatusPO"> <select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData">
select case run_code select sum(case when run_code = '0' then 1 else 0 end) as runIng,
when 0 then 2 sum(case when run_code = '1' or run_code = '3' then 1 else 0 end) as success,
when 1 then 3 sum(case when run_code = '2' or run_code = '4' or run_code = '6' then 1 else 0 end) as fail,
when 2 then 4 sum(case when run_code = '5' then 1 else 0 end) as 'kill'
when 3 then 3 from job_task_run_log
when 4 then 4 where start_time &gt;= ${startDate}
when 5 then 5
when 5 then 4
else 0
end status,
start_time
from job_task_run_log
where start_time &gt;= ${startDate}
and end_time &lt;= ${endDate} and end_time &lt;= ${endDate}
<if test="flowIds != null"> <if test="flowIds != null">
and flow_id in ( and flow_id in (
......
...@@ -148,26 +148,14 @@ ...@@ -148,26 +148,14 @@
where flow_id = #{flowId} where flow_id = #{flowId}
and flow_status != '4' and flow_status != '4'
</select> </select>
<select id="findStatusByStartAndEndTime" resultType="com.byit.model.po.StatusPO"> <select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData">
select flowStatus + results as status, start_time as startTime, flow_id as flowId select sum(case when flow_status = '1' then 1 else 0 end ) unstart,
from ( sum(case when flow_status='2' then 1 else 0 end ) runing,
select sum(case when flow_status='3' then 1 else 0 end ) stop,
case flow_status sum(case when flow_status='4' and (flow_run_result = '1' or flow_run_result = '3') then 1 else 0 end ) success,
when 1 then 1 sum(case when flow_status='4' and (flow_run_result = '2' or flow_run_result = '4') then 1 else 0 end ) fail,
when 2 then 2 sum(case when flow_run_result='5' then 1 else 0 end ) 'kill'
else 0 from run_recording
end flowStatus,
case flow_run_result
when 1 then 3
when 2 then 4
when 3 then 3
when 4 then 4
when 5 then 5
else 0
end results,
start_time,
flow_id
from run_recording
where start_time &gt;= ${startDate} where start_time &gt;= ${startDate}
and end_time &lt;= ${endDate} and end_time &lt;= ${endDate}
<if test="flowIds != null"> <if test="flowIds != null">
...@@ -177,7 +165,6 @@ ...@@ -177,7 +165,6 @@
</foreach> </foreach>
) )
</if> </if>
) recording
</select> </select>
<select id="findMaxByFlowId" resultType="com.byit.model.RunRecording"> <select id="findMaxByFlowId" resultType="com.byit.model.RunRecording">
select <include refid="Base_Column_List" /> select <include refid="Base_Column_List" />
......
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