Commit 63693302 authored by zhuxiang's avatar zhuxiang
Browse files

画布优化

parent a89b4c4e
......@@ -113,4 +113,7 @@ public class ExcelDataEntity {
@ApiModelProperty("关联账户")
@TableField(exist = false)
private String associationAccount;
@TableField(exist = false)
private int transactionCount;
}
......@@ -15,6 +15,8 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@Service
......@@ -163,10 +165,29 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
if (caseDTO.getPrincipal() == 1 && excelDataEntity.getPayeeName().contains("公司")) {
//移除被付款人是公司
iterator.remove(); // 安全移除元素
continue;
}
if (caseDTO.getPrincipal() == 2 && !excelDataEntity.getPayeeName().contains("公司")) {
//移除被付款人是公司
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
String payer = excelDataEntity.getPayUserName();
String payee = excelDataEntity.getPayeeName();
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 mac = excelDataEntity.getMac();
String account = excelDataEntity.getPaymentBankName();
......@@ -208,10 +234,10 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
if (existingEdge != null) {
// 更新现有边
existingEdge.setTotalTransactions(existingEdge.getTotalTransactions() + 1);
existingEdge.setTotalAmount(existingEdge.getTotalAmount() + amount);
existingEdge.setTotalAmount(existingEdge.getTotalAmount() + formattedAmount);
} 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);
}
}
......@@ -238,23 +264,6 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
!validNodes.contains(edge.getTarget())) {
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);
graph.addEdge(edge);
......@@ -447,7 +456,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
userEntity.setCaseId(userDTO.getCaseId());
userEntity.setType("1");
userService.save(userEntity);
}else {
} else {
userEntity.setType("1");
userEntity.setUserName(userDTO.getNewName());
userEntity.setSex(userDTO.getSex());
......
......@@ -34,7 +34,8 @@
select
pay_user_name payUserName,
payee_name payeeName,
amount amount,
SUM(amount) amount,
COUNT(*) AS transactionCount,
ip ip,
mac mac,
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