Commit acc846db authored by zhuxiang's avatar zhuxiang
Browse files

案件画布节点数据存入数据库

parent eb634572
......@@ -46,9 +46,9 @@ public class CaseController extends BaseController {
}
@ApiOperation(value = "案件详情-数据列表")
@GetMapping("/detail/dataList/{id}")
public Result dataList(@PathVariable String id) {
return Result.data(caseService.queryDataList(id));
@PostMapping("/detail/dataList")
public Result dataList(@RequestBody CaseDTO caseDTO) {
return Result.data(caseService.queryDataList(caseDTO));
}
@ApiOperation(value = "案件详情-数据更新所属人")
......
......@@ -20,4 +20,6 @@ public interface CaseMapper extends BaseMapper<CaseEntity> {
Boolean saveCase(CaseDTO caseDTO);
Boolean removeBatchCase(@Param("ids") List<String> ids);
CaseEntity getInfoById(Integer id);
}
package com.platform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.model.entity.EdgeEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EdgeMapper extends BaseMapper<EdgeEntity> {
}
......@@ -19,7 +19,8 @@ import java.util.List;
*/
@Mapper
public interface ExcelDataMapper extends BaseMapper<ExcelDataEntity> {
List<ExcelDataVO> queryByCaseId(String id);
List<ExcelDataVO> queryByCaseId(CaseDTO caseDTO);
List<ExcelDataEntity> queryList(CaseDTO caseDTO);
......
package com.platform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.model.entity.NodeEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface NodeMapper extends BaseMapper<NodeEntity> {
}
......@@ -38,4 +38,8 @@ public class CaseDTO extends CaseEntity {
@ApiModelProperty(value = "主体类型 1、个人 2、对公")
private Integer principal;
private String payUserName;
private String fileName;
}
......@@ -40,4 +40,6 @@ public class CaseEntity {
@TableField("template_id")
@ApiModelProperty(value = "模板id")
private String templateId;
private Boolean drawFlag;
}
package com.platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("edge")
public class EdgeEntity {
@TableId(value = "id", type = IdType.AUTO)
private int id;
private int caseId;
private String target;
private String source;
private String relation;
private int totalTransactions;
private double totalAmount;
private String ip;
private String mac;
private String account;
}
package com.platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("node")
public class NodeEntity {
@TableId(value = "id", type = IdType.AUTO)
private int id;
private int caseId;
private String node;
}
......@@ -27,9 +27,8 @@ public class EdgeVO {
private List<String> states;
public EdgeVO(String id, String source, String target, int totalTransactions, double totalAmount, String groupId,
public EdgeVO(String source, String target, int totalTransactions, double totalAmount, String groupId,
String ip, String mac, String account) {
this.id = id;
this.source = source;
this.target = target;
this.totalTransactions = totalTransactions;
......@@ -48,4 +47,9 @@ public class EdgeVO {
this.totalAmount = totalAmount;
}
// 添加无参构造方法
public EdgeVO() {
}
}
......@@ -31,4 +31,5 @@ public class GraphVO {
public void addGroup(GroupVO groupVO) {
groups.add(groupVO);
}
}
......@@ -22,4 +22,8 @@ public class GroupVO {
this.totalTransactions = totalTransactions;
this.groupDetailList = groupDetailList;
}
public GroupVO(){
}
}
......@@ -12,4 +12,8 @@ public class NodeVO {
public NodeVO(String node) {
this.node = node;
}
// 添加无参构造方法
public NodeVO() {
}
}
......@@ -20,7 +20,7 @@ public interface CaseService extends IService<CaseEntity> {
*/
List<CaseVO> pageCase(CaseDTO caseDTO);
List<CaseVO> queryDataList(String id);
List<CaseVO> queryDataList(CaseDTO caseDTO);
/**
* 数据更新所属人
......
package com.platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.platform.model.entity.EdgeEntity;
import com.platform.model.vo.EdgeVO;
import java.util.List;
public interface EdgeService extends IService<EdgeEntity> {
void saveData(Integer id, List<EdgeVO> edges);
List<EdgeVO> queryByCaseId(Integer id);
}
......@@ -17,7 +17,7 @@ import java.util.List;
* @Desc : 描述信息
*/
public interface ExcelDataService extends IService<ExcelDataEntity> {
List<ExcelDataVO> queryByCaseId(String id);
List<ExcelDataVO> queryByCaseId(CaseDTO caseDTO);
/**
* @param fileId
......
......@@ -9,4 +9,6 @@ import java.util.List;
public interface GroupService extends IService<GroupEntity> {
void saveGroup(int id, List<GroupVO> groups);
List<GroupVO> queryByCaseId(Integer id);
}
package com.platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.platform.model.entity.NodeEntity;
import com.platform.model.vo.NodeVO;
import java.util.List;
public interface NodeService extends IService<NodeEntity> {
void saveData(Integer id, List<NodeVO> nodes);
List<NodeVO> queryByCaseId(Integer id);
}
......@@ -23,6 +23,10 @@ import java.util.stream.Collectors;
@Service
public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> implements CaseService {
@Resource
private NodeService nodeService;
@Resource
private EdgeService edgeService;
@Resource
private WhiteService whiteService;
@Resource
......@@ -33,9 +37,9 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
private UserRelationService userRelationService;
@Override
public List<CaseVO> queryDataList(String id) {
public List<CaseVO> queryDataList(CaseDTO caseDTO) {
//查看案件所有的excelData
List<ExcelDataVO> excelDataEntityList = excelDataService.queryByCaseId(id);
List<ExcelDataVO> excelDataEntityList = excelDataService.queryByCaseId(caseDTO);
excelDataEntityList.forEach(excelDataEntity -> {
if (StringUtils.isNull(excelDataEntity.getPayUserName())) {
excelDataEntity.setPayUserName("无对应人员的数据");
......@@ -100,9 +104,21 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
@Override
public GraphVO draw(CaseDTO caseDTO) {
// 初始化返回对象
// 初始化画布对象
GraphVO graph = new GraphVO();
CaseEntity caseEntity = baseMapper.getInfoById(caseDTO.getId());
if (caseEntity == null) {
return graph;
}
if (caseEntity.getDrawFlag()) {
//查询数据库数据
List<NodeVO> nodeVOList = nodeService.queryByCaseId(caseDTO.getId());
List<EdgeVO> edgeVOList = edgeService.queryByCaseId(caseDTO.getId());
List<GroupVO> groupVOList = groupService.queryByCaseId(caseDTO.getId());
graph.setNodes(nodeVOList);
graph.setEdges(edgeVOList);
graph.setGroups(groupVOList);
} else {
// 使用并查集管理团体关系
UnionFindVO uf = new UnionFindVO();
......@@ -149,8 +165,7 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
existingEdge.setTotalAmount(existingEdge.getTotalAmount() + amount);
} else {
// 创建新边
String edgeId = "line-" + payer + "-" + payee;
EdgeVO newEdge = new EdgeVO(edgeId, payer, payee, 1, amount, uf.find(payer), ip, mac, account);
EdgeVO newEdge = new EdgeVO(payer, payee, 1, amount, uf.find(payer), ip, mac, account);
edgeMap.put(edgeKey, newEdge);
}
}
......@@ -317,8 +332,12 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CaseEntity> impleme
}
//处理付款人与收款人的关系
disposeUserRelation(caseDTO.getId(), validNodes, graph.getEdges());
//保存节点、边数据
nodeService.saveData(caseDTO.getId(), graph.getNodes());
edgeService.saveData(caseDTO.getId(), graph.getEdges());
//保存团体数据
groupService.saveGroup(caseDTO.getId(), graph.getGroups());
}
return graph;
}
......
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.EdgeMapper;
import com.platform.model.entity.EdgeEntity;
import com.platform.model.vo.EdgeVO;
import com.platform.service.EdgeService;
import com.platform.utils.DozerUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class EdgeServiceImpl extends ServiceImpl<EdgeMapper, EdgeEntity> implements EdgeService {
@Override
public void saveData(Integer id, List<EdgeVO> edges) {
List<EdgeEntity> edgeEntityList = DozerUtils.convertList(edges, EdgeEntity.class);
edgeEntityList.forEach(edgeEntity -> edgeEntity.setCaseId(id));
saveBatch(edgeEntityList);
}
@Override
public List<EdgeVO> queryByCaseId(Integer id) {
return DozerUtils.convertList(baseMapper.selectList(new LambdaQueryWrapper<EdgeEntity>()
.eq(EdgeEntity::getCaseId, id)), EdgeVO.class);
}
}
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