Commit 9f85871b authored by wuqinghua's avatar wuqinghua

2021/11/29 吴卿华 优化一级页面生成位置算法

parent 17032a4c
package com.example.gajz.transferrelationship.bean.vo;
import lombok.Data;
import lombok.ToString;
/**
* 计算中心点返回值封装类
*/
@Data
@ToString
public class CenterPointVo {
/**
* 卡号
*/
private String bankCardNo;
/**
* 姓名
*/
private String name;
/**
* X轴
*/
private int X;
/**
* Y轴
*/
private int Y;
/**
* 上级卡号
*/
private String superiorNumber;
}
package com.example.gajz.transferrelationship.dao;
import com.example.gajz.transferrelationship.bean.excel.abcExcie;
import com.example.gajz.transferrelationship.bean.vo.CenterPointVo;
import com.example.gajz.transferrelationship.bean.vo.SearchRelationshipVo;
import com.example.gajz.transferrelationship.bean.vo.TransferCardVo;
import com.example.gajz.transferrelationship.bean.vo.personalTransferRelationshipVo;
......@@ -115,4 +116,13 @@ public interface TransferRelationshipMapper {
* @return
*/
List<personalTransferRelationshipVo> trBetweenTwoPersons(String cardNumber);
/**
* 查询中心点下级中心点
* @param transferCardVoList
* @return
*/
List<CenterPointVo> centerPointMethod(List<TransferCardVo> transferCardVoList, String bankCardNo);
}
......@@ -2,11 +2,20 @@ package com.example.gajz.transferrelationship.neo4j;
import com.example.gajz.redis.ConFigRedis;
import redis.clients.jedis.Jedis;
import java.util.HashMap;
import java.util.Set;
public class test {
public static void main(String[] args) {
Jedis conn = ConFigRedis.getConn();
conn.flushAll();
HashMap hashMap=new HashMap();
hashMap.put("1","111");
hashMap.put("2","222");
hashMap.put("3","333");
hashMap.put("4","444");
System.out.println(hashMap.size());
......
package com.example.gajz.transferrelationship.relationalalgorithm;
import com.example.gajz.transferrelationship.bean.param.data;
import com.example.gajz.transferrelationship.dao.TransferRelationshipMapper;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* 算大图四个角的XY轴 工具类
*/
@Component
public class LocationCalculation {
/**关系图数据持久层*/
@Resource
TransferRelationshipMapper transferRelationshipMapper;
public static LocationCalculation test;
@PostConstruct
public void init(){
test= this;
test.transferRelationshipMapper=transferRelationshipMapper;
}
/**
* 算大图四个角的XY轴 方法
*/
public HashMap LocationCalculationMethod(String bankCardNo,int X,int Y){
/**存储大圆的四角X Y轴数据*/
HashMap xyMap = new HashMap();
/**查询被转账人(下级)全部信息*/
List<data> transfer = transferRelationshipMapper.transferRelationship(bankCardNo);
/**下级数据存放list*/
List<com.example.gajz.transferrelationship.bean.param.data> dataList=new ArrayList<>();
for (int i=0;i<transfer.size();i++){
com.example.gajz.transferrelationship.bean.param.data data=new com.example.gajz.transferrelationship.bean.param.data();
data.setName(transfer.get(i).getName());
dataList.add(data);
}
/**算大圈半径专用 下级数量总数*/
int bigTotal = dataList.size();
/**算大圈半径专用 每圈点数*/
int bigBase = 8;
for (int n=1;bigTotal>0;n++){
bigTotal = bigTotal-bigBase;
bigBase = bigBase+20;
}
/** 大圆最后一圈半径 每份多少点数 */
int bigPointsPerShare = bigBase/4;
/**大圆最后一圈半径 相等于大圈半径 点数*距离 */
int fullCircleRadius =bigPointsPerShare*2;
xyMap.put("zx",(X-fullCircleRadius)); //圆左X轴
xyMap.put("zy",Y); //圆左Y轴
xyMap.put("yx",(X+fullCircleRadius)); //圆右X轴
xyMap.put("yy",Y); //圆右Y轴
xyMap.put("sx",X); //圆上X轴
xyMap.put("sy",(Y-fullCircleRadius)); //圆上Y轴
xyMap.put("xx",X); //圆下X轴
xyMap.put("xy",(Y+fullCircleRadius)); //圆下Y轴
return xyMap;
}
}
......@@ -17,6 +17,7 @@ public class TransferLocation {
@Resource
TransferRelationshipMapper transferRelationshipMapper;
public static TransferLocation test;
@PostConstruct
......@@ -24,7 +25,6 @@ public class TransferLocation {
test= this;
test.transferRelationshipMapper=transferRelationshipMapper;
}
/**
* 双人转账关系 位置生成方法
* @param transferAssociationList
......
......@@ -10,6 +10,7 @@ import com.example.gajz.transferrelationship.bean.vo.*;
import com.example.gajz.transferrelationship.dao.TransferRelationshipMapper;
import com.example.gajz.transferrelationship.hugegraphclient.HugeCollectionProperties;
import com.example.gajz.transferrelationship.neo4j.Colour;
import com.example.gajz.transferrelationship.relationalalgorithm.CalculationCenterPoint;
import com.example.gajz.transferrelationship.relationalalgorithm.RelationalAlgorithm;
import com.example.gajz.transferrelationship.relationalalgorithm.TransferLocation;
import com.example.gajz.transferrelationship.service.TransferRelationshipService;
......@@ -35,6 +36,8 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
/**HugeGraph*/
@Autowired
HugeCollectionProperties hugeCollectionProperties;
@Autowired
CalculationCenterPoint calculationCenterPoint;
/**
......@@ -82,32 +85,44 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
public List diagramSpot() {
// Jedis conn = ConFigRedis.getConn();
/**已经存在的点 会存储到map里面*/
HashMap hashMap=new HashMap();
HashMap hashMap = new HashMap();
/**存储已经查找到的中心点下级 防止重复*/
HashMap centerPointMap = new HashMap();
//查询转账人(中心点)信息
List<TransferCardVo> transferCardVos = transferRelationshipMapper.selectTransferCard();
/**----------------------------------计算中心点位置 开始------------------------------------*/
/**计算中心点方法*/
List<CenterPointVo> centerPointVoList = calculationCenterPoint.CenterPointMethod(transferCardVos);
// System.out.println(centerPointVoList.size());
/**----------------------------------计算中心点位置 结束------------------------------------*/
List list=new ArrayList();
int centerPointX = 0;
int centerPointY = 0;
//存储所有大圆的四角X Y轴数据
HashMap xyMap = new HashMap();
/** 中心点*/
for (int i=0;i<transferCardVos.size();i++){
for (int i=0;i<centerPointVoList.size();i++){
//是否重叠
boolean overlap=false;
if (!overlap){
centerPointVoList.get(i).setX(centerPointVoList.get(i).getX()+20);
centerPointVoList.get(i).setY(centerPointVoList.get(i).getY()+20);
}
//生成颜色
Colour colour=new Colour();
String code=colour.getColour();
Test test=new Test();
test.setId(transferCardVos.get(i).getBankCardNo());
test.setX((int)(Math.random()*3000));
test.setY((int)(Math.random()*3000));
test.setName(transferCardVos.get(i).getName());
test.setId(centerPointVoList.get(i).getBankCardNo());
test.setX(centerPointVoList.get(i).getX());
test.setY(centerPointVoList.get(i).getY());
test.setName(centerPointVoList.get(i).getName());
test.setColor(code);
centerPointX=test.getX();
centerPointY=test.getY();
/** -----------------------------去掉被转账人对应中心点重复出现点 代码--------------------------------*/
/**查询被转账人全部信息*/
List<com.example.gajz.transferrelationship.bean.param.data> transfer = transferRelationshipMapper.transferRelationship(transferCardVos.get(i).getBankCardNo());
List<com.example.gajz.transferrelationship.bean.param.data> transfer = transferRelationshipMapper.transferRelationship(centerPointVoList.get(i).getBankCardNo());
/**将没有重复的值 存储到这个list里面*/
List<com.example.gajz.transferrelationship.bean.param.data> dataList=new ArrayList<>();
for (int p=0;p<transfer.size();p++){
......@@ -166,16 +181,12 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
}else {
for (int p=0;p<i;p++){
int zX = (int) xyMap.get(p + "zX");
int zY = (int) xyMap.get(p + "zY");
int yX = (int) xyMap.get(p + "yX");
int yY = (int) xyMap.get(p + "yY");
int sX = (int) xyMap.get(p + "sX");
int sY = (int) xyMap.get(p + "sY");
int xX = (int) xyMap.get(p + "xX");
int xY = (int) xyMap.get(p + "xY");
if( ((zX>(centerPointX-fullCircleRadius)&&zX>(centerPointX+fullCircleRadius)) ||(yX<(centerPointX-fullCircleRadius)&&yX<(centerPointX+fullCircleRadius)))
if(((zX>(centerPointX-fullCircleRadius)&&zX>(centerPointX+fullCircleRadius)) ||(yX<(centerPointX-fullCircleRadius)&&yX<(centerPointX+fullCircleRadius)))
||
((sY>(centerPointY-fullCircleRadius)&&sY>(centerPointY+fullCircleRadius)) ||(xY<(centerPointY-fullCircleRadius)&&xY<(centerPointY+fullCircleRadius))) ){
((sY>(centerPointY-fullCircleRadius)&&sY>(centerPointY+fullCircleRadius)) ||(xY<(centerPointY-fullCircleRadius)&&xY<(centerPointY+fullCircleRadius)))){
if (p==i-1) {
xyMap.put(i + "zX", (centerPointX-fullCircleRadius)); //圆左X轴
xyMap.put(i + "zY", centerPointY); //圆左Y轴
......
......@@ -150,5 +150,16 @@
group by bank_card_no
</select>
<!--查询中心点下级中心点-->
<select id="centerPointMethod" resultType="com.example.gajz.transferrelationship.bean.vo.CenterPointVo">
select bank_card_no as bankCardNo from (
select end_card_no as bank_card_no from abc_statement where bank_card_no=#{bankCardNo} and end_card_no is not null group by end_card_no) a
where a.bank_card_no in (
<foreach collection="transferCardVoList" item="transferCardVoList" index="index" separator=",">
#{transferCardVoList.bankCardNo}
</foreach>
)
</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