Commit 63693302 authored by zhuxiang's avatar zhuxiang
Browse files

画布优化

parent a89b4c4e
...@@ -113,4 +113,7 @@ public class ExcelDataEntity { ...@@ -113,4 +113,7 @@ public class ExcelDataEntity {
@ApiModelProperty("关联账户") @ApiModelProperty("关联账户")
@TableField(exist = false) @TableField(exist = false)
private String associationAccount; private String associationAccount;
@TableField(exist = false)
private int transactionCount;
} }
...@@ -15,6 +15,8 @@ import org.springframework.stereotype.Service; ...@@ -15,6 +15,8 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
@Service @Service
...@@ -163,10 +165,29 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -163,10 +165,29 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
if (caseDTO.getPrincipal() == 1 && excelDataEntity.getPayeeName().contains("公司")) { if (caseDTO.getPrincipal() == 1 && excelDataEntity.getPayeeName().contains("公司")) {
//移除被付款人是公司 //移除被付款人是公司
iterator.remove(); // 安全移除元素 iterator.remove(); // 安全移除元素
continue;
} }
if (caseDTO.getPrincipal() == 2 && !excelDataEntity.getPayeeName().contains("公司")) { if (caseDTO.getPrincipal() == 2 && !excelDataEntity.getPayeeName().contains("公司")) {
//移除被付款人是公司 //移除被付款人是公司
iterator.remove(); // 安全移除元素 iterator.remove(); // 安全移除元素
continue;
}
}
// 检查金额过滤条件
if (caseDTO.getMinAmount() != null && caseDTO.getMaxAmount() != null) {
if (excelDataEntity.getAmount() < caseDTO.getMinAmount() ||
excelDataEntity.getAmount() > caseDTO.getMaxAmount()) {
iterator.remove();
continue;
}
}
// 检查交易次数过滤条件
if (caseDTO.getMinTransaction() != null && caseDTO.getMaxTransaction() != null) {
if (excelDataEntity.getTransactionCount() < caseDTO.getMinTransaction() ||
excelDataEntity.getTransactionCount() > caseDTO.getMaxTransaction()) {
iterator.remove();
} }
} }
} }
...@@ -190,6 +211,11 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -190,6 +211,11 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
String payer = excelDataEntity.getPayUserName(); String payer = excelDataEntity.getPayUserName();
String payee = excelDataEntity.getPayeeName(); String payee = excelDataEntity.getPayeeName();
double amount = excelDataEntity.getAmount(); double amount = excelDataEntity.getAmount();
BigDecimal bd = new BigDecimal(amount);
bd = bd.setScale(2, RoundingMode.HALF_UP); // 保留两位小数,四舍五入
double formattedAmount = bd.doubleValue();
String ip = excelDataEntity.getIp(); String ip = excelDataEntity.getIp();
String mac = excelDataEntity.getMac(); String mac = excelDataEntity.getMac();
String account = excelDataEntity.getPaymentBankName(); String account = excelDataEntity.getPaymentBankName();
...@@ -208,10 +234,10 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -208,10 +234,10 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
if (existingEdge != null) { if (existingEdge != null) {
// 更新现有边 // 更新现有边
existingEdge.setTotalTransactions(existingEdge.getTotalTransactions() + 1); existingEdge.setTotalTransactions(existingEdge.getTotalTransactions() + 1);
existingEdge.setTotalAmount(existingEdge.getTotalAmount() + amount); existingEdge.setTotalAmount(existingEdge.getTotalAmount() + formattedAmount);
} else { } else {
// 创建新边 // 创建新边
EdgeVO newEdge = new EdgeVO(payer, payee, 1, amount, uf.find(payer), ip, mac, account); EdgeVO newEdge = new EdgeVO(payer, payee, 1, formattedAmount, uf.find(payer), ip, mac, account);
edgeMap.put(edgeKey, newEdge); edgeMap.put(edgeKey, newEdge);
} }
} }
...@@ -238,23 +264,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -238,23 +264,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
!validNodes.contains(edge.getTarget())) { !validNodes.contains(edge.getTarget())) {
continue; continue;
} }
// 检查金额过滤条件
if (caseDTO.getMinAmount() != null && caseDTO.getMaxAmount() != null) {
if (edge.getTotalAmount() < caseDTO.getMinAmount() ||
edge.getTotalAmount() > caseDTO.getMaxAmount()) {
continue;
}
}
// 检查交易次数过滤条件
if (caseDTO.getMinTransaction() != null && caseDTO.getMaxTransaction() != null) {
if (edge.getTotalTransactions() < caseDTO.getMinTransaction() ||
edge.getTotalTransactions() > caseDTO.getMaxTransaction()) {
continue;
}
}
// 添加到有效边集合 // 添加到有效边集合
validEdges.add(edge); validEdges.add(edge);
graph.addEdge(edge); graph.addEdge(edge);
...@@ -447,7 +456,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem ...@@ -447,7 +456,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
userEntity.setCaseId(userDTO.getCaseId()); userEntity.setCaseId(userDTO.getCaseId());
userEntity.setType("1"); userEntity.setType("1");
userService.save(userEntity); userService.save(userEntity);
}else { } else {
userEntity.setType("1"); userEntity.setType("1");
userEntity.setUserName(userDTO.getNewName()); userEntity.setUserName(userDTO.getNewName());
userEntity.setSex(userDTO.getSex()); userEntity.setSex(userDTO.getSex());
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
select select
pay_user_name payUserName, pay_user_name payUserName,
payee_name payeeName, payee_name payeeName,
amount amount, SUM(amount) amount,
COUNT(*) AS transactionCount,
ip ip, ip ip,
mac mac, mac mac,
payment_bank_name payment_bank_name
......
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