代码提交
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
package com.njcn.echarts.json;
|
package com.njcn.echarts.json;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
import com.njcn.echarts.pojo.bo.TolerateData;
|
import com.njcn.echarts.pojo.bo.TolerateData;
|
||||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||||
import org.icepear.echarts.Option;
|
import org.icepear.echarts.Option;
|
||||||
|
import org.icepear.echarts.charts.bar.BarLabel;
|
||||||
import org.icepear.echarts.charts.bar.BarSeries;
|
import org.icepear.echarts.charts.bar.BarSeries;
|
||||||
import org.icepear.echarts.charts.line.LineSeries;
|
import org.icepear.echarts.charts.line.LineSeries;
|
||||||
|
import org.icepear.echarts.charts.pie.PieLabel;
|
||||||
|
import org.icepear.echarts.charts.pie.PieSeries;
|
||||||
import org.icepear.echarts.charts.scatter.ScatterSeries;
|
import org.icepear.echarts.charts.scatter.ScatterSeries;
|
||||||
import org.icepear.echarts.components.coord.AxisNameTextStyle;
|
import org.icepear.echarts.components.coord.AxisNameTextStyle;
|
||||||
import org.icepear.echarts.components.coord.SplitLine;
|
import org.icepear.echarts.components.coord.SplitLine;
|
||||||
@@ -19,7 +23,9 @@ import org.icepear.echarts.components.tooltip.Tooltip;
|
|||||||
import org.icepear.echarts.origin.util.SeriesOption;
|
import org.icepear.echarts.origin.util.SeriesOption;
|
||||||
import org.icepear.echarts.render.Engine;
|
import org.icepear.echarts.render.Engine;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,5 +221,110 @@ public class LineGenerator {
|
|||||||
return ENGINE.renderJsonOption(iticOption);
|
return ENGINE.renderJsonOption(iticOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 生成月份统计
|
||||||
|
* @author wr
|
||||||
|
* @date 2023/6/21 10:06
|
||||||
|
*/
|
||||||
|
public static String generateMonthOption(List<String> xName, List<Integer> times, String year, Integer flag) {
|
||||||
|
xName.set(0, xName.get(0) + "\n" + "(" + year + ")");
|
||||||
|
String name = "";
|
||||||
|
Option iticOption = new Option();
|
||||||
|
//取消渲染动画
|
||||||
|
iticOption.setAnimation(false);
|
||||||
|
//背景色
|
||||||
|
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||||
|
//标题
|
||||||
|
if (flag == 0) {
|
||||||
|
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("月份统计"));
|
||||||
|
name = "月份";
|
||||||
|
} else {
|
||||||
|
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("天数统计"));
|
||||||
|
name = "天数";
|
||||||
|
}
|
||||||
|
//上下左右的图内间距
|
||||||
|
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||||
|
//设置图例
|
||||||
|
iticOption.setLegend(new Legend().setData(new String[]{"暂降次数"}).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||||
|
//设置图例对应的颜色
|
||||||
|
iticOption.setColor(new String[]{"#FF8C00"});
|
||||||
|
//横坐标
|
||||||
|
iticOption.setXAxis(new CategoryAxis()
|
||||||
|
.setBoundaryGap(true)
|
||||||
|
.setName(name)
|
||||||
|
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||||
|
.setData(xName.toArray())
|
||||||
|
);
|
||||||
|
//纵坐标
|
||||||
|
iticOption.setYAxis(new ValueAxis[]{
|
||||||
|
new ValueAxis()
|
||||||
|
.setName("次")
|
||||||
|
.setType("value")
|
||||||
|
});
|
||||||
|
|
||||||
|
//配置暂降次数
|
||||||
|
BarSeries probability = new BarSeries()
|
||||||
|
.setName("暂降次数")
|
||||||
|
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||||
|
.setData(times);
|
||||||
|
iticOption.setSeries(new SeriesOption[]{probability});
|
||||||
|
return ENGINE.renderJsonOption(iticOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 生成暂降原因
|
||||||
|
* @author wr
|
||||||
|
* @date 2023/6/21 10:06
|
||||||
|
*/
|
||||||
|
public static String generateReasonOption(List<String> xName, List<Map<String,Object>> map2) {
|
||||||
|
|
||||||
|
Option iticOption = new Option();
|
||||||
|
//取消渲染动画
|
||||||
|
iticOption.setAnimation(false);
|
||||||
|
//背景色
|
||||||
|
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||||
|
//标题
|
||||||
|
iticOption.setTitle(new Title().setRight("10%").setText("暂降原因"));
|
||||||
|
//上下左右的图内间距
|
||||||
|
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||||
|
//设置图例
|
||||||
|
iticOption.setLegend(new Legend().setOrient("vertical").setData(xName.toArray()).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||||
|
String s = map2.toString();
|
||||||
|
//配置暂降次数
|
||||||
|
PieSeries probability = new PieSeries()
|
||||||
|
.setType("pie")
|
||||||
|
.setName("暂降原因")
|
||||||
|
.setLabel(new PieLabel().setFormatter("{b}:{d}%"))
|
||||||
|
.setData(map2);
|
||||||
|
iticOption.setSeries(new SeriesOption[]{probability});
|
||||||
|
return ENGINE.renderJsonOption(iticOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 生成暂降类型
|
||||||
|
* @author wr
|
||||||
|
* @date 2023/6/21 10:06
|
||||||
|
*/
|
||||||
|
public static String generateTypeOption(List<String> xName, List<Map<String,Object>> map) {
|
||||||
|
|
||||||
|
Option iticOption = new Option();
|
||||||
|
//取消渲染动画
|
||||||
|
iticOption.setAnimation(false);
|
||||||
|
//背景色
|
||||||
|
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||||
|
//标题
|
||||||
|
iticOption.setTitle(new Title().setRight("10%").setText("暂降类型"));
|
||||||
|
//上下左右的图内间距
|
||||||
|
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||||
|
//设置图例
|
||||||
|
iticOption.setLegend(new Legend().setOrient("vertical").setData(xName.toArray()).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||||
|
//配置暂降次数
|
||||||
|
PieSeries probability = new PieSeries()
|
||||||
|
.setType("pie")
|
||||||
|
.setName("暂降类型")
|
||||||
|
.setLabel(new PieLabel().setFormatter("{b}:{d}%"))
|
||||||
|
.setData(map);
|
||||||
|
iticOption.setSeries(new SeriesOption[]{probability});
|
||||||
|
return ENGINE.renderJsonOption(iticOption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,10 +138,71 @@ public class DrawPicUtil {
|
|||||||
* @return String base64数据
|
* @return String base64数据
|
||||||
*/
|
*/
|
||||||
public String drawPersistentTime(List<String> ylinedata, List<String> ybardata, int width, int height) {
|
public String drawPersistentTime(List<String> ylinedata, List<String> ybardata, int width, int height) {
|
||||||
String persistentTimeJson = LineGenerator.generateEventAmplitudeOption(ylinedata, ybardata);
|
String persistentTimeJson = LineGenerator.generatePersistentTimeOption(ylinedata, ybardata);
|
||||||
return drawPic(persistentTimeJson, width, height);
|
return drawPic(persistentTimeJson, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成月份统计图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawMonth(List<String> xName, List<Integer> times, String year, Integer flag) {
|
||||||
|
return drawMonth(xName, times, year, flag, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成月份统计图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawMonth(List<String> xName, List<Integer> times, String year, Integer flag, int width, int height) {
|
||||||
|
String monthJson = LineGenerator.generateMonthOption( xName, times, year, flag);
|
||||||
|
return drawPic(monthJson, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成暂降原因图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawReason(List<String> xname, List<Map<String,Object>> map2) {
|
||||||
|
return drawReason(xname, map2, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成暂降原因图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawReason(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||||
|
String monthJson = LineGenerator.generateReasonOption(xname, map2);
|
||||||
|
return drawPic(monthJson, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成暂降类型图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawType(List<String> xname, List<Map<String,Object>> map2) {
|
||||||
|
return drawType(xname, map2, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 绘制生成暂降类型图
|
||||||
|
* @author hongawen
|
||||||
|
* @date 2023/6/21 11:01
|
||||||
|
* @return String base64数据
|
||||||
|
*/
|
||||||
|
public String drawType(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||||
|
String monthJson = LineGenerator.generateTypeOption(xname, map2);
|
||||||
|
return drawPic(monthJson, width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1940,7 +1940,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
count.add(Integer.parseInt(timeVO.getTimes()));
|
count.add(Integer.parseInt(timeVO.getTimes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String yftj = getYFTJ(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
|
String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
|
||||||
createPic(doc, yftj, "月份统计图");
|
createPic(doc, yftj, "月份统计图");
|
||||||
two++;
|
two++;
|
||||||
}
|
}
|
||||||
@@ -1983,11 +1983,18 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
if (exportParam.isYytx()) {
|
if (exportParam.isYytx()) {
|
||||||
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
|
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
|
||||||
List<String> xdata = new ArrayList<>();
|
List<String> xdata = new ArrayList<>();
|
||||||
|
List<Map<String,Object>> reasonList = new ArrayList<>();
|
||||||
|
|
||||||
List<ReasonsVO> reason = statistic.getReason();
|
List<ReasonsVO> reason = statistic.getReason();
|
||||||
for (ReasonsVO reasonsVO : reason) {
|
for (ReasonsVO reasonsVO : reason) {
|
||||||
|
Map<String,Object> map=new LinkedHashMap<>();
|
||||||
|
map.put("value",reasonsVO.getTimes());
|
||||||
|
map.put("name",reasonsVO.getReason());
|
||||||
|
reasonList.add(map);
|
||||||
|
// reasonList.add("{value:"+reasonsVO.getTimes()+",name:'"+reasonsVO.getReason()+"'}");
|
||||||
xdata.add(reasonsVO.getReason());
|
xdata.add(reasonsVO.getReason());
|
||||||
}
|
}
|
||||||
String tr = getR(xdata, reason, "bar9.ftl");
|
String tr = drawPicUtil.drawReason(xdata,reasonList);
|
||||||
createPic(doc, tr, "暂降原因图");
|
createPic(doc, tr, "暂降原因图");
|
||||||
two++;
|
two++;
|
||||||
}
|
}
|
||||||
@@ -2014,12 +2021,16 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
|
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
|
||||||
List<String> xdata = new ArrayList<>();
|
List<String> xdata = new ArrayList<>();
|
||||||
List<TypesVO> types = statistic.getTypes();
|
List<TypesVO> types = statistic.getTypes();
|
||||||
|
|
||||||
|
List<Map<String,Object>> reasonList = new ArrayList<>();
|
||||||
for (TypesVO type : types) {
|
for (TypesVO type : types) {
|
||||||
if (type.getTimes() > 0) {
|
Map<String,Object> map=new LinkedHashMap<>();
|
||||||
xdata.add(type.getType());
|
map.put("value",type.getTimes());
|
||||||
}
|
map.put("name",type.getType());
|
||||||
|
reasonList.add(map);
|
||||||
|
xdata.add(type.getType());
|
||||||
}
|
}
|
||||||
String tr = getT(xdata, types, "bar8.ftl");
|
String tr = drawPicUtil.drawType(xdata,reasonList);
|
||||||
createPic(doc, tr, "暂降类型图");
|
createPic(doc, tr, "暂降类型图");
|
||||||
two++;
|
two++;
|
||||||
}
|
}
|
||||||
@@ -2100,7 +2111,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
|
|
||||||
|
|
||||||
public String getStr(String barName, Map<String, Object> map) throws TemplateException, IOException {
|
public String getStr(String barName, Map<String, Object> map) throws TemplateException, IOException {
|
||||||
String s = freemarkerUtil.generateString(barName, "com/njcn/event/template", map);
|
String s = freemarkerUtil.generateString(barName, "com/njcn/event/templates", map);
|
||||||
return EchartsUtil.generateEchartsBase64(s, "8910");
|
return EchartsUtil.generateEchartsBase64(s, "8910");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class TerminalServiceImpl implements TerminalService {
|
|||||||
public List<TerminalVO> getTerminalData(DeviceInfoParam.BusinessParam terminalParam) {
|
public List<TerminalVO> getTerminalData(DeviceInfoParam.BusinessParam terminalParam) {
|
||||||
List<TerminalVO> terminalList = new ArrayList<>();
|
List<TerminalVO> terminalList = new ArrayList<>();
|
||||||
//按照条件获取所有终端综合信息
|
//按照条件获取所有终端综合信息
|
||||||
List<GeneralDeviceDTO> deviceDataList = generalDeviceInfoClient.getPracticalAllDeviceInfo(new DeviceInfoParam(terminalParam.getStatisticalType(), terminalParam.getDeptIndex(), generalInfo.getMicroServiceName(), null, terminalParam.getManufacturer(), null)).getData();
|
List<GeneralDeviceDTO> deviceDataList = generalDeviceInfoClient.getPracticalRunDeviceInfo(new DeviceInfoParam(terminalParam.getStatisticalType(), terminalParam.getDeptIndex(), generalInfo.getMicroServiceName(), null, terminalParam.getManufacturer(), null)).getData();
|
||||||
//组装终端Top层集合
|
//组装终端Top层集合
|
||||||
for (GeneralDeviceDTO generalDeviceDTO : deviceDataList) {
|
for (GeneralDeviceDTO generalDeviceDTO : deviceDataList) {
|
||||||
List<String> deviceIndexes = generalDeviceDTO.getDeviceIndexes();
|
List<String> deviceIndexes = generalDeviceDTO.getDeviceIndexes();
|
||||||
@@ -79,7 +79,7 @@ public class TerminalServiceImpl implements TerminalService {
|
|||||||
public TerminalCensusVO getTerminalDataCensus(DeviceInfoParam.BusinessParam terminalCensusParam) {
|
public TerminalCensusVO getTerminalDataCensus(DeviceInfoParam.BusinessParam terminalCensusParam) {
|
||||||
TerminalCensusVO terminalCensusVO = new TerminalCensusVO();
|
TerminalCensusVO terminalCensusVO = new TerminalCensusVO();
|
||||||
terminalCensusParam.setServerName(generalInfo.getMicroServiceName());
|
terminalCensusParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(terminalCensusParam).getData();
|
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(terminalCensusParam).getData();
|
||||||
List<String> type = new ArrayList<>();
|
List<String> type = new ArrayList<>();
|
||||||
List<Double> single = new ArrayList<>();
|
List<Double> single = new ArrayList<>();
|
||||||
List<Integer> runFlag = new ArrayList<>(),reaFlag = new ArrayList<>(),stopFlag = new ArrayList<>();
|
List<Integer> runFlag = new ArrayList<>(),reaFlag = new ArrayList<>(),stopFlag = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user