Commit 6a758e9e authored by wuqinghua's avatar wuqinghua

2021/11/16 吴卿华 增加echarts双人转账关系图接口 修改双人转账关系图显示位置

parent 4cb08521
package com.example.gajz.transferrelationship.bean.echarts;
import lombok.Data;
import lombok.ToString;
/**
* echarts 关系图
*/
@Data
@ToString
public class lineStyle {
/**
* 关系线曲度
*/
private double curveness;
}
package com.example.gajz.transferrelationship.bean.vo;
import lombok.Data;
import lombok.ToString;
/**
* echarts 双人转账关系图 关系 生成接口 返回值封装类
*/
@Data
@ToString
public class EchartsTrBetweenTwoPersonsVo {
/**
* 转账人
*/
private String source;
/**
* 收款人
*/
private String target;
/**
* 关系线曲度
*/
private com.example.gajz.transferrelationship.bean.echarts.lineStyle lineStyle;
}
......@@ -93,8 +93,8 @@ public class TransferLocation {
int total = parameterList.size();
//判断上级卡号是否是转账人 如果是就设置初始xy轴
if (searchRelationshipVoList.get(i).getHierarchy()==1){
searchRelationshipVoList.get(i).setY((int) (Math.random() * 200));
searchRelationshipVoList.get(i).setX((int) (Math.random() * 200));
searchRelationshipVoList.get(i).setY(300);
searchRelationshipVoList.get(i).setX(300);
searList.add(searchRelationshipVoList.get(i));
int centerPointX=searchRelationshipVoList.get(i).getX();
int centerPointY=searchRelationshipVoList.get(i).getY();
......@@ -103,18 +103,24 @@ public class TransferLocation {
/**循环下级点数 计算下级X Y轴位置*/
for (int y=1;total>0;y++){
/**点之间 x轴y轴间隔距离*/
int distance=30;
int distance=100;
/**圆分成两份 */
int pointsPerShare = base/2;
/**小圆半径 点数X距离*/
int circleRadius = 100;
/**右上逐渐递增*/
/**小圆半径 */
int circleRadius = 300;
/**X逐渐递增*/
int lowerRight = 0;
/**Y逐渐递增*/
int lowerRightY= 0;
if (base<=total){
for (int t=0;t<base;t++){
SearchRelationshipVo searchRelationship=new SearchRelationshipVo();
if (t<pointsPerShare){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
}
searchRelationship.setY(centerPointY-(distance*lowerRight));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
......@@ -124,15 +130,19 @@ public class TransferLocation {
searList.add(searchRelationship);
lowerRight++;
}else if (t<=pointsPerShare*2){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
searchRelationship.setY(centerPointY+(lowerRight*distance));
}
searchRelationship.setY(centerPointY+(lowerRightY*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
searchRelationship.setHierarchy(parameterList.get(numberCycles).getHierarchy());
searchRelationship.setCardNumber(parameterList.get(numberCycles).getCardNumber());
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
searList.add(searchRelationship);
lowerRight++;
lowerRightY++;
}
numberCycles++;
}
......@@ -144,7 +154,11 @@ public class TransferLocation {
for (int t=0;numberCycles<parameterList.size();t++){
SearchRelationshipVo searchRelationship=new SearchRelationshipVo();
if (t<pointsPerShare){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
}
searchRelationship.setY(centerPointY-(lowerRight*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
......@@ -153,15 +167,19 @@ public class TransferLocation {
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
lowerRight++;
}else if (t<=pointsPerShare*2){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
searchRelationship.setY(centerPointY+(lowerRight*distance));
}
searchRelationship.setY(centerPointY+(lowerRightY*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
searchRelationship.setHierarchy(parameterList.get(numberCycles).getHierarchy());
searchRelationship.setCardNumber(parameterList.get(numberCycles).getCardNumber());
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
searList.add(searchRelationship);
lowerRight++;
lowerRightY++;
}
searList.add(searchRelationship);
numberCycles++;
......@@ -181,18 +199,24 @@ public class TransferLocation {
/**循环下级点数 计算下级X Y轴位置*/
for (int y=1;total>0;y++){
/**点之间 x轴y轴间隔距离*/
int distance=30;
int distance=100;
/**圆分成两份 */
int pointsPerShare = base/2;
/**半径*/
int circleRadius = 300;
/**右下角逐渐递减*/
int lowerRight = 0;
int lowerRight = 1;
/**Y逐渐递增*/
int lowerRightY= 1;
if (base<=total){
for (int t=0;t<base;t++){
SearchRelationshipVo searchRelationship=new SearchRelationshipVo();
if (t<pointsPerShare){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
}
searchRelationship.setY(centerPointY-(lowerRight*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
......@@ -202,15 +226,19 @@ public class TransferLocation {
searList.add(searchRelationship);
lowerRight++;
}else if (t<=pointsPerShare*2){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
searchRelationship.setY(centerPointY+(lowerRight*distance));
}
searchRelationship.setY(centerPointY+(lowerRightY*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
searchRelationship.setHierarchy(parameterList.get(numberCycles).getHierarchy());
searchRelationship.setCardNumber(parameterList.get(numberCycles).getCardNumber());
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
searList.add(searchRelationship);
lowerRight++;
lowerRightY++;
}
numberCycles++;
}
......@@ -222,7 +250,11 @@ public class TransferLocation {
for (int t=0;numberCycles<parameterList.size();t++){
SearchRelationshipVo searchRelationship=new SearchRelationshipVo();
if (t<pointsPerShare){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
}
searchRelationship.setY(centerPointY-(lowerRight*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
......@@ -231,15 +263,19 @@ public class TransferLocation {
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
lowerRight++;
}else if (t<=pointsPerShare*2){
if(t%2==0){
searchRelationship.setX(centerPointX+circleRadius+50);
}else {
searchRelationship.setX(centerPointX+circleRadius);
searchRelationship.setY(centerPointY+(lowerRight*distance));
}
searchRelationship.setY(centerPointY+(lowerRightY*distance));
searchRelationship.setName(parameterList.get(numberCycles).getName());
searchRelationship.setColor(parameterList.get(numberCycles).getColor());
searchRelationship.setHierarchy(parameterList.get(numberCycles).getHierarchy());
searchRelationship.setCardNumber(parameterList.get(numberCycles).getCardNumber());
searchRelationship.setSize(parameterList.get(numberCycles).getSize());
searList.add(searchRelationship);
lowerRight++;
lowerRightY++;
}
searList.add(searchRelationship);
numberCycles++;
......
......@@ -78,4 +78,18 @@ public interface TransferRelationshipService {
* @return
*/
Result trBetweenTwoPersons(List<SearchRelationshipVo> transferAssociationParam);
/**
* echarts 双人转账关系图 点 生成接口
* @param transferAssociationParam
* @return
*/
Result echartsTransferAssociation(TransferAssociationParam transferAssociationParam);
/**
* echarts 双人转账关系图 关系 生成接口
* @param transferAssociationParam
* @return
*/
Result echartsTrBetweenTwoPersons(List<SearchRelationshipVo> transferAssociationParam);
}
......@@ -3,6 +3,7 @@ import com.example.gajz.redis.ConFigRedis;
import com.example.gajz.result.Result;
import com.example.gajz.result.ResultCode;
import com.example.gajz.transferrelationship.bean.dto.*;
import com.example.gajz.transferrelationship.bean.echarts.lineStyle;
import com.example.gajz.transferrelationship.bean.excel.abcExcie;
import com.example.gajz.transferrelationship.bean.param.TransferAssociationParam;
import com.example.gajz.transferrelationship.bean.vo.*;
......@@ -870,4 +871,81 @@ public class TransferRelationshipServiceImpl implements TransferRelationshipServ
}
return new Result(ResultCode.SUCCESS,list);
}
/**
* echarts 双人转账关系图 点 生成接口
* @param transferAssociationParam
* @return
*/
@Override
public Result echartsTransferAssociation(TransferAssociationParam transferAssociationParam) {
Result result = this.transferAssociation(transferAssociationParam);
Object obj = result.getData();
/**将有关系的数据放入这个list中 */
List<SearchRelationshipVo> transferAssociationList = new ArrayList<>();
if (obj instanceof ArrayList<?>) {
for (Object o : (List<?>) obj) {
transferAssociationList.add(SearchRelationshipVo.class.cast(o));
}
}
List<EchartsUserVo> list=new ArrayList<>();
for (int i=0;i<transferAssociationList.size();i++){
EchartsUserVo echartsUserVo=new EchartsUserVo();
echartsUserVo.setY(transferAssociationList.get(i).getY());
echartsUserVo.setX(transferAssociationList.get(i).getX());
echartsUserVo.setName(transferAssociationList.get(i).getCardNumber());
list.add(echartsUserVo);
}
return new Result(ResultCode.SUCCESS,list);
}
/**
* echarts 双人转账关系图 关系 生成接口
* @param transferAssociationParam
* @return
*/
@Override
public Result echartsTrBetweenTwoPersons(List<SearchRelationshipVo> transferAssociationParam) {
Result result = this.trBetweenTwoPersons(transferAssociationParam);
Object obj = result.getData();
/**将有关系的数据放入这个list中 */
List<TransferRelationship> transferAssociationList = new ArrayList<>();
if (obj instanceof ArrayList<?>) {
for (Object o : (List<?>) obj) {
transferAssociationList.add(TransferRelationship.class.cast(o));
}
}
/**将已经获取到的关系数据放入新list当中返回*/
List<EchartsTrBetweenTwoPersonsVo> echartsTrBetweenTwoPersonsVosList=new ArrayList<>();
for (int i=0;i<transferAssociationList.size();i++){
EchartsTrBetweenTwoPersonsVo echartsTrBetweenTwoPersonsVo=new EchartsTrBetweenTwoPersonsVo();
echartsTrBetweenTwoPersonsVo.setSource(transferAssociationList.get(i).getSource().getId());
echartsTrBetweenTwoPersonsVo.setTarget(transferAssociationList.get(i).getTarget().getId());
echartsTrBetweenTwoPersonsVosList.add(echartsTrBetweenTwoPersonsVo);
}
/**计算转账关系曲线*/
for (int p=0;p<echartsTrBetweenTwoPersonsVosList.size();p++){
//转账共有几人
int frequency=0;
//曲线值
double curveValue=0.01;
for (int k=0;k<echartsTrBetweenTwoPersonsVosList.size();k++){
if (echartsTrBetweenTwoPersonsVosList.get(p).getSource().equals(echartsTrBetweenTwoPersonsVosList.get(k).getSource())){
frequency++;
if (frequency>2){
lineStyle line=new lineStyle();
line.setCurveness(curveValue);
echartsTrBetweenTwoPersonsVosList.get(p).setLineStyle(line);
curveValue=curveValue+0.01;
}else {
lineStyle line=new lineStyle();
line.setCurveness(curveValue);
echartsTrBetweenTwoPersonsVosList.get(p).setLineStyle(line);
}
}
}
}
return new Result(ResultCode.SUCCESS,echartsTrBetweenTwoPersonsVosList);
}
}
......@@ -96,8 +96,10 @@
<!--查询搜索人关联下一级数据-->
<select id="querySubordinate" resultType="com.example.gajz.transferrelationship.bean.vo.SearchRelationshipVo">
select end_account_name as name,end_card_no as cardNumber,count(end_card_no) as transferTimes
from abc_statement where end_account_name is not null and end_card_no is not null and
bank_card_no=#{cardNumber} group by end_card_no
from abc_statement
where end_account_name is not null
and end_card_no is not null
and bank_card_no=#{cardNumber} group by end_card_no
</select>
<!--查询转账人-->
......@@ -138,7 +140,8 @@
<!--查询上级转账人方法-->
<select id="querySuperior" resultType="com.example.gajz.transferrelationship.bean.vo.SearchRelationshipVo">
select bank_account_name as name ,bank_card_no as cardNumber from abc_statement where end_card_no=#{cardNumbe} and bank_card_no is not null
select bank_account_name as name ,bank_card_no as cardNumber from abc_statement where end_card_no=#{cardNumbe}
and bank_card_no is not null
group by bank_card_no
</select>
......
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