Commit 6d9418b1 authored by wanglong's avatar wanglong

完善箱线图接口功能

parent 368450a2
package com.yeejoin.amos.boot.module.cas.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.module.cas.api.dto.IdxBizXnzsDto;
......@@ -39,36 +40,41 @@ public class IdxBizXnzsServiceImpl extends BaseService<IdxBizXnzsDto, IdxBizXnzs
List<IdxBizXnzsDto> xnzsDtoList = idxBizXnzsMapper.select();
List<String> axisData = new ArrayList<>();
List<List<Double>> seriesDataList=new ArrayList<>();
// List<List<Double>> seriesDataList=new ArrayList<>();
List<JSONObject> seriesDataList = new ArrayList<>();
String [] borderColor = {"#5966e6","#e7533b","#00c190","#8f57da","#f59c59","#19d3f3","#ff6692","#b6e880","#413a68","#f5c551","#4857c2","#ed553b","#01bb8d","#a561f3" };
String [] color = {"#354599","#7b393a","#047569","#584099","#835f4a","#15a7c7","#834166","#5e825c","#835a9c","#a18a49","#354599","#7b393b","#037569","#6f4ab4"};
int i = 0;
for(IdxBizXnzsDto bizXnzsDto : xnzsDtoList){
List<Double> list=new ArrayList<>();
// List<Double> list=new ArrayList<>();
JSONObject firstJson = new JSONObject();
JSONObject secondJson = new JSONObject();
JSONObject thirdly = new JSONObject();
axisData.add(bizXnzsDto.getAxisData());
Double one = bizXnzsDto.getOne();
Double two = bizXnzsDto.getTwo();
Double three = bizXnzsDto.getThree();
Double four = bizXnzsDto.getFour();
JSONArray json = new JSONArray();
Double min;
Double[] doubles = {one,two,three,four};
Double[] doubles = {bizXnzsDto.getOne(),bizXnzsDto.getTwo(),bizXnzsDto.getThree(),bizXnzsDto.getFour()};
thirdly.put("borderWidth","2");
thirdly.put("borderColor",borderColor[i]);
thirdly.put("color",color[i]);
secondJson.put("normal",thirdly);
i = i+1;
Arrays.sort(doubles);
list.add(doubles[0]);
list.add((doubles[0]+doubles[1])/2);
list.add((doubles[1]+doubles[2])/2);
list.add((doubles[2]+doubles[3])/2);
list.add(doubles[3]);
seriesDataList.add(list);
json.add(doubles[0]);
json.add((doubles[0]+doubles[1])/2);
json.add((doubles[1]+doubles[2])/2);
json.add((doubles[2]+doubles[3])/2);
json.add(doubles[3]);
firstJson.put("value",json);
firstJson.put("itemStyle",secondJson);
seriesDataList.add(firstJson);
// seriesDataList.add(list);
}
System.out.println(seriesDataList);
// ResultDto resultDto = new ResultDto();
// resultDto.setAxisData(axisData);
// resultDto.setSeriesData(seriesDataList);
message.put("axisData",axisData);
message.put("seriesData",seriesDataList);
......@@ -87,39 +93,57 @@ public class IdxBizXnzsServiceImpl extends BaseService<IdxBizXnzsDto, IdxBizXnzs
*/
JSONObject message = new JSONObject();
List<String> axisData=new ArrayList<>();
List<List<Double>> seriesDataList=new ArrayList<>();
// List<List<Double>> seriesDataList=new ArrayList<>();
List<JSONObject> seriesDataList = new ArrayList<>();
/**
* 颜色
*/
String [] borderColor = {"#5966e6","#e7533b","#00c190","#8f57da","#f59c59","#19d3f3","#ff6692","#b6e880","#413a68","#f5c551","#4857c2","#ed553b","#01bb8d","#a561f3" };
String [] color = {"#354599","#7b393a","#047569","#584099","#835f4a","#15a7c7","#834166","#5e825c","#835a9c","#a18a49","#354599","#7b393b","#037569","#6f4ab4"};
int i =0;
/**
* 获取政务大列数据
*/
List<IdxBizXnzsDto> zwdlDto = idxBizXnzsMapper.selectZwdl();
log.info(zwdlDto.toString());
/**
* 组装返回数据
*/
for(IdxBizXnzsDto idxBizXnzsDto : zwdlDto ) {
/**
* 子数据
*/
JSONObject firstJson = new JSONObject();
JSONObject secondJson = new JSONObject();
JSONObject thirdly = new JSONObject();
//预返回箱线图数据
List<Double> list = new ArrayList<>();
// List<Double> list = new ArrayList<>();
JSONArray json = new JSONArray();
//添加政务大类
axisData.add(idxBizXnzsDto.getAxisData());
//添加最近四季度
Double[] ottf = {idxBizXnzsDto.getOne(),idxBizXnzsDto.getTwo(),idxBizXnzsDto.getThree(), idxBizXnzsDto.getFour()};
log.info(String.valueOf(idxBizXnzsDto.getOne()));
thirdly.put("borderWidth","2");
thirdly.put("borderColor",borderColor[i]);
thirdly.put("color",color[i]);
secondJson.put("normal",thirdly);
i = i+1;
//排序(从小到大)
Arrays.sort(ottf);
/**
* 添加箱线图数据
*/
list.add(ottf[0]);
list.add((ottf[0]+ottf[1])/2);
list.add((ottf[1]+ottf[2])/2);
list.add((ottf[2]+ottf[3])/2);
list.add(ottf[3]);
json.add(ottf[0]);
json.add((ottf[0]+ottf[1])/2);
json.add((ottf[1]+ottf[2])/2);
json.add((ottf[2]+ottf[3])/2);
json.add(ottf[3]);
firstJson.put("value",json);
firstJson.put("itemStyle",secondJson);
seriesDataList.add(firstJson);
seriesDataList.add(list);
}
message.put("seriesData",seriesDataList);
......
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