Browse Source

fit: 新增风险问题库-新增问题功能

fix: 优化风险人员库详情界面
main
wxc 12 months ago
parent
commit
003885dd96
  1. 5
      sql/20241213.sql
  2. 19
      src/main/java/com/biutag/supervision/constants/enums/ModelTypeEnum.java
  3. 3
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelClueRecordController.java
  4. 25
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java
  5. 36
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java
  6. 8
      src/main/java/com/biutag/supervision/mapper/RiskTagMapMapper.java
  7. 16
      src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java
  8. 32
      src/main/java/com/biutag/supervision/pojo/dto/RiskClueDto.java
  9. 2
      src/main/java/com/biutag/supervision/pojo/entity/Model.java
  10. 6
      src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java
  11. 1
      src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java
  12. 2
      src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java
  13. 14
      src/main/java/com/biutag/supervision/pojo/entity/RiskTagMap.java
  14. 6
      src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java
  15. 6
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  16. 11
      src/main/java/com/biutag/supervision/service/RiskTagMapService.java
  17. 9
      src/main/resources/mapper/RiskPersonalMapper.xml
  18. 2
      src/test/java/com/biutag/supervision/tools/GenCodeTests.java

5
sql/20241213.sql

@ -0,0 +1,5 @@
CREATE TABLE `risk_tag_map` (
`risk_tag` varchar(255) NOT NULL,
`small_tag` varchar(255) NOT NULL,
PRIMARY KEY (`risk_tag`,`small_tag`)
) ENGINE=InnoDB;

19
src/main/java/com/biutag/supervision/constants/enums/ModelTypeEnum.java

@ -0,0 +1,19 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wxc
* @date 2024/12/12
*/
@AllArgsConstructor
public enum ModelTypeEnum {
NBJD("1"),
GRJD("2");
@Getter
private String value;
}

3
src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelClueRecordController.java

@ -2,6 +2,7 @@ package com.biutag.supervision.controller.sensitivePerception;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.constants.enums.ModelTypeEnum;
import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.Model; import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.ModelClueRecord; import com.biutag.supervision.pojo.entity.ModelClueRecord;
@ -36,7 +37,7 @@ public class ModelClueRecordController {
public Result list(@PathVariable Integer modelId) { public Result list(@PathVariable Integer modelId) {
Model model = modelService.getById(modelId); Model model = modelService.getById(modelId);
// 个人极端暴力风险 6 // 个人极端暴力风险 6
if ("6".equals(model.getClassId())) { if (ModelTypeEnum.GRJD.getValue().equals(model.getModelType())) {
LambdaQueryWrapper<RiskTask> queryWrapper = new LambdaQueryWrapper<RiskTask>() LambdaQueryWrapper<RiskTask> queryWrapper = new LambdaQueryWrapper<RiskTask>()
.eq(RiskTask::getModelId, modelId) .eq(RiskTask::getModelId, modelId)
.orderByDesc(RiskTask::getStartTime); .orderByDesc(RiskTask::getStartTime);

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

@ -1,19 +1,21 @@
package com.biutag.supervision.controller.sensitivePerception; package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.dto.RiskClueDto;
import com.biutag.supervision.pojo.entity.Model; import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.RiskModelTaskClue; import com.biutag.supervision.pojo.entity.RiskModelTaskClue;
import com.biutag.supervision.pojo.param.RiskModelTaskClueQueryParam; import com.biutag.supervision.pojo.param.RiskModelTaskClueQueryParam;
import com.biutag.supervision.service.ModelService; import com.biutag.supervision.service.ModelService;
import com.biutag.supervision.service.RiskModelTaskClueService; import com.biutag.supervision.service.RiskModelTaskClueService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -32,6 +34,7 @@ public class RiskClueController {
private final ModelService modelService; private final ModelService modelService;
@GetMapping @GetMapping
public Result<Page<RiskModelTaskClue>> page(RiskModelTaskClueQueryParam param) { public Result<Page<RiskModelTaskClue>> page(RiskModelTaskClueQueryParam param) {
LambdaQueryWrapper<RiskModelTaskClue> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RiskModelTaskClue> queryWrapper = new LambdaQueryWrapper<>();
@ -52,4 +55,20 @@ public class RiskClueController {
return Result.success(riskModelTaskClueService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper)); return Result.success(riskModelTaskClueService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper));
} }
@PostMapping
public Result<Void> save(@RequestBody RiskClueDto clue) {
List<Model> models = modelService.list(new LambdaUpdateWrapper<Model>().eq(Model::getRiskScoreRuleId, clue.getRiskScoreRuleId()));
if (models.isEmpty()) {
throw new RuntimeException("该风险因素位配置模型");
}
RiskModelTaskClue riskModelTaskClue = new RiskModelTaskClue();
BeanUtil.copyProperties(clue, riskModelTaskClue);
riskModelTaskClue.setModelId(models.get(0).getId());
riskModelTaskClue.setCreateTime(LocalDateTime.now());
riskModelTaskClue.setTaskId(-1);
riskModelTaskClueService.save(riskModelTaskClue);
return Result.success();
}
} }

36
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java

@ -1,6 +1,9 @@
package com.biutag.supervision.controller.sensitivePerception; package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -49,9 +53,15 @@ public class RiskPersonalController {
private final RiskPersonInfoService riskPersonInfoService; private final RiskPersonInfoService riskPersonInfoService;
private final RiskTagMapService riskTagMapService;
@GetMapping @GetMapping
public Result<Page<RiskPersonalVo>> list(RiskPersonalQueryParam param) { public Result<Page<RiskPersonalVo>> list(RiskPersonalQueryParam param) {
if (CollectionUtil.isNotEmpty(param.getSmallTags())) {
List<RiskTagMap> list = riskTagMapService.list(new LambdaQueryWrapper<RiskTagMap>().in(RiskTagMap::getRiskTag, param.getSmallTags()));
param.setSmallTags(list.stream().map(RiskTagMap::getSmallTag).toList());
}
Page<RiskPersonalVo> page = riskPersonalMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), param); Page<RiskPersonalVo> page = riskPersonalMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), param);
List<RiskPersonalVo> records = page.getRecords(); List<RiskPersonalVo> records = page.getRecords();
if (records.isEmpty()) { if (records.isEmpty()) {
@ -65,6 +75,13 @@ public class RiskPersonalController {
return Result.success(page); return Result.success(page);
} }
@GetMapping("query")
public Result<List<RiskPersonal>> query(String queryString) {
LambdaQueryWrapper<RiskPersonal> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(RiskPersonal::getName, queryString);
return Result.success(riskPersonalService.list(queryWrapper));
}
/** /**
* 风险人员查看详情 * 风险人员查看详情
* @param id * @param id
@ -82,6 +99,7 @@ public class RiskPersonalController {
if (info != null) { if (info != null) {
vo.setAvatar(info.getImageBase64()); vo.setAvatar(info.getImageBase64());
} }
List<RiskPersonalDetail.RiskRule> list = rules1.stream().map(rule -> { List<RiskPersonalDetail.RiskRule> list = rules1.stream().map(rule -> {
RiskPersonalDetail.RiskRule riskRule = new RiskPersonalDetail.RiskRule(); RiskPersonalDetail.RiskRule riskRule = new RiskPersonalDetail.RiskRule();
riskRule.setRiskName(rule.getRiskName()); riskRule.setRiskName(rule.getRiskName());
@ -90,20 +108,30 @@ public class RiskPersonalController {
if (rules2.isEmpty()) { if (rules2.isEmpty()) {
return riskRule; return riskRule;
} }
List<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getRiskScoreRuleId, rules2.stream().map(RiskScoreRule::getId).toList())); List<RiskPersonalDetail.RiskIndex> riskIndexs = rules2.stream().filter(obj -> StrUtil.isNotBlank(obj.getRiskIndex()))
.map(RiskScoreRule::getRiskIndex).distinct().map(index -> {
RiskPersonalDetail.RiskIndex riskIndex = new RiskPersonalDetail.RiskIndex();
riskIndex.setRiskIndex(index);
List<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getRiskScoreRuleId, rules2.stream().filter(item -> index.equals(item.getRiskIndex()))
.map(RiskScoreRule::getId).toList()));
QueryWrapper<RiskModelTaskClue> queryWrapper = new QueryWrapper<RiskModelTaskClue>() QueryWrapper<RiskModelTaskClue> queryWrapper = new QueryWrapper<RiskModelTaskClue>()
.eq("mc.id_code", riskPersonal.getIdCode()) .eq("mc.id_code", riskPersonal.getIdCode())
.in("mc.model_id", models.stream().map(Model::getId).toList()) .in("mc.model_id", models.stream().map(Model::getId).toList())
.eq("mc.del", AppConstants.UN_DEL) .eq("mc.del", AppConstants.UN_DEL)
.orderByAsc("r.sort_id") .orderByAsc("r.sort_id")
.orderByDesc("mc.score_result"); .orderByDesc("mc.score_result");
List<RiskModelTaskClueVo> records = models.isEmpty() ? new ArrayList<>() : riskModelTaskClueMapper.queryPage(Page.of(1, 100), queryWrapper).getRecords(); List<RiskModelTaskClueVo> clues = models.isEmpty() ? new ArrayList<>() : riskModelTaskClueMapper.queryPage(Page.of(1, 100), queryWrapper).getRecords();
riskRule.setClues(records); riskIndex.setScore(NumberUtil.round(clues.stream().filter(item -> Objects.nonNull(item.getScoreResult())).mapToDouble(RiskModelTaskClueVo::getScoreResult).sum(), 2).doubleValue());
riskIndex.setClues(clues);
return riskIndex;
}).toList();
riskRule.setRiskIndexs(riskIndexs);
riskRule.setScore(NumberUtil.round(riskIndexs.stream().mapToDouble(RiskPersonalDetail.RiskIndex::getScore).sum(), 2).doubleValue());
return riskRule; return riskRule;
}).toList(); }).toList();
RiskPersonalDetail riskPersonalDetail = new RiskPersonalDetail(); RiskPersonalDetail riskPersonalDetail = new RiskPersonalDetail();
riskPersonalDetail.setRiskPersonal(vo); riskPersonalDetail.setRiskPersonal(vo);
riskPersonalDetail.setRiskClueList(list); riskPersonalDetail.setRiskClues(list);
return Result.success(riskPersonalDetail); return Result.success(riskPersonalDetail);
} }

8
src/main/java/com/biutag/supervision/mapper/RiskTagMapMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.RiskTagMap;
public interface RiskTagMapMapper extends BaseMapper<RiskTagMap> {
}

16
src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java

@ -1,7 +1,5 @@
package com.biutag.supervision.pojo.domain; package com.biutag.supervision.pojo.domain;
import com.biutag.supervision.pojo.entity.RiskModelTaskClue;
import com.biutag.supervision.pojo.entity.RiskPersonal;
import com.biutag.supervision.pojo.vo.RiskModelTaskClueVo; import com.biutag.supervision.pojo.vo.RiskModelTaskClueVo;
import com.biutag.supervision.pojo.vo.RiskPersonalVo; import com.biutag.supervision.pojo.vo.RiskPersonalVo;
import lombok.Getter; import lombok.Getter;
@ -20,14 +18,24 @@ public class RiskPersonalDetail {
private RiskPersonalVo riskPersonal; private RiskPersonalVo riskPersonal;
private List<RiskRule> riskClueList = new ArrayList<>(); private List<RiskRule> riskClues = new ArrayList<>();
@Setter @Setter
@Getter @Getter
public static class RiskRule { public static class RiskRule {
private String riskName; private String riskName;
private Double score; private Double score = 0.0;
private List<RiskIndex> riskIndexs = new ArrayList<>();
}
@Setter
@Getter
public static class RiskIndex {
private String riskIndex;
private Double score = 0.0;
private List<RiskModelTaskClueVo> clues = new ArrayList<>(); private List<RiskModelTaskClueVo> clues = new ArrayList<>();
} }
} }

32
src/main/java/com/biutag/supervision/pojo/dto/RiskClueDto.java

@ -0,0 +1,32 @@
package com.biutag.supervision.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* @author wxc
* @date 2024/12/13
*/
@Setter
@Getter
public class RiskClueDto {
private String name;
// 证件号码
private String idCode;
private Integer riskScoreRuleId;
private Double score;
private Double scoreCalc;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm")
private LocalDateTime eventTime;
private String data;
}

2
src/main/java/com/biutag/supervision/pojo/entity/Model.java

@ -90,8 +90,6 @@ public class Model {
// 模型数据类型 // 模型数据类型
private String modelDataType; private String modelDataType;
@TableField("model_sql")
private String modelSql;
private Integer riskScoreRuleId; private Integer riskScoreRuleId;

6
src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java

@ -67,10 +67,14 @@ public class RiskModelTaskClue {
@TableField("score") @TableField("score")
private Double score; private Double score;
// 计算好的分数
private Double scoreCalc;
// 最终分
private Double scoreResult; private Double scoreResult;
// 发生时间 // 发生时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@TableField("event_time") @TableField("event_time")
private LocalDateTime eventTime; private LocalDateTime eventTime;

1
src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java

@ -65,7 +65,6 @@ public class RiskPersonal {
private String errorMsg; private String errorMsg;
// 逻辑删除键0-未删1已删 // 逻辑删除键0-未删1已删
@TableField("del")
private Boolean del; private Boolean del;
} }

2
src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java

@ -55,4 +55,6 @@ public class RiskScoreRule {
private Integer level; private Integer level;
// 一级值班
private String riskIndex;
} }

14
src/main/java/com/biutag/supervision/pojo/entity/RiskTagMap.java

@ -0,0 +1,14 @@
package com.biutag.supervision.pojo.entity;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class RiskTagMap {
private String riskTag;
private String smallTag;
}

6
src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java

@ -43,5 +43,11 @@ public class RiskScoreRuleTree {
private Integer level; private Integer level;
private String riskLevel;
// 一级值班
private String riskIndex;
private List<RiskScoreRuleTree> children = new ArrayList<>(); private List<RiskScoreRuleTree> children = new ArrayList<>();
} }

6
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -224,9 +224,9 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
} }
Model model = modelMapper.selectById(modelId); Model model = modelMapper.selectById(modelId);
List<ModelClue> modelClues = new ArrayList<>(); List<ModelClue> modelClues = new ArrayList<>();
if (!Objects.isNull(model) && model.getModelSql() != null) { // if (!Objects.isNull(model) && model.getModelSql() != null) {
modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId)); // modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId));
} // }
System.out.println("模型结果1:" + JSON.toJSONString(modelClues)); System.out.println("模型结果1:" + JSON.toJSONString(modelClues));
if (!modelClues.isEmpty()) { if (!modelClues.isEmpty()) {
List<ModelClue> result = new ArrayList<>(); List<ModelClue> result = new ArrayList<>();

11
src/main/java/com/biutag/supervision/service/RiskTagMapService.java

@ -0,0 +1,11 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.RiskTagMap;
import com.biutag.supervision.mapper.RiskTagMapMapper;
import org.springframework.stereotype.Service;
@Service
public class RiskTagMapService extends ServiceImpl<RiskTagMapMapper, RiskTagMap> {
}

9
src/main/resources/mapper/RiskPersonalMapper.xml

@ -7,6 +7,7 @@
distinct distinct
p.id, p.id,
p.NAME, p.NAME,
p.age,
p.gender, p.gender,
p.id_code, p.id_code,
p.mobile_number, p.mobile_number,
@ -30,7 +31,7 @@
small_tag = #{tag} small_tag = #{tag}
</foreach> </foreach>
<foreach collection="param.ageTags" item="tag" open="AND (" separator=" or " close=")"> <foreach collection="param.ageTags" item="tag" open="AND (" separator=" or " close=")">
small_tag like concat('%', #{tag}, '%') small_tag = #{tag}
</foreach> </foreach>
) t ) t
WHERE p.id_code = t.id_code WHERE p.id_code = t.id_code
@ -49,6 +50,12 @@
<if test="param.idCode != null and param.idCode != ''"> <if test="param.idCode != null and param.idCode != ''">
AND p.id_code like concat('%', #{param.idCode}, '%') AND p.id_code like concat('%', #{param.idCode}, '%')
</if> </if>
<if test="param.tags != null and param.tags.size() > 0">
AND p.tags in
<foreach collection="param.tags" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
</if>
order by p.risk_score desc order by p.risk_score desc
</select> </select>

2
src/test/java/com/biutag/supervision/tools/GenCodeTests.java

@ -25,7 +25,7 @@ public class GenCodeTests {
@Test @Test
public void genEntity() throws TemplateException, IOException { public void genEntity() throws TemplateException, IOException {
String tableName = "risk_person_info"; String tableName = "risk_tag_map";
String tableSchema = "negative"; String tableSchema = "negative";
boolean genMapper = true; boolean genMapper = true;
boolean genService = true; boolean genService = true;

Loading…
Cancel
Save