10 changed files with 303 additions and 1 deletions
@ -0,0 +1,55 @@ |
|||||||
|
package com.biutag.supervision.controller.sensitivePerception; |
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
|
import com.biutag.supervision.pojo.Result; |
||||||
|
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 java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Objects; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author wxc |
||||||
|
* @date 2024/11/14 |
||||||
|
*/ |
||||||
|
@RequiredArgsConstructor |
||||||
|
@RequestMapping("risk/clues") |
||||||
|
@RestController |
||||||
|
public class RiskClueController { |
||||||
|
|
||||||
|
private final RiskModelTaskClueService riskModelTaskClueService; |
||||||
|
|
||||||
|
private final ModelService modelService; |
||||||
|
|
||||||
|
@GetMapping |
||||||
|
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())); |
||||||
|
if (models.isEmpty()) { |
||||||
|
return Result.success(new Page<RiskModelTaskClue>().setRecords(new ArrayList<>()).setTotal(0)); |
||||||
|
} |
||||||
|
queryWrapper.in(RiskModelTaskClue::getModelId, models.stream().map(Model::getId).collect(Collectors.toSet())); |
||||||
|
} |
||||||
|
if (Objects.nonNull(param.getEventTime()) && param.getEventTime().size() == 2) { |
||||||
|
queryWrapper.between(RiskModelTaskClue::getEventTime, param.getEventTime().get(0), param.getEventTime().get(1)); |
||||||
|
} |
||||||
|
queryWrapper.like(StrUtil.isNotBlank(param.getName()), RiskModelTaskClue::getName, param.getName()) |
||||||
|
.like(StrUtil.isNotBlank(param.getIdCode()), RiskModelTaskClue::getIdCode, param.getIdCode()) |
||||||
|
.like(StrUtil.isNotBlank(param.getThingDesc()), RiskModelTaskClue::getThingDesc, param.getThingDesc()); |
||||||
|
queryWrapper.orderByDesc(RiskModelTaskClue::getCreateTime); |
||||||
|
return Result.success(riskModelTaskClueService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
package com.biutag.supervision.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.biutag.supervision.pojo.entity.RiskModelTaskClue; |
||||||
|
|
||||||
|
public interface RiskModelTaskClueMapper extends BaseMapper<RiskModelTaskClue> { |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
package com.biutag.supervision.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.biutag.supervision.pojo.entity.RiskScoreRule; |
||||||
|
|
||||||
|
public interface RiskScoreRuleMapper extends BaseMapper<RiskScoreRule> { |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,85 @@ |
|||||||
|
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 com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class RiskModelTaskClue { |
||||||
|
|
||||||
|
// 主键
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
// 模型id
|
||||||
|
@TableField("model_id") |
||||||
|
private Integer modelId; |
||||||
|
|
||||||
|
// 姓名
|
||||||
|
@TableField("name") |
||||||
|
private String name; |
||||||
|
|
||||||
|
// 证件号码
|
||||||
|
@TableField("id_code") |
||||||
|
private String idCode; |
||||||
|
|
||||||
|
// 预警内容
|
||||||
|
@TableField("thing_desc") |
||||||
|
private String thingDesc; |
||||||
|
|
||||||
|
// 状态 默认 0-未分发 1-已分发 2-已处理
|
||||||
|
@TableField("distribution_state") |
||||||
|
private Boolean distributionState; |
||||||
|
|
||||||
|
// 任务ID
|
||||||
|
@TableField("task_id") |
||||||
|
private Integer taskId; |
||||||
|
|
||||||
|
// 问题id
|
||||||
|
@TableField("negative_id") |
||||||
|
private String negativeId; |
||||||
|
|
||||||
|
// 原始id
|
||||||
|
@TableField("source_id") |
||||||
|
private String sourceId; |
||||||
|
|
||||||
|
// 案件id,“,”分割
|
||||||
|
@TableField("case_ids") |
||||||
|
private String caseIds; |
||||||
|
|
||||||
|
// 风险原因
|
||||||
|
@TableField("risk_reason") |
||||||
|
private String riskReason; |
||||||
|
|
||||||
|
// 数据详情 JSON
|
||||||
|
@TableField("data") |
||||||
|
private String data; |
||||||
|
|
||||||
|
// 分数
|
||||||
|
@TableField("score") |
||||||
|
private Integer score; |
||||||
|
|
||||||
|
// 发生时间
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
@TableField("event_time") |
||||||
|
private LocalDateTime eventTime; |
||||||
|
|
||||||
|
// 创建时间
|
||||||
|
@TableField("create_time") |
||||||
|
private LocalDateTime createTime; |
||||||
|
|
||||||
|
// 修改时间
|
||||||
|
@TableField("update_time") |
||||||
|
private LocalDateTime updateTime; |
||||||
|
|
||||||
|
// 逻辑删除键0-未删1已删
|
||||||
|
@TableField("del") |
||||||
|
private Boolean del; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,56 @@ |
|||||||
|
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 com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class RiskScoreRule { |
||||||
|
|
||||||
|
//
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
//
|
||||||
|
@TableField("pid") |
||||||
|
private Integer pid; |
||||||
|
|
||||||
|
// 风险因素
|
||||||
|
@TableField("risk_name") |
||||||
|
private String riskName; |
||||||
|
|
||||||
|
// 分值
|
||||||
|
@TableField("score") |
||||||
|
private String score; |
||||||
|
|
||||||
|
// 规则描述
|
||||||
|
@TableField("rule_desc") |
||||||
|
private String ruleDesc; |
||||||
|
|
||||||
|
// 权重
|
||||||
|
@TableField("weight") |
||||||
|
private Integer weight; |
||||||
|
|
||||||
|
// 状态
|
||||||
|
@TableField("status") |
||||||
|
private Boolean status; |
||||||
|
|
||||||
|
// 更新时间
|
||||||
|
@TableField("update_time") |
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm") |
||||||
|
private LocalDateTime updateTime; |
||||||
|
|
||||||
|
// 创建时间
|
||||||
|
@TableField("create_time") |
||||||
|
private LocalDateTime createTime; |
||||||
|
|
||||||
|
private Integer sortId; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
package com.biutag.supervision.pojo.param; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author wxc |
||||||
|
* @date 2024/11/14 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class RiskModelTaskClueQueryParam extends BasePage { |
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private List<Date> eventTime = new ArrayList<>(); |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
private String idCode; |
||||||
|
|
||||||
|
private String thingDesc; |
||||||
|
|
||||||
|
private List<Integer> riskScoreRuleId = new ArrayList<>(); |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
package com.biutag.supervision.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.biutag.supervision.pojo.entity.RiskModelTaskClue; |
||||||
|
import com.biutag.supervision.mapper.RiskModelTaskClueMapper; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class RiskModelTaskClueService extends ServiceImpl<RiskModelTaskClueMapper, RiskModelTaskClue> { |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
package com.biutag.supervision.service; |
||||||
|
|
||||||
|
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.RiskScoreRule; |
||||||
|
import com.biutag.supervision.pojo.vo.RiskScoreRuleTree; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class RiskScoreRuleService extends ServiceImpl<RiskScoreRuleMapper, RiskScoreRule> { |
||||||
|
|
||||||
|
public List<RiskScoreRuleTree> buildTree() { |
||||||
|
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; |
||||||
|
} |
||||||
|
|
||||||
|
private static RiskScoreRuleTree buildTreeRecursive(RiskScoreRuleTree node, Map<Integer, List<RiskScoreRuleTree>> childMap) { |
||||||
|
List<RiskScoreRuleTree> children = childMap.get(node.getId()); |
||||||
|
if (children != null) { |
||||||
|
node.getChildren().addAll(children.stream() |
||||||
|
.map(childNode -> buildTreeRecursive(childNode, childMap)) |
||||||
|
.toList()); |
||||||
|
} |
||||||
|
return node; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Binary file not shown.
Loading…
Reference in new issue