Jelajahi Sumber

风险分析接口处理

wukai 1 tahun lalu
induk
melakukan
7e52435955

+ 85 - 82
jjt-admin/pom.xml

@@ -76,76 +76,13 @@
 
     <build>
         <plugins>
-            <!--            <plugin>-->
-            <!--                <groupId>org.springframework.boot</groupId>-->
-            <!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
-            <!--                <version>2.5.15</version>-->
-            <!--                <configuration>-->
-            <!--                    <fork>true</fork> &lt;!&ndash; 如果没有该配置,devtools不会生效 &ndash;&gt;-->
-            <!--                </configuration>-->
-            <!--                <executions>-->
-            <!--                    <execution>-->
-            <!--                        <goals>-->
-            <!--                            <goal>repackage</goal>-->
-            <!--                        </goals>-->
-            <!--                    </execution>-->
-            <!--                </executions>-->
-            <!--            </plugin>-->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-war-plugin</artifactId>
-                <version>3.1.0</version>
-                <configuration>
-                    <failOnMissingWebXml>false</failOnMissingWebXml>
-                    <warName>${project.artifactId}</warName>
-                </configuration>
-            </plugin>
-
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <version>2.5.15</version>
                 <configuration>
                     <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
-                    <executable>true</executable>
-                    <layout>ZIP</layout>
-                    <!--这里是填写需要包含进去的jar,
-                         必须项目中的某些模块,会经常变动,那么就应该将其坐标写进来
-                         如果没有则nothing ,表示不打包依赖 -->
-                    <includes>
-                        <!-- 定时任务-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-quartz</artifactId>
-                        </include>
-                        <!-- 代码生成-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-generator</artifactId>
-                        </include>
-                        <!-- 核心模块-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-framework</artifactId>
-                        </include>
-                        <!-- 系统模块-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-system</artifactId>
-                        </include>
-                        <!-- 通用工具-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-common</artifactId>
-                        </include>
-                        <!-- 业务模块-->
-                        <include>
-                            <groupId>com.jjt</groupId>
-                            <artifactId>jjt-biz</artifactId>
-                        </include>
-                    </includes>
                 </configuration>
-
                 <executions>
                     <execution>
                         <goals>
@@ -153,29 +90,95 @@
                         </goals>
                     </execution>
                 </executions>
-
             </plugin>
-
-            <!--拷贝依赖到jar外面的lib目录-->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>copy</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>copy-dependencies</goal>
-                        </goals>
-                        <configuration>
-                            <!--指定的依赖路径-->
-                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
-                            <!--排除的ArtifactId-->
-                            <excludeArtifactIds>jjt-framework,jjt-system,jjt-quartz,jjt-generator,jjt-common,jjt-biz</excludeArtifactIds>
-                        </configuration>
-                    </execution>
-                </executions>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.1.0</version>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <warName>${project.artifactId}</warName>
+                </configuration>
             </plugin>
+
+            <!--下面这段是分离打包-->
+
+            <!--            <plugin>-->
+            <!--                <groupId>org.springframework.boot</groupId>-->
+            <!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
+            <!--                <version>2.5.15</version>-->
+            <!--                <configuration>-->
+            <!--                    <fork>true</fork> &lt;!&ndash; 如果没有该配置,devtools不会生效 &ndash;&gt;-->
+            <!--                    <executable>true</executable>-->
+            <!--                    <layout>ZIP</layout>-->
+            <!--                    &lt;!&ndash;这里是填写需要包含进去的jar,-->
+            <!--                         必须项目中的某些模块,会经常变动,那么就应该将其坐标写进来-->
+            <!--                         如果没有则nothing ,表示不打包依赖 &ndash;&gt;-->
+            <!--                    <includes>-->
+            <!--                        &lt;!&ndash; 定时任务&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-quartz</artifactId>-->
+            <!--                        </include>-->
+            <!--                        &lt;!&ndash; 代码生成&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-generator</artifactId>-->
+            <!--                        </include>-->
+            <!--                        &lt;!&ndash; 核心模块&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-framework</artifactId>-->
+            <!--                        </include>-->
+            <!--                        &lt;!&ndash; 系统模块&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-system</artifactId>-->
+            <!--                        </include>-->
+            <!--                        &lt;!&ndash; 通用工具&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-common</artifactId>-->
+            <!--                        </include>-->
+            <!--                        &lt;!&ndash; 业务模块&ndash;&gt;-->
+            <!--                        <include>-->
+            <!--                            <groupId>com.jjt</groupId>-->
+            <!--                            <artifactId>jjt-biz</artifactId>-->
+            <!--                        </include>-->
+            <!--                    </includes>-->
+            <!--                </configuration>-->
+
+            <!--                <executions>-->
+            <!--                    <execution>-->
+            <!--                        <goals>-->
+            <!--                            <goal>repackage</goal>-->
+            <!--                        </goals>-->
+            <!--                    </execution>-->
+            <!--                </executions>-->
+
+            <!--            </plugin>-->
+
+            <!--            &lt;!&ndash;拷贝依赖到jar外面的lib目录&ndash;&gt;-->
+            <!--            <plugin>-->
+            <!--                <groupId>org.apache.maven.plugins</groupId>-->
+            <!--                <artifactId>maven-dependency-plugin</artifactId>-->
+            <!--                <executions>-->
+            <!--                    <execution>-->
+            <!--                        <id>copy</id>-->
+            <!--                        <phase>package</phase>-->
+            <!--                        <goals>-->
+            <!--                            <goal>copy-dependencies</goal>-->
+            <!--                        </goals>-->
+            <!--                        <configuration>-->
+            <!--                            &lt;!&ndash;指定的依赖路径&ndash;&gt;-->
+            <!--                            <outputDirectory>${project.build.directory}/lib</outputDirectory>-->
+            <!--                            &lt;!&ndash;排除的ArtifactId&ndash;&gt;-->
+            <!--                            <excludeArtifactIds>jjt-framework,jjt-system,jjt-quartz,jjt-generator,jjt-common,jjt-biz-->
+            <!--                            </excludeArtifactIds>-->
+            <!--                        </configuration>-->
+            <!--                    </execution>-->
+            <!--                </executions>-->
+            <!--            </plugin>-->
         </plugins>
         <finalName>jy2024</finalName>
     </build>

+ 187 - 0
jjt-admin/src/main/resources/application-tt.yml

@@ -0,0 +1,187 @@
+# 项目相关配置
+jjt:
+  # 名称
+  name: jjt
+  # 版本
+  version: 3.8.7
+  # 版权年份
+  copyrightYear: 2024
+  # 文件路径 示例( Windows配置D:/jjt/uploadPath,Linux配置 /home/jjt/uploadPath)
+  profile: D:/jjt/uploadPath
+  # 获取ip地址开关
+  addressEnabled: false
+  # 验证码类型 math 数字计算 char 字符验证
+  captchaType: math
+
+# 开发环境配置
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 18081
+  servlet:
+    # 应用的访问路径
+    context-path: /
+  tomcat:
+    # tomcat的URI编码
+    uri-encoding: UTF-8
+    # 连接数满后的排队数,默认为100
+    accept-count: 1000
+    threads:
+      # tomcat最大线程数,默认为200
+      max: 800
+      # Tomcat启动初始化的线程数,默认值10
+      min-spare: 100
+
+# 日志配置
+logging:
+  level:
+    com.jjt: debug
+    org.springframework: warn
+
+# 用户配置
+user:
+  password:
+    # 密码最大错误次数
+    maxRetryCount: 5
+    # 密码锁定时间(默认10分钟)
+    lockTime: 10
+
+# Spring配置
+spring:
+  # 数据源配置
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://192.168.188.66:3306/jy2024?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
+        username: root
+        password: 123456
+      # 从库数据源
+      slave:
+        # 从数据源开关/默认关闭
+        enabled: false
+        url:
+        username:
+        password:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: jjt
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+  # 资源信息
+  messages:
+    # 国际化资源文件路径
+    basename: i18n/messages
+  # 文件上传
+  servlet:
+    multipart:
+      # 单个文件大小
+      max-file-size: 10MB
+      # 设置总上传的文件大小
+      max-request-size: 20MB
+  # 服务模块
+  devtools:
+    restart:
+      # 热部署开关
+      enabled: true
+  # redis 配置
+  redis:
+    # 地址
+    host: 192.168.188.66
+    # 端口,默认为6379
+    port: 6379
+    # 数据库索引
+    database: 0
+    # 密码
+    password: redis@123
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+
+# token配置
+token:
+  # 令牌自定义标识
+  header: Authorization
+  # 令牌密钥
+  secret: JJT@basic!2024.
+  # 令牌有效期(默认30分钟)
+  expireTime: 30
+
+# MyBatis Plus配置
+mybatis-plus:
+  # 搜索指定包别名
+  typeAliasesPackage: com.jjt.**.domain
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  # 加载全局的配置文件
+  configLocation: classpath:mybatis/mybatis-config.xml
+
+# PageHelper分页插件
+pagehelper:
+  helperDialect: mysql
+  supportMethodsArguments: true
+  params: count=countSql
+
+# Swagger配置
+swagger:
+  # 是否开启swagger
+  enabled: true
+  # 请求前缀
+  pathMapping: /dev-api
+
+# 防止XSS攻击
+xss:
+  # 过滤开关
+  enabled: true
+  # 排除链接(多个用逗号分隔)
+  excludes: /system/notice
+  # 匹配链接
+  urlPatterns: /system/*,/monitor/*,/tool/*

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

@@ -100,7 +100,7 @@ public class AlarmRecordController extends BaseController {
         return AjaxResult.success(list);
     }
 
-    @ApiOperation("业务类型统计")
+    @ApiOperation("业务组件统计")
     @GetMapping("/list/bizObj")
     public AjaxResult listBizObj(@ApiParam(value = "业务类型") String type, @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();

+ 14 - 7
jjt-biz/src/main/java/com/jjt/biz/mapper/BizObjMapper.java

@@ -6,7 +6,7 @@ import com.jjt.biz.domain.BizObj;
 
 /**
  * 业务对象Mapper接口
- * 
+ *
  * @author jjt
  * @date 2024-08-09
  */
@@ -14,7 +14,7 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 {
     /**
      * 查询业务对象
-     * 
+     *
      * @param objId 业务对象主键
      * @return 业务对象
      */
@@ -22,7 +22,7 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 
     /**
      * 查询业务对象列表
-     * 
+     *
      * @param bizObj 业务对象
      * @return 业务对象集合
      */
@@ -30,7 +30,7 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 
     /**
      * 新增业务对象
-     * 
+     *
      * @param bizObj 业务对象
      * @return 结果
      */
@@ -38,7 +38,7 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 
     /**
      * 修改业务对象
-     * 
+     *
      * @param bizObj 业务对象
      * @return 结果
      */
@@ -46,7 +46,7 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 
     /**
      * 删除业务对象
-     * 
+     *
      * @param objId 业务对象主键
      * @return 结果
      */
@@ -54,9 +54,16 @@ public interface BizObjMapper extends BaseMapper<BizObj>
 
     /**
      * 批量删除业务对象
-     * 
+     *
      * @param objIds 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteBizObjByObjIds(Long[] objIds);
+    /**
+     * 通过指标ID查询对象列表
+     *
+     * @param metricsId 指标ID
+     * @return 结果
+     */
+    List<BizObj> selectBizObjListByMetricsId(Long metricsId);
 }

+ 18 - 10
jjt-biz/src/main/java/com/jjt/biz/service/IBizObjService.java

@@ -1,19 +1,19 @@
 package com.jjt.biz.service;
 
-import java.util.List;
 import com.jjt.biz.domain.BizObj;
 
+import java.util.List;
+
 /**
  * 业务对象Service接口
- * 
+ *
  * @author jjt
  * @date 2024-08-09
  */
-public interface IBizObjService 
-{
+public interface IBizObjService {
     /**
      * 查询业务对象
-     * 
+     *
      * @param objId 业务对象主键
      * @return 业务对象
      */
@@ -21,7 +21,7 @@ public interface IBizObjService
 
     /**
      * 查询业务对象列表
-     * 
+     *
      * @param bizObj 业务对象
      * @return 业务对象集合
      */
@@ -29,7 +29,7 @@ public interface IBizObjService
 
     /**
      * 新增业务对象
-     * 
+     *
      * @param bizObj 业务对象
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface IBizObjService
 
     /**
      * 修改业务对象
-     * 
+     *
      * @param bizObj 业务对象
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface IBizObjService
 
     /**
      * 批量删除业务对象
-     * 
+     *
      * @param objIds 需要删除的业务对象主键集合
      * @return 结果
      */
@@ -53,9 +53,17 @@ public interface IBizObjService
 
     /**
      * 删除业务对象信息
-     * 
+     *
      * @param objId 业务对象主键
      * @return 结果
      */
     public int deleteBizObjByObjId(Long objId);
+
+    /**
+     * 通过指标ID查询对象列表
+     *
+     * @param metricsId 指标ID
+     * @return 结果
+     */
+    List<BizObj> selectBizObjListByMetricsId(Long metricsId);
 }

+ 11 - 0
jjt-biz/src/main/java/com/jjt/biz/service/impl/BizObjServiceImpl.java

@@ -101,4 +101,15 @@ public class BizObjServiceImpl implements IBizObjService {
     public int deleteBizObjByObjId(Long objId) {
         return bizObjMapper.deleteBizObjByObjId(objId);
     }
+
+    /**
+     * 通过指标ID查询对象列表
+     *
+     * @param metricsId 指标ID
+     * @return 结果
+     */
+    @Override
+    public List<BizObj> selectBizObjListByMetricsId(Long metricsId) {
+        return bizObjMapper.selectBizObjListByMetricsId(metricsId);
+    }
 }

+ 85 - 34
jjt-biz/src/main/java/com/jjt/risk/controller/RiskAnalysisController.java

@@ -1,28 +1,26 @@
 package com.jjt.risk.controller;
 
-import java.util.List;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.jjt.common.annotation.Log;
 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.enums.BusinessType;
+import com.jjt.common.utils.poi.ExcelUtil;
 import com.jjt.risk.domain.RiskAnalysis;
+import com.jjt.risk.domain.RiskModel;
 import com.jjt.risk.service.IRiskAnalysisService;
-import com.jjt.common.utils.poi.ExcelUtil;
-import com.jjt.common.core.page.TableDataInfo;
+import com.jjt.risk.service.IRiskModelService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.text.DecimalFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.*;
 
 /**
  * 风险分析结果Controller
@@ -30,13 +28,14 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author jjt
  * @date 2024-09-12
  */
-@Api(tags="风险分析结果")
+@Api(tags = "风险分析结果")
 @RestController
 @RequestMapping("/risk/analysis")
-public class RiskAnalysisController extends BaseController
-{
+public class RiskAnalysisController extends BaseController {
     @Resource
     private IRiskAnalysisService riskAnalysisService;
+    @Resource
+    private IRiskModelService riskModelService;
 
     /**
      * 查询风险分析结果列表
@@ -44,8 +43,7 @@ public class RiskAnalysisController extends BaseController
     @ApiOperation("查询风险分析结果列表")
     @PreAuthorize("@ss.hasPermi('risk:analysis:list')")
     @GetMapping("/list")
-    public TableDataInfo list(RiskAnalysis riskAnalysis)
-    {
+    public TableDataInfo list(RiskAnalysis riskAnalysis) {
         startPage();
         List<RiskAnalysis> list = riskAnalysisService.selectRiskAnalysisList(riskAnalysis);
         return getDataTable(list);
@@ -58,8 +56,7 @@ public class RiskAnalysisController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:analysis:export')")
     @Log(title = "风险分析结果", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, RiskAnalysis riskAnalysis)
-    {
+    public void export(HttpServletResponse response, RiskAnalysis riskAnalysis) {
         List<RiskAnalysis> list = riskAnalysisService.selectRiskAnalysisList(riskAnalysis);
         ExcelUtil<RiskAnalysis> util = new ExcelUtil<RiskAnalysis>(RiskAnalysis.class);
         util.exportExcel(response, list, "风险分析结果数据");
@@ -71,9 +68,66 @@ public class RiskAnalysisController extends BaseController
     @ApiOperation("获取风险分析结果详细信息")
     @PreAuthorize("@ss.hasPermi('risk:analysis:query')")
     @GetMapping(value = "/{resultId}")
-    public AjaxResult getInfo(@PathVariable("resultId") Long resultId)
-    {
-        return success(riskAnalysisService.selectRiskAnalysisByResultId(resultId));
+    public AjaxResult getInfo(@PathVariable("resultId") Long resultId) {
+        riskAnalysisService.selectRiskAnalysisByResultId(resultId);
+        return success();
+    }
+
+    @ApiOperation("立即分析")
+    @GetMapping(value = "/atOnce/{riskId}")
+    public AjaxResult atOnce(@PathVariable("riskId") Long riskId) {
+        RiskModel rm = riskModelService.selectRiskModelByRiskId(riskId);
+        if ("3".equals(rm.getRiskType())) {
+            return type3info(1L);
+        } else {
+            return getInfo(1L);
+        }
+    }
+
+    @ApiOperation("获取异类组件分析结果")
+    @GetMapping(value = "/type3/result/{resultId}")
+    public AjaxResult type3info(@PathVariable("resultId") Long resultId) {
+        Map<String, Object> result = new HashMap<>(16);
+        RiskAnalysis analysis = riskAnalysisService.selectRiskAnalysisByResultId(resultId);
+        List<Map<String, Object>> list = new ArrayList();
+        String[] names = {"基础支撑", "运行环境", "ES搜索服务", "nginx", "redis"};
+        for (int i = 0; i < names.length; i++) {
+            Map<String, Object> map = new HashMap<>(16);
+            map.put("id", (i + 1));
+            map.put("name", names[i]);
+            long num = Long.valueOf(new Random().nextInt(200) + 10);
+            map.put("num", num);
+            list.add(map);
+        }
+
+        result.put("imgPath", analysis.getImgPath());
+        result.put("top", list);
+        return success(result);
+    }
+
+    @ApiOperation("根据对象获取曲线")
+    @GetMapping(value = "/type3/trend/{id}")
+    public AjaxResult type3trend(@PathVariable("id") Long id) {
+        Map<String, Object> result = new HashMap<>(16);
+        List<Map<String, Object>> list = new ArrayList();
+        LocalDateTime ed = LocalDateTime.now();
+        LocalDateTime st = ed.minusDays(7);
+        List<Long> times = new ArrayList<>();
+        List<Float> values = new ArrayList<>();
+
+        Random r = new Random();
+        DecimalFormat df = new DecimalFormat("#0.00");
+        do {
+            long time = st.toEpochSecond(ZoneOffset.ofHours(8)) * 1000;
+            times.add(time);
+            float f = r.nextFloat() * 100;
+//                System.err.println(df.format(f));
+            values.add(Float.parseFloat(df.format(f)));
+            st = st.plusMinutes(15);
+        } while (!st.isAfter(ed));
+        result.put("times", times);
+        result.put("values", values);
+        return success(result);
     }
 
     /**
@@ -83,8 +137,7 @@ public class RiskAnalysisController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:analysis:add')")
     @Log(title = "风险分析结果", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody RiskAnalysis riskAnalysis)
-    {
+    public AjaxResult add(@RequestBody RiskAnalysis riskAnalysis) {
         return toAjax(riskAnalysisService.insertRiskAnalysis(riskAnalysis));
     }
 
@@ -95,8 +148,7 @@ public class RiskAnalysisController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:analysis:edit')")
     @Log(title = "风险分析结果", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody RiskAnalysis riskAnalysis)
-    {
+    public AjaxResult edit(@RequestBody RiskAnalysis riskAnalysis) {
         return toAjax(riskAnalysisService.updateRiskAnalysis(riskAnalysis));
     }
 
@@ -106,9 +158,8 @@ public class RiskAnalysisController extends BaseController
     @ApiOperation("删除风险分析结果")
     @PreAuthorize("@ss.hasPermi('risk:analysis:remove')")
     @Log(title = "风险分析结果", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{resultIds}")
-    public AjaxResult remove(@PathVariable Long[] resultIds)
-    {
+    @DeleteMapping("/{resultIds}")
+    public AjaxResult remove(@PathVariable Long[] resultIds) {
         return toAjax(riskAnalysisService.deleteRiskAnalysisByResultIds(resultIds));
     }
 }

+ 57 - 36
jjt-biz/src/main/java/com/jjt/risk/controller/RiskModelController.java

@@ -1,28 +1,28 @@
 package com.jjt.risk.controller;
 
-import java.util.List;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.jjt.biz.domain.BizObj;
+import com.jjt.biz.domain.MetricsDef;
+import com.jjt.biz.service.IBizObjService;
+import com.jjt.biz.service.IMetricsDefService;
 import com.jjt.common.annotation.Log;
 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.enums.BusinessType;
+import com.jjt.common.utils.poi.ExcelUtil;
 import com.jjt.risk.domain.RiskModel;
+import com.jjt.risk.domain.RiskObj;
 import com.jjt.risk.service.IRiskModelService;
-import com.jjt.common.utils.poi.ExcelUtil;
-import com.jjt.common.core.page.TableDataInfo;
+import com.jjt.risk.service.IRiskObjService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 风险管理Controller
@@ -30,13 +30,33 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author jjt
  * @date 2024-09-12
  */
-@Api(tags="风险管理")
+@Api(tags = "风险管理")
 @RestController
 @RequestMapping("/risk/model")
-public class RiskModelController extends BaseController
-{
+public class RiskModelController extends BaseController {
     @Resource
     private IRiskModelService riskModelService;
+    @Resource
+    private IMetricsDefService metricsDefService;
+    @Resource
+    private IBizObjService objService;
+    @Resource
+    private IRiskObjService riskObjService;
+
+
+    @ApiOperation("查询所有指标")
+    @GetMapping("/ms/list")
+    public AjaxResult msList() {
+        List<MetricsDef> list = metricsDefService.selectMetricsDefList(new MetricsDef());
+        return AjaxResult.success(list);
+    }
+
+    @ApiOperation("根据指标ID查询对象列表")
+    @GetMapping("/obj/list/{metricsId}")
+    public AjaxResult objList(@PathVariable Long metricsId) {
+        List<BizObj> list = objService.selectBizObjListByMetricsId(metricsId);
+        return AjaxResult.success(list);
+    }
 
     /**
      * 查询风险管理列表
@@ -44,8 +64,7 @@ public class RiskModelController extends BaseController
     @ApiOperation("查询风险管理列表")
     @PreAuthorize("@ss.hasPermi('risk:model:list')")
     @GetMapping("/list")
-    public TableDataInfo list(RiskModel riskModel)
-    {
+    public TableDataInfo list(RiskModel riskModel) {
         startPage();
         List<RiskModel> list = riskModelService.selectRiskModelList(riskModel);
         return getDataTable(list);
@@ -58,8 +77,7 @@ public class RiskModelController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:model:export')")
     @Log(title = "风险管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, RiskModel riskModel)
-    {
+    public void export(HttpServletResponse response, RiskModel riskModel) {
         List<RiskModel> list = riskModelService.selectRiskModelList(riskModel);
         ExcelUtil<RiskModel> util = new ExcelUtil<RiskModel>(RiskModel.class);
         util.exportExcel(response, list, "风险管理数据");
@@ -69,11 +87,12 @@ public class RiskModelController extends BaseController
      * 获取风险管理详细信息
      */
     @ApiOperation("获取风险管理详细信息")
-    @PreAuthorize("@ss.hasPermi('risk:model:query')")
     @GetMapping(value = "/{riskId}")
-    public AjaxResult getInfo(@PathVariable("riskId") Long riskId)
-    {
-        return success(riskModelService.selectRiskModelByRiskId(riskId));
+    public AjaxResult getInfo(@PathVariable("riskId") Long riskId) {
+        RiskModel riskModel = riskModelService.selectRiskModelByRiskId(riskId);
+        List<Long> ids = riskModel.getRiskObjList().stream().map(RiskObj::getObjId).collect(Collectors.toList());
+        riskModel.setObjIds(ids);
+        return success(riskModel);
     }
 
     /**
@@ -83,9 +102,13 @@ public class RiskModelController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:model:add')")
     @Log(title = "风险管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody RiskModel riskModel)
-    {
-        return toAjax(riskModelService.insertRiskModel(riskModel));
+    public AjaxResult add(@RequestBody RiskModel riskModel) {
+        int r = riskModelService.insertRiskModel(riskModel);
+        if ("2".equals(riskModel.getObjType())) {
+            //如果是自定义对象
+            riskObjService.process(riskModel.getRiskId(), riskModel.getObjIds());
+        }
+        return toAjax(r);
     }
 
     /**
@@ -95,8 +118,7 @@ public class RiskModelController extends BaseController
     @PreAuthorize("@ss.hasPermi('risk:model:edit')")
     @Log(title = "风险管理", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody RiskModel riskModel)
-    {
+    public AjaxResult edit(@RequestBody RiskModel riskModel) {
         return toAjax(riskModelService.updateRiskModel(riskModel));
     }
 
@@ -106,9 +128,8 @@ public class RiskModelController extends BaseController
     @ApiOperation("删除风险管理")
     @PreAuthorize("@ss.hasPermi('risk:model:remove')")
     @Log(title = "风险管理", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{riskIds}")
-    public AjaxResult remove(@PathVariable Long[] riskIds)
-    {
+    @DeleteMapping("/{riskIds}")
+    public AjaxResult remove(@PathVariable Long[] riskIds) {
         return toAjax(riskModelService.deleteRiskModelByRiskIds(riskIds));
     }
 }

+ 50 - 130
jjt-biz/src/main/java/com/jjt/risk/domain/RiskAnalysis.java

@@ -1,14 +1,14 @@
 package com.jjt.risk.domain;
 
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.baomidou.mybatisplus.annotation.TableId;
-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.fasterxml.jackson.annotation.JsonFormat;
 import com.jjt.common.annotation.Excel;
 import com.jjt.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
 
 /**
  * 风险分析结果对象 risk_analysis
@@ -17,170 +17,90 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2024-09-12
  */
 @ApiModel(value = "RiskAnalysis", description = "风险分析结果")
-public class RiskAnalysis extends BaseEntity
-{
+@Data
+public class RiskAnalysis extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 风险预测ID; */
+    /**
+     * 风险预测ID;
+     */
     @ApiModelProperty("风险预测ID;")
     @TableId
     private Long resultId;
 
-    /** 分析ID */
+    /**
+     * 分析ID
+     */
     @ApiModelProperty("分析ID")
     @Excel(name = "分析ID")
     private Long riskId;
 
-    /** 分析结果 */
+    @ApiModelProperty("分析类型")
+    private String riskType;
+    @ApiModelProperty("对象ID")
+    private String objId;
+    @ApiModelProperty("对象名称")
+    private String objName;
+    @ApiModelProperty("指标ID")
+    private Long metricsId;
+    @ApiModelProperty("指标名称;")
+    @Excel(name = "指标名称;")
+    private String metricsName;
+
+    /**
+     * 分析结果
+     */
     @ApiModelProperty("分析结果")
     @Excel(name = "分析结果")
     private String result;
 
-    /** 均值比较 */
+    /**
+     * 均值比较
+     */
     @ApiModelProperty("均值比较")
     @Excel(name = "均值比较")
     private String avgValue;
 
-    /** 正态检测 */
+    /**
+     * 正态检测
+     */
     @ApiModelProperty("正态检测")
     @Excel(name = "正态检测")
     private String normalValid;
 
-    /** 方差齐性检测 */
+    /**
+     * 方差齐性检测
+     */
     @ApiModelProperty("方差齐性检测")
     @Excel(name = "方差齐性检测")
     private String varianceValid;
 
-    /** 置信水平 */
+    /**
+     * 置信水平
+     */
     @ApiModelProperty("置信水平")
     @Excel(name = "置信水平")
     private String confidenceLevel;
 
-    /** p值 */
+    /**
+     * p值
+     */
     @ApiModelProperty("p值")
     @Excel(name = "p值")
     private String pValue;
 
-    /** 分析时间 */
+    /**
+     * 分析时间
+     */
     @ApiModelProperty("分析时间")
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "分析时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date analyseTime;
 
-    /** 图片地址 */
+    /**
+     * 图片地址
+     */
     @ApiModelProperty("图片地址")
     @Excel(name = "图片地址")
     private String imgPath;
-
-    public void setResultId(Long resultId)
-    {
-        this.resultId = resultId;
-    }
-
-    public Long getResultId()
-    {
-        return resultId;
-    }
-    public void setRiskId(Long riskId)
-    {
-        this.riskId = riskId;
-    }
-
-    public Long getRiskId()
-    {
-        return riskId;
-    }
-    public void setResult(String result)
-    {
-        this.result = result;
-    }
-
-    public String getResult()
-    {
-        return result;
-    }
-    public void setAvgValue(String avgValue)
-    {
-        this.avgValue = avgValue;
-    }
-
-    public String getAvgValue()
-    {
-        return avgValue;
-    }
-    public void setNormalValid(String normalValid)
-    {
-        this.normalValid = normalValid;
-    }
-
-    public String getNormalValid()
-    {
-        return normalValid;
-    }
-    public void setVarianceValid(String varianceValid)
-    {
-        this.varianceValid = varianceValid;
-    }
-
-    public String getVarianceValid()
-    {
-        return varianceValid;
-    }
-    public void setConfidenceLevel(String confidenceLevel)
-    {
-        this.confidenceLevel = confidenceLevel;
-    }
-
-    public String getConfidenceLevel()
-    {
-        return confidenceLevel;
-    }
-    public void setpValue(String pValue)
-    {
-        this.pValue = pValue;
-    }
-
-    public String getpValue()
-    {
-        return pValue;
-    }
-    public void setAnalyseTime(Date analyseTime)
-    {
-        this.analyseTime = analyseTime;
-    }
-
-    public Date getAnalyseTime()
-    {
-        return analyseTime;
-    }
-    public void setImgPath(String imgPath)
-    {
-        this.imgPath = imgPath;
-    }
-
-    public String getImgPath()
-    {
-        return imgPath;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("resultId", getResultId())
-            .append("riskId", getRiskId())
-            .append("result", getResult())
-            .append("avgValue", getAvgValue())
-            .append("normalValid", getNormalValid())
-            .append("varianceValid", getVarianceValid())
-            .append("confidenceLevel", getConfidenceLevel())
-            .append("pValue", getpValue())
-            .append("analyseTime", getAnalyseTime())
-            .append("imgPath", getImgPath())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
 }

+ 36 - 105
jjt-biz/src/main/java/com/jjt/risk/domain/RiskModel.java

@@ -1,13 +1,14 @@
 package com.jjt.risk.domain;
 
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.annotation.TableId;
-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 io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 风险管理对象 risk_model
@@ -16,139 +17,69 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2024-09-12
  */
 @ApiModel(value = "RiskModel", description = "风险管理")
-public class RiskModel extends BaseEntity
-{
+@Data
+public class RiskModel extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 风险预测ID; */
+    /**
+     * 风险预测ID;
+     */
     @ApiModelProperty("风险预测ID;")
     @TableId
     private Long riskId;
 
-    /** 指标ID */
+    /**
+     * 指标ID
+     */
     @ApiModelProperty("指标ID")
     @Excel(name = "指标ID")
     private Long metricsId;
 
-    /** 指标名称; */
+    /**
+     * 指标名称;
+     */
     @ApiModelProperty("指标名称;")
     @Excel(name = "指标名称;")
     private String metricsName;
 
-    /** 选择对象类型 */
+    /**
+     * 选择对象类型
+     */
     @ApiModelProperty("选择对象类型")
     @Excel(name = "选择对象类型")
     private String objType;
 
-    /** 指标方向 */
+    /**
+     * 指标方向
+     */
     @ApiModelProperty("指标方向")
     @Excel(name = "指标方向")
     private String upDown;
 
-    /** 置信水平 */
+    /**
+     * 置信水平
+     */
     @ApiModelProperty("置信水平")
     @Excel(name = "置信水平")
     private BigDecimal confidenceLevel;
 
-    /** 分析类型 */
+    /**
+     * 分析类型
+     */
     @ApiModelProperty("分析类型")
     @Excel(name = "分析类型")
     private String riskType;
 
-    /** 是否定时分析 */
+    /**
+     * 是否定时分析
+     */
     @ApiModelProperty("是否定时分析")
     @Excel(name = "是否定时分析")
     private String timeSwitch;
 
-    public void setRiskId(Long riskId)
-    {
-        this.riskId = riskId;
-    }
-
-    public Long getRiskId()
-    {
-        return riskId;
-    }
-    public void setMetricsId(Long metricsId)
-    {
-        this.metricsId = metricsId;
-    }
-
-    public Long getMetricsId()
-    {
-        return metricsId;
-    }
-    public void setMetricsName(String metricsName)
-    {
-        this.metricsName = metricsName;
-    }
-
-    public String getMetricsName()
-    {
-        return metricsName;
-    }
-    public void setObjType(String objType)
-    {
-        this.objType = objType;
-    }
-
-    public String getObjType()
-    {
-        return objType;
-    }
-    public void setUpDown(String upDown)
-    {
-        this.upDown = upDown;
-    }
-
-    public String getUpDown()
-    {
-        return upDown;
-    }
-    public void setConfidenceLevel(BigDecimal confidenceLevel)
-    {
-        this.confidenceLevel = confidenceLevel;
-    }
-
-    public BigDecimal getConfidenceLevel()
-    {
-        return confidenceLevel;
-    }
-    public void setRiskType(String riskType)
-    {
-        this.riskType = riskType;
-    }
-
-    public String getRiskType()
-    {
-        return riskType;
-    }
-    public void setTimeSwitch(String timeSwitch)
-    {
-        this.timeSwitch = timeSwitch;
-    }
-
-    public String getTimeSwitch()
-    {
-        return timeSwitch;
-    }
+    @ApiModelProperty("对象ids")
+    private List<Long> objIds;
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("riskId", getRiskId())
-            .append("metricsId", getMetricsId())
-            .append("metricsName", getMetricsName())
-            .append("objType", getObjType())
-            .append("upDown", getUpDown())
-            .append("confidenceLevel", getConfidenceLevel())
-            .append("riskType", getRiskType())
-            .append("timeSwitch", getTimeSwitch())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
+    @ApiModelProperty("对象列表")
+    private List<RiskObj> riskObjList;
 }

+ 16 - 45
jjt-biz/src/main/java/com/jjt/risk/domain/RiskObj.java

@@ -1,12 +1,11 @@
 package com.jjt.risk.domain;
 
 import com.baomidou.mybatisplus.annotation.TableId;
-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 io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 /**
  * 风险管理对象对象 risk_obj
@@ -15,59 +14,31 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2024-09-12
  */
 @ApiModel(value = "RiskObj", description = "风险管理对象")
-public class RiskObj extends BaseEntity
-{
+@Data
+public class RiskObj extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 风险对象ID */
+    /**
+     * 风险对象ID
+     */
     @ApiModelProperty("风险对象ID")
     @TableId
     private Long riskObjId;
 
-    /** 风险ID */
+    /**
+     * 风险ID
+     */
     @ApiModelProperty("风险ID")
     @Excel(name = "风险ID")
     private Long riskId;
 
-    /** 对象ID */
+    /**
+     * 对象ID
+     */
     @ApiModelProperty("对象ID")
     @Excel(name = "对象ID")
     private Long objId;
 
-    public void setRiskObjId(Long riskObjId)
-    {
-        this.riskObjId = riskObjId;
-    }
-
-    public Long getRiskObjId()
-    {
-        return riskObjId;
-    }
-    public void setRiskId(Long riskId)
-    {
-        this.riskId = riskId;
-    }
-
-    public Long getRiskId()
-    {
-        return riskId;
-    }
-    public void setObjId(Long objId)
-    {
-        this.objId = objId;
-    }
-
-    public Long getObjId()
-    {
-        return objId;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("riskObjId", getRiskObjId())
-            .append("riskId", getRiskId())
-            .append("objId", getObjId())
-            .toString();
-    }
+    @ApiModelProperty("对象名称")
+    private String objName;
 }

+ 17 - 10
jjt-biz/src/main/java/com/jjt/risk/mapper/RiskObjMapper.java

@@ -1,20 +1,20 @@
 package com.jjt.risk.mapper;
 
-import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jjt.risk.domain.RiskObj;
 
+import java.util.List;
+
 /**
  * 风险管理对象Mapper接口
- * 
+ *
  * @author jjt
  * @date 2024-09-12
  */
-public interface RiskObjMapper extends BaseMapper<RiskObj>
-{
+public interface RiskObjMapper extends BaseMapper<RiskObj> {
     /**
      * 查询风险管理对象
-     * 
+     *
      * @param riskObjId 风险管理对象主键
      * @return 风险管理对象
      */
@@ -22,7 +22,7 @@ public interface RiskObjMapper extends BaseMapper<RiskObj>
 
     /**
      * 查询风险管理对象列表
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 风险管理对象集合
      */
@@ -30,7 +30,7 @@ public interface RiskObjMapper extends BaseMapper<RiskObj>
 
     /**
      * 新增风险管理对象
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 结果
      */
@@ -38,7 +38,7 @@ public interface RiskObjMapper extends BaseMapper<RiskObj>
 
     /**
      * 修改风险管理对象
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 结果
      */
@@ -46,7 +46,7 @@ public interface RiskObjMapper extends BaseMapper<RiskObj>
 
     /**
      * 删除风险管理对象
-     * 
+     *
      * @param riskObjId 风险管理对象主键
      * @return 结果
      */
@@ -54,9 +54,16 @@ public interface RiskObjMapper extends BaseMapper<RiskObj>
 
     /**
      * 批量删除风险管理对象
-     * 
+     *
      * @param riskObjIds 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteRiskObjByRiskObjIds(Long[] riskObjIds);
+
+    /**
+     * 根据风险ID删除数据
+     *
+     * @param riskId 风险ID
+     */
+    void deleteRiskObjByRiskId(Long riskId);
 }

+ 18 - 10
jjt-biz/src/main/java/com/jjt/risk/service/IRiskObjService.java

@@ -1,19 +1,19 @@
 package com.jjt.risk.service;
 
-import java.util.List;
 import com.jjt.risk.domain.RiskObj;
 
+import java.util.List;
+
 /**
  * 风险管理对象Service接口
- * 
+ *
  * @author jjt
  * @date 2024-09-12
  */
-public interface IRiskObjService 
-{
+public interface IRiskObjService {
     /**
      * 查询风险管理对象
-     * 
+     *
      * @param riskObjId 风险管理对象主键
      * @return 风险管理对象
      */
@@ -21,7 +21,7 @@ public interface IRiskObjService
 
     /**
      * 查询风险管理对象列表
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 风险管理对象集合
      */
@@ -29,7 +29,7 @@ public interface IRiskObjService
 
     /**
      * 新增风险管理对象
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface IRiskObjService
 
     /**
      * 修改风险管理对象
-     * 
+     *
      * @param riskObj 风险管理对象
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface IRiskObjService
 
     /**
      * 批量删除风险管理对象
-     * 
+     *
      * @param riskObjIds 需要删除的风险管理对象主键集合
      * @return 结果
      */
@@ -53,9 +53,17 @@ public interface IRiskObjService
 
     /**
      * 删除风险管理对象信息
-     * 
+     *
      * @param riskObjId 风险管理对象主键
      * @return 结果
      */
     public int deleteRiskObjByRiskObjId(Long riskObjId);
+
+    /**
+     * 处理风险对象
+     *
+     * @param riskId 风险ID
+     * @param objIds 对象IDS
+     */
+    void process(Long riskId, List<Long> objIds);
 }

+ 23 - 4
jjt-biz/src/main/java/com/jjt/risk/service/impl/RiskObjServiceImpl.java

@@ -1,11 +1,12 @@
 package com.jjt.risk.service.impl;
 
-import java.util.List;
-import org.springframework.stereotype.Service;
-import com.jjt.risk.mapper.RiskObjMapper;
 import com.jjt.risk.domain.RiskObj;
+import com.jjt.risk.mapper.RiskObjMapper;
 import com.jjt.risk.service.IRiskObjService;
+import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 风险管理对象Service业务层处理
@@ -48,7 +49,7 @@ public class RiskObjServiceImpl implements IRiskObjService {
      */
     @Override
     public int insertRiskObj(RiskObj riskObj) {
-            return riskObjMapper.insertRiskObj(riskObj);
+        return riskObjMapper.insertRiskObj(riskObj);
     }
 
     /**
@@ -83,4 +84,22 @@ public class RiskObjServiceImpl implements IRiskObjService {
     public int deleteRiskObjByRiskObjId(Long riskObjId) {
         return riskObjMapper.deleteRiskObjByRiskObjId(riskObjId);
     }
+
+    /**
+     * 处理风险对象
+     *
+     * @param riskId 风险ID
+     * @param objIds 对象IDS
+     */
+    @Override
+    public void process(Long riskId, List<Long> objIds) {
+        //1.先删除,再插入
+        riskObjMapper.deleteRiskObjByRiskId(riskId);
+        for (Long objId : objIds) {
+            RiskObj riskObj = new RiskObj();
+            riskObj.setRiskId(riskId);
+            riskObj.setObjId(objId);
+            insertRiskObj(riskObj);
+        }
+    }
 }

+ 5 - 0
jjt-biz/src/main/resources/mapper/obj/BizObjMapper.xml

@@ -77,6 +77,11 @@
         where OBJ_ID = #{objId}
     </select>
 
+    <select id="selectBizObjListByMetricsId" resultMap="BizObjResult">
+        <include refid="selectBizObjVo"/>
+        where obj_id in(SELECT distinct obj_id FROM biz_obj_metrics WHERE metrics_id=#{metricsId})
+    </select>
+
     <insert id="insertBizObj" parameterType="BizObj" useGeneratedKeys="true"
             keyProperty="objId">
         insert into biz_obj

+ 197 - 160
jjt-biz/src/main/resources/mapper/risk/RiskAnalysisMapper.xml

@@ -5,199 +5,236 @@
 <mapper namespace="com.jjt.risk.mapper.RiskAnalysisMapper">
 
     <resultMap type="RiskAnalysis" id="RiskAnalysisResult">
-            <result property="resultId" column="RESULT_ID"/>
-            <result property="riskId" column="RISK_ID"/>
-            <result property="result" column="RESULT"/>
-            <result property="avgValue" column="AVG_VALUE"/>
-            <result property="normalValid" column="NORMAL_VALID"/>
-            <result property="varianceValid" column="VARIANCE_VALID"/>
-            <result property="confidenceLevel" column="CONFIDENCE_LEVEL"/>
-            <result property="pValue" column="P_VALUE"/>
-            <result property="analyseTime" column="ANALYSE_TIME"/>
-            <result property="imgPath" column="IMG_PATH"/>
-            <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="resultId" column="RESULT_ID"/>
+        <result property="riskId" column="RISK_ID"/>
+        <result property="riskType" column="RISK_TYPE"/>
+        <result property="result" column="RESULT"/>
+        <result property="avgValue" column="AVG_VALUE"/>
+        <result property="normalValid" column="NORMAL_VALID"/>
+        <result property="varianceValid" column="VARIANCE_VALID"/>
+        <result property="confidenceLevel" column="CONFIDENCE_LEVEL"/>
+        <result property="pValue" column="P_VALUE"/>
+        <result property="analyseTime" column="ANALYSE_TIME"/>
+        <result property="imgPath" column="IMG_PATH"/>
+        <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="selectRiskAnalysisVo">
-        select RESULT_ID, RISK_ID, RESULT, AVG_VALUE, NORMAL_VALID, VARIANCE_VALID, CONFIDENCE_LEVEL, P_VALUE, ANALYSE_TIME, IMG_PATH, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK
-        from risk_analysis
+        select *
+        from (select A.RESULT_ID,
+                     A.RISK_ID,
+                     A.OBJ_ID,
+                     C.OBJ_NAME,
+                     B.RISK_TYPE,
+                     B.METRICS_NAME,
+                     A.RESULT,
+                     A.AVG_VALUE,
+                     A.NORMAL_VALID,
+                     A.VARIANCE_VALID,
+                     A.CONFIDENCE_LEVEL,
+                     A.P_VALUE,
+                     A.ANALYSE_TIME,
+                     A.IMG_PATH,
+                     A.CREATE_BY,
+                     A.CREATE_TIME,
+                     A.UPDATE_BY,
+                     A.UPDATE_TIME,
+                     A.REMARK
+              from risk_analysis a LEFT JOIN biz_obj c ON a.OBJ_ID=c.OBJ_ID,risk_model b
+              where a.risk_id = b.risk_id ) t
     </sql>
 
     <select id="selectRiskAnalysisList" parameterType="RiskAnalysis" resultMap="RiskAnalysisResult">
         <include refid="selectRiskAnalysisVo"/>
         <where>
-                        <if test="riskId != null ">
-                            and RISK_ID = #{riskId}
-                        </if>
-                        <if test="result != null  and result != ''">
-                            and RESULT = #{result}
-                        </if>
-                        <if test="avgValue != null  and avgValue != ''">
-                            and AVG_VALUE = #{avgValue}
-                        </if>
-                        <if test="normalValid != null  and normalValid != ''">
-                            and NORMAL_VALID = #{normalValid}
-                        </if>
-                        <if test="varianceValid != null  and varianceValid != ''">
-                            and VARIANCE_VALID = #{varianceValid}
-                        </if>
-                        <if test="confidenceLevel != null  and confidenceLevel != ''">
-                            and CONFIDENCE_LEVEL = #{confidenceLevel}
-                        </if>
-                        <if test="pValue != null  and pValue != ''">
-                            and P_VALUE = #{pValue}
-                        </if>
-                        <if test="analyseTime != null ">
-                            and ANALYSE_TIME = #{analyseTime}
-                        </if>
-                        <if test="imgPath != null  and imgPath != ''">
-                            and IMG_PATH = #{imgPath}
-                        </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="riskId != null ">
+                and RISK_ID = #{riskId}
+            </if>
+            <if test="riskType != null ">
+                and RISK_TYPE = #{riskType}
+            </if>
+            <if test="metricsId != null ">
+                and METRICS_ID = #{metricsId}
+            </if>
+            <if test="metricsName != null  and metricsName != ''">
+                and METRICS_NAME like concat('%', #{metricsName}, '%')
+            </if>
+            <if test="objId != null ">
+                and OBJ_ID = #{objId}
+            </if>
+            <if test="objName != null ">
+                and OBJ_NAME like concat('%', #{objName}, '%')
+            </if>
+            <if test="result != null  and result != ''">
+                and RESULT = #{result}
+            </if>
+            <if test="avgValue != null  and avgValue != ''">
+                and AVG_VALUE = #{avgValue}
+            </if>
+            <if test="normalValid != null  and normalValid != ''">
+                and NORMAL_VALID = #{normalValid}
+            </if>
+            <if test="varianceValid != null  and varianceValid != ''">
+                and VARIANCE_VALID = #{varianceValid}
+            </if>
+            <if test="confidenceLevel != null  and confidenceLevel != ''">
+                and CONFIDENCE_LEVEL = #{confidenceLevel}
+            </if>
+            <if test="pValue != null  and pValue != ''">
+                and P_VALUE = #{pValue}
+            </if>
+            <if test="analyseTime != null ">
+                and ANALYSE_TIME = #{analyseTime}
+            </if>
+            <if test="imgPath != null  and imgPath != ''">
+                and IMG_PATH = #{imgPath}
+            </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="selectRiskAnalysisByResultId" parameterType="Long"
             resultMap="RiskAnalysisResult">
-            <include refid="selectRiskAnalysisVo"/>
-            where RESULT_ID = #{resultId}
+        <include refid="selectRiskAnalysisVo"/>
+        where RESULT_ID = #{resultId}
     </select>
 
     <insert id="insertRiskAnalysis" parameterType="RiskAnalysis" useGeneratedKeys="true"
             keyProperty="resultId">
         insert into risk_analysis
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="riskId != null">RISK_ID,
-                    </if>
-                    <if test="result != null">RESULT,
-                    </if>
-                    <if test="avgValue != null">AVG_VALUE,
-                    </if>
-                    <if test="normalValid != null">NORMAL_VALID,
-                    </if>
-                    <if test="varianceValid != null">VARIANCE_VALID,
-                    </if>
-                    <if test="confidenceLevel != null">CONFIDENCE_LEVEL,
-                    </if>
-                    <if test="pValue != null">P_VALUE,
-                    </if>
-                    <if test="analyseTime != null">ANALYSE_TIME,
-                    </if>
-                    <if test="imgPath != null">IMG_PATH,
-                    </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="riskId != null">RISK_ID,
+            </if>
+            <if test="result != null">RESULT,
+            </if>
+            <if test="avgValue != null">AVG_VALUE,
+            </if>
+            <if test="normalValid != null">NORMAL_VALID,
+            </if>
+            <if test="varianceValid != null">VARIANCE_VALID,
+            </if>
+            <if test="confidenceLevel != null">CONFIDENCE_LEVEL,
+            </if>
+            <if test="pValue != null">P_VALUE,
+            </if>
+            <if test="analyseTime != null">ANALYSE_TIME,
+            </if>
+            <if test="imgPath != null">IMG_PATH,
+            </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="riskId != null">#{riskId},
-                    </if>
-                    <if test="result != null">#{result},
-                    </if>
-                    <if test="avgValue != null">#{avgValue},
-                    </if>
-                    <if test="normalValid != null">#{normalValid},
-                    </if>
-                    <if test="varianceValid != null">#{varianceValid},
-                    </if>
-                    <if test="confidenceLevel != null">#{confidenceLevel},
-                    </if>
-                    <if test="pValue != null">#{pValue},
-                    </if>
-                    <if test="analyseTime != null">#{analyseTime},
-                    </if>
-                    <if test="imgPath != null">#{imgPath},
-                    </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="riskId != null">#{riskId},
+            </if>
+            <if test="result != null">#{result},
+            </if>
+            <if test="avgValue != null">#{avgValue},
+            </if>
+            <if test="normalValid != null">#{normalValid},
+            </if>
+            <if test="varianceValid != null">#{varianceValid},
+            </if>
+            <if test="confidenceLevel != null">#{confidenceLevel},
+            </if>
+            <if test="pValue != null">#{pValue},
+            </if>
+            <if test="analyseTime != null">#{analyseTime},
+            </if>
+            <if test="imgPath != null">#{imgPath},
+            </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="updateRiskAnalysis" parameterType="RiskAnalysis">
         update risk_analysis
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="riskId != null">RISK_ID =
-                        #{riskId},
-                    </if>
-                    <if test="result != null">RESULT =
-                        #{result},
-                    </if>
-                    <if test="avgValue != null">AVG_VALUE =
-                        #{avgValue},
-                    </if>
-                    <if test="normalValid != null">NORMAL_VALID =
-                        #{normalValid},
-                    </if>
-                    <if test="varianceValid != null">VARIANCE_VALID =
-                        #{varianceValid},
-                    </if>
-                    <if test="confidenceLevel != null">CONFIDENCE_LEVEL =
-                        #{confidenceLevel},
-                    </if>
-                    <if test="pValue != null">P_VALUE =
-                        #{pValue},
-                    </if>
-                    <if test="analyseTime != null">ANALYSE_TIME =
-                        #{analyseTime},
-                    </if>
-                    <if test="imgPath != null">IMG_PATH =
-                        #{imgPath},
-                    </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="riskId != null">RISK_ID =
+                #{riskId},
+            </if>
+            <if test="result != null">RESULT =
+                #{result},
+            </if>
+            <if test="avgValue != null">AVG_VALUE =
+                #{avgValue},
+            </if>
+            <if test="normalValid != null">NORMAL_VALID =
+                #{normalValid},
+            </if>
+            <if test="varianceValid != null">VARIANCE_VALID =
+                #{varianceValid},
+            </if>
+            <if test="confidenceLevel != null">CONFIDENCE_LEVEL =
+                #{confidenceLevel},
+            </if>
+            <if test="pValue != null">P_VALUE =
+                #{pValue},
+            </if>
+            <if test="analyseTime != null">ANALYSE_TIME =
+                #{analyseTime},
+            </if>
+            <if test="imgPath != null">IMG_PATH =
+                #{imgPath},
+            </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 RESULT_ID = #{resultId}
     </update>
 
     <delete id="deleteRiskAnalysisByResultId" parameterType="Long">
         delete
-        from risk_analysis where RESULT_ID = #{resultId}
+        from risk_analysis
+        where RESULT_ID = #{resultId}
     </delete>
 
     <delete id="deleteRiskAnalysisByResultIds" parameterType="String">

+ 166 - 138
jjt-biz/src/main/resources/mapper/risk/RiskModelMapper.xml

@@ -5,177 +5,205 @@
 <mapper namespace="com.jjt.risk.mapper.RiskModelMapper">
 
     <resultMap type="RiskModel" id="RiskModelResult">
-            <result property="riskId" column="RISK_ID"/>
-            <result property="metricsId" column="METRICS_ID"/>
-            <result property="metricsName" column="METRICS_NAME"/>
-            <result property="objType" column="OBJ_TYPE"/>
-            <result property="upDown" column="UP_DOWN"/>
-            <result property="confidenceLevel" column="CONFIDENCE_LEVEL"/>
-            <result property="riskType" column="RISK_TYPE"/>
-            <result property="timeSwitch" column="TIME_SWITCH"/>
-            <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"/>
+        <id property="riskId" column="RISK_ID"/>
+        <result property="metricsId" column="METRICS_ID"/>
+        <result property="metricsName" column="METRICS_NAME"/>
+        <result property="objType" column="OBJ_TYPE"/>
+        <result property="upDown" column="UP_DOWN"/>
+        <result property="confidenceLevel" column="CONFIDENCE_LEVEL"/>
+        <result property="riskType" column="RISK_TYPE"/>
+        <result property="timeSwitch" column="TIME_SWITCH"/>
+        <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"/>
+        <collection property="riskObjList" javaType="java.util.List" resultMap="riskObjResult"/>
+    </resultMap>
+    <resultMap id="riskObjResult" type="RiskObj">
+        <result property="riskObjId" column="RISK_OBJ_ID"/>
+        <result property="objId" column="OBJ_ID"/>
+        <result property="objName" column="OBJ_NAME"/>
     </resultMap>
 
     <sql id="selectRiskModelVo">
-        select RISK_ID, METRICS_ID, METRICS_NAME, OBJ_TYPE, UP_DOWN, CONFIDENCE_LEVEL, RISK_TYPE, TIME_SWITCH, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK
-        from risk_model
+        select *
+        from (select A.RISK_ID,
+                     A.METRICS_ID,
+                     A.METRICS_NAME,
+                     A.OBJ_TYPE,
+                     A.UP_DOWN,
+                     A.CONFIDENCE_LEVEL,
+                     A.RISK_TYPE,
+                     A.TIME_SWITCH,
+                     A.CREATE_BY,
+                     A.CREATE_TIME,
+                     A.UPDATE_BY,
+                     A.UPDATE_TIME,
+                     A.REMARK,
+                     b.OBJ_ID,
+                     b.OBJ_NAME,
+                     b.RISK_OBJ_ID
+              from risk_model a
+                       LEFT JOIN (SELECT a.*, b.OBJ_NAME
+                                  FROM risk_obj a,
+                                       biz_obj b
+                                  WHERE a.obj_id = b.obj_id) b
+                                 ON a.risk_id = b.risk_id) t
     </sql>
 
     <select id="selectRiskModelList" parameterType="RiskModel" resultMap="RiskModelResult">
         <include refid="selectRiskModelVo"/>
         <where>
-                        <if test="metricsId != null ">
-                            and METRICS_ID = #{metricsId}
-                        </if>
-                        <if test="metricsName != null  and metricsName != ''">
-                            and METRICS_NAME like concat('%', #{metricsName}, '%')
-                        </if>
-                        <if test="objType != null  and objType != ''">
-                            and OBJ_TYPE = #{objType}
-                        </if>
-                        <if test="upDown != null  and upDown != ''">
-                            and UP_DOWN = #{upDown}
-                        </if>
-                        <if test="confidenceLevel != null ">
-                            and CONFIDENCE_LEVEL = #{confidenceLevel}
-                        </if>
-                        <if test="riskType != null  and riskType != ''">
-                            and RISK_TYPE = #{riskType}
-                        </if>
-                        <if test="timeSwitch != null  and timeSwitch != ''">
-                            and TIME_SWITCH = #{timeSwitch}
-                        </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="metricsId != null ">
+                and METRICS_ID = #{metricsId}
+            </if>
+            <if test="metricsName != null  and metricsName != ''">
+                and METRICS_NAME like concat('%', #{metricsName}, '%')
+            </if>
+            <if test="objType != null  and objType != ''">
+                and OBJ_TYPE = #{objType}
+            </if>
+            <if test="upDown != null  and upDown != ''">
+                and UP_DOWN = #{upDown}
+            </if>
+            <if test="confidenceLevel != null ">
+                and CONFIDENCE_LEVEL = #{confidenceLevel}
+            </if>
+            <if test="riskType != null  and riskType != ''">
+                and RISK_TYPE = #{riskType}
+            </if>
+            <if test="timeSwitch != null  and timeSwitch != ''">
+                and TIME_SWITCH = #{timeSwitch}
+            </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="selectRiskModelByRiskId" parameterType="Long"
             resultMap="RiskModelResult">
-            <include refid="selectRiskModelVo"/>
-            where RISK_ID = #{riskId}
+        <include refid="selectRiskModelVo"/>
+        where RISK_ID = #{riskId}
     </select>
 
     <insert id="insertRiskModel" parameterType="RiskModel" useGeneratedKeys="true"
             keyProperty="riskId">
         insert into risk_model
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="metricsId != null">METRICS_ID,
-                    </if>
-                    <if test="metricsName != null">METRICS_NAME,
-                    </if>
-                    <if test="objType != null">OBJ_TYPE,
-                    </if>
-                    <if test="upDown != null">UP_DOWN,
-                    </if>
-                    <if test="confidenceLevel != null">CONFIDENCE_LEVEL,
-                    </if>
-                    <if test="riskType != null">RISK_TYPE,
-                    </if>
-                    <if test="timeSwitch != null">TIME_SWITCH,
-                    </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="metricsId != null">METRICS_ID,
+            </if>
+            <if test="metricsName != null">METRICS_NAME,
+            </if>
+            <if test="objType != null">OBJ_TYPE,
+            </if>
+            <if test="upDown != null">UP_DOWN,
+            </if>
+            <if test="confidenceLevel != null">CONFIDENCE_LEVEL,
+            </if>
+            <if test="riskType != null">RISK_TYPE,
+            </if>
+            <if test="timeSwitch != null">TIME_SWITCH,
+            </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="metricsId != null">#{metricsId},
-                    </if>
-                    <if test="metricsName != null">#{metricsName},
-                    </if>
-                    <if test="objType != null">#{objType},
-                    </if>
-                    <if test="upDown != null">#{upDown},
-                    </if>
-                    <if test="confidenceLevel != null">#{confidenceLevel},
-                    </if>
-                    <if test="riskType != null">#{riskType},
-                    </if>
-                    <if test="timeSwitch != null">#{timeSwitch},
-                    </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="metricsId != null">#{metricsId},
+            </if>
+            <if test="metricsName != null">#{metricsName},
+            </if>
+            <if test="objType != null">#{objType},
+            </if>
+            <if test="upDown != null">#{upDown},
+            </if>
+            <if test="confidenceLevel != null">#{confidenceLevel},
+            </if>
+            <if test="riskType != null">#{riskType},
+            </if>
+            <if test="timeSwitch != null">#{timeSwitch},
+            </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="updateRiskModel" parameterType="RiskModel">
         update risk_model
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="metricsId != null">METRICS_ID =
-                        #{metricsId},
-                    </if>
-                    <if test="metricsName != null">METRICS_NAME =
-                        #{metricsName},
-                    </if>
-                    <if test="objType != null">OBJ_TYPE =
-                        #{objType},
-                    </if>
-                    <if test="upDown != null">UP_DOWN =
-                        #{upDown},
-                    </if>
-                    <if test="confidenceLevel != null">CONFIDENCE_LEVEL =
-                        #{confidenceLevel},
-                    </if>
-                    <if test="riskType != null">RISK_TYPE =
-                        #{riskType},
-                    </if>
-                    <if test="timeSwitch != null">TIME_SWITCH =
-                        #{timeSwitch},
-                    </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="metricsId != null">METRICS_ID =
+                #{metricsId},
+            </if>
+            <if test="metricsName != null">METRICS_NAME =
+                #{metricsName},
+            </if>
+            <if test="objType != null">OBJ_TYPE =
+                #{objType},
+            </if>
+            <if test="upDown != null">UP_DOWN =
+                #{upDown},
+            </if>
+            <if test="confidenceLevel != null">CONFIDENCE_LEVEL =
+                #{confidenceLevel},
+            </if>
+            <if test="riskType != null">RISK_TYPE =
+                #{riskType},
+            </if>
+            <if test="timeSwitch != null">TIME_SWITCH =
+                #{timeSwitch},
+            </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 RISK_ID = #{riskId}
     </update>
 
     <delete id="deleteRiskModelByRiskId" parameterType="Long">
         delete
-        from risk_model where RISK_ID = #{riskId}
+        from risk_model
+        where RISK_ID = #{riskId}
     </delete>
 
     <delete id="deleteRiskModelByRiskIds" parameterType="String">

+ 32 - 26
jjt-biz/src/main/resources/mapper/risk/RiskObjMapper.xml

@@ -5,9 +5,9 @@
 <mapper namespace="com.jjt.risk.mapper.RiskObjMapper">
 
     <resultMap type="RiskObj" id="RiskObjResult">
-            <result property="riskObjId" column="RISK_OBJ_ID"/>
-            <result property="riskId" column="RISK_ID"/>
-            <result property="objId" column="OBJ_ID"/>
+        <result property="riskObjId" column="RISK_OBJ_ID"/>
+        <result property="riskId" column="RISK_ID"/>
+        <result property="objId" column="OBJ_ID"/>
     </resultMap>
 
     <sql id="selectRiskObjVo">
@@ -18,54 +18,55 @@
     <select id="selectRiskObjList" parameterType="RiskObj" resultMap="RiskObjResult">
         <include refid="selectRiskObjVo"/>
         <where>
-                        <if test="riskId != null ">
-                            and RISK_ID = #{riskId}
-                        </if>
-                        <if test="objId != null ">
-                            and OBJ_ID = #{objId}
-                        </if>
+            <if test="riskId != null ">
+                and RISK_ID = #{riskId}
+            </if>
+            <if test="objId != null ">
+                and OBJ_ID = #{objId}
+            </if>
         </where>
     </select>
 
     <select id="selectRiskObjByRiskObjId" parameterType="Long"
             resultMap="RiskObjResult">
-            <include refid="selectRiskObjVo"/>
-            where RISK_OBJ_ID = #{riskObjId}
+        <include refid="selectRiskObjVo"/>
+        where RISK_OBJ_ID = #{riskObjId}
     </select>
 
     <insert id="insertRiskObj" parameterType="RiskObj" useGeneratedKeys="true"
             keyProperty="riskObjId">
         insert into risk_obj
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="riskId != null">RISK_ID,
-                    </if>
-                    <if test="objId != null">OBJ_ID,
-                    </if>
+            <if test="riskId != null">RISK_ID,
+            </if>
+            <if test="objId != null">OBJ_ID,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test="riskId != null">#{riskId},
-                    </if>
-                    <if test="objId != null">#{objId},
-                    </if>
+            <if test="riskId != null">#{riskId},
+            </if>
+            <if test="objId != null">#{objId},
+            </if>
         </trim>
     </insert>
 
     <update id="updateRiskObj" parameterType="RiskObj">
         update risk_obj
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="riskId != null">RISK_ID =
-                        #{riskId},
-                    </if>
-                    <if test="objId != null">OBJ_ID =
-                        #{objId},
-                    </if>
+            <if test="riskId != null">RISK_ID =
+                #{riskId},
+            </if>
+            <if test="objId != null">OBJ_ID =
+                #{objId},
+            </if>
         </trim>
         where RISK_OBJ_ID = #{riskObjId}
     </update>
 
     <delete id="deleteRiskObjByRiskObjId" parameterType="Long">
         delete
-        from risk_obj where RISK_OBJ_ID = #{riskObjId}
+        from risk_obj
+        where RISK_OBJ_ID = #{riskObjId}
     </delete>
 
     <delete id="deleteRiskObjByRiskObjIds" parameterType="String">
@@ -74,4 +75,9 @@
             #{riskObjId}
         </foreach>
     </delete>
+    <delete id="deleteRiskObjByRiskId" parameterType="Long">
+        delete
+        from risk_obj
+        where RISK_ID = #{riskId}
+    </delete>
 </mapper>