Commit a8cbf70c authored by zhuxiang's avatar zhuxiang
Browse files

增加是否公共账户标识

parent 076cf80f
package com.platform.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.platform.model.entity.PublicAccountEntity;
import com.platform.model.resp.Result;
import com.platform.service.PublicAccountService;
......@@ -24,7 +25,9 @@ public class PublicAccountController extends BaseController {
try {
return toAjax(publicAccountService.save(publicAccountEntity));
} 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 {
private Integer whiteId;
private Boolean publicAccountFlag;
private int degree;
public NodeVO(String node, String label) {
public NodeVO(String node, String label, boolean publicAccountFlag) {
this.node = node;
this.label = label;
this.publicAccountFlag = publicAccountFlag;
if (node.contains("公司")) {
this.nodeType = "对公";
} else {
......
......@@ -54,7 +54,8 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
for (ExcelDataVO excelDataVO : excelDataEntityList) {
if (StringUtils.isNotEmpty(excelDataVO.getPayUserName())
&& StringUtils.isNotEmpty(excelDataVO.getPayeeName())
&& excelDataVO.getPayUserName().equals(excelDataVO.getPayeeName())) {
&& excelDataVO.getPayUserName().equals(excelDataVO.getPayeeName())
|| StringUtils.isEmpty(excelDataVO.getFileId())) {
} else {
excelDataEntityList1.add(excelDataVO);
}
......@@ -158,6 +159,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
UnionFindVO uf = new UnionFindVO();
Set<String> uniqueUserName = new HashSet<>();
Map<String, EdgeVO> edgeMap = new HashMap<>();
Map<String, Boolean> publicAccountMap = new HashMap<>();
// 配置规则
applyCaseRules(caseDTO);
......@@ -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());
// 添加节点
addNodesToGraph(graph, uniqueUserName, userAndLabel);
addNodesToGraph(graph, uniqueUserName, userAndLabel, publicAccountMap);
// 过滤有效边
List<EdgeVO> validEdges = filterValidEdges(edgeMap, uf);
......@@ -268,6 +270,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
UnionFindVO uf,
Set<String> uniqueUserName,
Map<String, EdgeVO> edgeMap,
Map<String, Boolean> publicAccountMap,
int caseId) {
//查看公共账号的数据
......@@ -281,15 +284,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
String payer = excelDataEntity.getPayUserName();
String payee = excelDataEntity.getPayeeName();
// 跳过公共账户中的中号
if (isPublicAccount(payer, publicAccountEntityList) || isPublicAccount(payee, publicAccountEntityList)) {
continue;
}
double amount = formatAmount(excelDataEntity.getAmount());
uniqueUserName.add(payer);
uniqueUserName.add(payee);
// 跳过公共账户中的中号
if (isPublicAccount(payer, publicAccountEntityList, publicAccountMap) || isPublicAccount(payee, publicAccountEntityList, publicAccountMap)) {
continue;
}
// 使用UnionFindVO的接口正确添加节点
if (!uf.getParent().containsKey(payer)) {
uf.makeSet(payer);
......@@ -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;
publicAccountMap.put(accountName, result);
// 实现您的公共账户识别逻辑
for (PublicAccountEntity publicAccountEntity : publicAccountEntityList) {
if (publicAccountEntity.getAccountName().equals(accountName)) {
result = true;
publicAccountMap.put(accountName, result);
}
}
return result;
......@@ -354,10 +360,14 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
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) {
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
excelDataEntityListNew.forEach(excelDataVO -> userAndLabel.put(excelDataVO.getPayUserName(), excelDataVO.getLabel()));
// 添加去重后的节点
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