代码调整
This commit is contained in:
@@ -33,9 +33,9 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.icepear.echarts</groupId>
|
||||
<artifactId>echarts-java</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>echarts5-java</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<!-- echarts绘图所需,可以将包含function的对象转为json -->
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.njcn.echarts.json;
|
||||
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import org.icepear.echarts.Option;
|
||||
import org.icepear.echarts.charts.bar.BarLabel;
|
||||
import org.icepear.echarts.charts.bar.BarSeries;
|
||||
import org.icepear.echarts.charts.bar3D.Bar3DSeries;
|
||||
import org.icepear.echarts.components.coord.AxisNameTextStyle;
|
||||
import org.icepear.echarts.components.coord.SplitLine;
|
||||
import org.icepear.echarts.components.coord.cartesian.CategoryAxis;
|
||||
import org.icepear.echarts.components.coord.cartesian.ValueAxis;
|
||||
import org.icepear.echarts.components.grid.Grid;
|
||||
import org.icepear.echarts.components.grid3D.Grid3D;
|
||||
import org.icepear.echarts.components.grid3D.ViewControl;
|
||||
import org.icepear.echarts.components.inRange.InRange;
|
||||
import org.icepear.echarts.components.legend.Legend;
|
||||
import org.icepear.echarts.components.series.LineStyle;
|
||||
import org.icepear.echarts.components.title.Title;
|
||||
import org.icepear.echarts.components.visualMap.ContinousVisualMap;
|
||||
import org.icepear.echarts.origin.util.SeriesOption;
|
||||
import org.icepear.echarts.render.Engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年06月25日 20:10
|
||||
*/
|
||||
public class BarGenerator {
|
||||
|
||||
private final static Engine ENGINE = new Engine();
|
||||
|
||||
|
||||
/***
|
||||
* 生成月份统计
|
||||
* @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 monthOption = new Option();
|
||||
//取消渲染动画
|
||||
monthOption.setAnimation(false);
|
||||
//背景色
|
||||
monthOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
if (flag == 0) {
|
||||
monthOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("月份统计"));
|
||||
name = "月份";
|
||||
} else {
|
||||
monthOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("天数统计"));
|
||||
name = "天数";
|
||||
}
|
||||
//上下左右的图内间距
|
||||
monthOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
monthOption.setLegend(new Legend().setData(new String[]{"暂降次数"}).setTop("26px").setLeft(10).setBottom("94%").setShow(true));
|
||||
//设置图例对应的颜色
|
||||
monthOption.setColor(new String[]{"#FF8C00"});
|
||||
//横坐标
|
||||
monthOption.setXAxis(new CategoryAxis()
|
||||
.setBoundaryGap(true)
|
||||
.setName(name)
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
.setData(xName.toArray())
|
||||
);
|
||||
//纵坐标
|
||||
monthOption.setYAxis(new ValueAxis[]{
|
||||
new ValueAxis()
|
||||
.setName("次")
|
||||
.setType("value")
|
||||
});
|
||||
|
||||
//配置暂降次数
|
||||
BarSeries probability = new BarSeries()
|
||||
.setName("暂降次数")
|
||||
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||
.setData(times);
|
||||
monthOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(monthOption);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 生成暂降密度图
|
||||
* @author hongawen
|
||||
* @date 2023/6/25 20:12
|
||||
*/
|
||||
public static String generateEventDensity(Number[][] data) {
|
||||
Option option3D = new Option();
|
||||
option3D.setBackgroundColor("#fff");
|
||||
option3D.setTitle(new Title().setText("暂降密度图").setX("center"));
|
||||
option3D.setVisualMap(new ContinousVisualMap().setMax(20).setShow(false).setInRange(new InRange().setColor(new String[]{"#313695", "#00BB00", "#ff8000", "#a50026"})));
|
||||
option3D.setXAxis3D(new CategoryAxis().setName("剩余电压(%)").setData(new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100"}));
|
||||
option3D.setYAxis3D(new CategoryAxis()
|
||||
.setName("持续时间(cyc)")
|
||||
.setData(new String[]{"1cyc", "2cyc", "3cyc", "4cyc", "5cyc", "6~10cyc", "10~20cyc", "20~30cyc", "30~60cyc"})
|
||||
.setSplitLine(new SplitLine().setLineStyle(new LineStyle().setColor("#").setType("dashed").setOpacity(0.5)))
|
||||
);
|
||||
option3D.setZAxis3D(new ValueAxis().setSplitNumber(8).setMinInterval(5).setName("次数"));
|
||||
option3D.setGrid3D(new Grid3D()
|
||||
.setViewControl(new ViewControl().setBeta(8).setAlpha(5))
|
||||
.setBoxWidth(200)
|
||||
.setBoxDepth(80)
|
||||
);
|
||||
Bar3DSeries bar3DSeries = new Bar3DSeries()
|
||||
.setData(data)
|
||||
.setShading("realistic");
|
||||
option3D.setSeries(new SeriesOption[]{bar3DSeries});
|
||||
return ENGINE.renderJsonOption(option3D);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import org.icepear.echarts.components.grid.Grid;
|
||||
import org.icepear.echarts.components.legend.Legend;
|
||||
import org.icepear.echarts.components.title.Title;
|
||||
import org.icepear.echarts.components.tooltip.Tooltip;
|
||||
import org.icepear.echarts.components.visualMap.ContinousVisualMap;
|
||||
import org.icepear.echarts.origin.util.SeriesOption;
|
||||
import org.icepear.echarts.render.Engine;
|
||||
|
||||
@@ -95,23 +96,23 @@ public class LineGenerator {
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateF47Option(TolerateData tolerateData) {
|
||||
Option iticOption = new Option();
|
||||
Option f47Option = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
f47Option.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
f47Option.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("SEMI F47曲线"));
|
||||
f47Option.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("SEMI F47曲线"));
|
||||
//上下左右的图内间距
|
||||
iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("40px").setBottom("10%"));
|
||||
f47Option.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("40px").setBottom("10%"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setData(new String[]{"边界线", "可容忍事件", "不可容忍事件"}).setTop("26px").setLeft(0).setBottom("94%"));
|
||||
f47Option.setLegend(new Legend().setData(new String[]{"边界线", "可容忍事件", "不可容忍事件"}).setTop("26px").setLeft(0).setBottom("94%"));
|
||||
//设置图例对应的颜色
|
||||
iticOption.setColor(new String[]{"yellow", "green", "red"});
|
||||
f47Option.setColor(new String[]{"yellow", "green", "red"});
|
||||
//横坐标
|
||||
iticOption.setXAxis(new LogAxis().setMin("0.001").setMax("1000").setSplitLine(new SplitLine().setShow(false)).setName("s"));
|
||||
f47Option.setXAxis(new LogAxis().setMin("0.001").setMax("1000").setSplitLine(new SplitLine().setShow(false)).setName("s"));
|
||||
//纵坐标
|
||||
iticOption.setYAxis(new ValueAxis().setName("%").setMinInterval(0.1).setSplitNumber(10).setMax(100));
|
||||
f47Option.setYAxis(new ValueAxis().setName("%").setMinInterval(0.1).setSplitNumber(10).setMax(100));
|
||||
//处理边界线
|
||||
LineSeries borderLimit = new LineSeries()
|
||||
.setName("边界线")
|
||||
@@ -128,8 +129,8 @@ public class LineGenerator {
|
||||
.setName("不可容忍事件")
|
||||
.setSymbol("circle")
|
||||
.setData(tolerateData.getUnTolerateData());
|
||||
iticOption.setSeries(new SeriesOption[]{borderLimit, tolerate, unTolerate});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
f47Option.setSeries(new SeriesOption[]{borderLimit, tolerate, unTolerate});
|
||||
return ENGINE.renderJsonOption(f47Option);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,24 +140,24 @@ public class LineGenerator {
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateEventAmplitudeOption(List<String> ylinedata, List<String> ybardata) {
|
||||
Option iticOption = new Option();
|
||||
Option eventAmplitudeOption = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
eventAmplitudeOption.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
eventAmplitudeOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("暂降幅值的概率分布"));
|
||||
eventAmplitudeOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("暂降幅值的概率分布"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setData(new String[]{"概率分布", "占比"}).setLeft(10).setShow(true));
|
||||
eventAmplitudeOption.setLegend(new Legend().setData(new String[]{"概率分布", "占比"}).setLeft(10).setShow(true));
|
||||
//横坐标
|
||||
iticOption.setXAxis(new CategoryAxis()
|
||||
eventAmplitudeOption.setXAxis(new CategoryAxis()
|
||||
.setBoundaryGap(true)
|
||||
.setName("暂降幅值")
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
.setData(new String[]{"0", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%"})
|
||||
);
|
||||
//纵坐标
|
||||
iticOption.setYAxis(new ValueAxis[]{
|
||||
eventAmplitudeOption.setYAxis(new ValueAxis[]{
|
||||
new ValueAxis()
|
||||
.setName("%")
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
@@ -173,8 +174,8 @@ public class LineGenerator {
|
||||
.setBarWidth(30)
|
||||
.setData(ybardata);
|
||||
|
||||
iticOption.setSeries(new SeriesOption[]{probability, proportion});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
eventAmplitudeOption.setSeries(new SeriesOption[]{probability, proportion});
|
||||
return ENGINE.renderJsonOption(eventAmplitudeOption);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -183,24 +184,24 @@ public class LineGenerator {
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generatePersistentTimeOption(List<String> ylinedata, List<String> ybardata) {
|
||||
Option iticOption = new Option();
|
||||
Option persistentTimeOption = new Option();
|
||||
//取消渲染动画
|
||||
iticOption.setAnimation(false);
|
||||
persistentTimeOption.setAnimation(false);
|
||||
//背景色
|
||||
iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
persistentTimeOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("持续时间的概率分布"));
|
||||
persistentTimeOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("持续时间的概率分布"));
|
||||
//设置图例
|
||||
iticOption.setLegend(new Legend().setData(new String[]{"概率分布", "占比"}).setLeft(10).setShow(true));
|
||||
persistentTimeOption.setLegend(new Legend().setData(new String[]{"概率分布", "占比"}).setLeft(10).setShow(true));
|
||||
//横坐标
|
||||
iticOption.setXAxis(new CategoryAxis()
|
||||
persistentTimeOption.setXAxis(new CategoryAxis()
|
||||
.setBoundaryGap(true)
|
||||
.setName("暂态持续时间(s)")
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
.setData(new String[]{"0.01", "0.1", "0.25", "0.5", "1", "3", "20", "60", "180"})
|
||||
);
|
||||
//纵坐标
|
||||
iticOption.setYAxis(new ValueAxis[]{
|
||||
persistentTimeOption.setYAxis(new ValueAxis[]{
|
||||
new ValueAxis()
|
||||
.setName("%")
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
@@ -217,114 +218,9 @@ public class LineGenerator {
|
||||
.setBarWidth(30)
|
||||
.setData(ybardata);
|
||||
|
||||
iticOption.setSeries(new SeriesOption[]{probability, proportion});
|
||||
return ENGINE.renderJsonOption(iticOption);
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{probability, proportion});
|
||||
return ENGINE.renderJsonOption(persistentTimeOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成月份统计
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.njcn.echarts.json;
|
||||
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import org.icepear.echarts.Option;
|
||||
import org.icepear.echarts.charts.pie.PieLabel;
|
||||
import org.icepear.echarts.charts.pie.PieSeries;
|
||||
import org.icepear.echarts.components.grid.Grid;
|
||||
import org.icepear.echarts.components.legend.Legend;
|
||||
import org.icepear.echarts.components.title.Title;
|
||||
import org.icepear.echarts.origin.util.SeriesOption;
|
||||
import org.icepear.echarts.render.Engine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年06月25日 21:42
|
||||
*/
|
||||
public class PieGenerator {
|
||||
|
||||
private final static Engine ENGINE = new Engine();
|
||||
|
||||
|
||||
/***
|
||||
* 生成暂降原因
|
||||
* @author wr
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateReasonOption(List<String> xName, List<Map<String,Object>> map2) {
|
||||
|
||||
Option reasonOption = new Option();
|
||||
//取消渲染动画
|
||||
reasonOption.setAnimation(false);
|
||||
//背景色
|
||||
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
reasonOption.setTitle(new Title().setRight("10%").setText("暂降原因"));
|
||||
//上下左右的图内间距
|
||||
reasonOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
reasonOption.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);
|
||||
reasonOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(reasonOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成暂降类型
|
||||
* @author wr
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateTypeOption(List<String> xName, List<Map<String,Object>> map) {
|
||||
|
||||
Option typeOption = new Option();
|
||||
//取消渲染动画
|
||||
typeOption.setAnimation(false);
|
||||
//背景色
|
||||
typeOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
typeOption.setTitle(new Title().setRight("10%").setText("暂降类型"));
|
||||
//上下左右的图内间距
|
||||
typeOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("60px").setBottom("20px"));
|
||||
//设置图例
|
||||
typeOption.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);
|
||||
typeOption.setSeries(new SeriesOption[]{probability});
|
||||
return ENGINE.renderJsonOption(typeOption);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.njcn.echarts.util;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.echarts.json.BarGenerator;
|
||||
import com.njcn.echarts.json.LineGenerator;
|
||||
import com.njcn.echarts.json.PieGenerator;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -46,8 +48,8 @@ public class DrawPicUtil {
|
||||
*/
|
||||
private String drawPic(String option, int width, int height) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("width", width == 0 ? 925 : width);
|
||||
jsonObject.set("height", height == 0 ? 300 : height);
|
||||
jsonObject.set("width", width == 0 ? 950 : width);
|
||||
jsonObject.set("height", height == 0 ? 400 : height);
|
||||
jsonObject.set("option", JSONUtil.parseObj(option));
|
||||
ResponseEntity<String> picResult = RestTemplateUtil.post(URL, jsonObject, String.class);
|
||||
return Objects.requireNonNull(picResult.getBody()).indexOf("image/png") > 0 ? picResult.getBody() : "";
|
||||
@@ -160,7 +162,7 @@ public class DrawPicUtil {
|
||||
* @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);
|
||||
String monthJson = BarGenerator.generateMonthOption( xName, times, year, flag);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -181,7 +183,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawReason(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateReasonOption(xname, map2);
|
||||
String monthJson = PieGenerator.generateReasonOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -202,7 +204,29 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawType(List<String> xname, List<Map<String,Object>> map2, int width, int height) {
|
||||
String monthJson = LineGenerator.generateTypeOption(xname, map2);
|
||||
String monthJson = PieGenerator.generateTypeOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制生成暂降密度图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventDensity(Number[][] data) {
|
||||
return drawEventDensity(data, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制生成暂降类型图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventDensity(Number[][] data, int width, int height) {
|
||||
String eventDensityJson = BarGenerator.generateEventDensity(data);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,5 +74,5 @@ public interface EventReportService {
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<CoordsVO> getCoords(List<EventDetail> info);
|
||||
Integer[][] getCoords(List<EventDetail> info);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@@ -822,7 +823,7 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException {
|
||||
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam, List<EventDetail> info) throws ParseException {
|
||||
List<TimeVO> list = new ArrayList<>();
|
||||
//参数
|
||||
StringBuilder builder1 = new StringBuilder();
|
||||
@@ -837,7 +838,7 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
Integer endMonth = Integer.parseInt(endTime.substring(5, 7));
|
||||
Integer startYear = Integer.parseInt(startTime.substring(0, 4));
|
||||
Integer endYear = Integer.parseInt(endTime.substring(0, 4));
|
||||
if (statisticsParam.getFlag()==0){
|
||||
if (statisticsParam.getFlag() == 0) {
|
||||
while (!startYear.equals(endYear) && !startMonth.equals(endMonth)) {
|
||||
builder1.delete(0, builder1.length());
|
||||
builder2.delete(0, builder2.length());
|
||||
@@ -847,14 +848,14 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
} else {
|
||||
builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays);
|
||||
}
|
||||
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
|
||||
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
|
||||
long count = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
|
||||
if (startMonth < 10) {
|
||||
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
|
||||
list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
|
||||
} else {
|
||||
list.add(new TimeVO(null, null,"", startMonth.toString(), count+"", startYear.toString(),startYear.toString()+"-"+startMonth.toString()));
|
||||
list.add(new TimeVO(null, null, "", startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
|
||||
}
|
||||
startMonth++;
|
||||
if (startMonth == 13) {
|
||||
@@ -866,63 +867,62 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
builder2.delete(0, builder2.length());
|
||||
builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays);
|
||||
builder2.append(startYear).append("-").append(startMonth).append("-").append(endDays);
|
||||
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
|
||||
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
|
||||
long count1 = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
|
||||
if (startMonth < 10) {
|
||||
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count1+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
|
||||
list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
|
||||
} else {
|
||||
list.add(new TimeVO(null, null,"", startMonth.toString(), count1+"", startYear.toString(),startYear.toString()+"-"+startMonth.toString()));
|
||||
list.add(new TimeVO(null, null, "", startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
QueryResult monitorQuery = MonitorQuery(statisticsParam);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
|
||||
|
||||
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType()=="1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
|
||||
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
|
||||
Set<String> keySet = map.keySet();
|
||||
|
||||
LocalDate parse1 = LocalDate.parse(startTime);
|
||||
LocalDate parse2 = LocalDate.parse(endTime);
|
||||
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))){
|
||||
if (keySet.contains(parse1.toString())){
|
||||
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))) {
|
||||
if (keySet.contains(parse1.toString())) {
|
||||
List<EventDetailNew> eventDetailNews = map.get(parse1.toString());
|
||||
TimeVO timeVO = new TimeVO();
|
||||
timeVO.setTimes(eventDetailNews.size()+"");
|
||||
if (parse1.getDayOfMonth()<10){
|
||||
timeVO.setDay("0"+parse1.getDayOfMonth()+"");
|
||||
}else {
|
||||
timeVO.setDay(parse1.getDayOfMonth()+"");
|
||||
timeVO.setTimes(eventDetailNews.size() + "");
|
||||
if (parse1.getDayOfMonth() < 10) {
|
||||
timeVO.setDay("0" + parse1.getDayOfMonth() + "");
|
||||
} else {
|
||||
timeVO.setDay(parse1.getDayOfMonth() + "");
|
||||
}
|
||||
timeVO.setYear(parse1.getYear()+"");
|
||||
if (parse1.getMonthValue()<10){
|
||||
timeVO.setMonth("0"+parse1.getMonthValue()+"");
|
||||
}else {
|
||||
timeVO.setMonth(parse1.getMonthValue()+"");
|
||||
timeVO.setYear(parse1.getYear() + "");
|
||||
if (parse1.getMonthValue() < 10) {
|
||||
timeVO.setMonth("0" + parse1.getMonthValue() + "");
|
||||
} else {
|
||||
timeVO.setMonth(parse1.getMonthValue() + "");
|
||||
}
|
||||
timeVO.setFulltime(parse1.toString());
|
||||
list.add(timeVO);
|
||||
}else {
|
||||
} else {
|
||||
TimeVO timeVO = new TimeVO();
|
||||
timeVO.setTimes("0");
|
||||
if (parse1.getDayOfMonth()<10){
|
||||
timeVO.setDay("0"+parse1.getDayOfMonth()+"");
|
||||
}else {
|
||||
timeVO.setDay(parse1.getDayOfMonth()+"");
|
||||
if (parse1.getDayOfMonth() < 10) {
|
||||
timeVO.setDay("0" + parse1.getDayOfMonth() + "");
|
||||
} else {
|
||||
timeVO.setDay(parse1.getDayOfMonth() + "");
|
||||
}
|
||||
timeVO.setYear(parse1.getYear()+"");
|
||||
if (parse1.getMonthValue()<10){
|
||||
timeVO.setMonth("0"+parse1.getMonthValue()+"");
|
||||
}else {
|
||||
timeVO.setMonth(parse1.getMonthValue()+"");
|
||||
timeVO.setYear(parse1.getYear() + "");
|
||||
if (parse1.getMonthValue() < 10) {
|
||||
timeVO.setMonth("0" + parse1.getMonthValue() + "");
|
||||
} else {
|
||||
timeVO.setMonth(parse1.getMonthValue() + "");
|
||||
}
|
||||
timeVO.setFulltime(parse1.toString());
|
||||
list.add(timeVO);
|
||||
}
|
||||
parse1=parse1.plus(1, ChronoUnit.DAYS);
|
||||
parse1 = parse1.plus(1, ChronoUnit.DAYS);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -931,10 +931,11 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
|
||||
/**
|
||||
* 暂降事件点图
|
||||
*
|
||||
* @author wr
|
||||
*/
|
||||
@Override
|
||||
public List<EventDetail> getPlot(List<EventDetail> info,List<DictData> reasonData,List<DictData> typeData) {
|
||||
public List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
|
||||
//添加detail
|
||||
for (EventDetail detail : info) {
|
||||
for (DictData data : reasonData) {
|
||||
@@ -952,7 +953,7 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData) {
|
||||
public StatisticVO getStatistic(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
|
||||
StatisticVO result = new StatisticVO();
|
||||
List<EventDetail> list = new ArrayList<>();
|
||||
List<ReasonsVO> reasonsVOS = new ArrayList<>();
|
||||
@@ -963,13 +964,13 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
//添加detail
|
||||
for (EventDetail detail : info) {
|
||||
for (DictData data : reasonData) {
|
||||
reasonMap.put(data.getName(),0);
|
||||
reasonMap.put(data.getName(), 0);
|
||||
if (detail.getAdvanceReason().equals(data.getId())) {
|
||||
detail.setAdvanceReason(data.getName());
|
||||
}
|
||||
}
|
||||
for (DictData data : typeData) {
|
||||
typeMap.put(data.getName(),0);
|
||||
typeMap.put(data.getName(), 0);
|
||||
if (detail.getAdvanceType().equals(data.getId())) {
|
||||
detail.setAdvanceType(data.getName());
|
||||
}
|
||||
@@ -1002,17 +1003,18 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CoordsVO> getCoords(List<EventDetail> info) {
|
||||
List<CoordsVO> result = new ArrayList<>();
|
||||
public Integer[][] getCoords(List<EventDetail> info) {
|
||||
Integer[][] eventDensityData = new Integer[90][3];
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// eventDensityData[i] = new Integer[]{i % 10, i % 9, 0};
|
||||
for (int j = 0; j < 9; j++) {
|
||||
result.add(new CoordsVO(i, j, 0));
|
||||
eventDensityData[i * 9 + j] = new Integer[]{i, j % 9, 0};
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
Integer index = null;
|
||||
CoordsVO dto = new CoordsVO();
|
||||
if (info.get(i).getFeatureAmplitude() >= 0 && info.get(i).getFeatureAmplitude() <= 0.1) {
|
||||
if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
|
||||
index = 0;
|
||||
@@ -1215,11 +1217,11 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(index)) {
|
||||
CoordsVO coordsVO = result.get(index);
|
||||
coordsVO.setZ(coordsVO.getZ() + 1);
|
||||
Integer[] temNumber = eventDensityData[index];
|
||||
temNumber[2] = temNumber[2] + 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return eventDensityData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1848,11 +1848,8 @@ public class ReportServiceImpl implements ReportService {
|
||||
int two = 1;
|
||||
if (exportParam.isMdtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
|
||||
List<CoordsVO> coords = eventReportService.getCoords(info);
|
||||
Integer[][] a = new Integer[87][];
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("data", JSONArray.fromObject(coords).toString());
|
||||
String str = getStr("bar10.ftl", map);
|
||||
Integer[][] eventDensityData = eventReportService.getCoords(info);
|
||||
String str = drawPicUtil.drawEventDensity(eventDensityData);
|
||||
createPic(doc, str, "暂降密度图");
|
||||
two++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user