Explorar o código

健康度分数调整
处理pinpoint指标名称

wukai hai 8 meses
pai
achega
9b0910f000

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

@@ -203,8 +203,8 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
                     ms.setObjId(objId);
                     ms.setTplId(tplId);
                     ms.setMetricsId(d.getMetricsId());
-                    ms.setMetricsName(pp.getPpName() + "/" + d.getMetricsDef().getMetricsName());
-                    ms.setMetricsCode(pp.getPpName() + "/" + d.getMetricsCode());
+                    ms.setMetricsName(pp.getPpType() + "/" + d.getMetricsDef().getMetricsName());
+                    ms.setMetricsCode(d.getMetricsCode());
                     ms.setDataExp(ms.getMetricsCode());
                     ms.setAlarmLow(d.getAlarmLow());
                     ms.setAlarmMid(d.getAlarmMid());
@@ -233,7 +233,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
                 ms.setObjId(objId);
                 ms.setTplId(tplId);
                 ms.setMetricsId(d.getMetricsId());
-                ms.setMetricsName(d.getMetricsDef().getMetricsName() + "/" + obj.getObjAddr() + ":" + obj.getObjPort());
+                ms.setMetricsName(d.getMetricsDef().getMetricsName());
                 ms.setMetricsCode(d.getMetricsCode());
                 if ("1".equals(d.getMetricsDef().getMetricsType())) {
                     ms.setDataExp(d.getMetricsCode());

+ 0 - 14
jjt-biz/src/main/java/com/jjt/hl/controller/HlMetricsScoreController.java

@@ -54,21 +54,7 @@ public class HlMetricsScoreController extends BaseController {
     @ApiOperation("根据指标查询扣分明细")
     @GetMapping("/detail/{scoreMetricsId}")
     public AjaxResult detail4score(@PathVariable("scoreMetricsId") Long scoreMetricsId) {
-        //TODO 到处都是模拟数据
-//        String[] names = {"cluster-node1", "cluster-node2", "cluster-node3", "cluster-node4", "cluster-node5"};
-//        String[] remarks = {"超过80%,且持续1小时", "超过60,且持续1小时", "超过90%", "超过200,且持续1小时", "当前值超过5"};
-        Random random = new Random();
         List<ScoreDetailVO> list = detailService.detailList(scoreMetricsId);
-//        for (int i = 0; i < 5; i++) {
-//            ScoreDetailVO vo = new ScoreDetailVO();
-//            vo.setObjName("node-" + random.nextInt(50));
-//            vo.setEvent("超过80,且持续1小时");
-//            vo.setMetricsName("内存使用率");
-//            float v = 80F + random.nextInt(20);
-//            vo.setValue(v);
-//            vo.setTime(new Date());
-//            list.add(vo);
-//        }
         return AjaxResult.success(list);
     }
 

+ 1 - 1
jjt-biz/src/main/java/com/jjt/hl/controller/HlScoreController.java

@@ -62,7 +62,7 @@ public class HlScoreController extends BaseController {
     public TableDataInfo dayList(HlScore hlScore) {
         startPage();
         //type=2表示日健康度
-        hlScore.setHlType("1");
+        hlScore.setHlType("2");
         List<HlScore> list = hlScoreService.selectHlScoreList(hlScore);
         return getDataTable(list);
     }

+ 7 - 1
jjt-biz/src/main/java/com/jjt/task/HlTask.java

@@ -1,5 +1,7 @@
 package com.jjt.task;
 
+import com.jjt.biz.domain.BizModel;
+import com.jjt.biz.service.IBizModelService;
 import com.jjt.common.utils.StringUtils;
 import com.jjt.hl.service.IHlScoreService;
 import org.springframework.stereotype.Component;
@@ -18,9 +20,13 @@ import java.util.Date;
 public class HlTask {
     @Resource
     private IHlScoreService scoreService;
+    @Resource
+    private IBizModelService bizModelService;
 
     public void score() {
-        scoreService.score();
+        bizModelService.selectBizModelList(new BizModel()).forEach(bm -> {
+            scoreService.score(bm.getModelId());
+        });
     }
 
     public void day() {

+ 2 - 2
jjt-biz/src/main/resources/mapper/hl/HlMetricsScoreDetailMapper.xml

@@ -35,14 +35,14 @@
     </select>
     <select id="detailList" resultType="com.jjt.hl.vo.ScoreDetailVO">
         SELECT b.obj_name, c.METRICS_NAME,a.start_time TIME,a.event_value value,c.EVENT
-        FROM (SELECT a.*, b.SCORE_DETAIL_ID, SCORE_METRICS_ID
+        FROM (SELECT a.*, b.SCORE_DETAIL_ID, b.SCORE_METRICS_ID
             FROM hl_event a,
             hl_metrics_score_detail b
             WHERE a.event_id = b.EVENT_ID) a,
             biz_obj b,
             biz_obj_metrics c
         WHERE a.obj_id = b.obj_id
-          AND a.OBJ_METRICS_ID = c.OBJ_METRICS_ID
+          AND a.OBJ_METRICS_ID = c.OBJ_METRICS_ID and a.SCORE_METRICS_ID=#{scoreMetricsId}
     </select>
 
     <insert id="insertHlMetricsScoreDetail" parameterType="HlMetricsScoreDetail" useGeneratedKeys="true"

+ 1 - 0
jjt-biz/src/main/resources/mapper/hl/HlScoreMapper.xml

@@ -62,6 +62,7 @@
                 and REMARK = #{remark}
             </if>
         </where>
+        order by hl_date desc
     </select>
 
     <select id="selectHlScoreByHlScoreId" parameterType="Long"

+ 1 - 1
jjt-biz/src/main/resources/mapper/obj/BizObjMetricsMapper.xml

@@ -42,7 +42,7 @@
                      a.OBJ_ID,
                      a.TPL_ID,
                      a.METRICS_ID,
-                     b.METRICS_NAME,
+                     a.METRICS_NAME,
                      a.METRICS_CODE,
                      a.DATA_EXP,
                      a.ALARM_LOW,

+ 126 - 115
jjt-biz/src/main/resources/mapper/obj/BizObjPpMapper.xml

@@ -5,155 +5,166 @@
 <mapper namespace="com.jjt.biz.mapper.BizObjPpMapper">
 
     <resultMap type="BizObjPp" id="BizObjPpResult">
-            <result property="objPpId" column="OBJ_PP_ID"/>
-            <result property="objId" column="OBJ_ID"/>
-            <result property="ppName" column="PP_NAME"/>
-            <result property="ppKey" column="PP_KEY"/>
-            <result property="ppType" column="PP_TYPE"/>
-            <result property="ppAddr" column="PP_ADDR"/>
-            <result property="createBy" column="CREATE_BY"/>
-            <result property="createTime" column="CREATE_TIME"/>
-            <result property="updateBy" column="UPDATE_BY"/>
-            <result property="updateTime" column="UPDATE_TIME"/>
-            <result property="remark" column="REMARK"/>
+        <result property="objPpId" column="OBJ_PP_ID"/>
+        <result property="objId" column="OBJ_ID"/>
+        <result property="ppName" column="PP_NAME"/>
+        <result property="ppKey" column="PP_KEY"/>
+        <result property="ppType" column="PP_TYPE"/>
+        <result property="ppAddr" column="PP_ADDR"/>
+        <result property="createBy" column="CREATE_BY"/>
+        <result property="createTime" column="CREATE_TIME"/>
+        <result property="updateBy" column="UPDATE_BY"/>
+        <result property="updateTime" column="UPDATE_TIME"/>
+        <result property="remark" column="REMARK"/>
     </resultMap>
 
     <sql id="selectBizObjPpVo">
-        select OBJ_PP_ID, OBJ_ID, PP_NAME, PP_KEY, PP_TYPE, PP_ADDR, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK
+        select OBJ_PP_ID,
+               OBJ_ID,
+               PP_NAME,
+               PP_KEY,
+               PP_TYPE,
+               PP_ADDR,
+               CREATE_BY,
+               CREATE_TIME,
+               UPDATE_BY,
+               UPDATE_TIME,
+               REMARK
         from biz_obj_pp
     </sql>
 
     <select id="selectBizObjPpList" parameterType="BizObjPp" resultMap="BizObjPpResult">
         <include refid="selectBizObjPpVo"/>
         <where>
-                        <if test="objId != null ">
-                            and OBJ_ID = #{objId}
-                        </if>
-                        <if test="ppName != null  and ppName != ''">
-                            and PP_NAME like concat('%', #{ppName}, '%')
-                        </if>
-                        <if test="ppKey != null  and ppKey != ''">
-                            and PP_KEY = #{ppKey}
-                        </if>
-                        <if test="ppType != null  and ppType != ''">
-                            and PP_TYPE = #{ppType}
-                        </if>
-                        <if test="ppAddr != null  and ppAddr != ''">
-                            and PP_ADDR = #{ppAddr}
-                        </if>
-                        <if test="createBy != null  and createBy != ''">
-                            and CREATE_BY = #{createBy}
-                        </if>
-                        <if test="createTime != null ">
-                            and CREATE_TIME = #{createTime}
-                        </if>
-                        <if test="updateBy != null  and updateBy != ''">
-                            and UPDATE_BY = #{updateBy}
-                        </if>
-                        <if test="updateTime != null ">
-                            and UPDATE_TIME = #{updateTime}
-                        </if>
-                        <if test="remark != null  and remark != ''">
-                            and REMARK = #{remark}
-                        </if>
+            <if test="objId != null ">
+                and OBJ_ID = #{objId}
+            </if>
+            <if test="ppName != null  and ppName != ''">
+                and PP_NAME like concat('%', #{ppName}, '%')
+            </if>
+            <if test="ppKey != null  and ppKey != ''">
+                and PP_KEY = #{ppKey}
+            </if>
+            <if test="ppType != null  and ppType != ''">
+                and PP_TYPE = #{ppType}
+            </if>
+            <if test="ppAddr != null  and ppAddr != ''">
+                and PP_ADDR = #{ppAddr}
+            </if>
+            <if test="createBy != null  and createBy != ''">
+                and CREATE_BY = #{createBy}
+            </if>
+            <if test="createTime != null ">
+                and CREATE_TIME = #{createTime}
+            </if>
+            <if test="updateBy != null  and updateBy != ''">
+                and UPDATE_BY = #{updateBy}
+            </if>
+            <if test="updateTime != null ">
+                and UPDATE_TIME = #{updateTime}
+            </if>
+            <if test="remark != null  and remark != ''">
+                and REMARK = #{remark}
+            </if>
         </where>
     </select>
 
     <select id="selectBizObjPpByObjPpId" parameterType="Long"
             resultMap="BizObjPpResult">
-            <include refid="selectBizObjPpVo"/>
-            where OBJ_PP_ID = #{objPpId}
+        <include refid="selectBizObjPpVo"/>
+        where OBJ_PP_ID = #{objPpId}
     </select>
 
     <insert id="insertBizObjPp" parameterType="BizObjPp" useGeneratedKeys="true"
             keyProperty="objPpId">
         insert into biz_obj_pp
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="objId != null">OBJ_ID,
-                    </if>
-                    <if test="ppName != null">PP_NAME,
-                    </if>
-                    <if test="ppKey != null">PP_KEY,
-                    </if>
-                    <if test="ppType != null">PP_TYPE,
-                    </if>
-                    <if test="ppAddr != null">PP_ADDR,
-                    </if>
-                    <if test="createBy != null">CREATE_BY,
-                    </if>
-                    <if test="createTime != null">CREATE_TIME,
-                    </if>
-                    <if test="updateBy != null">UPDATE_BY,
-                    </if>
-                    <if test="updateTime != null">UPDATE_TIME,
-                    </if>
-                    <if test="remark != null">REMARK,
-                    </if>
+            <if test="objId != null">OBJ_ID,
+            </if>
+            <if test="ppName != null">PP_NAME,
+            </if>
+            <if test="ppKey != null">PP_KEY,
+            </if>
+            <if test="ppType != null">PP_TYPE,
+            </if>
+            <if test="ppAddr != null">PP_ADDR,
+            </if>
+            <if test="createBy != null">CREATE_BY,
+            </if>
+            <if test="createTime != null">CREATE_TIME,
+            </if>
+            <if test="updateBy != null">UPDATE_BY,
+            </if>
+            <if test="updateTime != null">UPDATE_TIME,
+            </if>
+            <if test="remark != null">REMARK,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test="objId != null">#{objId},
-                    </if>
-                    <if test="ppName != null">#{ppName},
-                    </if>
-                    <if test="ppKey != null">#{ppKey},
-                    </if>
-                    <if test="ppType != null">#{ppType},
-                    </if>
-                    <if test="ppAddr != null">#{ppAddr},
-                    </if>
-                    <if test="createBy != null">#{createBy},
-                    </if>
-                    <if test="createTime != null">#{createTime},
-                    </if>
-                    <if test="updateBy != null">#{updateBy},
-                    </if>
-                    <if test="updateTime != null">#{updateTime},
-                    </if>
-                    <if test="remark != null">#{remark},
-                    </if>
+            <if test="objId != null">#{objId},
+            </if>
+            <if test="ppName != null">#{ppName},
+            </if>
+            <if test="ppKey != null">#{ppKey},
+            </if>
+            <if test="ppType != null">#{ppType},
+            </if>
+            <if test="ppAddr != null">#{ppAddr},
+            </if>
+            <if test="createBy != null">#{createBy},
+            </if>
+            <if test="createTime != null">#{createTime},
+            </if>
+            <if test="updateBy != null">#{updateBy},
+            </if>
+            <if test="updateTime != null">#{updateTime},
+            </if>
+            <if test="remark != null">#{remark},
+            </if>
         </trim>
     </insert>
 
     <update id="updateBizObjPp" parameterType="BizObjPp">
         update biz_obj_pp
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="objId != null">OBJ_ID =
-                        #{objId},
-                    </if>
-                    <if test="ppName != null">PP_NAME =
-                        #{ppName},
-                    </if>
-                    <if test="ppKey != null">PP_KEY =
-                        #{ppKey},
-                    </if>
-                    <if test="ppType != null">PP_TYPE =
-                        #{ppType},
-                    </if>
-                    <if test="ppAddr != null">PP_ADDR =
-                        #{ppAddr},
-                    </if>
-                    <if test="createBy != null">CREATE_BY =
-                        #{createBy},
-                    </if>
-                    <if test="createTime != null">CREATE_TIME =
-                        #{createTime},
-                    </if>
-                    <if test="updateBy != null">UPDATE_BY =
-                        #{updateBy},
-                    </if>
-                    <if test="updateTime != null">UPDATE_TIME =
-                        #{updateTime},
-                    </if>
-                    <if test="remark != null">REMARK =
-                        #{remark},
-                    </if>
+            <if test="objId != null">OBJ_ID =
+                #{objId},
+            </if>
+            <if test="ppName != null">PP_NAME =
+                #{ppName},
+            </if>
+            <if test="ppKey != null">PP_KEY =
+                #{ppKey},
+            </if>
+            <if test="ppType != null">PP_TYPE =
+                #{ppType},
+            </if>
+            <if test="ppAddr != null">PP_ADDR =
+                #{ppAddr},
+            </if>
+            <if test="createBy != null">CREATE_BY =
+                #{createBy},
+            </if>
+            <if test="createTime != null">CREATE_TIME =
+                #{createTime},
+            </if>
+            <if test="updateBy != null">UPDATE_BY =
+                #{updateBy},
+            </if>
+            <if test="updateTime != null">UPDATE_TIME =
+                #{updateTime},
+            </if>
+            <if test="remark != null">REMARK =
+                #{remark},
+            </if>
         </trim>
         where OBJ_PP_ID = #{objPpId}
     </update>
 
     <delete id="deleteBizObjPpByObjPpId" parameterType="Long">
         delete
-        from biz_obj_pp where OBJ_PP_ID = #{objPpId}
+        from biz_obj_pp
+        where OBJ_PP_ID = #{objPpId}
     </delete>
 
     <delete id="deleteBizObjPpByObjPpIds" parameterType="String">