Commit 6522b5e0 authored by wuqinghua's avatar wuqinghua

2021/12/7 吴卿华 1修改一级关系图展示形状为圆形 2修改颜色生成算法

parent 9f85871b
package com.example.gajz.transferrelationship;
import org.junit.Test;
import java.awt.*;
import java.util.Random;
public class TEST {
public static void main(String[] args) {
}
@Test
public void RandomHexColor_test() {
Random random = new Random();
float hue = random.nextFloat();
float saturation = (random.nextInt(7000) + 4000) / 10000f;
float luminance = 1f;
Color color = Color.getHSBColor(hue, saturation, luminance);
System.out.println(color);
System.out.println("#" + Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1));
//红色
String red;
//绿色
String green;
//蓝色
String blue;
//生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
//判断红色代码的位数
red = red.length()==1 ? "0" + red : red ;
//判断绿色代码的位数
green = green.length()==1 ? "0" + green : green ;
//判断蓝色代码的位数
blue = blue.length()==1 ? "0" + blue : blue ;
//生成十六进制颜色值
String color1 = "0x"+red+green+blue;
System.out.println(color1);
}
}
package com.example.gajz.transferrelationship.neo4j;
import java.awt.*;
import java.util.Random;
public class Colour {
public String getColour(){
//红色
String red;
//绿色
String green;
//蓝色
String blue;
// //红色
// String red;
// //绿色
// String green;
// //蓝色
// String blue;
//生成随机对象
Random random = new Random();
//生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
//判断红色代码的位数
red = red.length()==1 ? "0" + red : red ;
//判断绿色代码的位数
green = green.length()==1 ? "0" + green : green ;
//判断蓝色代码的位数
blue = blue.length()==1 ? "0" + blue : blue ;
//生成十六进制颜色值
String color = "0x"+red+green+blue;
return color;
// //生成红色颜色代码
// red = Integer.toHexString(random.nextInt(256)).toUpperCase();
// //生成绿色颜色代码
// green = Integer.toHexString(random.nextInt(256)).toUpperCase();
// //生成蓝色颜色代码
// blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
// //判断红色代码的位数
// red = red.length()==1 ? "0" + red : red ;
// //判断绿色代码的位数
// green = green.length()==1 ? "0" + green : green ;
// //判断蓝色代码的位数
// blue = blue.length()==1 ? "0" + blue : blue ;
// //生成十六进制颜色值
// String color = "0x"+red+green+blue;
float hue = random.nextFloat();
float saturation = (random.nextInt(7000) + 4000) / 10000f;
float luminance = 1f;
Color color1= Color.getHSBColor(hue, saturation, luminance);
String cos="0x" + Integer.toHexString((color1.getRGB() & 0xffffff) | 0x1000000).substring(1);
return cos;
}
}
......@@ -2,22 +2,35 @@ 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;
import java.util.*;
public class test {
public static void main(String[] args) {
int START = 1;
int END = 100;
Random random = new Random();
for (int idx = 1; idx <= 1; ++idx){
showRandomInteger(START, END, random);
}
}
HashMap hashMap=new HashMap();
hashMap.put("1","111");
hashMap.put("2","222");
hashMap.put("3","333");
hashMap.put("4","444");
private static void showRandomInteger(int aStart, int aEnd, Random aRandom){
if ( aStart > aEnd ) {
throw new IllegalArgumentException("Start cannot exceed End.");
}
//get the range, casting to long to avoid overflow problems
long range = (long)aEnd - (long)aStart + 1;
// compute a fraction of the range, 0 <= frac < range
long fraction = (long)(range * aRandom.nextDouble());
int randomNumber = (int)(fraction + aStart);
log("Generated : " + randomNumber);
}
private static void log(String aMessage){
System.out.println(aMessage);
}
System.out.println(hashMap.size());
}
}
......@@ -273,8 +273,8 @@ public class CalculationCenterPoint {
CenterPointVo centerPointVo1=new CenterPointVo();
centerPointVo1.setBankCardNo(transferCardVoList.get(p).getBankCardNo());
centerPointVo1.setName(transferCardVoList.get(p).getName());
centerPointVo1.setX((int)(Math.random()*2000));
centerPointVo1.setY((int)(Math.random()*2000));
centerPointVo1.setX((int)(Math.random()*1000));
centerPointVo1.setY((int)(Math.random()*1000));
temporaryList.add(centerPointVo1);
repeat.put(transferCardVoList.get(p).getBankCardNo(),1);
}
......@@ -294,11 +294,8 @@ public class CalculationCenterPoint {
subordinateList.add(temporary.get(x));
}
}
}
return centerPointVoList;
}
......
......@@ -36,6 +36,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
/**HugeGraph*/
@Autowired
HugeCollectionProperties hugeCollectionProperties;
@Autowired
CalculationCenterPoint calculationCenterPoint;
......@@ -85,48 +86,50 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
public List diagramSpot() {
// Jedis conn = ConFigRedis.getConn();
/**已经存在的点 会存储到map里面*/
HashMap hashMap = new HashMap();
/**存储已经查找到的中心点下级 防止重复*/
HashMap centerPointMap = new HashMap();
HashMap hashMap=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;
//重复次数
int repeatFrequency = 0;
//存储所有大圆的四角X Y轴数据
HashMap xyMap = new HashMap();
/** 中心点*/
for (int i=0;i<centerPointVoList.size();i++){
for (int i=0;i<transferCardVos.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);
centerPointVoList.get(i).setY(centerPointVoList.get(i).getY());
}
//生成颜色
Colour colour=new Colour();
String code=colour.getColour();
Test test=new Test();
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.setId(transferCardVos.get(i).getBankCardNo());
test.setX((int)(Math.random()*5000));
test.setY((int)(Math.random()*5000));
test.setName(transferCardVos.get(i).getName());
test.setColor(code);
centerPointX=test.getX();
centerPointY=test.getY();
/** -----------------------------去掉被转账人对应中心点重复出现点 代码--------------------------------*/
/**查询被转账人全部信息*/
List<com.example.gajz.transferrelationship.bean.param.data> transfer = transferRelationshipMapper.transferRelationship(centerPointVoList.get(i).getBankCardNo());
List<com.example.gajz.transferrelationship.bean.param.data> transfer = transferRelationshipMapper.transferRelationship(transferCardVos.get(i).getBankCardNo());
/**将没有重复的值 存储到这个list里面*/
List<com.example.gajz.transferrelationship.bean.param.data> dataList=new ArrayList<>();
for (int p=0;p<transfer.size();p++){
Object target = hashMap.get(transfer.get(p).getTarget());
/**判断此中心点是否是因为碰撞第一次生成下级数据 如果不是第一次就设置防重复map失效*/
if (repeatFrequency!=0){
target = null;
}
if (target==null){
com.example.gajz.transferrelationship.bean.param.data data=new com.example.gajz.transferrelationship.bean.param.data();
data.setName(transfer.get(p).getName());
......@@ -144,7 +147,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
}
/**每圈点数 动态变化 */
int base = 8;
int base = 40;
/**总数*/
int total = dataList.size();
/**循环次数*/
......@@ -154,10 +157,10 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
/**算大圈半径专用 总数*/
int bigTotal = dataList.size();
/**算大圈半径专用 每圈点数*/
int bigBase = 8;
int bigBase = 20;
for (int n=1;bigTotal>0;n++){
bigTotal = bigTotal-bigBase;
bigBase = bigBase+20;
bigBase = bigBase+50;
}
/** 大圆最后一圈半径 每份多少点数 */
int bigPointsPerShare = bigBase/4;
......@@ -181,12 +184,16 @@ 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)))
||
((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轴
......@@ -201,8 +208,12 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
// conn.set(test.getId(),position);
list.add(test);
overlap=true;
repeatFrequency=0;
}
}else {
//设置碰撞次数
repeatFrequency++;
//设置已经碰撞
overlap=false;
break;
}
......@@ -213,15 +224,17 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
continue;
}
/**圆圈层数 每循环一次 就是一圈*/
for (int y=1;total>0;y++){
/**点之间 x轴y轴间隔距离*/
int distance=2;
/**圆分成四份 每份多少点数*/
int pointsPerShare = base/4;
float pointsPerShare = base/4;
/**每份点数 / 90度 算出每个点数的度数*/
float number=90/pointsPerShare;
int eachDegree = (int)Math.ceil(number);
/**小圆半径 点数X距离*/
int circleRadius = pointsPerShare * distance;
int circleRadius = (int) (pointsPerShare * distance);
/**右下角逐渐递减*/
int lowerRight = 0;
/**左下角逐渐递减*/
......@@ -234,33 +247,57 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
for (int t=0;t<base;t++){
Test test1=new Test();
if (t<pointsPerShare){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((distance*t)+centerPointX);
test1.setY((centerPointY-circleRadius)+(distance*t));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
}else if (t<=pointsPerShare*2){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((centerPointX+circleRadius)-(distance*lowerRight));
test1.setY(centerPointY+(lowerRight*distance));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
lowerRight++;
}else if (t<=pointsPerShare*3){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((centerPointX-circleRadius)+(distance*lowerLeft));
test1.setY(centerPointY+(distance*lowerLeft));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
lowerLeft++;
}else if (t<=pointsPerShare*4){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX(centerPointX-(distance*upperLeft));
test1.setY((centerPointY-circleRadius)+(distance*upperLeft));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
upperLeft++;
......@@ -272,40 +309,64 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
numberCycles++;
}
total=total-base;
base = base+20;
base = base+(y*45);
continue;
}
if (base>0){
for (int t=0;numberCycles<dataList.size();t++){
Test test1=new Test();
if (t<pointsPerShare){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((distance*t)+centerPointX);
test1.setY((centerPointY-circleRadius)+(distance*t));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
}else if (t<=pointsPerShare*2){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((centerPointX+circleRadius)-(distance*lowerRight));
test1.setY(centerPointY+(lowerRight*distance));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
lowerRight++;
}else if (t<=pointsPerShare*3){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX((centerPointX-circleRadius)+(distance*lowerLeft));
test1.setY(centerPointY+(distance*lowerLeft));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
lowerLeft++;
}else if (t<=pointsPerShare*4){
//算出A角度数 (每份点数-t)* 每点度数
int Adegrees = (int) ((pointsPerShare-t) * eachDegree);
//Y轴
int a= (int) (circleRadius*Math.sin(Adegrees));
//X轴
int b= (int) (circleRadius*Math.cos(Adegrees));
test1.setId(dataList.get(numberCycles).getTarget());
test1.setName(dataList.get(numberCycles).getName());
test1.setX(centerPointX-(distance*upperLeft));
test1.setY((centerPointY-circleRadius)+(distance*upperLeft));
test1.setX(centerPointX+b);
test1.setY(centerPointY-a);
test1.setColor(code);
test1.setSize(pointSize);
upperLeft++;
......@@ -313,7 +374,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
// /** 将其他点 X Y轴拼接 并存入Redis中*/
// String position=test1.getX()+"Y"+test1.getY();
// conn.set(test1.getId(),position);
list.add(test1);
// list.add(test1);
numberCycles++;
}
break;
......@@ -321,6 +382,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
}
}
// conn.close();
// System.out.println(list.size());
return list;
}
......@@ -339,25 +401,25 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
/**先查询用户信息是转账人还是被转账人 之后将数据存入list中 如果两个都没有就返回null*/
List<SearchRelationshipVo> searchRelationshipVos = new ArrayList<>();
if (searchRelationshipVos1.size()!=0||searchRelationshipVos2.size()!=0){
if (searchRelationshipVos1.size()!=0){
for (int i=0;i<searchRelationshipVos1.size();i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos1.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos1.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos1.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos1.get(i).getCardNumber());
searchRelationshipVos.add(searchRelationshipVo);
}
}else{
for (int i=0;i<searchRelationshipVos2.size();i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos2.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos2.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos2.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos2.get(i).getCardNumber());
searchRelationshipVos.add(searchRelationshipVo);
if (searchRelationshipVos1.size()!=0){
for (int i=0;i<searchRelationshipVos1.size();i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos1.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos1.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos1.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos1.get(i).getCardNumber());
searchRelationshipVos.add(searchRelationshipVo);
}
}else{
for (int i=0;i<searchRelationshipVos2.size();i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos2.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos2.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos2.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos2.get(i).getCardNumber());
searchRelationshipVos.add(searchRelationshipVo);
}
}
}
}else {
return new Result(ResultCode.SUCCESS);
}
......@@ -365,109 +427,109 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
List<SearchRelationshipVo> searchRelationshipVoList = new ArrayList<>();
/**创建map 将已经查询出来的下级存入map中 防止相互转账进入死循环*/
HashMap hashMap=new HashMap();
//转账人
for (int i = 0; i < searchRelationshipVos.size(); i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos.get(i).getCardNumber());
//存入map
hashMap.put(searchRelationshipVos.get(i).getCardNumber(),searchRelationshipVos.get(i).getCardNumber());
/** 查询下级数据*/
List<SearchRelationshipVo> searchRelationshipVoSubordinateList = transferRelationshipMapper.querySubordinate(searchRelationshipVos.get(i).getCardNumber());
/**判断是否有下级 如果有给true*/
if (searchRelationshipVoSubordinateList.size()!=0){
searchRelationshipVo.setSubordinate(true);
}else {
searchRelationshipVo.setSubordinate(false);
//转账人
for (int i = 0; i < searchRelationshipVos.size(); i++) {
SearchRelationshipVo searchRelationshipVo = new SearchRelationshipVo();
searchRelationshipVo.setName(searchRelationshipVos.get(i).getName());
searchRelationshipVo.setRelationship(searchRelationshipVos.get(i).getRelationship());
searchRelationshipVo.setTransferTimes(searchRelationshipVos.get(i).getTransferTimes());
searchRelationshipVo.setCardNumber(searchRelationshipVos.get(i).getCardNumber());
//存入map
hashMap.put(searchRelationshipVos.get(i).getCardNumber(),searchRelationshipVos.get(i).getCardNumber());
/** 查询下级数据*/
List<SearchRelationshipVo> searchRelationshipVoSubordinateList = transferRelationshipMapper.querySubordinate(searchRelationshipVos.get(i).getCardNumber());
/**判断是否有下级 如果有给true*/
if (searchRelationshipVoSubordinateList.size()!=0){
searchRelationshipVo.setSubordinate(true);
}else {
searchRelationshipVo.setSubordinate(false);
}
searchRelationshipVoList.add(searchRelationshipVo);
if (searchRelationshipVoSubordinateList.size() != 0) {
/**存放下级参数list*/
List<SearchRelationshipVo> list = new ArrayList<>();
for (int n = 0; n < searchRelationshipVoSubordinateList.size(); n++) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setName(searchRelationshipVoSubordinateList.get(n).getName());
searchRelationshipSubordinateVo.setCardNumber(searchRelationshipVoSubordinateList.get(n).getCardNumber());
searchRelationshipSubordinateVo.setTransferTimes(searchRelationshipVoSubordinateList.get(n).getTransferTimes());
searchRelationshipSubordinateVo.setRelationship(searchRelationshipVos.get(i).getCardNumber());
List<SearchRelationshipVo> searchRelationshipVoSubordinateList1 = transferRelationshipMapper.querySubordinate(searchRelationshipVoSubordinateList.get(n).getCardNumber());
/**判断是否有下级 如果有给true*/
if (searchRelationshipVoSubordinateList1.size()!=0){
searchRelationshipSubordinateVo.setSubordinate(true);
}else {
searchRelationshipSubordinateVo.setSubordinate(false);
}
//存放数据
searchRelationshipVoList.add(searchRelationshipSubordinateVo);
//存入map
hashMap.put(searchRelationshipVoSubordinateList.get(n).getCardNumber(),searchRelationshipVoSubordinateList.get(n).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
searchRelationshipVoList.add(searchRelationshipVo);
if (searchRelationshipVoSubordinateList.size() != 0) {
/**存放下级参数list*/
List<SearchRelationshipVo> list = new ArrayList<>();
for (int n = 0; n < searchRelationshipVoSubordinateList.size(); n++) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setName(searchRelationshipVoSubordinateList.get(n).getName());
searchRelationshipSubordinateVo.setCardNumber(searchRelationshipVoSubordinateList.get(n).getCardNumber());
searchRelationshipSubordinateVo.setTransferTimes(searchRelationshipVoSubordinateList.get(n).getTransferTimes());
searchRelationshipSubordinateVo.setRelationship(searchRelationshipVos.get(i).getCardNumber());
List<SearchRelationshipVo> searchRelationshipVoSubordinateList1 = transferRelationshipMapper.querySubordinate(searchRelationshipVoSubordinateList.get(n).getCardNumber());
/**判断是否有下级 如果有给true*/
if (searchRelationshipVoSubordinateList1.size()!=0){
searchRelationshipSubordinateVo.setSubordinate(true);
}else {
searchRelationshipSubordinateVo.setSubordinate(false);
}
//存放数据
searchRelationshipVoList.add(searchRelationshipSubordinateVo);
//存入map
hashMap.put(searchRelationshipVoSubordinateList.get(n).getCardNumber(),searchRelationshipVoSubordinateList.get(n).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
for (int r = 0; r < 1; ) {
//临时存储查询出来的参数
List<SearchRelationshipVo> list1 = new ArrayList<>();
for (int y = 0; y < list.size(); y++) {
List<SearchRelationshipVo> searchRelationshipVoSubordinateList1 = transferRelationshipMapper.querySubordinate(list.get(y).getCardNumber());
if (searchRelationshipVoSubordinateList1.size() != 0) {
for (int l=0;l<searchRelationshipVoSubordinateList1.size();l++) {
/**根据下级卡号 对比map 如果已经有值代表已经查询出过此卡号 跳过此次循环开启下一圈*/
Object number = hashMap.get(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
if (number==null) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setName(searchRelationshipVoSubordinateList1.get(l).getName());
searchRelationshipSubordinateVo.setCardNumber(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
searchRelationshipSubordinateVo.setRelationship(list.get(y).getCardNumber());
searchRelationshipSubordinateVo.setTransferTimes(searchRelationshipVoSubordinateList1.get(l).getTransferTimes());
List<SearchRelationshipVo> searchRelationshipVoSubordinateList2 = transferRelationshipMapper.querySubordinate(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
if (searchRelationshipVoSubordinateList2.size()!=0){
searchRelationshipSubordinateVo.setSubordinate(true);
}else {
searchRelationshipSubordinateVo.setSubordinate(false);
}
searchRelationshipVoList.add(searchRelationshipSubordinateVo);
list1.add(searchRelationshipSubordinateVo);
//存入map
hashMap.put(searchRelationshipVoSubordinateList1.get(l).getCardNumber(), searchRelationshipVoSubordinateList1.get(l).getCardNumber());
for (int r = 0; r < 1; ) {
//临时存储查询出来的参数
List<SearchRelationshipVo> list1 = new ArrayList<>();
for (int y = 0; y < list.size(); y++) {
List<SearchRelationshipVo> searchRelationshipVoSubordinateList1 = transferRelationshipMapper.querySubordinate(list.get(y).getCardNumber());
if (searchRelationshipVoSubordinateList1.size() != 0) {
for (int l=0;l<searchRelationshipVoSubordinateList1.size();l++) {
/**根据下级卡号 对比map 如果已经有值代表已经查询出过此卡号 跳过此次循环开启下一圈*/
Object number = hashMap.get(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
if (number==null) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setName(searchRelationshipVoSubordinateList1.get(l).getName());
searchRelationshipSubordinateVo.setCardNumber(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
searchRelationshipSubordinateVo.setRelationship(list.get(y).getCardNumber());
searchRelationshipSubordinateVo.setTransferTimes(searchRelationshipVoSubordinateList1.get(l).getTransferTimes());
List<SearchRelationshipVo> searchRelationshipVoSubordinateList2 = transferRelationshipMapper.querySubordinate(searchRelationshipVoSubordinateList1.get(l).getCardNumber());
if (searchRelationshipVoSubordinateList2.size()!=0){
searchRelationshipSubordinateVo.setSubordinate(true);
}else {
searchRelationshipSubordinateVo.setSubordinate(false);
}
searchRelationshipVoList.add(searchRelationshipSubordinateVo);
list1.add(searchRelationshipSubordinateVo);
//存入map
hashMap.put(searchRelationshipVoSubordinateList1.get(l).getCardNumber(), searchRelationshipVoSubordinateList1.get(l).getCardNumber());
}
}
}
//清空上一级的参数
list.clear();
if (list1.size() == 0) {
r++;
}
//将新查询出来下一级的参数放入list当中
for (int v = 0; v < list1.size(); v++) {
/**循环完成后 判断只让有下级的人进入下次循环*/
if (list1.get(v).getSubordinate()){
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setCardNumber(list1.get(v).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
}
list1.clear();
}
//清空上一级的参数
list.clear();
if (list1.size() == 0) {
r++;
}
//将新查询出来下一级的参数放入list当中
for (int v = 0; v < list1.size(); v++) {
/**循环完成后 判断只让有下级的人进入下次循环*/
if (list1.get(v).getSubordinate()){
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setCardNumber(list1.get(v).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
}
list1.clear();
}
}
RelationalAlgorithm relationalAlgorithm=new RelationalAlgorithm();
//生成Redis随机数
int intFlag = (int)(Math.random() * 1000000);
//开启redis
Jedis redis = ConFigRedis.getConn();
int o=0;
for (int i=0;i<searchRelationshipVoList.size();i++){
if (searchRelationshipVoList.get(i).getSubordinate()){
redis.set(intFlag+"cardnumbe"+o++,searchRelationshipVoList.get(i).getCardNumber());
}
}
RelationalAlgorithm relationalAlgorithm=new RelationalAlgorithm();
//生成Redis随机数
int intFlag = (int)(Math.random() * 1000000);
//开启redis
Jedis redis = ConFigRedis.getConn();
int o=0;
for (int i=0;i<searchRelationshipVoList.size();i++){
if (searchRelationshipVoList.get(i).getSubordinate()){
redis.set(intFlag+"cardnumbe"+o++,searchRelationshipVoList.get(i).getCardNumber());
}
//关闭redis
redis.close();
List list = relationalAlgorithm.searchPresentation(searchRelationshipVoList,intFlag);
return new Result(ResultCode.SUCCESS,list);
}
//关闭redis
redis.close();
List list = relationalAlgorithm.searchPresentation(searchRelationshipVoList,intFlag);
return new Result(ResultCode.SUCCESS,list);
}catch (Exception e){
return new Result(ResultCode.FAIL);
}
......@@ -732,87 +794,87 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
superiorList.add(searchRelationshipSubordinateVo);
//向防止重复map添加已经查询到的上级卡号
hashMap1.put(searchRelationshipSubordinateVo.getCardNumber(),searchRelationshipSubordinateVo.getCardNumber());
for (int b=0;b<1;) {
for (int a = 0; a < superiorList.size(); a++) {
for (int b=0;b<1;) {
for (int a = 0; a < superiorList.size(); a++) {
//存放查询出来的上级信息
List<SearchRelationshipVo> superior=new ArrayList<>();
//循环查询出来的上级信息 之后将查出来的上级信息存入到list中
for (int m=0;m<superiorList.size();m++){
//查询上级转账人方法
List<SearchRelationshipVo> superior1 = transferRelationshipMapper.querySuperior(superiorList.get(m).getCardNumber());
for (int j=0;j<superior1.size();j++){
superior.add(superior1.get(j));
}
}
//清空list数据
superiorList.clear();
//判断上级是否是转账人 如果是 就直接返回数据
for (int h = 0; h < superior.size(); h++) {
if (superior.get(h).getCardNumber().equals(transferAssociationParam.getTransfer())) {
List<SearchRelationshipVo> searchRelationshipVoList2 = transferLocation.transferLocation(transferAssociationList);
return new Result(ResultCode.SUCCESS, searchRelationshipVoList2);
}
}
//循环对比查询出来的上级与所有list存储的下级做对比
for (int k = 0; k < searchRelationshipVoList.size(); k++) {
for (int n = 0; n < superior.size(); n++) {
//对比
if (superior.get(n).getCardNumber().equals(searchRelationshipVoList.get(k).getCardNumber())) {
SearchRelationshipVo searchRelationshipSubordinateVo1 = new SearchRelationshipVo();
searchRelationshipSubordinateVo1.setCardNumber(superior.get(n).getCardNumber());
searchRelationshipSubordinateVo1.setName(superior.get(n).getName());
searchRelationshipSubordinateVo1.setX((int) (Math.random() * 2000));
searchRelationshipSubordinateVo1.setY((int) (Math.random() * 800));
searchRelationshipSubordinateVo1.setColor(colour.getColour());
searchRelationshipSubordinateVo1.setSize(10);
searchRelationshipSubordinateVo1.setHierarchy(searchRelationshipVoList.get(k).getHierarchy());
searchRelationshipSubordinateVo1.setSubordinateQuantity(searchRelationshipVoList.get(k).getSubordinateQuantity());
Object Number = hashMap1.get(superior.get(n).getCardNumber());
if (Number==null){
//添加被转账人信息
transferAssociationList.add(searchRelationshipSubordinateVo1);
//向防止重复map添加已经查询到的上级卡号
hashMap1.put(superior.get(n).getCardNumber(), superior.get(n).getCardNumber());
}
superiorList.add(searchRelationshipSubordinateVo1);
}
}
}
}
}
}
//存放查询出来的上级信息
List<SearchRelationshipVo> superior=new ArrayList<>();
//循环查询出来的上级信息 之后将查出来的上级信息存入到list中
for (int m=0;m<superiorList.size();m++){
//查询上级转账人方法
List<SearchRelationshipVo> superior1 = transferRelationshipMapper.querySuperior(superiorList.get(m).getCardNumber());
for (int j=0;j<superior1.size();j++){
superior.add(superior1.get(j));
}
}
//清空list数据
superiorList.clear();
//判断上级是否是转账人 如果是 就直接返回数据
for (int h = 0; h < superior.size(); h++) {
if (superior.get(h).getCardNumber().equals(transferAssociationParam.getTransfer())) {
List<SearchRelationshipVo> searchRelationshipVoList2 = transferLocation.transferLocation(transferAssociationList);
return new Result(ResultCode.SUCCESS, searchRelationshipVoList2);
}
}
//循环对比查询出来的上级与所有list存储的下级做对比
for (int k = 0; k < searchRelationshipVoList.size(); k++) {
for (int n = 0; n < superior.size(); n++) {
//对比
if (superior.get(n).getCardNumber().equals(searchRelationshipVoList.get(k).getCardNumber())) {
SearchRelationshipVo searchRelationshipSubordinateVo1 = new SearchRelationshipVo();
searchRelationshipSubordinateVo1.setCardNumber(superior.get(n).getCardNumber());
searchRelationshipSubordinateVo1.setName(superior.get(n).getName());
searchRelationshipSubordinateVo1.setX((int) (Math.random() * 2000));
searchRelationshipSubordinateVo1.setY((int) (Math.random() * 800));
searchRelationshipSubordinateVo1.setColor(colour.getColour());
searchRelationshipSubordinateVo1.setSize(10);
searchRelationshipSubordinateVo1.setHierarchy(searchRelationshipVoList.get(k).getHierarchy());
searchRelationshipSubordinateVo1.setSubordinateQuantity(searchRelationshipVoList.get(k).getSubordinateQuantity());
Object Number = hashMap1.get(superior.get(n).getCardNumber());
if (Number==null){
//添加被转账人信息
transferAssociationList.add(searchRelationshipSubordinateVo1);
//向防止重复map添加已经查询到的上级卡号
hashMap1.put(superior.get(n).getCardNumber(), superior.get(n).getCardNumber());
}
superiorList.add(searchRelationshipSubordinateVo1);
}
}
}
}
}
}
}
}
}
//清空上一级的参数
list.clear();
if (list1.size() == 0) {
r++;
}
//将新查询出来下一级的参数放入list当中
for (int v = 0; v < list1.size(); v++) {
/**循环完成后 判断只让有下级的人进入下次循环*/
if (list1.get(v).getSubordinate()) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setCardNumber(list1.get(v).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
}
//清空上一级的参数
list.clear();
if (list1.size() == 0) {
r++;
}
//将新查询出来下一级的参数放入list当中
for (int v = 0; v < list1.size(); v++) {
/**循环完成后 判断只让有下级的人进入下次循环*/
if (list1.get(v).getSubordinate()) {
SearchRelationshipVo searchRelationshipSubordinateVo = new SearchRelationshipVo();
searchRelationshipSubordinateVo.setCardNumber(list1.get(v).getCardNumber());
list.add(searchRelationshipSubordinateVo);
}
list1.clear();
}
list1.clear();
}
}
for (int p = 0; p < searchRelationshipVoList.size(); p++) {
if (searchRelationshipVoList.get(p).getCardNumber() == transferAssociationParam.getPayee()) {
List<SearchRelationshipVo> searchRelationshipVoList2 = transferLocation.transferLocation(searchRelationshipVoList);
return new Result(ResultCode.SUCCESS, searchRelationshipVoList2);
}
}
for (int p = 0; p < searchRelationshipVoList.size(); p++) {
if (searchRelationshipVoList.get(p).getCardNumber() == transferAssociationParam.getPayee()) {
List<SearchRelationshipVo> searchRelationshipVoList2 = transferLocation.transferLocation(searchRelationshipVoList);
return new Result(ResultCode.SUCCESS, searchRelationshipVoList2);
}
//如果没有 就返回null
return new Result(ResultCode.SUCCESS, null);
}
//如果没有 就返回null
return new Result(ResultCode.SUCCESS, null);
}
/**
......@@ -887,20 +949,20 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
List<TransferRelationship> transferRelationshipList=new ArrayList();
for (int k=0;k<list.size();k++){
TransferRelationship transferRelationship=new TransferRelationship();
for (int n=0;n<transferAssociationParam.size();n++){
if (list.get(k).getSource().getId().equals(transferAssociationParam.get(n).getCardNumber())){
Source source=new Source();
String o= String.valueOf(n);
source.setId(o);
transferRelationship.setSource(source);
}
if (list.get(k).getTarget().getId().equals(transferAssociationParam.get(n).getCardNumber())){
Target target=new Target();
String o= String.valueOf(n);
target.setId(o);
transferRelationship.setTarget(target);
}
}
for (int n=0;n<transferAssociationParam.size();n++){
if (list.get(k).getSource().getId().equals(transferAssociationParam.get(n).getCardNumber())){
Source source=new Source();
String o= String.valueOf(n);
source.setId(o);
transferRelationship.setSource(source);
}
if (list.get(k).getTarget().getId().equals(transferAssociationParam.get(n).getCardNumber())){
Target target=new Target();
String o= String.valueOf(n);
target.setId(o);
transferRelationship.setTarget(target);
}
}
transferRelationship.setTransferTimes(list.get(k).getTransferTimes());
transferRelationshipList.add(transferRelationship);
}
......@@ -952,7 +1014,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
transferAssociationList.add(TransferRelationship.class.cast(o));
}
}
/**将已经获取到的关系数据放入新list当中返回*/
/**将已经获取到的关系数据放入新list当中返回*/
List<EchartsTrBetweenTwoPersonsVo> echartsTrBetweenTwoPersonsVosList=new ArrayList<>();
for (int i=0;i<transferAssociationList.size();i++){
EchartsTrBetweenTwoPersonsVo echartsTrBetweenTwoPersonsVo=new EchartsTrBetweenTwoPersonsVo();
......@@ -973,7 +1035,7 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
lineStyle line=new lineStyle();
line.setCurveness(curveValue);
echartsTrBetweenTwoPersonsVosList.get(p).setLineStyle(line);
curveValue=curveValue+0.01;
curveValue=curveValue+0.01;
}else {
lineStyle line=new lineStyle();
line.setCurveness(curveValue);
......
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