Browse Source

修改灵敏感知-问题线索,将个人风险移到风险问题中

main
sjh 1 year ago
parent
commit
cd21f655d7
  1. 2
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java
  2. 8
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskScoreRuleController.java
  3. 10
      src/main/java/com/biutag/supervision/mapper/RiskScoreRuleMapper.java
  4. 25
      src/main/java/com/biutag/supervision/pojo/entity/RiskClass.java
  5. 24
      src/main/java/com/biutag/supervision/pojo/model/RiskClassModel.java
  6. 36
      src/main/java/com/biutag/supervision/pojo/vo/RiskTree.java
  7. 54
      src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java
  8. BIN
      src/main/resources/static/templates/长沙公安数字督察灵敏感知体系问题赋分及风险预警机制.pdf

2
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java

@ -36,7 +36,7 @@ public class RiskClueController {
public Result<Page<RiskModelTaskClue>> page(RiskModelTaskClueQueryParam param) {
LambdaQueryWrapper<RiskModelTaskClue> queryWrapper = new LambdaQueryWrapper<>();
if (Objects.nonNull(param.getRiskScoreRuleId()) && !param.getRiskScoreRuleId().isEmpty()) {
List<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getRiskScoreRuleId, param.getRiskScoreRuleId()));
List<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getId, param.getRiskScoreRuleId()));
if (models.isEmpty()) {
return Result.success(new Page<RiskModelTaskClue>().setRecords(new ArrayList<>()).setTotal(0));
}

8
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskScoreRuleController.java

@ -3,6 +3,7 @@ package com.biutag.supervision.controller.sensitivePerception;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
import com.biutag.supervision.pojo.vo.RiskScoreRuleTree;
import com.biutag.supervision.pojo.vo.RiskTree;
import com.biutag.supervision.service.RiskScoreRuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -22,10 +23,15 @@ public class RiskScoreRuleController {
private final RiskScoreRuleService riskScoreRuleService;
@GetMapping("tree")
public Result<List<RiskScoreRuleTree>> list() {
public Result<List<RiskTree>> list() {
return Result.success(riskScoreRuleService.buildTree());
}
@GetMapping("oldTree")
public Result<List<RiskScoreRuleTree>> oldList() {
return Result.success(riskScoreRuleService.oldBuildTree());
}
@PostMapping
public Result<Boolean> add(@RequestBody RiskScoreRule scoreRule) {
scoreRule.setCreateTime(LocalDateTime.now());

10
src/main/java/com/biutag/supervision/mapper/RiskScoreRuleMapper.java

@ -2,7 +2,17 @@ package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
import com.biutag.supervision.pojo.model.RiskClassModel;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface RiskScoreRuleMapper extends BaseMapper<RiskScoreRule> {
@Select("select mc.id, mc.pid, mc.risk_name NAME, mc.sort_id, count(mc2.id) size from risk_score_rule mc left join model m on mc.id = m.risk_score_rule_id LEFT JOIN risk_score_rule mc2 on mc.id = mc2.pid where mc.pid = 0 GROUP BY mc.id, mc.risk_name, mc.sort_id order by sort_id")
List<RiskClassModel> selectListRoot();
@Select("select mc.id, mc.pid, mc.risk_name NAME, mc.sort_id, count(m.risk_score_rule_id) size from risk_score_rule mc left join model m on mc.id = m.risk_score_rule_id GROUP BY mc.id, mc.risk_name, mc.sort_id order by sort_id")
List<RiskClassModel> selectListAll();
}

25
src/main/java/com/biutag/supervision/pojo/entity/RiskClass.java

@ -0,0 +1,25 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class RiskClass {
//
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
//
@TableField("name")
private String name;
//
@TableField("sort")
private Integer sort;
}

24
src/main/java/com/biutag/supervision/pojo/model/RiskClassModel.java

@ -0,0 +1,24 @@
package com.biutag.supervision.pojo.model;
import lombok.Getter;
import lombok.Setter;
/**
* @author wxc
* @date 2024/11/13
*/
@Setter
@Getter
public class RiskClassModel {
private Integer id;
private Integer pid;
private String name;
private Integer sort;
private Integer size;
}

36
src/main/java/com/biutag/supervision/pojo/vo/RiskTree.java

@ -0,0 +1,36 @@
package com.biutag.supervision.pojo.vo;
import com.biutag.supervision.pojo.entity.Model;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* @author wxc
* @date 2024/10/15
*/
@Setter
@Getter
public class RiskTree {
private Integer id;
private String riskName;
private String type;
private Integer size;
private List<RiskTree> children = new ArrayList<>();
public static RiskTree of(Model model) {
RiskTree child = new RiskTree();
child.setId(model.getId());
child.setRiskName(model.getModelName());
child.setType("model");
return child;
}
}

54
src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java

@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.constants.AppConstants;
import com.biutag.supervision.mapper.RiskScoreRuleMapper;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
import com.biutag.supervision.pojo.model.RiskClassModel;
import com.biutag.supervision.pojo.vo.RiskScoreRuleTree;
import com.biutag.supervision.pojo.vo.RiskTree;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -14,10 +18,58 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
@Service
public class RiskScoreRuleService extends ServiceImpl<RiskScoreRuleMapper, RiskScoreRule> {
public List<RiskScoreRuleTree> buildTree() {
private final RiskScoreRuleMapper riskScoreRuleMapper;
private final ModelService modelService;
public List<RiskTree> buildTree() {
List<RiskClassModel> rootsList = riskScoreRuleMapper.selectListRoot();
List<RiskClassModel> riskClasses = riskScoreRuleMapper.selectListAll();
List<RiskClassModel> treeList = riskClasses.stream().filter(item -> item.getPid() != 0).toList();
List<Model> models = modelService.list();
List<RiskTree> list = new ArrayList<>();
list.addAll(rootsList.stream().map(item -> {
RiskTree node = new RiskTree();
node.setId(item.getId());
node.setRiskName(item.getName());
node.setSize(item.getSize());
node.setType("modelClass");
List<RiskTree> children = models.stream().filter(
model -> {
for (RiskClassModel riskClassModel : treeList) {
return item.getId().equals(riskClassModel.getPid()) && riskClassModel.getId().equals(model.getRiskScoreRuleId());
}
return false;
}
).map(RiskTree::of).toList();
node.setChildren(children);
return node;
}).toList());
return list;
// List<RiskScoreRule> scoreRules = list(new LambdaQueryWrapper<RiskScoreRule>().orderByAsc(RiskScoreRule::getSortId));
// Map<Integer, List<RiskScoreRuleTree>> childMap = new HashMap<>();
// List<RiskScoreRuleTree> tree = new ArrayList<>();
// for (RiskScoreRule rule: scoreRules) {
// RiskScoreRuleTree node = new RiskScoreRuleTree();
// BeanUtils.copyProperties(rule, node);
// List<RiskScoreRuleTree> children = childMap.computeIfAbsent(node.getPid(), k -> new ArrayList<>());
// children.add(node);
// Integer pid = node.getPid();
// if (AppConstants.TREE_ROOT_ID.equals(pid)) {
// tree.add(node);
// }
// }
// for (RiskScoreRuleTree node : tree) {
// buildTreeRecursive(node, childMap);
// }
// return tree;
}
public List<RiskScoreRuleTree> oldBuildTree() {
List<RiskScoreRule> scoreRules = list(new LambdaQueryWrapper<RiskScoreRule>().orderByAsc(RiskScoreRule::getSortId));
Map<Integer, List<RiskScoreRuleTree>> childMap = new HashMap<>();
List<RiskScoreRuleTree> tree = new ArrayList<>();

BIN
src/main/resources/static/templates/长沙公安数字督察灵敏感知体系问题赋分及风险预警机制.pdf

Binary file not shown.
Loading…
Cancel
Save