|
|
|
|
@ -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<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); |
|
|
|
|
List<RiskPersonalVo> records = page.getRecords(); |
|
|
|
|
if (records.isEmpty()) { |
|
|
|
|
@ -65,6 +75,13 @@ public class RiskPersonalController {
|
|
|
|
|
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 |
|
|
|
|
@ -82,6 +99,7 @@ public class RiskPersonalController {
|
|
|
|
|
if (info != null) { |
|
|
|
|
vo.setAvatar(info.getImageBase64()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<RiskPersonalDetail.RiskRule> 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<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getRiskScoreRuleId, rules2.stream().map(RiskScoreRule::getId).toList())); |
|
|
|
|
QueryWrapper<RiskModelTaskClue> queryWrapper = new QueryWrapper<RiskModelTaskClue>() |
|
|
|
|
.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<RiskModelTaskClueVo> records = models.isEmpty() ? new ArrayList<>() : riskModelTaskClueMapper.queryPage(Page.of(1, 100), queryWrapper).getRecords(); |
|
|
|
|
riskRule.setClues(records); |
|
|
|
|
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>() |
|
|
|
|
.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<RiskModelTaskClueVo> 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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|