feiyu02
2023-11-07 7f580342dce92cb321e2566ef9a02827435a2de2
1. 新增风险值数据库表;
2. 修改异常分析模块的代码位置;
已修改4个文件
已添加4个文件
已重命名10个文件
301 ■■■■■ 文件已修改
src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionAnalysisController.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/RiskAnalysisController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/BaseDustExceptionAnalysis.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/BaseExceptionContinuous.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionApproachExceeding.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataExceed.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataLowValue.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataMissing.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionExceedingTimes.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionNoFluctuation.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionSlideAverage.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionValueMutation.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/domain/ds1/entity/RiskValue.java 214 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RiskValueMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig4ds1.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ds1/RiskValueMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/flightfeather/monitor/analysis/dust/ExceptionAnalysisControllerTest.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionAnalysisController.kt
@@ -1,5 +1,6 @@
package com.flightfeather.monitor.analysis.dust
import com.flightfeather.monitor.analysis.dust.exception.*
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
import com.flightfeather.monitor.domain.ds1.repository.DustExceptionDataRep
import com.flightfeather.monitor.domain.ds1.repository.DustExceptionSettingRep
src/main/java/com/flightfeather/monitor/analysis/dust/RiskAnalysisController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
package com.flightfeather.monitor.analysis.dust;
/**
 * æ•°æ®é£Žé™©åˆ†æžæŽ§åˆ¶å™¨
 */
public class RiskAnalysisController {
}
src/main/java/com/flightfeather/monitor/analysis/dust/exception/BaseDustExceptionAnalysis.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/BaseDustExceptionAnalysis.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.analysis.BaseDataAnalysis
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/BaseExceptionContinuous.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/BaseExceptionContinuous.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionApproachExceeding.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionApproachExceeding.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataExceed.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionDataExceed.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataLowValue.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionDataLowValue.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionDataMissing.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionDataMissing.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionExceedingTimes.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionExceedingTimes.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionNoFluctuation.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionNoFluctuation.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionSlideAverage.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionSlideAverage.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/analysis/dust/exception/ExceptionValueMutation.kt
ÎļþÃû´Ó src/main/java/com/flightfeather/monitor/analysis/dust/ExceptionValueMutation.kt ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.flightfeather.monitor.analysis.dust
package com.flightfeather.monitor.analysis.dust.exception
import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
src/main/java/com/flightfeather/monitor/domain/ds1/entity/RiskValue.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,214 @@
package com.flightfeather.monitor.domain.ds1.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "du_js_t_risk_value")
public class RiskValue {
    @Id
    private Integer id;
    /**
     * ç›‘测点编号
     */
    @Column(name = "mn_code")
    private String mnCode;
    /**
     * æ—¶é—´
     */
    private Date lst;
    /**
     * åœ¨çº¿çŽ‡é£Žé™©å€¼
     */
    @Column(name = "online_risk")
    private Double onlineRisk;
    /**
     * æœ‰æ•ˆçŽ‡é£Žé™©å€¼
     */
    @Column(name = "valid_risk")
    private Double validRisk;
    /**
     * è¶…标风险值
     */
    @Column(name = "exceed_risk")
    private Double exceedRisk;
    /**
     * å¼‚常类型聚集度
     */
    @Column(name = "exception_type_aggregation")
    private Double exceptionTypeAggregation;
    /**
     * å…¸åž‹å¼‚常复现率
     */
    @Column(name = "typical_exception_repetition_rate")
    private Double typicalExceptionRepetitionRate;
    /**
     * ç»Ÿè®¡ç±»åž‹ï¼ˆæ—¥ç»Ÿè®¡æˆ–月统计),day month
     */
    private String type;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * èŽ·å–ç›‘æµ‹ç‚¹ç¼–å·
     *
     * @return mn_code - ç›‘测点编号
     */
    public String getMnCode() {
        return mnCode;
    }
    /**
     * è®¾ç½®ç›‘测点编号
     *
     * @param mnCode ç›‘测点编号
     */
    public void setMnCode(String mnCode) {
        this.mnCode = mnCode == null ? null : mnCode.trim();
    }
    /**
     * èŽ·å–æ—¶é—´
     *
     * @return lst - æ—¶é—´
     */
    public Date getLst() {
        return lst;
    }
    /**
     * è®¾ç½®æ—¶é—´
     *
     * @param lst æ—¶é—´
     */
    public void setLst(Date lst) {
        this.lst = lst;
    }
    /**
     * èŽ·å–åœ¨çº¿çŽ‡é£Žé™©å€¼
     *
     * @return online_risk - åœ¨çº¿çŽ‡é£Žé™©å€¼
     */
    public Double getOnlineRisk() {
        return onlineRisk;
    }
    /**
     * è®¾ç½®åœ¨çº¿çŽ‡é£Žé™©å€¼
     *
     * @param onlineRisk åœ¨çº¿çŽ‡é£Žé™©å€¼
     */
    public void setOnlineRisk(Double onlineRisk) {
        this.onlineRisk = onlineRisk;
    }
    /**
     * èŽ·å–æœ‰æ•ˆçŽ‡é£Žé™©å€¼
     *
     * @return valid_risk - æœ‰æ•ˆçŽ‡é£Žé™©å€¼
     */
    public Double getValidRisk() {
        return validRisk;
    }
    /**
     * è®¾ç½®æœ‰æ•ˆçŽ‡é£Žé™©å€¼
     *
     * @param validRisk æœ‰æ•ˆçŽ‡é£Žé™©å€¼
     */
    public void setValidRisk(Double validRisk) {
        this.validRisk = validRisk;
    }
    /**
     * èŽ·å–è¶…æ ‡é£Žé™©å€¼
     *
     * @return exceed_risk - è¶…标风险值
     */
    public Double getExceedRisk() {
        return exceedRisk;
    }
    /**
     * è®¾ç½®è¶…标风险值
     *
     * @param exceedRisk è¶…标风险值
     */
    public void setExceedRisk(Double exceedRisk) {
        this.exceedRisk = exceedRisk;
    }
    /**
     * èŽ·å–å¼‚å¸¸ç±»åž‹èšé›†åº¦
     *
     * @return exception_type_aggregation - å¼‚常类型聚集度
     */
    public Double getExceptionTypeAggregation() {
        return exceptionTypeAggregation;
    }
    /**
     * è®¾ç½®å¼‚常类型聚集度
     *
     * @param exceptionTypeAggregation å¼‚常类型聚集度
     */
    public void setExceptionTypeAggregation(Double exceptionTypeAggregation) {
        this.exceptionTypeAggregation = exceptionTypeAggregation;
    }
    /**
     * èŽ·å–å…¸åž‹å¼‚å¸¸å¤çŽ°çŽ‡
     *
     * @return typical_exception_repetition_rate - å…¸åž‹å¼‚常复现率
     */
    public Double getTypicalExceptionRepetitionRate() {
        return typicalExceptionRepetitionRate;
    }
    /**
     * è®¾ç½®å…¸åž‹å¼‚常复现率
     *
     * @param typicalExceptionRepetitionRate å…¸åž‹å¼‚常复现率
     */
    public void setTypicalExceptionRepetitionRate(Double typicalExceptionRepetitionRate) {
        this.typicalExceptionRepetitionRate = typicalExceptionRepetitionRate;
    }
    /**
     * èŽ·å–ç»Ÿè®¡ç±»åž‹ï¼ˆæ—¥ç»Ÿè®¡æˆ–æœˆç»Ÿè®¡ï¼‰,day month
     *
     * @return type - ç»Ÿè®¡ç±»åž‹ï¼ˆæ—¥ç»Ÿè®¡æˆ–月统计),day month
     */
    public String getType() {
        return type;
    }
    /**
     * è®¾ç½®ç»Ÿè®¡ç±»åž‹ï¼ˆæ—¥ç»Ÿè®¡æˆ–月统计),day month
     *
     * @param type ç»Ÿè®¡ç±»åž‹ï¼ˆæ—¥ç»Ÿè®¡æˆ–月统计),day month
     */
    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }
}
src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RiskValueMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.monitor.domain.ds1.mapper
import com.flightfeather.monitor.domain.ds1.entity.RiskValue
import com.flightfeather.monitor.domain.util.MyMapper
import org.apache.ibatis.annotations.Mapper
@Mapper
interface RiskValueMapper : MyMapper<RiskValue?>
src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt
@@ -33,28 +33,31 @@
            // åˆ¤æ–­ä»Šæ—¥çˆ¬å–任务是否完成
            val task = requestTaskRep.findLatestTask(localtime)
            task1Delay = isTaskDelay(task)
            if (task1Delay) return
            if (!task1Delay) {
            log.info("异常分析执行")
            exceptionAnalysisController.init()
            exceptionAnalysisController.autoRun()
            }
        }
        if (task2Delay || (localtime.hour == 9 && localtime.minute == 0)) {
            val task = requestTaskRep.findLatestTask(localtime)
            task2Delay = isTaskDelay(task)
            if (task2Delay) return
            if (!task2Delay) {
            log.info("日分析执行")
            statisticAnalysisController.autoRunDailyStatics()
            }
        }
        if (task3Delay || (localtime.dayOfMonth == 1 && localtime.hour == 9 && localtime.minute == 0)) {
            val task = requestTaskRep.findLatestTask(localtime)
            task3Delay = isTaskDelay(task)
            if (task3Delay) return
            if (!task3Delay) {
            log.info("月分析执行")
            statisticAnalysisController.autoRunMonthlyStatics()
        }
    }
    }
    /**
     * å½“任务开始执行时,判断任务状态,决定是否延迟执行
src/main/resources/generator/generatorConfig4ds1.xml
@@ -86,7 +86,11 @@
<!--               enableCountByExample="false"-->
<!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
<!--               enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="du_js_t_request_task" domainObjectName="RequestTask"
<!--        <table tableName="du_js_t_request_task" domainObjectName="RequestTask"-->
<!--               enableCountByExample="false"-->
<!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
<!--               enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="du_js_t_risk_value" domainObjectName="RiskValue"
               enableCountByExample="false"
               enableUpdateByExample="false" enableDeleteByExample="false"
               enableSelectByExample="false" selectByExampleQueryId="false"/>
src/main/resources/mapper/ds1/RiskValueMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.flightfeather.monitor.domain.ds1.mapper.RiskValueMapper">
  <resultMap id="BaseResultMap" type="com.flightfeather.monitor.domain.ds1.entity.RiskValue">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="mn_code" jdbcType="VARCHAR" property="mnCode" />
    <result column="lst" jdbcType="DATE" property="lst" />
    <result column="online_risk" jdbcType="DOUBLE" property="onlineRisk" />
    <result column="valid_risk" jdbcType="DOUBLE" property="validRisk" />
    <result column="exceed_risk" jdbcType="DOUBLE" property="exceedRisk" />
    <result column="exception_type_aggregation" jdbcType="DOUBLE" property="exceptionTypeAggregation" />
    <result column="typical_exception_repetition_rate" jdbcType="DOUBLE" property="typicalExceptionRepetitionRate" />
    <result column="type" jdbcType="VARCHAR" property="type" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, mn_code, lst, online_risk, valid_risk, exceed_risk, exception_type_aggregation,
    typical_exception_repetition_rate, type
  </sql>
</mapper>
src/test/java/com/flightfeather/monitor/analysis/dust/ExceptionAnalysisControllerTest.kt
@@ -1,12 +1,13 @@
package com.flightfeather.monitor.analysis.dust
import org.junit.jupiter.api.Test
import org.junit.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.context.junit4.SpringRunner
import java.time.Duration
import java.time.LocalDate
@RunWith(SpringRunner::class)
@@ -26,8 +27,12 @@
    @Test
    fun run() {
        exceptionAnalysisController.init()
        val d = LocalDate.of(2023, 7, 2)
        exceptionAnalysisController.run(d)
        var d1 = LocalDate.of(2023, 10, 26)
        val d2 = LocalDate.of(2023, 10, 26)
        while (Duration.between(d1.atStartOfDay(), d2.atStartOfDay()).toDays() >= 0L) {
            exceptionAnalysisController.run(d1)
            d1 = d1.plusDays(1)
        }
//        exceptionAnalysisController.debugRun()
    }
}