Authored by mlge

gatewayAccess事件检测 支持 按照事件名称 搜索

  1 +package com.monitor.model.request;
  2 +
  3 +import com.monitor.model.page.PageRequest;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * Created by meiling.ge on 2017/8/18.
  8 + */
  9 +@Data
  10 +public class GateWayTaskReq extends PageRequest {
  11 + private String eventName;
  12 +// private int dataSource;
  13 +}
@@ -16,9 +16,9 @@ public interface TaskSheduleMapper { @@ -16,9 +16,9 @@ public interface TaskSheduleMapper {
16 16
17 TaskModel selectById(int id); 17 TaskModel selectById(int id);
18 18
19 - List<TaskModel> selectByPageWithSourceTask(PageBean page); 19 + List<TaskModel> selectByPageWithSourceTask(@Param("page")PageBean page);
20 20
21 - List<TaskModel> selectByPageWithSourceGateway(PageBean page); 21 +// List<TaskModel> selectByPageWithSourceGateway(@Param("page")PageBean page);
22 22
23 int deleteById(int id); 23 int deleteById(int id);
24 24
@@ -26,7 +26,7 @@ public interface TaskSheduleMapper { @@ -26,7 +26,7 @@ public interface TaskSheduleMapper {
26 26
27 int insert(TaskModel taskModel); 27 int insert(TaskModel taskModel);
28 28
29 - int selectCount(int addSource); 29 + int selectCount(@Param("page")PageBean page);
30 30
31 int updateLastTime(int id); 31 int updateLastTime(int id);
32 } 32 }
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 <result column="alarm_group_id" property="alarmGroupId" jdbcType="INTEGER"/> 25 <result column="alarm_group_id" property="alarmGroupId" jdbcType="INTEGER"/>
26 <result column="addsource" property="addSource" jdbcType="INTEGER"/> 26 <result column="addsource" property="addSource" jdbcType="INTEGER"/>
27 <result column="influx_sql_snd" property="influxSqlSnd" jdbcType="VARCHAR"/> 27 <result column="influx_sql_snd" property="influxSqlSnd" jdbcType="VARCHAR"/>
28 - <result column="eventName" property="eventName" jdbcType="VARCHAR"/> 28 + <result column="eventname" property="eventName" jdbcType="VARCHAR"/>
29 <result column="operation" property="operation" jdbcType="INTEGER"/> 29 <result column="operation" property="operation" jdbcType="INTEGER"/>
30 <result column="data_interval_times" property="dataIntervalTimes" jdbcType="INTEGER"/> 30 <result column="data_interval_times" property="dataIntervalTimes" jdbcType="INTEGER"/>
31 </resultMap> 31 </resultMap>
@@ -47,25 +47,34 @@ @@ -47,25 +47,34 @@
47 select 47 select
48 * 48 *
49 from task_shedule 49 from task_shedule
50 - where addsource = 0  
51 - order by id  
52 - limit #{startIndex},#{pageSize} 50 + where addsource = #{page.params.addSource,jdbcType=INTEGER}
  51 + <if test="page.params.eventName != null &amp;&amp; page.params.eventName != ''" >
  52 + and eventname like CONCAT('%',#{page.params.eventName,jdbcType=VARCHAR},'%' )
  53 + </if>
  54 + order by id
  55 + limit #{page.startIndex},#{page.pageSize}
53 </select> 56 </select>
54 57
55 - <select id="selectByPageWithSourceGateway" resultMap="BaseResultMap"> 58 + <!--<select id="selectByPageWithSourceGateway" resultMap="BaseResultMap">
56 select 59 select
57 * 60 *
58 from task_shedule 61 from task_shedule
59 where addsource = 1 62 where addsource = 1
  63 + <if test="page.params.eventName != null &amp;&amp; page.params.eventName != ''" >
  64 + and eventname like CONCAT('%',#{page.params.eventName,jdbcType=VARCHAR},'%' )
  65 + </if>
60 order by id 66 order by id
61 - limit #{startIndex},#{pageSize}  
62 - </select> 67 + limit #{page.startIndex},#{page.pageSize}
  68 + </select>-->
63 69
64 <select id="selectCount" resultType="java.lang.Integer"> 70 <select id="selectCount" resultType="java.lang.Integer">
65 select 71 select
66 count(1) 72 count(1)
67 from task_shedule 73 from task_shedule
68 - where addsource = #{addSource,jdbcType=INTEGER} 74 + where addsource = #{page.params.addSource,jdbcType=INTEGER}
  75 + <if test="page.params.eventName != null &amp;&amp; page.params.eventName != ''" >
  76 + and eventname like CONCAT('%',#{page.params.eventName,jdbcType=VARCHAR},'%' )
  77 + </if>
69 </select> 78 </select>
70 79
71 <delete id="deleteById" parameterType="java.lang.Integer"> 80 <delete id="deleteById" parameterType="java.lang.Integer">
@@ -93,7 +102,7 @@ @@ -93,7 +102,7 @@
93 description = #{description,jdbcType=VARCHAR}, 102 description = #{description,jdbcType=VARCHAR},
94 inf_database = #{database,jdbcType=VARCHAR}, 103 inf_database = #{database,jdbcType=VARCHAR},
95 alarm_group_id = #{alarmGroupId,jdbcType=INTEGER}, 104 alarm_group_id = #{alarmGroupId,jdbcType=INTEGER},
96 - eventName = #{eventName,jdbcType=INTEGER}, 105 + eventname = #{eventName,jdbcType=INTEGER},
97 operation = #{operation,jdbcType=INTEGER}, 106 operation = #{operation,jdbcType=INTEGER},
98 data_interval_times = #{dataIntervalTimes,jdbcType=INTEGER} 107 data_interval_times = #{dataIntervalTimes,jdbcType=INTEGER}
99 where id = #{id,jdbcType=INTEGER} 108 where id = #{id,jdbcType=INTEGER}
@@ -120,7 +129,7 @@ @@ -120,7 +129,7 @@
120 alarm_group_id, 129 alarm_group_id,
121 addsource, 130 addsource,
122 influx_sql_snd, 131 influx_sql_snd,
123 - eventName, 132 + eventname,
124 operation, 133 operation,
125 data_interval_times) 134 data_interval_times)
126 values 135 values
@@ -28,7 +28,7 @@ public class NewTask implements Runnable{ @@ -28,7 +28,7 @@ public class NewTask implements Runnable{
28 } 28 }
29 if (!TaskStroe.isOn(taskModel.getId())){ 29 if (!TaskStroe.isOn(taskModel.getId())){
30 SingleTask singleTask = new SingleTask(taskModel.getId()); 30 SingleTask singleTask = new SingleTask(taskModel.getId());
31 - ScheduledFuture scheduledFuture = taskScheduler.scheduleAtFixedRate(singleTask, taskModel.getInterval() * 60 * 1000); 31 + ScheduledFuture scheduledFuture = taskScheduler.scheduleAtFixedRate(singleTask, taskModel.getInterval() * 60 * 1000);
32 TaskStroe.addTask(taskModel.getId(),scheduledFuture); 32 TaskStroe.addTask(taskModel.getId(),scheduledFuture);
33 } 33 }
34 } 34 }
@@ -4,6 +4,7 @@ import com.model.TaskModel; @@ -4,6 +4,7 @@ import com.model.TaskModel;
4 import com.monitor.model.domain.PageBean; 4 import com.monitor.model.domain.PageBean;
5 import com.monitor.model.page.PageRequest; 5 import com.monitor.model.page.PageRequest;
6 import com.monitor.model.page.PageResponse; 6 import com.monitor.model.page.PageResponse;
  7 +import com.monitor.model.request.GateWayTaskReq;
7 import com.monitor.model.response.BaseResponse; 8 import com.monitor.model.response.BaseResponse;
8 import com.monitor.mysql.mapper.TaskSheduleMapper; 9 import com.monitor.mysql.mapper.TaskSheduleMapper;
9 import org.slf4j.Logger; 10 import org.slf4j.Logger;
@@ -26,37 +27,35 @@ public class TaskConfigureCtrl { @@ -26,37 +27,35 @@ public class TaskConfigureCtrl {
26 27
27 Logger log = LoggerFactory.getLogger(TaskConfigureCtrl.class); 28 Logger log = LoggerFactory.getLogger(TaskConfigureCtrl.class);
28 29
29 - private final int menu_task_addSource=0;//来源于任务管理的菜单数据  
30 - private final int menu_gateway_addSource=1;//来源于gataway任务管理菜单的数据 30 + private static final int MENU_TASK_ADDSOURCE = 0;//来源于任务管理的菜单数据
  31 + private static final int MEBU_GATEWAY_ADDSOURCE = 1;//来源于gataway任务管理菜单的数据
31 32
32 @Autowired 33 @Autowired
33 private TaskSheduleMapper taskSheduleMapper; 34 private TaskSheduleMapper taskSheduleMapper;
34 35
  36 + //任务管理
35 @RequestMapping("/getTaskConfigure") 37 @RequestMapping("/getTaskConfigure")
36 @ResponseBody 38 @ResponseBody
37 - public BaseResponse<PageResponse<TaskModel>> getTaskConfigure(@RequestBody PageRequest request) {  
38 - return getTaskConfigureFromMenu(request,menu_task_addSource); 39 + public BaseResponse<PageResponse<TaskModel>> getTaskConfigure(@RequestBody GateWayTaskReq request) {
  40 + return getTaskConfigureFromMenu(request,MENU_TASK_ADDSOURCE);
39 } 41 }
40 42
41 - private BaseResponse<PageResponse<TaskModel>> getTaskConfigureFromMenu(PageRequest request ,int addSource){ 43 + private BaseResponse<PageResponse<TaskModel>> getTaskConfigureFromMenu(GateWayTaskReq request , int addSource){
42 try { 44 try {
43 // 组装分页对象 45 // 组装分页对象
44 PageBean page = PageBean.initPageInfo(request.getCurrentPage(), 46 PageBean page = PageBean.initPageInfo(request.getCurrentPage(),
45 request.getPageSize(), request); 47 request.getPageSize(), request);
  48 + page.getParams().put("addSource",addSource);//设置数据源
46 // 先查询符合条件的总数量 49 // 先查询符合条件的总数量
47 - int total = taskSheduleMapper.selectCount(addSource); 50 + int total = taskSheduleMapper.selectCount(page);
48 // 数量为0 直接返回 51 // 数量为0 直接返回
49 if (total == 0) { 52 if (total == 0) {
50 // 返回初始page对象 53 // 返回初始page对象
51 return null; 54 return null;
52 } 55 }
53 // 获取列表 56 // 获取列表
54 - List<TaskModel> taskModels =null;  
55 - if(menu_task_addSource==addSource){  
56 - taskModels=taskSheduleMapper.selectByPageWithSourceTask(page);  
57 - }else if(menu_gateway_addSource==addSource){  
58 - taskModels=taskSheduleMapper.selectByPageWithSourceGateway(page);  
59 - } 57 + List<TaskModel> taskModels = null;
  58 + taskModels = taskSheduleMapper.selectByPageWithSourceTask(page);
60 if (CollectionUtils.isEmpty(taskModels)) { 59 if (CollectionUtils.isEmpty(taskModels)) {
61 return null; 60 return null;
62 } 61 }
@@ -115,11 +114,11 @@ public class TaskConfigureCtrl { @@ -115,11 +114,11 @@ public class TaskConfigureCtrl {
115 } 114 }
116 115
117 116
118 - 117 + //gateWay access事件检测----后续新增功能--MEBU_GATEWAY_ADDSOURCE区分数据源
119 @RequestMapping("/getGatewayConfigure") 118 @RequestMapping("/getGatewayConfigure")
120 @ResponseBody 119 @ResponseBody
121 - public BaseResponse<PageResponse<TaskModel>> getGateWayTaskConfigure(@RequestBody PageRequest request) {  
122 - return getTaskConfigureFromMenu(request,menu_gateway_addSource); 120 + public BaseResponse<PageResponse<TaskModel>> getGateWayTaskConfigure(@RequestBody GateWayTaskReq request) {
  121 + return getTaskConfigureFromMenu(request,MEBU_GATEWAY_ADDSOURCE);
123 122
124 } 123 }
125 } 124 }