Prechádzať zdrojové kódy

告警图形化界面,模拟数据

wukai 10 mesiacov pred
rodič
commit
41f2d0dd5c

+ 1 - 1
jjt-admin/src/main/resources/application-test.yml

@@ -16,7 +16,7 @@ jjt:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8080
+  port: 9527
   servlet:
     # 应用的访问路径
     context-path: /

+ 1 - 1
jjt-admin/src/main/resources/application.yml

@@ -16,7 +16,7 @@ jjt:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8080
+  port: 9527
   servlet:
     # 应用的访问路径
     context-path: /

+ 8 - 11
jjt-admin/src/test/java/com/test/AlarmTest.java

@@ -11,7 +11,6 @@ import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -22,7 +21,7 @@ import java.util.stream.Collectors;
  *
  */
 @SpringBootTest(classes = JjtApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
+//@ActiveProfiles("test")
 public class AlarmTest {
     @Resource
     private IBizObjMetricsService objMetricsService;
@@ -32,22 +31,20 @@ public class AlarmTest {
     private SqlSessionFactory factory;
 
     public static void main(String[] args) {
-        Random random = new Random();
-        long start = 1722441600l;
-        long end = 1725033600l;
-        int diffMillis = (int) (end - start);
-        System.err.println(diffMillis);
-        long randomMillis = start + random.nextInt(diffMillis);
+        long end = new Date().getTime();
+        System.err.println(new Date(end));
+        for (int i = 0; i < 1000; i++) {
+
+        }
     }
 
     @Test
     void test() {
-        long start = 1722441600000l;
         List<BizObjMetrics> list = objMetricsService.selectBizObjMetricsList(new BizObjMetrics());
         String[] levels = {"low", "mid", "high"};
         Random random = new Random();
         List<AlarmRecord> records = new ArrayList<>();
-        for (int i = 0; i < 500; i++) {
+        for (int i = 0; i < 1000; i++) {
             int index = random.nextInt(list.size());
             BizObjMetrics om = list.get(index);
             AlarmRecord record = new AlarmRecord();
@@ -56,7 +53,7 @@ public class AlarmTest {
             String level = levels[random.nextInt(3)];
             record.setAlarmLevel(level);
             record.setAlarmValue(BigDecimal.valueOf(random.nextInt(100)));
-            long randomMillis = start + random.nextInt(2592000) * 1000;
+            long randomMillis = new Date().getTime() - Math.abs(random.nextInt(2592000)) * 1000;
             record.setAlarmTime(new Date(randomMillis));
             records.add(record);
         }

+ 127 - 69
jjt-biz/src/main/java/com/jjt/biz/controller/AlarmRecordController.java

@@ -7,8 +7,8 @@ import com.jjt.biz.vo.BizSortVO;
 import com.jjt.biz.vo.BizTypeVO;
 import com.jjt.biz.vo.LevelSortVO;
 import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
 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;
@@ -20,7 +20,6 @@ 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.*;
 
 /**
@@ -50,96 +49,143 @@ public class AlarmRecordController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 查询告警记录列表
+     */
+    @ApiOperation("统计数据")
+    @GetMapping("/lastMonth")
+    public AjaxResult calc(AlarmRecord alarmRecord) {
+        List<AlarmRecord> list = alarmRecordService.selectAlarmRecordList(alarmRecord);
+        return AjaxResult.success();
+//        return getDataTable(list);
+    }
+
     @ApiOperation("业务类型统计")
     @GetMapping("/list/bizType")
-    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) {
+    public AjaxResult 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();
-        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);
+//      TODO 暂时使用模拟数据
+
+//        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);
+//        });
+        String[] names = {"mysql", "基础支撑", "运行环境", "ES搜索服务", "nginx", "redis", "负载均衡", "其他", "JAVA应用"};
+        for (int i = 0; i < names.length; i++) {
+            BizTypeVO vo = new BizTypeVO();
+            vo.setBizType(names[i]);
+            long num = Long.valueOf(new Random().nextInt(200) + 10);
+            vo.setNum(num);
+            list.add(vo);
         }
-        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);
+
+        list.sort(Comparator.comparing(BizTypeVO::getNum));
+        return AjaxResult.success(list);
     }
 
     @ApiOperation("应用组件统计")
     @GetMapping("/list/bizSort")
-    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) {
+    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) {
         List<BizSortVO> list = new ArrayList();
-        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);
+//          TODO 暂时使用模拟数据
+//        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);
+//        });
+
+        for (int i = 0; i < 10; i++) {
+            BizSortVO vo = new BizSortVO(true);
+            list.add(vo);
         }
-        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);
+        list.sort(Comparator.comparing(BizSortVO::getNum));
+        return AjaxResult.success(list);
     }
 
     @ApiOperation("系统压力排名")
     @GetMapping("/list/bizAccess")
-    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) {
+    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();
-        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 -> {
+//        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++) {
             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.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);
-        });
-        return getDataTable(list);
+        }
+
+        list.sort(Comparator.comparing(BizAccessVO::getAccess).reversed());
+        return AjaxResult.success(list);
     }
 
     @ApiOperation("等级级别排名")
     @GetMapping("/list/levelSort")
-    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) {
+    public AjaxResult listLevelSort(AlarmRecord alarmRecord) {
         List<LevelSortVO> list = new ArrayList();
         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);
+        String sql = "SELECT alarm_level,COUNT(*) num FROM alarm_record where 1=1";
+        if (alarmRecord.getObjId() != null) {
+            sql += " and OBJ_ID = ?";
+            v.add(alarmRecord.getObjId());
+        }
+        if (alarmRecord.getParams().get("beginAlarmTime") != null && alarmRecord.getParams().get("endAlarmTime") != null) {
+            sql += " AND alarm_time BETWEEN ? AND ?";
+            v.add(alarmRecord.getParams().get("beginAlarmTime"));
+            v.add(alarmRecord.getParams().get("endAlarmTime") != null);
         }
         sql += " GROUP BY alarm_level";
         List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, v.toArray());
@@ -147,10 +193,22 @@ public class AlarmRecordController extends BaseController {
         results.forEach(map -> {
             LevelSortVO ls = new LevelSortVO();
             ls.setLevel((String) map.get("alarm_level"));
+            switch (ls.getLevel()) {
+                case "low":
+                    ls.setName("低");
+                    break;
+                case "mid":
+                    ls.setName("中");
+                    break;
+                case "high":
+                    ls.setName("高");
+                    break;
+                default:
+            }
             ls.setNum((Long) map.get("num"));
             list.add(ls);
         });
-        return getDataTable(list);
+        return AjaxResult.success(list);
     }
 
 //    /**

+ 55 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/BizModelController.java

@@ -3,6 +3,7 @@ package com.jjt.biz.controller;
 import com.jjt.biz.domain.BizModel;
 import com.jjt.biz.domain.BizObj;
 import com.jjt.biz.service.IBizModelService;
+import com.jjt.biz.vo.CheckVO;
 import com.jjt.common.annotation.Log;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
@@ -17,7 +18,10 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 业务模型Controller
@@ -129,4 +133,55 @@ public class BizModelController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] modelIds) {
         return toAjax(bizModelService.deleteBizModelByModelIds(modelIds));
     }
+
+    @ApiOperation("一健巡检--模型列表")
+    @GetMapping("/check/list")
+    public AjaxResult checkList() {
+        List<Map<String, String>> classList = new ArrayList<>();
+        Map<String, String> map = new HashMap<>();
+        map.put("class", "基础支撑");
+        map.put("option", "容器服务1、容器服务2、node-1、node-2");
+        classList.add(map);
+
+        map = new HashMap<>();
+        map.put("class", "mysql");
+        map.put("option", "mysql主服务器、mysql从服务器");
+        classList.add(map);
+
+        map = new HashMap<>();
+        map.put("class", "JAVA应用");
+        map.put("option", "服务网关、系统服务、权限服务、业务服务、定时器服务");
+        classList.add(map);
+        map = new HashMap<>();
+
+        map.put("class", "运行环境");
+        map.put("option", "ECS-1、ECS-cluster-2、ECS-node-3");
+        classList.add(map);
+
+        map.put("class", "中间件");
+        map.put("option", "ES搜索服务、文件服务、其他");
+        classList.add(map);
+
+        List<CheckVO> list = new ArrayList<>();
+        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
+        for (int i = 0; i < names.length; i++) {
+            CheckVO model = new CheckVO();
+            model.setModelId((long) (i+1));
+            model.setModelName(names[i]);
+            model.setClassList(classList);
+            list.add(model);
+        }
+        return AjaxResult.success(list);
+    }
+
+    @ApiOperation("一健巡检--按模型ID巡检")
+    @GetMapping("/check/{modelId}")
+    public AjaxResult checkModel(@PathVariable("modelId") Long modelId) {
+        try {
+            Thread.sleep(3000);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+        return AjaxResult.success();
+    }
 }

+ 30 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/HlDayController.java

@@ -6,6 +6,7 @@ import com.jjt.biz.domain.HlDayDetail;
 import com.jjt.biz.service.IHlBaseService;
 import com.jjt.biz.service.IHlDayDetailService;
 import com.jjt.biz.service.IHlDayService;
+import com.jjt.biz.vo.ScoreVO;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
 import com.jjt.common.core.page.TableDataInfo;
@@ -19,8 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.stream.Collectors;
 
 /**
@@ -41,6 +45,32 @@ public class HlDayController extends BaseController {
     @Resource
     private IHlBaseService baseService;
 
+    @ApiOperation("历史健康度得分情况")
+    @GetMapping("/history")
+    public List<ScoreVO> history() {
+        List<ScoreVO> result = new ArrayList<>();
+        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
+        for (int i = 0; i < names.length; i++) {
+            ScoreVO vo = new ScoreVO();
+            List<String> xData = new ArrayList<>();
+            List<Float> scores = new ArrayList<>();
+            LocalDate time = LocalDate.now().minusDays(8);
+            for (int j = 0; j < 7; j++) {
+                time = time.plusDays(1);
+                xData.add(time.getMonthValue() + "-" + time.getDayOfMonth());
+                Float score = Float.valueOf(new Random().nextInt(50) + 50);
+                scores.add(score);
+            }
+
+            vo.setModelId((long) (i + 1));
+            vo.setModelName(names[i]);
+            vo.setScores(scores);
+            vo.setXData(xData);
+            result.add(vo);
+        }
+        return result;
+    }
+
     @ApiOperation("根据模型ID查询健康度得分")
     @GetMapping("/list/{modelId}")
     public TableDataInfo list(@PathVariable("modelId") Long modelId) {

+ 33 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/HlScoreController.java

@@ -6,6 +6,7 @@ import com.jjt.biz.domain.HlScoreDetail;
 import com.jjt.biz.service.IHlBaseService;
 import com.jjt.biz.service.IHlScoreDetailService;
 import com.jjt.biz.service.IHlScoreService;
+import com.jjt.biz.vo.ScoreVO;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
 import com.jjt.common.core.page.TableDataInfo;
@@ -19,8 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.stream.Collectors;
 
 /**
@@ -40,6 +44,35 @@ public class HlScoreController extends BaseController {
     @Resource
     private IHlBaseService baseService;
 
+    @ApiOperation("历史健康度得分情况")
+    @GetMapping("/history")
+    public List<ScoreVO> history() {
+        List<ScoreVO> result = new ArrayList<>();
+        String[] names = {"市场服务", "市场出清", "信息发布", "市场合规", "市场结算"};
+        for (int i = 0; i < names.length; i++) {
+            ScoreVO vo = new ScoreVO();
+            List<LocalDateTime> times = new ArrayList<>();
+            List<String> xData = new ArrayList<>();
+            List<Float> scores = new ArrayList<>();
+            LocalDateTime time = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).minusHours(23);
+            for (int j = 0; j < 24; j++) {
+                time = time.plusHours(1);
+                times.add(time);
+                xData.add(time.getHour() + "");
+                Float score = Float.valueOf(new Random().nextInt(50) + 50);
+                scores.add(score);
+            }
+
+            vo.setModelId((long) (i + 1));
+            vo.setModelName(names[i]);
+            vo.setTimes(times);
+            vo.setScores(scores);
+            vo.setXData(xData);
+            result.add(vo);
+        }
+        return result;
+    }
+
     @ApiOperation("根据模型ID查询健康度得分")
     @GetMapping("/list/{modelId}")
     public TableDataInfo list(@PathVariable("modelId") Long modelId) {

+ 32 - 30
jjt-biz/src/main/java/com/jjt/biz/domain/HlScore.java

@@ -1,13 +1,14 @@
 package com.jjt.biz.domain;
 
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
-import com.jjt.common.annotation.Excel;
-import com.jjt.common.core.domain.BaseEntity;
+
+import java.math.BigDecimal;
 
 /**
  * 健康度分数记录对象 hl_score
@@ -16,64 +17,65 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2024-08-29
  */
 @ApiModel(value = "HlScore", description = "健康度分数记录")
-public class HlScore extends BaseEntity
-{
+public class HlScore extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 健康度分数记录ID; */
+    /**
+     * 健康度分数记录ID;
+     */
     @ApiModelProperty("健康度分数记录ID;")
     @TableId
     private Long hlScoreId;
 
-    /** 模型ID */
+    /**
+     * 模型ID
+     */
     @ApiModelProperty("模型ID")
     @Excel(name = "模型ID")
     private Long modelId;
 
-    /** 健康度分值 */
+    /**
+     * 健康度分值
+     */
     @ApiModelProperty("健康度分值")
     @Excel(name = "健康度分值")
     private BigDecimal hlScore;
 
-    public void setHlScoreId(Long hlScoreId)
-    {
+    public void setHlScoreId(Long hlScoreId) {
         this.hlScoreId = hlScoreId;
     }
 
-    public Long getHlScoreId()
-    {
+    public Long getHlScoreId() {
         return hlScoreId;
     }
-    public void setModelId(Long modelId)
-    {
+
+    public void setModelId(Long modelId) {
         this.modelId = modelId;
     }
 
-    public Long getModelId()
-    {
+    public Long getModelId() {
         return modelId;
     }
-    public void setHlScore(BigDecimal hlScore)
-    {
+
+    public void setHlScore(BigDecimal hlScore) {
         this.hlScore = hlScore;
     }
 
-    public BigDecimal getHlScore()
-    {
+    public BigDecimal getHlScore() {
         return hlScore;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("hlScoreId", getHlScoreId())
-            .append("modelId", getModelId())
-            .append("hlScore", getHlScore())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("hlScoreId", getHlScoreId())
+                .append("modelId", getModelId())
+                .append("hlScore", getHlScore())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
     }
 }

+ 15 - 13
jjt-biz/src/main/java/com/jjt/biz/service/impl/BizObjMetricsServiceImpl.java

@@ -347,20 +347,22 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
         List<BizObjMetrics> mList = getAllMetricsForObjIdList(objId);
         List<BizObjMetrics> metricsToUpdate = new ArrayList<>();
         mList.stream().filter(om -> !"1".equals(om.getMetricsDef().getMetricsType())).forEach(om -> {
-            //非pinpoint
-            Float value = prometheusService.query(om.getDataExp());
-            if (value != null) {
-                String alarmLevel = getAlarmLevel(value, om);
-                om.setDValue(BigDecimal.valueOf(value));
-
-                if (alarmLevel != null) {
-                    insertAlarm(om, alarmLevel);
+            if (StringUtils.isNotEmpty(om.getDataExp())) {
+                //非pinpoint
+                Float value = prometheusService.query(om.getDataExp());
+                if (value != null) {
+                    String alarmLevel = getAlarmLevel(value, om);
+                    om.setDValue(BigDecimal.valueOf(value));
+
+                    if (alarmLevel != null) {
+                        insertAlarm(om, alarmLevel);
+                    }
+                    BizObjMetricsData data = new BizObjMetricsData();
+                    data.setObjMetricsId(om.getObjMetricsId());
+                    data.setdValue(om.getDValue());
+                    metricsDataService.insertBizObjMetricsData(data);
+                    metricsToUpdate.add(om);
                 }
-                BizObjMetricsData data = new BizObjMetricsData();
-                data.setObjMetricsId(om.getObjMetricsId());
-                data.setdValue(om.getDValue());
-                metricsDataService.insertBizObjMetricsData(data);
-                metricsToUpdate.add(om);
             }
         });
         // 更新所有需要更新的BizObjMetrics对象

+ 17 - 0
jjt-biz/src/main/java/com/jjt/biz/util/EvaluatorUtil.java

@@ -0,0 +1,17 @@
+package com.jjt.biz.util;
+
+import com.googlecode.aviator.AviatorEvaluator;
+
+import java.util.Map;
+
+/**
+ * 公式计算工具类
+ *
+ * @author wukai
+ * @date 2024/9/2 01:59
+ */
+public class EvaluatorUtil {
+    public static boolean evaluator(String exp, Map<String, Object> env) {
+        return (boolean) AviatorEvaluator.execute(exp, env);
+    }
+}

+ 1 - 1
jjt-biz/src/main/java/com/jjt/biz/vo/BizAccessVO.java

@@ -13,7 +13,7 @@ import java.util.Random;
  * @author wukai
  * @date 2024/8/21 10:16
  */
-@ApiModel(value = "BizAccessVO", description = "业务类型统计")
+@ApiModel(value = "BizAccessVO", description = "业务压力")
 @Data
 @NoArgsConstructor
 public class BizAccessVO {

+ 1 - 1
jjt-biz/src/main/java/com/jjt/biz/vo/BizSortVO.java

@@ -28,7 +28,7 @@ public class BizSortVO {
 
     public BizSortVO(boolean flag) {
         if (flag) {
-            this.objName = "测试数据" + (new Random().nextInt(10) + 1);
+            this.objName = "测试对象" + (new Random().nextInt(10) + 1);
             this.num = Long.valueOf(new Random().nextInt(200) + 10);
             this.bizType = "" + (new Random().nextInt(10) + 1);
             this.objId = Long.valueOf(new Random().nextInt(20) + 1);

+ 27 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/CheckVO.java

@@ -0,0 +1,27 @@
+package com.jjt.biz.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 业务类型统计
+ *
+ * @author wukai
+ * @date 2024/8/21 10:16
+ */
+@ApiModel(value = "CheckVO", description = "巡检对象")
+@Data
+@NoArgsConstructor
+public class CheckVO {
+    @ApiModelProperty("模型ID")
+    private Long modelId;
+    @ApiModelProperty("模型名称")
+    private String modelName;
+    @ApiModelProperty("模型名称")
+    private List<Map<String, String>> classList;
+}

+ 2 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/LevelSortVO.java

@@ -19,6 +19,8 @@ import java.util.Random;
 public class LevelSortVO {
     @ApiModelProperty("告警级别")
     private String level;
+    @ApiModelProperty("告警级别")
+    private String name;
     @ApiModelProperty("告警数量")
     private Long num;
 

+ 31 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/ScoreVO.java

@@ -0,0 +1,31 @@
+package com.jjt.biz.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 业务类型统计
+ *
+ * @author wukai
+ * @date 2024/8/21 10:16
+ */
+@ApiModel(value = "ScoreVO", description = "健康度分数VO")
+@Data
+@NoArgsConstructor
+public class ScoreVO {
+    @ApiModelProperty("模型ID")
+    private Long modelId;
+    @ApiModelProperty("模型名称")
+    private String modelName;
+    @ApiModelProperty("时间")
+    private List<LocalDateTime> times;
+    @ApiModelProperty("x轴")
+    private List<String> xData;
+    @ApiModelProperty("分数")
+    private List<Float> scores;
+}