diff --git a/sql/20241213.sql b/sql/20241213.sql new file mode 100644 index 0000000..f62b740 --- /dev/null +++ b/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; \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/constants/enums/ModelTypeEnum.java b/src/main/java/com/biutag/supervision/constants/enums/ModelTypeEnum.java new file mode 100644 index 0000000..cae189a --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelClueRecordController.java b/src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelClueRecordController.java index 9f3f761..34381ec 100644 --- a/src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelClueRecordController.java +++ b/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.extension.plugins.pagination.Page; +import com.biutag.supervision.constants.enums.ModelTypeEnum; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.entity.Model; import com.biutag.supervision.pojo.entity.ModelClueRecord; @@ -36,7 +37,7 @@ public class ModelClueRecordController { public Result list(@PathVariable Integer modelId) { Model model = modelService.getById(modelId); // 个人极端暴力风险 6 - if ("6".equals(model.getClassId())) { + if (ModelTypeEnum.GRJD.getValue().equals(model.getModelType())) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(RiskTask::getModelId, modelId) .orderByDesc(RiskTask::getStartTime); diff --git a/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java b/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java index da790e8..dfa1779 100644 --- a/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java +++ b/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java @@ -1,19 +1,21 @@ package com.biutag.supervision.controller.sensitivePerception; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; 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.biutag.supervision.pojo.Result; +import com.biutag.supervision.pojo.dto.RiskClueDto; import com.biutag.supervision.pojo.entity.Model; import com.biutag.supervision.pojo.entity.RiskModelTaskClue; import com.biutag.supervision.pojo.param.RiskModelTaskClueQueryParam; import com.biutag.supervision.service.ModelService; import com.biutag.supervision.service.RiskModelTaskClueService; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -32,6 +34,7 @@ public class RiskClueController { private final ModelService modelService; + @GetMapping public Result> page(RiskModelTaskClueQueryParam param) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -52,4 +55,20 @@ public class RiskClueController { return Result.success(riskModelTaskClueService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper)); } + @PostMapping + + public Result save(@RequestBody RiskClueDto clue) { + List models = modelService.list(new LambdaUpdateWrapper().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(); + } + } diff --git a/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java b/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java index 67addd1..c4e1b63 100644 --- a/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java +++ b/src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java @@ -1,6 +1,9 @@ package com.biutag.supervision.controller.sensitivePerception; 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.QueryWrapper; 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.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -49,9 +53,15 @@ public class RiskPersonalController { private final RiskPersonInfoService riskPersonInfoService; + private final RiskTagMapService riskTagMapService; + @GetMapping public Result> list(RiskPersonalQueryParam param) { + if (CollectionUtil.isNotEmpty(param.getSmallTags())) { + List list = riskTagMapService.list(new LambdaQueryWrapper().in(RiskTagMap::getRiskTag, param.getSmallTags())); + param.setSmallTags(list.stream().map(RiskTagMap::getSmallTag).toList()); + } Page page = riskPersonalMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), param); List records = page.getRecords(); if (records.isEmpty()) { @@ -65,6 +75,13 @@ public class RiskPersonalController { return Result.success(page); } + @GetMapping("query") + public Result> query(String queryString) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(RiskPersonal::getName, queryString); + return Result.success(riskPersonalService.list(queryWrapper)); + } + /** * 风险人员查看详情 * @param id @@ -82,6 +99,7 @@ public class RiskPersonalController { if (info != null) { vo.setAvatar(info.getImageBase64()); } + List list = rules1.stream().map(rule -> { RiskPersonalDetail.RiskRule riskRule = new RiskPersonalDetail.RiskRule(); riskRule.setRiskName(rule.getRiskName()); @@ -90,20 +108,30 @@ public class RiskPersonalController { if (rules2.isEmpty()) { return riskRule; } - List models = modelService.list(new LambdaQueryWrapper().in(Model::getRiskScoreRuleId, rules2.stream().map(RiskScoreRule::getId).toList())); - QueryWrapper queryWrapper = new QueryWrapper() - .eq("mc.id_code", riskPersonal.getIdCode()) - .in("mc.model_id", models.stream().map(Model::getId).toList()) - .eq("mc.del", AppConstants.UN_DEL) - .orderByAsc("r.sort_id") - .orderByDesc("mc.score_result"); - List records = models.isEmpty() ? new ArrayList<>() : riskModelTaskClueMapper.queryPage(Page.of(1, 100), queryWrapper).getRecords(); - riskRule.setClues(records); + List 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 models = modelService.list(new LambdaQueryWrapper().in(Model::getRiskScoreRuleId, rules2.stream().filter(item -> index.equals(item.getRiskIndex())) + .map(RiskScoreRule::getId).toList())); + QueryWrapper queryWrapper = new QueryWrapper() + .eq("mc.id_code", riskPersonal.getIdCode()) + .in("mc.model_id", models.stream().map(Model::getId).toList()) + .eq("mc.del", AppConstants.UN_DEL) + .orderByAsc("r.sort_id") + .orderByDesc("mc.score_result"); + List clues = models.isEmpty() ? new ArrayList<>() : riskModelTaskClueMapper.queryPage(Page.of(1, 100), queryWrapper).getRecords(); + 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; }).toList(); RiskPersonalDetail riskPersonalDetail = new RiskPersonalDetail(); riskPersonalDetail.setRiskPersonal(vo); - riskPersonalDetail.setRiskClueList(list); + riskPersonalDetail.setRiskClues(list); return Result.success(riskPersonalDetail); } diff --git a/src/main/java/com/biutag/supervision/mapper/RiskTagMapMapper.java b/src/main/java/com/biutag/supervision/mapper/RiskTagMapMapper.java new file mode 100644 index 0000000..a49d9a2 --- /dev/null +++ b/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 { + +} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java b/src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java index 68702ef..4cf4f27 100644 --- a/src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java +++ b/src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java @@ -1,7 +1,5 @@ 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.RiskPersonalVo; import lombok.Getter; @@ -20,14 +18,24 @@ public class RiskPersonalDetail { private RiskPersonalVo riskPersonal; - private List riskClueList = new ArrayList<>(); + private List riskClues = new ArrayList<>(); + @Setter @Getter public static class RiskRule { private String riskName; - private Double score; + private Double score = 0.0; + private List riskIndexs = new ArrayList<>(); + } + + @Setter + @Getter + public static class RiskIndex { + private String riskIndex; + private Double score = 0.0; private List clues = new ArrayList<>(); } + } diff --git a/src/main/java/com/biutag/supervision/pojo/dto/RiskClueDto.java b/src/main/java/com/biutag/supervision/pojo/dto/RiskClueDto.java new file mode 100644 index 0000000..6f9d479 --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/biutag/supervision/pojo/entity/Model.java b/src/main/java/com/biutag/supervision/pojo/entity/Model.java index ac75e73..0f1415b 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/Model.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/Model.java @@ -90,8 +90,6 @@ public class Model { // 模型数据类型 private String modelDataType; - @TableField("model_sql") - private String modelSql; private Integer riskScoreRuleId; diff --git a/src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java b/src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java index cf09e2c..f9b49cb 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java @@ -67,10 +67,14 @@ public class RiskModelTaskClue { @TableField("score") private Double score; + // 计算好的分数 + private Double scoreCalc; + + // 最终分 private Double scoreResult; // 发生时间 - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") @TableField("event_time") private LocalDateTime eventTime; diff --git a/src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java b/src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java index 09acc99..30246b7 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java @@ -65,7 +65,6 @@ public class RiskPersonal { private String errorMsg; // 逻辑删除键0-未删1已删 - @TableField("del") private Boolean del; } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java b/src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java index 338b4b8..21b7915 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java @@ -55,4 +55,6 @@ public class RiskScoreRule { private Integer level; + // 一级值班 + private String riskIndex; } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/RiskTagMap.java b/src/main/java/com/biutag/supervision/pojo/entity/RiskTagMap.java new file mode 100644 index 0000000..e236d13 --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java b/src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java index 38f2177..1602897 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java @@ -43,5 +43,11 @@ public class RiskScoreRuleTree { private Integer level; + private String riskLevel; + + + // 一级值班 + private String riskIndex; + private List children = new ArrayList<>(); } diff --git a/src/main/java/com/biutag/supervision/service/ModelClueService.java b/src/main/java/com/biutag/supervision/service/ModelClueService.java index 16e4c04..c775a2d 100644 --- a/src/main/java/com/biutag/supervision/service/ModelClueService.java +++ b/src/main/java/com/biutag/supervision/service/ModelClueService.java @@ -224,9 +224,9 @@ public class ModelClueService extends ServiceImpl { } Model model = modelMapper.selectById(modelId); List modelClues = new ArrayList<>(); - if (!Objects.isNull(model) && model.getModelSql() != null) { - modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId)); - } +// if (!Objects.isNull(model) && model.getModelSql() != null) { +// modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId)); +// } System.out.println("模型结果1:" + JSON.toJSONString(modelClues)); if (!modelClues.isEmpty()) { List result = new ArrayList<>(); diff --git a/src/main/java/com/biutag/supervision/service/RiskTagMapService.java b/src/main/java/com/biutag/supervision/service/RiskTagMapService.java new file mode 100644 index 0000000..59dac7d --- /dev/null +++ b/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 { + +} diff --git a/src/main/resources/mapper/RiskPersonalMapper.xml b/src/main/resources/mapper/RiskPersonalMapper.xml index e973d0d..11be50f 100644 --- a/src/main/resources/mapper/RiskPersonalMapper.xml +++ b/src/main/resources/mapper/RiskPersonalMapper.xml @@ -7,6 +7,7 @@ distinct p.id, p.NAME, + p.age, p.gender, p.id_code, p.mobile_number, @@ -30,7 +31,7 @@ small_tag = #{tag} - small_tag like concat('%', #{tag}, '%') + small_tag = #{tag} ) t WHERE p.id_code = t.id_code @@ -49,6 +50,12 @@ AND p.id_code like concat('%', #{param.idCode}, '%') + + AND p.tags in + + #{tag} + + order by p.risk_score desc diff --git a/src/test/java/com/biutag/supervision/tools/GenCodeTests.java b/src/test/java/com/biutag/supervision/tools/GenCodeTests.java index a6b4972..a366897 100644 --- a/src/test/java/com/biutag/supervision/tools/GenCodeTests.java +++ b/src/test/java/com/biutag/supervision/tools/GenCodeTests.java @@ -25,7 +25,7 @@ public class GenCodeTests { @Test public void genEntity() throws TemplateException, IOException { - String tableName = "risk_person_info"; + String tableName = "risk_tag_map"; String tableSchema = "negative"; boolean genMapper = true; boolean genService = true;