Commit 50016fb9 authored by zhuxiang's avatar zhuxiang
Browse files

画布接口

parent 8c249aa2
......@@ -15,7 +15,7 @@ import java.util.List;
@RestController
@RequestMapping("/case")
public class CaseController extends BaseController{
public class CaseController extends BaseController {
@Resource
private CaseService caseService;
......@@ -71,7 +71,13 @@ public class CaseController extends BaseController{
@ApiOperation(value = "合并人员")
@PutMapping("/detail/mergeUser")
public Result mergeUser(@RequestBody ExcelDataDTO excelDataDTO){
public Result mergeUser(@RequestBody ExcelDataDTO excelDataDTO) {
return toAjax(caseService.mergeUser(excelDataDTO));
}
@ApiOperation(value = "画布")
@PostMapping("/detail/draw")
public Result draw(@RequestBody CaseDTO caseDTO) {
return Result.data(caseService.draw(caseDTO));
}
}
package com.platform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.vo.ExcelDataVO;
import org.apache.ibatis.annotations.Mapper;
......@@ -16,4 +17,6 @@ import java.util.List;
@Mapper
public interface ExcelDataMapper extends BaseMapper<ExcelDataEntity> {
List<ExcelDataVO> queryByCaseId(String id);
List<ExcelDataEntity> queryList(CaseDTO caseDTO);
}
......@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author : wujipeng
* @date : 2025/7/31 10:47
......@@ -21,4 +23,17 @@ public class CaseDTO extends CaseEntity {
@ApiModelProperty(value = "每页显示的数量", example = "10")
private Integer pageSize;
@ApiModelProperty(value = "开始时间")
private Date startTime;
private Date endTime;
private Integer minTransaction;
private Integer maxTransaction;
private Double maxAmount;
private Double minAmount;
@ApiModelProperty(value = "主体类型 1、个人 2、对公")
private Integer principal;
}
package com.platform.model.vo;
import lombok.Data;
import java.util.List;
@Data
public class EdgeVO {
private String id;
private String source;
private String target;
// 总汇款笔数
private int totalTransactions;
private double totalAmount;
private List<String> states;
public EdgeVO(String id, String source, String target, int totalTransactions, double totalAmount) {
this.id = id;
this.source = source;
this.target = target;
this.totalTransactions = totalTransactions;
this.totalAmount = totalAmount;
}
}
package com.platform.model.vo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class GraphVO {
private List<NodeVO> nodes;
private List<EdgeVO> edges;
public GraphVO() {
this.nodes = new ArrayList<>();
this.edges = new ArrayList<>();
}
public void addNode(NodeVO node) {
nodes.add(node);
}
public void addEdge(EdgeVO edge) {
edges.add(edge);
}
}
package com.platform.model.vo;
import lombok.Data;
@Data
public class NodeVO {
private String node;
public NodeVO(String node) {
this.node = node;
}
}
......@@ -5,6 +5,7 @@ import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.entity.CaseEntity;
import com.platform.model.vo.CaseVO;
import com.platform.model.vo.GraphVO;
import java.util.List;
......@@ -17,6 +18,7 @@ public interface CaseService extends IService<CaseEntity> {
* @return List<CaseVO>
*/
List<CaseVO> pageCase(CaseDTO caseDTO);
List<CaseVO> queryDataList(String id);
/**
......@@ -35,15 +37,23 @@ public interface CaseService extends IService<CaseEntity> {
/**
* 更新是否使用
*
* @param excelDataDTO
* @return
*/
boolean updateExcelUse(ExcelDataDTO excelDataDTO);
/**
*
* @param excelDataDTO
* @return
*/
boolean mergeUser(ExcelDataDTO excelDataDTO);
/**
* 画布
*
* @param caseDTO caseDTO
* @return GraphVO
*/
GraphVO draw(CaseDTO caseDTO);
}
package com.platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.vo.ExcelDataVO;
......@@ -36,4 +37,13 @@ public interface ExcelDataService extends IService<ExcelDataEntity> {
* @return
*/
List<ExcelDataEntity> queryListByCaseIdAndPayUserName(String caseId,String payUserName);
/**
* 查看案件所有的人员
* @param id
* @return
*/
List<ExcelDataEntity> queryListByCaseId(String id);
List<ExcelDataEntity> queryList(CaseDTO caseDTO);
}
......@@ -7,8 +7,7 @@ import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.entity.CaseEntity;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.vo.CaseVO;
import com.platform.model.vo.ExcelDataVO;
import com.platform.model.vo.*;
import com.platform.service.CaseService;
import com.platform.service.ExcelDataService;
import com.platform.utils.StringUtils;
......@@ -16,10 +15,7 @@ import org.apache.commons.compress.utils.Lists;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> implements CaseService {
......@@ -93,6 +89,96 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
return Boolean.TRUE;
}
@Override
public GraphVO draw(CaseDTO caseDTO) {
// 初始化画布
GraphVO graph = new GraphVO();
// 使用Map来存储边的信息,键为payer-payee组合,值为Edge对象
Map<String, EdgeVO> edgeMap = new HashMap<>();
//查看案件所有的人员
List<ExcelDataEntity> excelDataEntityList = excelDataService.queryList(caseDTO);
if (CollUtil.isNotEmpty(excelDataEntityList)) {
//初始化set集合
// 使用Set去重
Set<String> uniqueNodes = new HashSet<>();
excelDataEntityList.forEach(excelDataEntity -> {
if (StringUtils.isNotEmpty(excelDataEntity.getPayUserName())
&& StringUtils.isNotEmpty(excelDataEntity.getPayeeName())) {
uniqueNodes.add(excelDataEntity.getPayUserName());
uniqueNodes.add(excelDataEntity.getPayeeName());
// 生成边的唯一标识
String edgeKey = excelDataEntity.getPayUserName() + "-" + excelDataEntity.getPayeeName();
// 检查是否已经存在这条边
if (edgeMap.containsKey(edgeKey)) {
// 如果存在,更新总笔数和总金额
EdgeVO existingEdge = edgeMap.get(edgeKey);
existingEdge.setTotalTransactions(existingEdge.getTotalTransactions() + 1);
existingEdge.setTotalAmount(existingEdge.getTotalAmount() + excelDataEntity.getAmount());
} else {
// 如果不存在,创建新的边
String edgeId = "line-" + excelDataEntity.getPayUserName() + "-" + excelDataEntity.getPayeeName();
EdgeVO newEdge = new EdgeVO(edgeId, excelDataEntity.getPayUserName(), excelDataEntity.getPayeeName(), 1, excelDataEntity.getAmount());
edgeMap.put(edgeKey, newEdge);
}
}
});
// 添加去重后的节点
for (String node : uniqueNodes) {
if (caseDTO.getPrincipal() != null) {
if (caseDTO.getPrincipal() == 1) {
//过滤掉收款人名称中带有公司的数据
if (node.contains("公司") || node.length() > 4) {
continue;
}
} else {
//过滤掉收款人名称中不含公司的数据
if (!node.contains("公司") || node.length() > 4) {
continue;
}
}
graph.addNode(new NodeVO(node));
continue;
}
graph.addNode(new NodeVO(node));
}
// 添加边
for (EdgeVO edge : edgeMap.values()) {
if (caseDTO.getMinAmount() != null && caseDTO.getMaxAmount() != null) {
if (edge.getTotalAmount() >= caseDTO.getMinAmount() && edge.getTotalAmount() <= caseDTO.getMaxAmount()) {
graph.addEdge(edge);
continue;
}
}
if (caseDTO.getMaxTransaction() != null && caseDTO.getMinTransaction() != null) {
if (edge.getTotalTransactions() >= caseDTO.getMinTransaction() && edge.getTotalTransactions() <= caseDTO.getMaxTransaction()) {
graph.addEdge(edge);
continue;
}
}
if (caseDTO.getPrincipal() != null) {
if (caseDTO.getPrincipal() == 1) {
//过滤掉收款人名称中带有公司的数据
if (edge.getTarget().contains("公司") || edge.getTarget().length() > 4) {
continue;
}
} else {
//过滤掉收款人名称中不含公司的数据
if (!edge.getTarget().contains("公司") || edge.getTarget().length() > 4) {
continue;
}
}
graph.addEdge(edge);
continue;
}
graph.addEdge(edge);
}
}
return graph;
}
private Map<String, List<ExcelDataVO>> groupByPayUserName(List<ExcelDataVO> excelDataVOList) {
Map<String, List<ExcelDataVO>> groupedMap = new HashMap<>();
......@@ -105,6 +191,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
}
return groupedMap;
}
@Override
public List<CaseVO> pageCase(CaseDTO caseDTO) {
return baseMapper.pageCase(caseDTO);
......
......@@ -3,6 +3,7 @@ package com.platform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.mapper.ExcelDataMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.vo.ExcelDataVO;
......@@ -47,4 +48,16 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
.eq(ExcelDataEntity::getCaseId, caseId)
.eq(ExcelDataEntity::getPayUserName, payUserName));
}
@Override
public List<ExcelDataEntity> queryListByCaseId(String id) {
return baseMapper.selectList(new LambdaQueryWrapper<ExcelDataEntity>()
.eq(ExcelDataEntity::getCaseId, id)
.eq(ExcelDataEntity::getUseFlag, true));
}
@Override
public List<ExcelDataEntity> queryList(CaseDTO caseDTO) {
return baseMapper.queryList(caseDTO);
}
}
......@@ -19,4 +19,18 @@
group by
ed.file_id,ed.pay_user_name,fu.file_name,fu.path,ed.use_flag
</select>
<select id="queryList" resultType="com.platform.model.entity.ExcelDataEntity">
select
pay_user_name payUserName,
payee_name payeeName,
amount amount
from
excel_data
where
use_flag = 1
<if test="startTime != null and endTime != ''">
and time betwenn #{startTime} and #{endTime}
</if>
</select>
</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