Commit a8cbf70c authored by zhuxiang's avatar zhuxiang
Browse files

增加是否公共账户标识

parent 076cf80f
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())));
} }
} }
} }
...@@ -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 {
......
...@@ -54,7 +54,8 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -54,7 +54,8 @@ 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())
|| StringUtils.isEmpty(excelDataVO.getFileId())) {
} else { } else {
excelDataEntityList1.add(excelDataVO); excelDataEntityList1.add(excelDataVO);
} }
...@@ -158,6 +159,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -158,6 +159,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 +171,13 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -169,13 +171,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 +270,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -268,6 +270,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 +284,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -281,15 +284,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 +308,16 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -306,12 +308,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 +360,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -354,10 +360,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));
} }
} }
......
...@@ -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));
} }
// 添加边 // 添加边
......
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