Commit 0ee46ee5 authored by wujipeng's avatar wujipeng
Browse files

Merge remote-tracking branch 'origin/dev' into dev

parents ed242cb5 e06648bb
package com.platform.controller; package com.platform.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.platform.model.entity.PublicAccountEntity; import com.platform.model.entity.PublicAccountEntity;
import com.platform.model.resp.Result; import com.platform.model.resp.Result;
import com.platform.service.PublicAccountService; import com.platform.service.PublicAccountService;
...@@ -24,7 +25,9 @@ public class PublicAccountController extends BaseController { ...@@ -24,7 +25,9 @@ public class PublicAccountController extends BaseController {
try { try {
return toAjax(publicAccountService.save(publicAccountEntity)); return toAjax(publicAccountService.save(publicAccountEntity));
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
return Result.fail("该账户已是公共账户"); return toAjax(publicAccountService.remove(new LambdaQueryWrapper<PublicAccountEntity>()
.eq(PublicAccountEntity::getCaseId, publicAccountEntity.getCaseId())
.eq(PublicAccountEntity::getAccountName, publicAccountEntity.getAccountName())));
} }
} }
} }
package com.platform.mapper; package com.platform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.entity.UserEntity; import com.platform.model.entity.UserEntity;
import com.platform.model.vo.ExcelDataVO; import com.platform.model.vo.ExcelDataVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -14,4 +15,6 @@ public interface UserMapper extends BaseMapper<UserEntity> { ...@@ -14,4 +15,6 @@ public interface UserMapper extends BaseMapper<UserEntity> {
@Param("caseId") Integer id); @Param("caseId") Integer id);
void saveUserBatch(@Param("userList") List<UserEntity> userList); void saveUserBatch(@Param("userList") List<UserEntity> userList);
List<ExcelDataVO> queryList(CaseDTO caseDTO);
} }
...@@ -17,11 +17,14 @@ public class NodeVO { ...@@ -17,11 +17,14 @@ public class NodeVO {
private Integer whiteId; private Integer whiteId;
private Boolean publicAccountFlag;
private int degree; private int degree;
public NodeVO(String node, String label) { public NodeVO(String node, String label, boolean publicAccountFlag) {
this.node = node; this.node = node;
this.label = label; this.label = label;
this.publicAccountFlag = publicAccountFlag;
if (node.contains("公司")) { if (node.contains("公司")) {
this.nodeType = "对公"; this.nodeType = "对公";
} else { } else {
......
package com.platform.service; package com.platform.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.UserDTO; import com.platform.model.dto.UserDTO;
import com.platform.model.entity.ExcelDataEntity; import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.entity.UserEntity; import com.platform.model.entity.UserEntity;
...@@ -42,4 +43,6 @@ public interface UserService extends IService<UserEntity> { ...@@ -42,4 +43,6 @@ public interface UserService extends IService<UserEntity> {
List<ExcelDataVO> queryUserLabel(List<String> userNameList, Integer id); List<ExcelDataVO> queryUserLabel(List<String> userNameList, Integer id);
void saveUserBatch(List<UserEntity> userList); void saveUserBatch(List<UserEntity> userList);
List<ExcelDataVO> queryList(CaseDTO caseDTO);
} }
...@@ -54,12 +54,11 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -54,12 +54,11 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
for (ExcelDataVO excelDataVO : excelDataEntityList) { for (ExcelDataVO excelDataVO : excelDataEntityList) {
if (StringUtils.isNotEmpty(excelDataVO.getPayUserName()) if (StringUtils.isNotEmpty(excelDataVO.getPayUserName())
&& StringUtils.isNotEmpty(excelDataVO.getPayeeName()) && StringUtils.isNotEmpty(excelDataVO.getPayeeName())
&& excelDataVO.getPayUserName().equals(excelDataVO.getPayeeName())) { && !excelDataVO.getPayUserName().equals(excelDataVO.getPayeeName())
}else { && StringUtils.isNotEmpty(excelDataVO.getFileId())) {
excelDataEntityList1.add(excelDataVO); excelDataEntityList1.add(excelDataVO);
} }
} }
excelDataEntityList1.forEach(excelDataEntity -> { excelDataEntityList1.forEach(excelDataEntity -> {
if (StringUtils.isNull(excelDataEntity.getPayUserName())) { if (StringUtils.isNull(excelDataEntity.getPayUserName())) {
excelDataEntity.setPayUserName("无对应人员的数据"); excelDataEntity.setPayUserName("无对应人员的数据");
...@@ -158,6 +157,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -158,6 +157,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
UnionFindVO uf = new UnionFindVO(); UnionFindVO uf = new UnionFindVO();
Set<String> uniqueUserName = new HashSet<>(); Set<String> uniqueUserName = new HashSet<>();
Map<String, EdgeVO> edgeMap = new HashMap<>(); Map<String, EdgeVO> edgeMap = new HashMap<>();
Map<String, Boolean> publicAccountMap = new HashMap<>();
// 配置规则 // 配置规则
applyCaseRules(caseDTO); applyCaseRules(caseDTO);
...@@ -169,13 +169,13 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -169,13 +169,13 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
} }
// 处理原始数据 // 处理原始数据
processRawData(excelDataEntityList, uf, uniqueUserName, edgeMap, caseDTO.getId()); processRawData(excelDataEntityList, uf, uniqueUserName, edgeMap, publicAccountMap, caseDTO.getId());
// 获取用户标签 // 获取用户标签
Map<String, String> userAndLabel = getUserLabels(uniqueUserName, caseDTO.getId()); Map<String, String> userAndLabel = getUserLabels(uniqueUserName, caseDTO.getId());
// 添加节点 // 添加节点
addNodesToGraph(graph, uniqueUserName, userAndLabel); addNodesToGraph(graph, uniqueUserName, userAndLabel, publicAccountMap);
// 过滤有效边 // 过滤有效边
List<EdgeVO> validEdges = filterValidEdges(edgeMap, uf); List<EdgeVO> validEdges = filterValidEdges(edgeMap, uf);
...@@ -268,6 +268,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -268,6 +268,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
UnionFindVO uf, UnionFindVO uf,
Set<String> uniqueUserName, Set<String> uniqueUserName,
Map<String, EdgeVO> edgeMap, Map<String, EdgeVO> edgeMap,
Map<String, Boolean> publicAccountMap,
int caseId) { int caseId) {
//查看公共账号的数据 //查看公共账号的数据
...@@ -281,15 +282,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -281,15 +282,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
String payer = excelDataEntity.getPayUserName(); String payer = excelDataEntity.getPayUserName();
String payee = excelDataEntity.getPayeeName(); String payee = excelDataEntity.getPayeeName();
// 跳过公共账户中的中号
if (isPublicAccount(payer, publicAccountEntityList) || isPublicAccount(payee, publicAccountEntityList)) {
continue;
}
double amount = formatAmount(excelDataEntity.getAmount()); double amount = formatAmount(excelDataEntity.getAmount());
uniqueUserName.add(payer); uniqueUserName.add(payer);
uniqueUserName.add(payee); uniqueUserName.add(payee);
// 跳过公共账户中的中号
if (isPublicAccount(payer, publicAccountEntityList, publicAccountMap) || isPublicAccount(payee, publicAccountEntityList, publicAccountMap)) {
continue;
}
// 使用UnionFindVO的接口正确添加节点 // 使用UnionFindVO的接口正确添加节点
if (!uf.getParent().containsKey(payer)) { if (!uf.getParent().containsKey(payer)) {
uf.makeSet(payer); uf.makeSet(payer);
...@@ -306,12 +306,16 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -306,12 +306,16 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
} }
} }
private boolean isPublicAccount(String accountName, List<PublicAccountEntity> publicAccountEntityList) { private boolean isPublicAccount(String accountName,
List<PublicAccountEntity> publicAccountEntityList,
Map<String, Boolean> publicAccountMap) {
boolean result = false; boolean result = false;
publicAccountMap.put(accountName, result);
// 实现您的公共账户识别逻辑 // 实现您的公共账户识别逻辑
for (PublicAccountEntity publicAccountEntity : publicAccountEntityList) { for (PublicAccountEntity publicAccountEntity : publicAccountEntityList) {
if (publicAccountEntity.getAccountName().equals(accountName)) { if (publicAccountEntity.getAccountName().equals(accountName)) {
result = true; result = true;
publicAccountMap.put(accountName, result);
} }
} }
return result; return result;
...@@ -354,10 +358,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -354,10 +358,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
return userAndLabel; return userAndLabel;
} }
private void addNodesToGraph(GraphVO graph, Set<String> uniqueUserName, Map<String, String> userAndLabel) { private void addNodesToGraph(GraphVO graph,
Set<String> uniqueUserName,
Map<String, String> userAndLabel,
Map<String, Boolean> publicAccountMap) {
for (String userName : uniqueUserName) { for (String userName : uniqueUserName) {
String label = userAndLabel.getOrDefault(userName, ""); String label = userAndLabel.getOrDefault(userName, "");
graph.addNode(new NodeVO(userName, label)); boolean publicAccount = publicAccountMap.getOrDefault(userName, false);
graph.addNode(new NodeVO(userName, label, publicAccount));
} }
} }
...@@ -558,13 +566,15 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -558,13 +566,15 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
@Override @Override
public List<NodeVO> info(CaseDTO caseDTO) { public List<NodeVO> info(CaseDTO caseDTO) {
// 使用Set去重
Set<String> uniqueNodes = new HashSet<>();
// 使用Map来统计每个人关联的节点数量 // 使用Map来统计每个人关联的节点数量
Map<String, Integer> nodeDegreeMap = new HashMap<>(); Map<String, Integer> nodeDegreeMap = new HashMap<>();
Map<String, String> nodeAndUser = new HashMap<>(); Map<String, String> nodeAndUser = new HashMap<>();
List<ExcelDataEntity> excelDataEntityList = excelDataService.queryInfoList(caseDTO); List<ExcelDataVO> excelDataVOList = userService.queryList(caseDTO);
List<String> userNameList = new ArrayList<>();
excelDataVOList.forEach(excelDataVO -> userNameList.add(excelDataVO.getPayUserName()));
List<ExcelDataEntity> excelDataEntityList = filterInfoExcelData(caseDTO);
// 遍历结果集 // 遍历结果集
for (ExcelDataEntity excelDataEntity : excelDataEntityList) { for (ExcelDataEntity excelDataEntity : excelDataEntityList) {
...@@ -573,9 +583,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -573,9 +583,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
if (StringUtils.isEmpty(payee) || StringUtils.isEmpty(payer)) { if (StringUtils.isEmpty(payee) || StringUtils.isEmpty(payer)) {
continue; continue;
} }
// 添加节点
uniqueNodes.add(payer);
uniqueNodes.add(payee);
// 更新每个人关联的节点数量 // 更新每个人关联的节点数量
String key = payer + payee; String key = payer + payee;
if (nodeAndUser.get(key) == null) { if (nodeAndUser.get(key) == null) {
...@@ -584,10 +591,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -584,10 +591,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
nodeAndUser.put(key, key); nodeAndUser.put(key, key);
} }
} }
//查看每个人的账号类型
List<String> userNameList = new ArrayList<>(uniqueNodes);
//查看每个人的账号标签
List<ExcelDataVO> excelDataEntityListNew = userService.queryUserLabel(userNameList, caseDTO.getId());
//查看是否存在白名单 //查看是否存在白名单
List<WhiteEntity> whiteEntityList = whiteService.queryByNameList(userNameList); List<WhiteEntity> whiteEntityList = whiteService.queryByNameList(userNameList);
...@@ -595,7 +598,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -595,7 +598,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
Map<String, Integer> whiteMap = new HashMap<>(); Map<String, Integer> whiteMap = new HashMap<>();
whiteEntityList.forEach(whiteEntity -> whiteMap.put(whiteEntity.getName(), whiteEntity.getId())); whiteEntityList.forEach(whiteEntity -> whiteMap.put(whiteEntity.getName(), whiteEntity.getId()));
for (ExcelDataVO dataVO : excelDataEntityListNew) { for (ExcelDataVO dataVO : excelDataVOList) {
for (Map.Entry<String, Integer> entry : nodeDegreeMap.entrySet()) { for (Map.Entry<String, Integer> entry : nodeDegreeMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
Integer value = entry.getValue(); Integer value = entry.getValue();
...@@ -612,7 +615,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -612,7 +615,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
dataVO.setWhiteId(whiteId); dataVO.setWhiteId(whiteId);
} }
Iterator<ExcelDataVO> iterator = excelDataEntityListNew.iterator(); Iterator<ExcelDataVO> iterator = excelDataVOList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
ExcelDataVO excelDataVO = iterator.next(); ExcelDataVO excelDataVO = iterator.next();
if (caseDTO.getMinTransaction() != null && caseDTO.getMaxTransaction() != null) { if (caseDTO.getMinTransaction() != null && caseDTO.getMaxTransaction() != null) {
...@@ -628,7 +631,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -628,7 +631,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
} }
List<NodeVO> result = Lists.newArrayList(); List<NodeVO> result = Lists.newArrayList();
excelDataEntityListNew.forEach(excelDataVO -> { excelDataVOList.forEach(excelDataVO -> {
NodeVO org = new NodeVO(); NodeVO org = new NodeVO();
if (excelDataVO.getAccountType().equals("银联")) { if (excelDataVO.getAccountType().equals("银联")) {
...@@ -651,6 +654,50 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -651,6 +654,50 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
return result; return result;
} }
private List<ExcelDataEntity> filterInfoExcelData(CaseDTO caseDTO) {
List<ExcelDataEntity> excelDataEntityList = excelDataService.queryList(caseDTO);
if (CollUtil.isEmpty(excelDataEntityList)) {
return excelDataEntityList;
}
// 使用迭代器安全删除
Iterator<ExcelDataEntity> iterator = excelDataEntityList.iterator();
while (iterator.hasNext()) {
ExcelDataEntity excelDataEntity = iterator.next();
// 过滤付款人类型
if (caseDTO.getNodeType() != null) {
if (caseDTO.getNodeType().equals("银联") && excelDataEntity.getPayeeName().contains("公司")) {
iterator.remove();
continue;
}
if (caseDTO.getNodeType().equals("个人") && !excelDataEntity.getPayeeName().contains("公司")) {
iterator.remove();
continue;
}
}
// 过滤金额范围
if (!isWithinAmountRange(excelDataEntity, caseDTO.getMinAmount(), caseDTO.getMaxAmount())) {
iterator.remove();
continue;
}
// 过滤交易次数
if (!isWithinTransactionRange(excelDataEntity, caseDTO.getMinTransaction(), caseDTO.getMaxTransaction())) {
iterator.remove();
}
}
// 白名单过滤
if (caseDTO.getWhiteFlag() != null && caseDTO.getWhiteFlag()) {
filterWhite(excelDataEntityList);
}
return excelDataEntityList;
}
// 检查团体是否有实际连接(非孤立节点) // 检查团体是否有实际连接(非孤立节点)
private boolean hasConnections(Set<String> members, GraphVO graph) { private boolean hasConnections(Set<String> members, GraphVO graph) {
return graph.getEdges().stream() return graph.getEdges().stream()
......
...@@ -120,7 +120,7 @@ public class GroupDetailServiceImpl extends ServiceImpl<GroupDetailMapper, Group ...@@ -120,7 +120,7 @@ public class GroupDetailServiceImpl extends ServiceImpl<GroupDetailMapper, Group
excelDataEntityListNew.forEach(excelDataVO -> userAndLabel.put(excelDataVO.getPayUserName(), excelDataVO.getLabel())); excelDataEntityListNew.forEach(excelDataVO -> userAndLabel.put(excelDataVO.getPayUserName(), excelDataVO.getLabel()));
// 添加去重后的节点 // 添加去重后的节点
for (String node : uniqueNodes) { for (String node : uniqueNodes) {
graph.addNode(new NodeVO(node, userAndLabel.get(node))); graph.addNode(new NodeVO(node, userAndLabel.get(node), false));
} }
// 添加边 // 添加边
......
...@@ -11,6 +11,7 @@ import com.google.common.collect.Maps; ...@@ -11,6 +11,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.platform.exception.BusinessException; import com.platform.exception.BusinessException;
import com.platform.mapper.UserMapper; import com.platform.mapper.UserMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.UserDTO; import com.platform.model.dto.UserDTO;
import com.platform.model.entity.ExcelDataEntity; import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.entity.UserAccountEntity; import com.platform.model.entity.UserAccountEntity;
...@@ -248,7 +249,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme ...@@ -248,7 +249,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
PageHelper.startPage(userDTO.getPageNum(), userDTO.getPageSize()); PageHelper.startPage(userDTO.getPageNum(), userDTO.getPageSize());
if(!ObjectUtils.isEmpty(oneselfAccountList) && !ObjectUtils.isEmpty(otherAccountList)){ if (!ObjectUtils.isEmpty(oneselfAccountList) && !ObjectUtils.isEmpty(otherAccountList)) {
List<ExcelDataEntity> details = excelDataService.relationPage(oneselfAccountList, otherAccountList); List<ExcelDataEntity> details = excelDataService.relationPage(oneselfAccountList, otherAccountList);
everyoneVO.setDetails(details); everyoneVO.setDetails(details);
} }
...@@ -317,4 +318,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme ...@@ -317,4 +318,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public void saveUserBatch(List<UserEntity> userList) { public void saveUserBatch(List<UserEntity> userList) {
baseMapper.saveUserBatch(userList); baseMapper.saveUserBatch(userList);
} }
@Override
public List<ExcelDataVO> queryList(CaseDTO caseDTO) {
return baseMapper.queryList(caseDTO);
}
} }
...@@ -54,6 +54,12 @@ ...@@ -54,6 +54,12 @@
<if test="endTime != null"> <if test="endTime != null">
and time &lt;= #{endTime} and time &lt;= #{endTime}
</if> </if>
<if test="startTime != null and endTime == null">
and time >= #{startTime}
</if>
<if test="startTime == null and endTime != null">
and time <![CDATA[ <= ]]> #{startTime}
</if>
group by pay_user_name,payee_name group by pay_user_name,payee_name
</select> </select>
<select id="selectFinancialTransactions" resultType="com.platform.model.vo.AssociationVO"> <select id="selectFinancialTransactions" resultType="com.platform.model.vo.AssociationVO">
......
...@@ -23,4 +23,26 @@ ...@@ -23,4 +23,26 @@
LEFT JOIN LEFT JOIN
user u ON u.user_name = v.userName AND u.case_id = #{caseId} user u ON u.user_name = v.userName AND u.case_id = #{caseId}
</select> </select>
<select id="queryList" resultType="com.platform.model.vo.ExcelDataVO">
select
u.user_name payUserName,
u.label label
from
user u
left join
user_account ua
on
u.user_name = ua.user_name
<where>
and u.case_id = #{id}
<if test="nodeName != null and nodeName != ''">
and (u.user_name like concat('%',#{nodeName},'%') or u.id_card like concat('%',#{nodeName},'%') or ua.code like concat('%',#{nodeName},'%') )
</if>
<if test="label != null and label != ''">
and u.label like concat('%',#{label},'%')
</if>
</where>
group by u.user_name
</select>
</mapper> </mapper>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment