|
|
|
|
@ -1,13 +1,17 @@
|
|
|
|
|
package com.biutag.supervisiondata.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.biutag.supervisiondata.common.exception.BusinessException; |
|
|
|
|
import com.biutag.supervisiondata.common.response.StatusCode; |
|
|
|
|
import com.biutag.supervisiondata.mapper.mine.RiskModelTaskClueMapper; |
|
|
|
|
import com.biutag.supervisiondata.pojo.constants.Default; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.mine.RiskModelTaskClue; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.mine.RiskPersonalControlRecord; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.mine.RiskPersonalTag; |
|
|
|
|
import com.biutag.supervisiondata.repository.RiskPersonalTagRepository; |
|
|
|
|
import com.biutag.supervisiondata.service.RiskModelTaskClueService; |
|
|
|
|
import com.biutag.supervisiondata.service.RiskPersonalTagService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
|
@ -17,9 +21,9 @@ import javax.sql.DataSource;
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.PreparedStatement; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
@ -36,13 +40,15 @@ public class RiskModelTaskClueServiceImpl implements RiskModelTaskClueService {
|
|
|
|
|
@Qualifier("chaosBean") |
|
|
|
|
private final DataSource dataSource; |
|
|
|
|
|
|
|
|
|
public Connection getConnection() throws SQLException { |
|
|
|
|
private final RiskPersonalTagRepository tagRepository; |
|
|
|
|
|
|
|
|
|
Connection getConnection() throws SQLException { |
|
|
|
|
return dataSource.getConnection(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void saveClues(List<RiskModelTaskClue> list) { |
|
|
|
|
public void saveClues(List<RiskModelTaskClue> list, String bigTag) { |
|
|
|
|
List<List<RiskModelTaskClue>> control = IntStream.range(0, (list.size() + 9999) / 10000) |
|
|
|
|
.mapToObj(i -> list.subList(i * 10000, Math.min((i + 1) * 10000, list.size()))) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
@ -53,6 +59,46 @@ public class RiskModelTaskClueServiceImpl implements RiskModelTaskClueService {
|
|
|
|
|
log.error("", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, List<RiskModelTaskClue>> map = list.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode)); |
|
|
|
|
// 标签要插入的人员
|
|
|
|
|
List<String> idCodes = new ArrayList<>(); |
|
|
|
|
for (Map.Entry<String, List<RiskModelTaskClue>> entry : map.entrySet()) { |
|
|
|
|
idCodes.add(entry.getKey()); |
|
|
|
|
} |
|
|
|
|
List<RiskPersonalTag> oldTags = tagRepository.list(new LambdaQueryWrapper<RiskPersonalTag>().eq(RiskPersonalTag::getBigTag, bigTag) |
|
|
|
|
.in(RiskPersonalTag::getIdCode, idCodes)); |
|
|
|
|
Map<String, List<RiskPersonalTag>> oldTagMap = oldTags.stream().collect(Collectors.groupingBy(RiskPersonalTag::getIdCode)); |
|
|
|
|
Map<String, Byte[]> oldMap; |
|
|
|
|
|
|
|
|
|
List<RiskPersonalTag> tags = new ArrayList<>(); |
|
|
|
|
for (Map.Entry<String, List<RiskModelTaskClue>> entry : map.entrySet()) { |
|
|
|
|
List<RiskPersonalTag> oldTagList = Optional.ofNullable(oldTagMap.get(entry.getKey())).orElse(new ArrayList<>()); |
|
|
|
|
// 旧的tag
|
|
|
|
|
oldMap = new WeakHashMap<>(); |
|
|
|
|
for (RiskPersonalTag tag : oldTagList) { |
|
|
|
|
oldMap.put(tag.getSmallTag(), new Byte[0]); |
|
|
|
|
} |
|
|
|
|
for (RiskModelTaskClue clue : entry.getValue()) { |
|
|
|
|
if(bigTag.equals(Default.BIG_TAG_SHWFR)) { |
|
|
|
|
String [] strs = clue.getRiskReason().split(","); |
|
|
|
|
for (int i =0,len = strs.length; i < len; i++) { |
|
|
|
|
if(oldMap.get(strs[i]) == null) { |
|
|
|
|
tags.add(creatTag(bigTag, strs[i], clue)); |
|
|
|
|
oldMap.put(strs[i], new Byte[0]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if(oldMap.get(clue.getRiskReason()) == null) { |
|
|
|
|
tags.add(creatTag(bigTag, clue.getRiskReason(), clue)); |
|
|
|
|
oldMap.put(clue.getRiskReason(), new Byte[0]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!tags.isEmpty()) { |
|
|
|
|
tagRepository.saveBatch(tags, 10000); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final String sql = "INSERT INTO risk_model_task_clue(model_id, name, id_code, task_id, source_id, risk_reason, data, score, event_time, create_time, update_time, case_ids) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"; |
|
|
|
|
@ -87,4 +133,15 @@ public class RiskModelTaskClueServiceImpl implements RiskModelTaskClueService {
|
|
|
|
|
throw new BusinessException(StatusCode.BUSINESS, "数据保存失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RiskPersonalTag creatTag(String bigTag, String tag, RiskModelTaskClue clue) { |
|
|
|
|
RiskPersonalTag riskTag = new RiskPersonalTag(); |
|
|
|
|
riskTag.setBigTag(bigTag); |
|
|
|
|
riskTag.setTagTime(LocalDateTime.now()); |
|
|
|
|
riskTag.setName(clue.getName()); |
|
|
|
|
riskTag.setIdCode(clue.getIdCode()); |
|
|
|
|
riskTag.setSmallTag(tag); |
|
|
|
|
riskTag.setCreateTime(LocalDateTime.now()); |
|
|
|
|
return riskTag; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|