| 
					
				 | 
			
			
				@@ -8,18 +8,20 @@ import com.jjt.biz.vo.BizTypeVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.vo.LevelSortVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.core.controller.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.core.page.TableDataInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.jjt.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.format.annotation.DateTimeFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.security.access.prepost.PreAuthorize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.GetMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 告警记录Controller 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -33,6 +35,8 @@ import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class AlarmRecordController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IAlarmRecordService alarmRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询告警记录列表 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -48,47 +52,104 @@ public class AlarmRecordController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("业务类型统计") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/list/bizType") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TableDataInfo listBizType(@ApiParam(value = "开始时间") Date start, @ApiParam(value = "结束时间") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TableDataInfo listBizType(@ApiParam(value = "开始时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @ApiParam(value = "结束时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<BizTypeVO> list = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (int i = 0; i < 10; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            list.add(new BizTypeVO(true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT b.obj_type,COUNT(*) num FROM alarm_record a,biz_obj b WHERE a.obj_id=b.obj_id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Vector<Object> v = new Vector<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (start != null && end != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sql += " AND a.alarm_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(start); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sql += " GROUP BY b.obj_type"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, v.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        results.forEach(map -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BizTypeVO ls = new BizTypeVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setBizType((String) map.get("obj_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setNum((Long) map.get("num")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(ls); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return getDataTable(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("应用组件统计") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/list/bizSort") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TableDataInfo listBizSort(@ApiParam(value = "分类") String bizType, @ApiParam(value = "开始时间") Date start, @ApiParam(value = "结束时间") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TableDataInfo listBizSort(@ApiParam(value = "分类") String bizType, @ApiParam(value = "开始时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @ApiParam(value = "结束时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<BizSortVO> list = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (int i = 0; i < 10; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            list.add(new BizSortVO(true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT a.obj_id,b.obj_name,b.obj_type,COUNT(*) num FROM alarm_record a,biz_obj b WHERE a.obj_id=b.obj_id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Vector<Object> v = new Vector<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.isNotEmpty(bizType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sql += " AND b.obj_type=?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(bizType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (start != null && end != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sql += " AND a.alarm_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(start); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sql += " GROUP BY a.obj_id,b.obj_name,b.obj_type"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, v.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        results.forEach(map -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BizSortVO ls = new BizSortVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setObjId(Long.valueOf((Integer) map.get("obj_id"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setObjName((String) map.get("obj_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setBizType((String) map.get("obj_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setNum((Long) map.get("num")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(ls); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return getDataTable(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("系统压力排名") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/list/bizAccess") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TableDataInfo listBizAccess(@ApiParam(value = "开始时间") Date start, @ApiParam(value = "结束时间") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TableDataInfo listBizAccess(@ApiParam(value = "开始时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @ApiParam(value = "结束时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<BizAccessVO> list = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (int i = 0; i < 10; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            list.add(new BizAccessVO(true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT a.model_id,a.model_name,ifnull(sum(c.ACCESS_TIMES),0) times FROM biz_model a,biz_model_detail b,biz_obj c" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                " WHERE a.model_id=b.model_id AND b.obj_id=c.obj_id GROUP BY a.model_id,a.model_name ORDER BY times desc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> mdList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mdList.forEach(map -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BizAccessVO vo = new BizAccessVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer modelId = (Integer) map.get("model_id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String modelName = (String) map.get("model_name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal times = (BigDecimal) map.get("times"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            vo.setAccess(times.longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            vo.setModelId(Long.valueOf(modelId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            vo.setModelName(modelName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Vector<Object> v = new Vector<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String sql1 = "SELECT COUNT(*) FROM alarm_record WHERE obj_id IN(SELECT obj_id FROM biz_model_detail WHERE model_id=?)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(modelId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (start != null && end != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sql1 += " AND alarm_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                v.add(start); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                v.add(end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long num = jdbcTemplate.queryForObject(sql1, Long.class, v.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            vo.setNum(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(vo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return getDataTable(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("等级级别排名") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/list/levelSort") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TableDataInfo listLevelSort(@ApiParam(value = "开始时间") Date start, @ApiParam(value = "结束时间") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TableDataInfo listLevelSort(@ApiParam(value = "开始时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @ApiParam(value = "结束时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<LevelSortVO> list = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        LevelSortVO ls1 = new LevelSortVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls1.setLevel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls1.setNum(88L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        LevelSortVO ls2 = new LevelSortVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls2.setLevel("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls1.setNum(15L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        LevelSortVO ls3 = new LevelSortVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls3.setLevel("3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ls1.setNum(3L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Vector<Object> v = new Vector<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT alarm_level,COUNT(*) num FROM alarm_record"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (start != null && end != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sql += " WHERE alarm_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(start); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            v.add(end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sql += " GROUP BY alarm_level"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, v.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        results.forEach(map -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LevelSortVO ls = new LevelSortVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setLevel((String) map.get("alarm_level")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ls.setNum((Long) map.get("num")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(ls); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return getDataTable(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |