|
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -131,6 +132,34 @@ public class AlarmRecordController extends BaseController {
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("业务指标统计")
|
|
|
+ @GetMapping("/list/getMetrics")
|
|
|
+ public AjaxResult getMetrics(@ApiParam(value = "对象ID") Long objId, @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();
|
|
|
+ String sql = "SELECT b.metrics_name,COUNT(*) num FROM alarm_record a,biz_obj_metrics b WHERE a.obj_metrics_id=b.obj_metrics_id";
|
|
|
+ Vector<Object> v = new Vector<>();
|
|
|
+ if (objId != null) {
|
|
|
+ sql += " AND b.obj_id=?";
|
|
|
+ v.add(objId);
|
|
|
+ }
|
|
|
+ if (start != null && end != null) {
|
|
|
+ sql += " AND a.alarm_time BETWEEN ? AND ?";
|
|
|
+ v.add(start);
|
|
|
+ v.add(end);
|
|
|
+ }
|
|
|
+ sql += " GROUP by b.metrics_name order by num desc";
|
|
|
+ List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, v.toArray());
|
|
|
+ results.forEach(map -> {
|
|
|
+ BizTypeVO ls = new BizTypeVO();
|
|
|
+ String obj_name = (String) map.get("metrics_name");
|
|
|
+ ls.setName(obj_name);
|
|
|
+ ls.setNum((Long) map.get("num"));
|
|
|
+ list.add(ls);
|
|
|
+ });
|
|
|
+
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("应用组件统计")
|
|
|
@GetMapping("/list/bizSort")
|
|
|
public AjaxResult 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) {
|
|
@@ -170,45 +199,81 @@ public class AlarmRecordController extends BaseController {
|
|
|
@GetMapping("/list/bizAccess")
|
|
|
public AjaxResult 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();
|
|
|
-// TODO 暂时使用模拟数据
|
|
|
-// 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);
|
|
|
-// });
|
|
|
- String[] names = {"市场服务", "市场出清", "市场结算", "市场合规", "信息发布"};
|
|
|
- for (int i = 0; i < names.length; i++) {
|
|
|
+ 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();
|
|
|
- vo.setModelName(names[i]);
|
|
|
- long access = Long.valueOf(new Random().nextInt(600) + 10);
|
|
|
- long num = Long.valueOf(new Random().nextInt(200) + 10);
|
|
|
- vo.setAccess(access);
|
|
|
+ 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);
|
|
|
- }
|
|
|
+ });
|
|
|
+// String[] names = {"市场服务", "市场出清", "市场结算", "市场合规", "信息发布"};
|
|
|
+// for (int i = 0; i < names.length; i++) {
|
|
|
+// BizAccessVO vo = new BizAccessVO();
|
|
|
+// vo.setModelName(names[i]);
|
|
|
+// long access = Long.valueOf(new Random().nextInt(600) + 10);
|
|
|
+// long num = Long.valueOf(new Random().nextInt(200) + 10);
|
|
|
+// vo.setAccess(access);
|
|
|
+// vo.setNum(num);
|
|
|
+// list.add(vo);
|
|
|
+// }
|
|
|
|
|
|
list.sort(Comparator.comparing(BizAccessVO::getAccess).reversed());
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("组件告警数量排名")
|
|
|
+ @GetMapping("/list/objAlarm")
|
|
|
+ public AjaxResult objAlarm(@ApiParam(value = "对象ID") Long modelId, @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();
|
|
|
+ String sql = "SELECT a.obj_id,c.obj_name,COUNT(*) num FROM alarm_record a,biz_model_detail b,biz_obj c WHERE a.obj_id=b.obj_id AND b.obj_id=c.obj_id";
|
|
|
+ Vector<Object> v = new Vector<>();
|
|
|
+ if (modelId != null) {
|
|
|
+ sql += " AND b.MODEL_ID=? ";
|
|
|
+ v.add(modelId);
|
|
|
+ }
|
|
|
+ if (start != null && end != null) {
|
|
|
+ sql += " AND a.alarm_time BETWEEN ? AND ?";
|
|
|
+ v.add(start);
|
|
|
+ v.add(end);
|
|
|
+ }
|
|
|
+ sql += " GROUP BY a.obj_id,c.obj_name order by num desc";
|
|
|
+ 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.setNum((Long) map.get("num"));
|
|
|
+ list.add(ls);
|
|
|
+ });
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("组件压力排名")
|
|
|
+ @GetMapping("/list/objAccess")
|
|
|
+ public AjaxResult objAccess(@ApiParam(value = "对象ID") Long modelId, @ApiParam(value = "开始时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @ApiParam(value = "结束时间yyyy-mm-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
|
|
|
+ String sql = "SELECT b.OBJ_ID,c.OBJ_NAME,ifnull(sum(c.ACCESS_TIMES),0) TIMES FROM biz_model_detail b,biz_obj c WHERE b.obj_id=c.obj_id AND c.OBJ_TYPE=1";
|
|
|
+ sql += " AND b.model_id=?";
|
|
|
+ sql += " GROUP BY b.OBJ_ID,c.obj_name order by TIMES desc";
|
|
|
+ List<Map<String, Object>> mdList = jdbcTemplate.queryForList(sql, modelId);
|
|
|
+ return AjaxResult.success(mdList);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("等级级别排名")
|
|
|
@GetMapping("/list/levelSort")
|
|
|
public AjaxResult listLevelSort(AlarmRecord alarmRecord) {
|