소스 검색

搞定模型指标选择相关事项

wukai 2 주 전
부모
커밋
ed7c27a1ca

+ 12 - 5
jjt-biz/src/main/java/com/jjt/biz/controller/RipaMetricsController.java

@@ -2,6 +2,7 @@ package com.jjt.biz.controller;
 
 import com.jjt.biz.domain.RipaMetrics;
 import com.jjt.biz.service.IRipaMetricsService;
+import com.jjt.biz.vo.ObjMetrics;
 import com.jjt.common.annotation.Log;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
@@ -15,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 模型指标配置Controller
@@ -48,9 +48,9 @@ public class RipaMetricsController extends BaseController {
     @ApiOperation("查询模型指标配置列表")
     //@PreAuthorize("@ss.hasPermi('biz:metrics:list')")
     @GetMapping("/select")
-    public TableDataInfo select(RipaMetrics ripaMetrics) {
+    public TableDataInfo select(ObjMetrics objMetrics) {
         startPage();
-        List<Map<String,Object>> list = ripaMetricsService.selectRiskMetricsList();
+        List<ObjMetrics> list = ripaMetricsService.selectRiskMetricsList(objMetrics);
         return getDataTable(list);
     }
 
@@ -84,8 +84,15 @@ public class RipaMetricsController extends BaseController {
     //@PreAuthorize("@ss.hasPermi('biz:metrics:add')")
     @Log(title = "模型指标配置", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody RipaMetrics ripaMetrics) {
-        return toAjax(ripaMetricsService.insertRipaMetrics(ripaMetrics));
+    public AjaxResult add(@RequestBody List<RipaMetrics> metricsList) {
+        try {
+            ripaMetricsService.insertRipaMetricsList(metricsList);
+            return success();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return error();
+        }
+//        return toAjax(ripaMetricsService.insertRipaMetrics(ripaMetrics));
     }
 
     /**

+ 6 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/RipaModelController.java

@@ -94,4 +94,10 @@ public class RipaModelController extends BaseController {
     public AjaxResult remove(Long modelId) {
         return toAjax(ripaModelService.deleteRipaModelByModelId(modelId));
     }
+
+    @ApiOperation("查询模型树")
+    @GetMapping("/modelTree")
+    public AjaxResult modelTree() {
+        return success(ripaModelService.selectModelTreeList());
+    }
 }

+ 35 - 0
jjt-biz/src/main/java/com/jjt/biz/domain/ModelTreeSelect.java

@@ -0,0 +1,35 @@
+package com.jjt.biz.domain;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * ModelTreeSelect$
+ *
+ * @author wukai
+ * @date 2025/10/22 21:50
+ */
+@Data
+public class ModelTreeSelect implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Long id;
+
+    /**
+     * 节点名称
+     */
+    private String label;
+
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private List<ModelTreeSelect> children;
+
+    public ModelTreeSelect(RipaModel model) {
+        this.id = model.getModelId();
+        this.label = model.getModelName();
+        List<RipaModel> children = (List<RipaModel>) model.getChildren();
+        this.children = children.stream().map(ModelTreeSelect::new).collect(Collectors.toList());
+    }
+}

+ 49 - 58
jjt-biz/src/main/java/com/jjt/biz/domain/RipaMetrics.java

@@ -1,12 +1,11 @@
 package com.jjt.biz.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;
 
 /**
  * 模型指标配置对象 ripa_metrics
@@ -15,79 +14,71 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2025-10-22
  */
 @ApiModel(value = "RipaMetrics", description = "模型指标配置")
-public class RipaMetrics extends BaseEntity
-{
+@Data
+public class RipaMetrics extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 自动ID */
+    /**
+     * 自动ID
+     */
     @ApiModelProperty("自动ID")
     @TableId
     private Long autoId;
 
-    /** 模型ID */
+    /**
+     * 模型ID
+     */
     @ApiModelProperty("模型ID")
     @Excel(name = "模型ID")
     private Long modelId;
 
-    /** 指标ID */
+    @ApiModelProperty("模型名称")
+    private String modelName;
+    /**
+     * 指标ID
+     */
     @ApiModelProperty("指标ID")
     @Excel(name = "指标ID")
     private Long objMetricsId;
 
-    /** 指标名称 */
+    /**
+     * 指标名称
+     */
     @ApiModelProperty("指标名称")
     @Excel(name = "指标名称")
     private String metricsName;
+    /**
+     * 对象类型
+     */
+    @ApiModelProperty("对象类型")
+    @Excel(name = "对象类型")
+    private String objType;
 
-    public void setAutoId(Long autoId)
-    {
-        this.autoId = autoId;
-    }
-
-    public Long getAutoId()
-    {
-        return autoId;
-    }
-    public void setModelId(Long modelId)
-    {
-        this.modelId = modelId;
-    }
-
-    public Long getModelId()
-    {
-        return modelId;
-    }
-    public void setObjMetricsId(Long objMetricsId)
-    {
-        this.objMetricsId = objMetricsId;
-    }
+    /**
+     * 对象名称
+     */
+    @ApiModelProperty("对象名称")
+    @Excel(name = "对象名称")
+    private String objName;
 
-    public Long getObjMetricsId()
-    {
-        return objMetricsId;
-    }
-    public void setMetricsName(String metricsName)
-    {
-        this.metricsName = metricsName;
-    }
+    /**
+     * 适用算法类别
+     */
+    @ApiModelProperty("适用算法类别")
+    @Excel(name = "适用算法类别")
+    private String algoType;
 
-    public String getMetricsName()
-    {
-        return metricsName;
-    }
+    /**
+     * 正态校验结果
+     */
+    @ApiModelProperty("正态校验结果")
+    @Excel(name = "正态校验结果")
+    private String ntr;
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("autoId", getAutoId())
-            .append("modelId", getModelId())
-            .append("objMetricsId", getObjMetricsId())
-            .append("metricsName", getMetricsName())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
+    /**
+     * 方差校验结果
+     */
+    @ApiModelProperty("方差校验结果")
+    @Excel(name = "方差校验结果")
+    private String hov;
 }

+ 16 - 53
jjt-biz/src/main/java/com/jjt/biz/domain/RipaModel.java

@@ -1,12 +1,13 @@
 package com.jjt.biz.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.TreeEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
 
 /**
  * 分析模型对象 ripa_model
@@ -15,66 +16,28 @@ import com.jjt.common.core.domain.TreeEntity;
  * @date 2025-10-21
  */
 @ApiModel(value = "RipaModel", description = "分析模型")
-public class RipaModel extends TreeEntity
-{
+@Data
+public class RipaModel extends TreeEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 模型ID */
+    /**
+     * 模型ID
+     */
     @ApiModelProperty("模型ID")
     @TableId
     private Long modelId;
 
-    /** 模型名称 */
+    /**
+     * 模型名称
+     */
     @ApiModelProperty("模型名称")
     @Excel(name = "模型名称")
     private String modelName;
 
-    /** 模型描述 */
+    /**
+     * 模型描述
+     */
     @ApiModelProperty("模型描述")
     @Excel(name = "模型描述")
     private String modelDesc;
-
-    public void setModelId(Long modelId)
-    {
-        this.modelId = modelId;
-    }
-
-    public Long getModelId()
-    {
-        return modelId;
-    }
-    public void setModelName(String modelName)
-    {
-        this.modelName = modelName;
-    }
-
-    public String getModelName()
-    {
-        return modelName;
-    }
-    public void setModelDesc(String modelDesc)
-    {
-        this.modelDesc = modelDesc;
-    }
-
-    public String getModelDesc()
-    {
-        return modelDesc;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("modelId", getModelId())
-            .append("modelName", getModelName())
-            .append("modelDesc", getModelDesc())
-            .append("orderNum", getOrderNum())
-            .append("parentId", getParentId())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
 }

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

@@ -1,21 +1,20 @@
 package com.jjt.biz.mapper;
 
-import java.util.List;
-import java.util.Map;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jjt.biz.domain.RipaMetrics;
+import com.jjt.biz.vo.ObjMetrics;
 import com.jjt.common.annotation.DataSource;
 import com.jjt.common.enums.DataSourceType;
 
+import java.util.List;
+
 /**
  * 模型指标配置Mapper接口
  *
  * @author jjt
  * @date 2025-10-22
  */
-public interface RipaMetricsMapper extends BaseMapper<RipaMetrics>
-{
+public interface RipaMetricsMapper extends BaseMapper<RipaMetrics> {
     /**
      * 查询模型指标配置
      *
@@ -63,11 +62,12 @@ public interface RipaMetricsMapper extends BaseMapper<RipaMetrics>
      * @return 结果
      */
     public int deleteRipaMetricsByAutoIds(Long[] autoIds);
+
     /**
      * 查询模型指标配置列表
-     *
+     * @param objMetrics 指标模型
      * @return 模型指标配置集合
      */
     @DataSource(value = DataSourceType.SLAVE)
-    List<Map<String, Object>> selectRiskMetricsList();
+    List<ObjMetrics> selectRiskMetricsList(ObjMetrics objMetrics);
 }

+ 27 - 10
jjt-biz/src/main/java/com/jjt/biz/mapper/RipaModelMapper.java

@@ -1,20 +1,21 @@
 package com.jjt.biz.mapper;
 
-import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jjt.biz.domain.RipaModel;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 分析模型Mapper接口
- * 
+ *
  * @author jjt
  * @date 2025-10-21
  */
-public interface RipaModelMapper extends BaseMapper<RipaModel>
-{
+public interface RipaModelMapper extends BaseMapper<RipaModel> {
     /**
      * 查询分析模型
-     * 
+     *
      * @param modelId 分析模型主键
      * @return 分析模型
      */
@@ -22,7 +23,7 @@ public interface RipaModelMapper extends BaseMapper<RipaModel>
 
     /**
      * 查询分析模型列表
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 分析模型集合
      */
@@ -30,7 +31,7 @@ public interface RipaModelMapper extends BaseMapper<RipaModel>
 
     /**
      * 新增分析模型
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 结果
      */
@@ -38,7 +39,7 @@ public interface RipaModelMapper extends BaseMapper<RipaModel>
 
     /**
      * 修改分析模型
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 结果
      */
@@ -46,7 +47,7 @@ public interface RipaModelMapper extends BaseMapper<RipaModel>
 
     /**
      * 删除分析模型
-     * 
+     *
      * @param modelId 分析模型主键
      * @return 结果
      */
@@ -54,9 +55,25 @@ public interface RipaModelMapper extends BaseMapper<RipaModel>
 
     /**
      * 批量删除分析模型
-     * 
+     *
      * @param modelIds 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteRipaModelByModelIds(Long[] modelIds);
+
+    /**
+     * 根据ID查询所有模型
+     *
+     * @param modelId 模型ID
+     * @return 模型列表
+     */
+    List<RipaModel> selectChildrenModelById(Long modelId);
+
+    /**
+     * 修改子元素关系
+     *
+     * @param models 子元素
+     * @return 结果
+     */
+    int updateModelChildren(@Param("models") List<RipaModel> models);
 }

+ 10 - 2
jjt-biz/src/main/java/com/jjt/biz/service/IRipaMetricsService.java

@@ -1,6 +1,7 @@
 package com.jjt.biz.service;
 
 import com.jjt.biz.domain.RipaMetrics;
+import com.jjt.biz.vo.ObjMetrics;
 
 import java.util.List;
 import java.util.Map;
@@ -62,8 +63,15 @@ public interface IRipaMetricsService {
 
     /**
      * 查询模型指标配置列表
-     *
+     *@param objMetrics 指标模型
      * @return 模型指标配置集合
      */
-    List<Map<String,Object>> selectRiskMetricsList();
+    List<ObjMetrics> selectRiskMetricsList(ObjMetrics objMetrics);
+
+    /**
+     * 批量插入
+     * @param metricsList 列表
+     * @return 结果
+     */
+    void insertRipaMetricsList(List<RipaMetrics> metricsList);
 }

+ 19 - 10
jjt-biz/src/main/java/com/jjt/biz/service/IRipaModelService.java

@@ -1,19 +1,21 @@
 package com.jjt.biz.service;
 
-import java.util.List;
+import com.jjt.biz.domain.ModelTreeSelect;
 import com.jjt.biz.domain.RipaModel;
+import com.jjt.common.core.domain.TreeSelect;
+
+import java.util.List;
 
 /**
  * 分析模型Service接口
- * 
+ *
  * @author jjt
  * @date 2025-10-21
  */
-public interface IRipaModelService 
-{
+public interface IRipaModelService {
     /**
      * 查询分析模型
-     * 
+     *
      * @param modelId 分析模型主键
      * @return 分析模型
      */
@@ -21,7 +23,7 @@ public interface IRipaModelService
 
     /**
      * 查询分析模型列表
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 分析模型集合
      */
@@ -29,7 +31,7 @@ public interface IRipaModelService
 
     /**
      * 新增分析模型
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 结果
      */
@@ -37,7 +39,7 @@ public interface IRipaModelService
 
     /**
      * 修改分析模型
-     * 
+     *
      * @param ripaModel 分析模型
      * @return 结果
      */
@@ -45,7 +47,7 @@ public interface IRipaModelService
 
     /**
      * 批量删除分析模型
-     * 
+     *
      * @param modelIds 需要删除的分析模型主键集合
      * @return 结果
      */
@@ -53,9 +55,16 @@ public interface IRipaModelService
 
     /**
      * 删除分析模型信息
-     * 
+     *
      * @param modelId 分析模型主键
      * @return 结果
      */
     public int deleteRipaModelByModelId(Long modelId);
+
+    /**
+     * 获取模型树
+     *
+     * @return 模型树
+     */
+    List<ModelTreeSelect> selectModelTreeList();
 }

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

@@ -3,7 +3,11 @@ package com.jjt.biz.service.impl;
 import java.util.List;
 import java.util.Map;
 
+import com.jjt.biz.vo.ObjMetrics;
 import com.jjt.common.utils.DateUtils;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.stereotype.Service;
 import com.jjt.biz.mapper.RipaMetricsMapper;
 import com.jjt.biz.domain.RipaMetrics;
@@ -20,6 +24,8 @@ import javax.annotation.Resource;
 public class RipaMetricsServiceImpl implements IRipaMetricsService {
     @Resource
     private RipaMetricsMapper ripaMetricsMapper;
+    @Resource
+    private SqlSessionFactory factory;
 
     /**
      * 查询模型指标配置
@@ -91,11 +97,28 @@ public class RipaMetricsServiceImpl implements IRipaMetricsService {
 
     /**
      * 查询模型指标配置列表
-     *
+     *@param objMetrics 指标模型
      * @return 模型指标配置集合
      */
     @Override
-    public List<Map<String, Object>> selectRiskMetricsList() {
-        return ripaMetricsMapper.selectRiskMetricsList();
+    public List<ObjMetrics> selectRiskMetricsList(ObjMetrics objMetrics) {
+        return ripaMetricsMapper.selectRiskMetricsList(objMetrics);
+    }
+
+    /**
+     * 批量插入
+     *
+     * @param metricsList 列表
+     * @return 结果
+     */
+    @Override
+    public void insertRipaMetricsList(List<RipaMetrics> metricsList) {
+        if (metricsList.size() > 0) {
+            try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+                RipaMetricsMapper mapper = sqlSession.getMapper(RipaMetricsMapper.class);
+                metricsList.forEach(mapper::insertRipaMetrics);
+                sqlSession.commit();
+            }
+        }
     }
 }

+ 122 - 8
jjt-biz/src/main/java/com/jjt/biz/service/impl/RipaModelServiceImpl.java

@@ -1,12 +1,18 @@
 package com.jjt.biz.service.impl;
 
-import java.util.List;
-        import com.jjt.common.utils.DateUtils;
-import org.springframework.stereotype.Service;
-import com.jjt.biz.mapper.RipaModelMapper;
+import com.jjt.biz.domain.ModelTreeSelect;
 import com.jjt.biz.domain.RipaModel;
+import com.jjt.biz.mapper.RipaModelMapper;
 import com.jjt.biz.service.IRipaModelService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.common.utils.StringUtils;
+import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 分析模型Service业务层处理
@@ -49,8 +55,14 @@ public class RipaModelServiceImpl implements IRipaModelService {
      */
     @Override
     public int insertRipaModel(RipaModel ripaModel) {
-                ripaModel.setCreateTime(DateUtils.getNowDate());
-            return ripaModelMapper.insertRipaModel(ripaModel);
+        String parent = "";
+        if (ripaModel.getParentId() != 0) {
+            RipaModel info = selectRipaModelByModelId(ripaModel.getParentId());
+            parent = info.getRemark() + ",";
+        }
+        ripaModel.setRemark(parent + ripaModel.getParentId());
+        ripaModel.setCreateTime(DateUtils.getNowDate());
+        return ripaModelMapper.insertRipaModel(ripaModel);
     }
 
     /**
@@ -61,9 +73,35 @@ public class RipaModelServiceImpl implements IRipaModelService {
      */
     @Override
     public int updateRipaModel(RipaModel ripaModel) {
-                ripaModel.setUpdateTime(DateUtils.getNowDate());
-        return ripaModelMapper.updateRipaModel(ripaModel);
+        RipaModel newParentDept = selectRipaModelByModelId(ripaModel.getParentId());
+        RipaModel oldDept = selectRipaModelByModelId(ripaModel.getModelId());
+        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
+            String newAncestors = newParentDept.getRemark() + "," + newParentDept.getModelId();
+            String oldAncestors = oldDept.getRemark();
+            ripaModel.setRemark(newAncestors);
+            updateModelChildren(ripaModel.getModelId(), newAncestors, oldAncestors);
+        }
+        ripaModel.setUpdateTime(DateUtils.getNowDate());
+        int result = ripaModelMapper.updateRipaModel(ripaModel);
+        return result;
     }
+    /**
+     * 修改子元素关系
+     *
+     * @param modelId       被修改的部门ID
+     * @param newAncestors 新的父ID集合
+     * @param oldAncestors 旧的父ID集合
+     */
+    private void updateModelChildren(Long modelId, String newAncestors, String oldAncestors) {
+        List<RipaModel> children = ripaModelMapper.selectChildrenModelById(modelId);
+        for (RipaModel child : children) {
+            child.setRemark(child.getRemark().replaceFirst(oldAncestors, newAncestors));
+        }
+        if (children.size() > 0) {
+            ripaModelMapper.updateModelChildren(children);
+        }
+    }
+
 
     /**
      * 批量删除分析模型
@@ -86,4 +124,80 @@ public class RipaModelServiceImpl implements IRipaModelService {
     public int deleteRipaModelByModelId(Long modelId) {
         return ripaModelMapper.deleteRipaModelByModelId(modelId);
     }
+
+    /**
+     * 获取模型树
+     *
+     * @return 模型树
+     */
+    @Override
+    public List<ModelTreeSelect> selectModelTreeList() {
+        List<RipaModel> models = selectRipaModelList(new RipaModel());
+        List<ModelTreeSelect> treeSelects = buildModelTreeSelect(models);
+        return treeSelects;
+    }
+
+    private List<ModelTreeSelect> buildModelTreeSelect(List<RipaModel> models) {
+        List<RipaModel> deptTrees = buildModelTree(models);
+        return deptTrees.stream().map(ModelTreeSelect::new).collect(Collectors.toList());
+    }
+
+    /**
+     * 构建前端所需要树结构
+     *
+     * @param models 模型列表
+     * @return 树结构列表
+     */
+    public List<RipaModel> buildModelTree(List<RipaModel> models) {
+        List<RipaModel> returnList = new ArrayList<>();
+        List<Long> tempList = models.stream().map(RipaModel::getModelId).collect(Collectors.toList());
+        for (RipaModel dept : models) {
+            // 如果是顶级节点, 遍历该父节点的所有子节点
+            if (!tempList.contains(dept.getParentId())) {
+                recursionFn(models, dept);
+                returnList.add(dept);
+            }
+        }
+        if (returnList.isEmpty()) {
+            returnList = models;
+        }
+        return returnList;
+    }
+
+    /**
+     * 递归列表
+     */
+    private void recursionFn(List<RipaModel> list, RipaModel t) {
+        // 得到子节点列表
+        List<RipaModel> childList = getChildList(list, t);
+        t.setChildren(childList);
+        for (RipaModel tChild : childList) {
+            if (hasChild(list, tChild)) {
+                recursionFn(list, tChild);
+            }
+        }
+    }
+
+    /**
+     * 得到子节点列表
+     */
+    private List<RipaModel> getChildList(List<RipaModel> list, RipaModel t) {
+        List<RipaModel> tlist = new ArrayList<RipaModel>();
+        Iterator<RipaModel> it = list.iterator();
+        while (it.hasNext()) {
+            RipaModel n = (RipaModel) it.next();
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getModelId().longValue()) {
+                tlist.add(n);
+            }
+        }
+        return tlist;
+    }
+
+    /**
+     * 判断是否有子节点
+     */
+    private boolean hasChild(List<RipaModel> list, RipaModel t) {
+        return getChildList(list, t).size() > 0;
+    }
+
 }

+ 17 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/ObjMetrics.java

@@ -0,0 +1,17 @@
+package com.jjt.biz.vo;
+
+import lombok.Data;
+
+/**
+ * ObjMetrics$
+ *
+ * @author wukai
+ * @date 2025/10/23 00:16
+ */
+@Data
+public class ObjMetrics {
+    private Long objMetricsId;
+    private String objType;
+    private String objName;
+    private String metricsName;
+}

+ 183 - 96
jjt-biz/src/main/resources/mapper/biz/RipaMetricsMapper.xml

@@ -5,136 +5,223 @@
 <mapper namespace="com.jjt.biz.mapper.RipaMetricsMapper">
 
     <resultMap type="RipaMetrics" id="RipaMetricsResult">
-            <result property="autoId" column="AUTO_ID"/>
-            <result property="modelId" column="MODEL_ID"/>
-            <result property="objMetricsId" column="OBJ_METRICS_ID"/>
-            <result property="metricsName" column="METRICS_NAME"/>
-            <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="autoId" column="AUTO_ID"/>
+        <result property="modelId" column="MODEL_ID"/>
+        <result property="modelName" column="MODEL_NAME"/>
+        <result property="objMetricsId" column="OBJ_METRICS_ID"/>
+        <result property="metricsName" column="METRICS_NAME"/>
+        <result property="objType" column="OBJ_TYPE"/>
+        <result property="objName" column="OBJ_NAME"/>
+        <result property="algoType" column="ALGO_TYPE"/>
+        <result property="ntr" column="NTR"/>
+        <result property="hov" column="HOV"/>
+        <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>
+
+    <resultMap type="com.jjt.biz.vo.ObjMetrics" id="ObjMetricsResult">
+        <result property="objType" column="OBJ_TYPE"/>
+        <result property="objName" column="OBJ_NAME"/>
+        <result property="metricsName" column="METRICS_NAME"/>
+        <result property="objMetricsId" column="OBJ_METRICS_ID"/>
     </resultMap>
 
     <sql id="selectRipaMetricsVo">
-        select AUTO_ID, MODEL_ID, OBJ_METRICS_ID, METRICS_NAME, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK
-        from ripa_metrics
+        select *
+        from (select a.AUTO_ID,
+                     a.MODEL_ID,
+                     b.MODEL_NAME,
+                     a.OBJ_METRICS_ID,
+                     a.METRICS_NAME,
+                     A.OBJ_TYPE,
+                     A.OBJ_NAME,
+                     A.ALGO_TYPE,
+                     A.NTR,
+                     A.HOV,
+                     a.CREATE_BY,
+                     a.CREATE_TIME,
+                     a.UPDATE_BY,
+                     a.UPDATE_TIME,
+                     a.REMARK
+              from ripa_metrics a,
+                   ripa_model b
+              where a.model_id = b.model_id) t
     </sql>
 
     <select id="selectRipaMetricsList" parameterType="RipaMetrics" resultMap="RipaMetricsResult">
         <include refid="selectRipaMetricsVo"/>
         <where>
-                        <if test="modelId != null ">
-                            and MODEL_ID = #{modelId}
-                        </if>
-                        <if test="objMetricsId != null ">
-                            and OBJ_METRICS_ID = #{objMetricsId}
-                        </if>
-                        <if test="metricsName != null  and metricsName != ''">
-                            and METRICS_NAME like concat('%', #{metricsName}, '%')
-                        </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="modelId != null ">
+                and (MODEL_ID=#{modelId} or MODEL_ID in(
+                select MODEL_ID from ripa_model where find_in_set(#{modelId}, remark)))
+            </if>
+            <if test="objMetricsId != null ">
+                and OBJ_METRICS_ID = #{objMetricsId}
+            </if>
+            <if test="metricsName != null  and metricsName != ''">
+                and METRICS_NAME like concat('%', #{metricsName}, '%')
+            </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="selectRipaMetricsByAutoId" parameterType="Long"
             resultMap="RipaMetricsResult">
-            <include refid="selectRipaMetricsVo"/>
-            where AUTO_ID = #{autoId}
+        <include refid="selectRipaMetricsVo"/>
+        where AUTO_ID = #{autoId}
     </select>
-    <select id="selectRiskMetricsList" resultType="java.util.Map">
-        SELECT a.obj_type,a.obj_name,b.obj_metrics_id,metrics_name FROM biz_obj a,biz_obj_metrics b WHERE a.OBJ_ID=b.OBJ_ID
+    <select id="selectRiskMetricsList" parameterType="com.jjt.biz.vo.ObjMetrics" resultMap="ObjMetricsResult">
+        SELECT a.OBJ_TYPE, a.OBJ_NAME, b.METRICS_NAME, b.OBJ_METRICS_ID
+        FROM (SELECT B.DICT_LABEL OBJ_TYPE, A.OBJ_ID, A.OBJ_NAME
+        FROM biz_obj a,
+        (SELECT dict_value, dict_label FROM sys_dict_data WHERE dict_type = 'biz_type') b
+        WHERE a.OBJ_TYPE = b.dict_value) a,
+        biz_obj_metrics b
+        <where>
+            a.OBJ_ID = b.OBJ_ID
+            <if test="objMetricsId != null ">
+                and OBJ_METRICS_ID = #{objMetricsId}
+            </if>
+            <if test="metricsName != null  and metricsName != ''">
+                and METRICS_NAME like concat('%', #{metricsName}, '%')
+            </if>
+            <if test="objName != null  and objName != ''">
+                and OBJ_NAME like concat('%', #{objName}, '%')
+            </if>
+            <if test="objType != null  and objType != ''">
+                and OBJ_TYPE like concat('%', #{objType}, '%')
+            </if>
+        </where>
     </select>
 
     <insert id="insertRipaMetrics" parameterType="RipaMetrics" useGeneratedKeys="true"
             keyProperty="autoId">
         insert into ripa_metrics
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="modelId != null">MODEL_ID,
-                    </if>
-                    <if test="objMetricsId != null">OBJ_METRICS_ID,
-                    </if>
-                    <if test="metricsName != null">METRICS_NAME,
-                    </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="modelId != null">MODEL_ID,
+            </if>
+            <if test="objMetricsId != null">OBJ_METRICS_ID,
+            </if>
+            <if test="metricsName != null">METRICS_NAME,
+            </if>
+            <if test="objType != null">OBJ_TYPE,
+            </if>
+            <if test="objName != null">OBJ_NAME,
+            </if>
+            <if test="algoType != null">ALGO_TYPE,
+            </if>
+            <if test="ntr != null">NTR,
+            </if>
+            <if test="hov != null">HOV,
+            </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="modelId != null">#{modelId},
-                    </if>
-                    <if test="objMetricsId != null">#{objMetricsId},
-                    </if>
-                    <if test="metricsName != null">#{metricsName},
-                    </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="modelId != null">#{modelId},
+            </if>
+            <if test="objMetricsId != null">#{objMetricsId},
+            </if>
+            <if test="metricsName != null">#{metricsName},
+            </if>
+            <if test="objType != null">#{objType},
+            </if>
+            <if test="objName != null">#{objName},
+            </if>
+            <if test="algoType != null">#{algoType},
+            </if>
+            <if test="ntr != null">#{ntr},
+            </if>
+            <if test="hov != null">#{hov},
+            </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="updateRipaMetrics" parameterType="RipaMetrics">
         update ripa_metrics
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="modelId != null">MODEL_ID =
-                        #{modelId},
-                    </if>
-                    <if test="objMetricsId != null">OBJ_METRICS_ID =
-                        #{objMetricsId},
-                    </if>
-                    <if test="metricsName != null">METRICS_NAME =
-                        #{metricsName},
-                    </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="modelId != null">MODEL_ID =
+                #{modelId},
+            </if>
+            <if test="objMetricsId != null">OBJ_METRICS_ID =
+                #{objMetricsId},
+            </if>
+            <if test="metricsName != null">METRICS_NAME =
+                #{metricsName},
+            </if>
+            <if test="objType != null">OBJ_TYPE =
+                #{objType},
+            </if>
+            <if test="objName != null">OBJ_NAME =
+                #{objName},
+            </if>
+            <if test="algoType != null">ALGO_TYPE =
+                #{algoType},
+            </if>
+            <if test="ntr != null">NTR =
+                #{ntr},
+            </if>
+            <if test="hov != null">HOV =
+                #{hov},
+            </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 AUTO_ID = #{autoId}
     </update>
 
     <delete id="deleteRipaMetricsByAutoId" parameterType="Long">
         delete
-        from ripa_metrics where AUTO_ID = #{autoId}
+        from ripa_metrics
+        where AUTO_ID = #{autoId}
     </delete>
 
     <delete id="deleteRipaMetricsByAutoIds" parameterType="String">

+ 119 - 89
jjt-biz/src/main/resources/mapper/biz/RipaModelMapper.xml

@@ -5,129 +5,159 @@
 <mapper namespace="com.jjt.biz.mapper.RipaModelMapper">
 
     <resultMap type="RipaModel" id="RipaModelResult">
-            <result property="modelId" column="MODEL_ID"/>
-            <result property="modelName" column="MODEL_NAME"/>
-            <result property="modelDesc" column="MODEL_DESC"/>
-            <result property="orderNum" column="ORDER_NUM"/>
-            <result property="parentId" column="PARENT_ID"/>
-            <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="modelId" column="MODEL_ID"/>
+        <result property="modelName" column="MODEL_NAME"/>
+        <result property="modelDesc" column="MODEL_DESC"/>
+        <result property="orderNum" column="ORDER_NUM"/>
+        <result property="parentId" column="PARENT_ID"/>
+        <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="selectRipaModelVo">
-        select MODEL_ID, MODEL_NAME, MODEL_DESC, ORDER_NUM, PARENT_ID, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK
+        select MODEL_ID,
+               MODEL_NAME,
+               MODEL_DESC,
+               ORDER_NUM,
+               PARENT_ID,
+               CREATE_BY,
+               CREATE_TIME,
+               UPDATE_BY,
+               UPDATE_TIME,
+               REMARK
         from ripa_model
     </sql>
 
     <select id="selectRipaModelList" parameterType="RipaModel" resultMap="RipaModelResult">
         <include refid="selectRipaModelVo"/>
         <where>
-                        <if test="modelName != null  and modelName != ''">
-                            and MODEL_NAME like concat('%', #{modelName}, '%')
-                        </if>
-                        <if test="modelDesc != null  and modelDesc != ''">
-                            and MODEL_DESC like concat('%', #{modelDesc}, '%')
-                        </if>
-                        <if test="orderNum != null ">
-                            and ORDER_NUM = #{orderNum}
-                        </if>
-                        <if test="parentId != null ">
-                            and PARENT_ID = #{parentId}
-                        </if>
+            <if test="modelName != null  and modelName != ''">
+                and MODEL_NAME like concat('%', #{modelName}, '%')
+            </if>
+            <if test="modelDesc != null  and modelDesc != ''">
+                and MODEL_DESC like concat('%', #{modelDesc}, '%')
+            </if>
+            <if test="orderNum != null ">
+                and ORDER_NUM = #{orderNum}
+            </if>
+            <if test="parentId != null ">
+                and PARENT_ID = #{parentId}
+            </if>
         </where>
+        order by order_num,model_name
     </select>
+    <select id="selectChildrenModelById" parameterType="Long" resultMap="RipaModelResult">
+        select *
+        from ripa_model
+        where find_in_set(#{modelId}, remark)
+        order by order_num,model_name
+    </select>
+
+    <update id="updateModelChildren" parameterType="java.util.List">
+        update ripa_model set remark =
+        <foreach collection="models" item="item" index="index"
+                 separator=" " open="case model_id" close="end">
+            when #{item.modelId} then #{item.remark}
+        </foreach>
+        where model_id in
+        <foreach collection="models" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item.modelId}
+        </foreach>
+    </update>
 
     <select id="selectRipaModelByModelId" parameterType="Long"
             resultMap="RipaModelResult">
-            <include refid="selectRipaModelVo"/>
-            where MODEL_ID = #{modelId}
+        <include refid="selectRipaModelVo"/>
+        where MODEL_ID = #{modelId}
     </select>
 
     <insert id="insertRipaModel" parameterType="RipaModel" useGeneratedKeys="true"
             keyProperty="modelId">
         insert into ripa_model
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="modelName != null and modelName != ''">MODEL_NAME,
-                    </if>
-                    <if test="modelDesc != null">MODEL_DESC,
-                    </if>
-                    <if test="orderNum != null">ORDER_NUM,
-                    </if>
-                    <if test="parentId != null">PARENT_ID,
-                    </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="modelName != null and modelName != ''">MODEL_NAME,
+            </if>
+            <if test="modelDesc != null">MODEL_DESC,
+            </if>
+            <if test="orderNum != null">ORDER_NUM,
+            </if>
+            <if test="parentId != null">PARENT_ID,
+            </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="modelName != null and modelName != ''">#{modelName},
-                    </if>
-                    <if test="modelDesc != null">#{modelDesc},
-                    </if>
-                    <if test="orderNum != null">#{orderNum},
-                    </if>
-                    <if test="parentId != null">#{parentId},
-                    </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="modelName != null and modelName != ''">#{modelName},
+            </if>
+            <if test="modelDesc != null">#{modelDesc},
+            </if>
+            <if test="orderNum != null">#{orderNum},
+            </if>
+            <if test="parentId != null">#{parentId},
+            </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="updateRipaModel" parameterType="RipaModel">
         update ripa_model
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="modelName != null and modelName != ''">MODEL_NAME =
-                        #{modelName},
-                    </if>
-                    <if test="modelDesc != null">MODEL_DESC =
-                        #{modelDesc},
-                    </if>
-                    <if test="orderNum != null">ORDER_NUM =
-                        #{orderNum},
-                    </if>
-                    <if test="parentId != null">PARENT_ID =
-                        #{parentId},
-                    </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="modelName != null and modelName != ''">MODEL_NAME =
+                #{modelName},
+            </if>
+            <if test="modelDesc != null">MODEL_DESC =
+                #{modelDesc},
+            </if>
+            <if test="orderNum != null">ORDER_NUM =
+                #{orderNum},
+            </if>
+            <if test="parentId != null">PARENT_ID =
+                #{parentId},
+            </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 MODEL_ID = #{modelId}
     </update>
 
     <delete id="deleteRipaModelByModelId" parameterType="Long">
         delete
-        from ripa_model where MODEL_ID = #{modelId}
+        from ripa_model
+        where MODEL_ID = #{modelId}
     </delete>
 
     <delete id="deleteRipaModelByModelIds" parameterType="String">