添加暂态事件波形图后台绘图并保存文件服务器
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.njcn.echarts.json;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.njcn.echarts.pojo.bo.TolerateData;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import org.icepear.echarts.Option;
|
||||
@@ -8,8 +7,6 @@ import org.icepear.echarts.charts.bar.BarItemStyle;
|
||||
import org.icepear.echarts.charts.bar.BarLabel;
|
||||
import org.icepear.echarts.charts.bar.BarSeries;
|
||||
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.components.coord.*;
|
||||
import org.icepear.echarts.components.coord.cartesian.CategoryAxis;
|
||||
@@ -17,17 +14,14 @@ import org.icepear.echarts.components.coord.cartesian.LogAxis;
|
||||
import org.icepear.echarts.components.coord.cartesian.ValueAxis;
|
||||
import org.icepear.echarts.components.grid.Grid;
|
||||
import org.icepear.echarts.components.legend.Legend;
|
||||
import org.icepear.echarts.components.text.Label;
|
||||
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.chart.bar.BarItemStyleOption;
|
||||
import org.icepear.echarts.origin.coord.AxisLabelBaseOption;
|
||||
import org.icepear.echarts.origin.util.SeriesOption;
|
||||
import org.icepear.echarts.render.Engine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -252,7 +246,7 @@ public class LineGenerator {
|
||||
persistentTimeOption.setYAxis(new ValueAxis()
|
||||
.setName("(次)")
|
||||
.setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
//配置占比
|
||||
@@ -264,6 +258,7 @@ public class LineGenerator {
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion});
|
||||
return ENGINE.renderJsonOption(persistentTimeOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 生成电压暂降,已关联未关联得次数
|
||||
* @author hongawen
|
||||
@@ -307,7 +302,7 @@ public class LineGenerator {
|
||||
.setItemStyle(new BarItemStyle().setColor("#ccc").setBorderColor("#ccc").setBorderWidth(2).setBorderRadius(0))
|
||||
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||
.setData(pereventValue1);
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion,proportion2});
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion, proportion2});
|
||||
return ENGINE.renderJsonOption(persistentTimeOption);
|
||||
}
|
||||
|
||||
@@ -358,7 +353,7 @@ public class LineGenerator {
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateRegionDeviceOption(List<String> xData, List<Integer> onlineData,List<Integer> offlineData,String subtext,String xName) {
|
||||
public static String generateRegionDeviceOption(List<String> xData, List<Integer> onlineData, List<Integer> offlineData, String subtext, String xName) {
|
||||
Option persistentTimeOption = new Option();
|
||||
//取消渲染动画
|
||||
persistentTimeOption.setAnimation(false);
|
||||
@@ -398,7 +393,7 @@ public class LineGenerator {
|
||||
.setItemStyle(new BarItemStyle().setColor("orange").setBorderColor("orange").setBorderWidth(2).setBorderRadius(0))
|
||||
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||
.setData(offlineData);
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion,proportion2});
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion, proportion2});
|
||||
return ENGINE.renderJsonOption(persistentTimeOption);
|
||||
}
|
||||
|
||||
@@ -407,7 +402,7 @@ public class LineGenerator {
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 10:06
|
||||
*/
|
||||
public static String generateFrequencyOption(List<String> xData, List<Integer> dip,List<Integer> interruptions,List<Integer> rise,String subtext,String xName) {
|
||||
public static String generateFrequencyOption(List<String> xData, List<Integer> dip, List<Integer> interruptions, List<Integer> rise, String subtext, String xName) {
|
||||
Option persistentTimeOption = new Option();
|
||||
//取消渲染动画
|
||||
persistentTimeOption.setAnimation(false);
|
||||
@@ -418,7 +413,7 @@ public class LineGenerator {
|
||||
.setSubtext(subtext)
|
||||
);
|
||||
//设置图例
|
||||
persistentTimeOption.setLegend(new Legend().setData(new String[]{"暂降次数", "中断次数","暂升次数"}).setLeft(10).setShow(true));
|
||||
persistentTimeOption.setLegend(new Legend().setData(new String[]{"暂降次数", "中断次数", "暂升次数"}).setLeft(10).setShow(true));
|
||||
//横坐标
|
||||
persistentTimeOption.setXAxis(new CategoryAxis()
|
||||
.setBoundaryGap(true)
|
||||
@@ -453,7 +448,73 @@ public class LineGenerator {
|
||||
.setItemStyle(new BarItemStyle().setColor("#0066ff").setBorderColor("#0066ff").setBorderWidth(2).setBorderRadius(0))
|
||||
.setLabel(new BarLabel().setShow(true).setColor("#8B008B"))
|
||||
.setData(rise);
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion,proportion2,proportion3});
|
||||
persistentTimeOption.setSeries(new SeriesOption[]{proportion, proportion2, proportion3});
|
||||
return ENGINE.renderJsonOption(persistentTimeOption);
|
||||
}
|
||||
|
||||
/***
|
||||
* 准备波形json
|
||||
* @author hongawen
|
||||
* @date 2023/9/21 9:41
|
||||
* @return String
|
||||
*/
|
||||
public static String generateWaveOption(String title, List<List<Float>> aValue, List<List<Float>> bValue, List<List<Float>> cValue, String unit, Float max, Float min, String a, String b, String c, List<String> colors, Boolean isOpen) {
|
||||
DecimalFormat df1 = new DecimalFormat("#.00");
|
||||
DecimalFormat df2 = new DecimalFormat("#");
|
||||
Option instantOption = new Option();
|
||||
//取消渲染动画
|
||||
instantOption.setAnimation(false);
|
||||
//背景色
|
||||
instantOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
instantOption.setTitle(new Title()
|
||||
.setText(title)
|
||||
.setLeft(PicCommonData.CENTER)
|
||||
.setTextStyle(new Label().setFontSize(14))
|
||||
);
|
||||
//配置颜色
|
||||
instantOption.setColor(colors.toArray(new String[colors.size()]));
|
||||
//配置图例
|
||||
if (isOpen) {
|
||||
instantOption.setLegend(new Legend().setData(new String[]{a, b}).setLeft("10px"));
|
||||
} else {
|
||||
instantOption.setLegend(new Legend().setData(new String[]{a, b, c}).setLeft("10px"));
|
||||
}
|
||||
//上下左右的图内间距
|
||||
instantOption.setGrid(new Grid().setTop("60px").setLeft("55px").setRight("40px").setBottom("10%"));
|
||||
//横坐标
|
||||
instantOption.setXAxis(new ValueAxis().setName("ms")
|
||||
.setMax(df2.format(aValue.get(0).get(0)))
|
||||
.setMin(df2.format(aValue.get(aValue.size() - 1).get(0)))
|
||||
.setSplitLine(new SplitLine().setShow(false))
|
||||
.setAxisLine(new AxisLine().setOnZero(false))
|
||||
.setMinInterval(1)
|
||||
);
|
||||
//纵坐标
|
||||
instantOption.setYAxis(new ValueAxis()
|
||||
.setName(unit)
|
||||
.setMax(df1.format(max * 1.1))
|
||||
.setMin(df1.format(min * 1.1))
|
||||
.setPosition(PicCommonData.LEFT)
|
||||
.setAxisLine(new AxisLine().setShow(false).setOnZero(false))
|
||||
);
|
||||
//数据信息
|
||||
LineSeries aSeries = new LineSeries()
|
||||
.setName(a)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setData(aValue);
|
||||
LineSeries bSeries = new LineSeries()
|
||||
.setName(b)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setData(bValue);
|
||||
LineSeries cSeries = new LineSeries()
|
||||
.setName(c)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setData(cValue);
|
||||
instantOption.setSeries(new LineSeries[]{aSeries, bSeries, cSeries});
|
||||
return ENGINE.renderJsonOption(instantOption);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ public interface PicCommonData {
|
||||
*/
|
||||
String CENTER = "center";
|
||||
|
||||
/**
|
||||
* 绘图定位
|
||||
*/
|
||||
String LEFT = "left";
|
||||
|
||||
|
||||
/***
|
||||
* png base64固定前缀
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -56,6 +57,28 @@ public class DrawPicUtil {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制波形图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawWavePic(String title, List<List<Float>> aValue, List<List<Float>> bValue, List<List<Float>> cValue, String unit, Float max, Float min, String a, String b, String c, List<String> colors, Boolean isOpen) {
|
||||
return drawWavePic(title, aValue, bValue, cValue, unit, max, min, a, b, c, colors, isOpen, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制波形图
|
||||
* @author hongawen
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawWavePic(String title, List<List<Float>> aValue, List<List<Float>> bValue, List<List<Float>> cValue, String unit, Float max, Float min, String a, String b, String c, List<String> colors, Boolean isOpen, int width, int height) {
|
||||
String instantJson = LineGenerator.generateWaveOption(title, aValue, bValue, cValue, unit, max, min, a, b, c, colors, isOpen);
|
||||
return drawPic(instantJson, width, height);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制itic曲线图
|
||||
* @author hongawen
|
||||
@@ -152,7 +175,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawMonth(List<String> xName, List<Integer> times, String year, Integer flag) {
|
||||
return drawMonth(xName, times, year, flag, 0, 0);
|
||||
return drawMonth(xName, times, year, flag, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -162,7 +185,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 = BarGenerator.generateMonthOption( xName, times, year, flag);
|
||||
String monthJson = BarGenerator.generateMonthOption(xName, times, year, flag);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -172,8 +195,8 @@ public class DrawPicUtil {
|
||||
* @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);
|
||||
public String drawReason(List<String> xname, List<Map<String, Object>> map2) {
|
||||
return drawReason(xname, map2, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -182,8 +205,8 @@ public class DrawPicUtil {
|
||||
* @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 = PieGenerator.generateReasonOption(xname, map2);
|
||||
public String drawReason(List<String> xname, List<Map<String, Object>> map2, int width, int height) {
|
||||
String monthJson = PieGenerator.generateReasonOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -193,8 +216,8 @@ public class DrawPicUtil {
|
||||
* @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);
|
||||
public String drawType(List<String> xname, List<Map<String, Object>> map2) {
|
||||
return drawType(xname, map2, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -203,8 +226,8 @@ public class DrawPicUtil {
|
||||
* @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 = PieGenerator.generateTypeOption(xname, map2);
|
||||
public String drawType(List<String> xname, List<Map<String, Object>> map2, int width, int height) {
|
||||
String monthJson = PieGenerator.generateTypeOption(xname, map2);
|
||||
return drawPic(monthJson, width, height);
|
||||
}
|
||||
|
||||
@@ -237,7 +260,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventRegion(List<String> xData, List<Integer> yData) {
|
||||
return drawEventRegion(xData,yData, 0, 0);
|
||||
return drawEventRegion(xData, yData, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -247,7 +270,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventRegion(List<String> xData, List<Integer> yData, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateRegionOption(xData,yData);
|
||||
String eventDensityJson = LineGenerator.generateRegionOption(xData, yData);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
|
||||
@@ -258,7 +281,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventAssociatedUnassociated(List<String> eventValue, List<Integer> pereventValue, List<Integer> pereventValue1, String xName) {
|
||||
return drawEventAssociatedUnassociated(eventValue,pereventValue,pereventValue1,xName, 0, 0);
|
||||
return drawEventAssociatedUnassociated(eventValue, pereventValue, pereventValue1, xName, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -268,7 +291,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventAssociatedUnassociated(List<String> eventValue, List<Integer> pereventValue, List<Integer> pereventValue1, String xName, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateAssociatedUnassociatedOption(eventValue,pereventValue,pereventValue1,xName);
|
||||
String eventDensityJson = LineGenerator.generateAssociatedUnassociatedOption(eventValue, pereventValue, pereventValue1, xName);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
|
||||
@@ -279,7 +302,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventVoltageLevel(List<String> xData, List<Integer> yData) {
|
||||
return drawEventVoltageLevel(xData,yData, 0, 0);
|
||||
return drawEventVoltageLevel(xData, yData, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -289,7 +312,7 @@ public class DrawPicUtil {
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventVoltageLevel(List<String> xData, List<Integer> yData, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateVoltageLevelOption(xData,yData);
|
||||
String eventDensityJson = LineGenerator.generateVoltageLevelOption(xData, yData);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
|
||||
@@ -299,8 +322,8 @@ public class DrawPicUtil {
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventRegionDevice(List<String> xData, List<Integer> onlineData,List<Integer> offlineData,String subtext,String xName) {
|
||||
return drawEventRegionDevice(xData,onlineData,offlineData,subtext,xName, 0, 0);
|
||||
public String drawEventRegionDevice(List<String> xData, List<Integer> onlineData, List<Integer> offlineData, String subtext, String xName) {
|
||||
return drawEventRegionDevice(xData, onlineData, offlineData, subtext, xName, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -309,8 +332,8 @@ public class DrawPicUtil {
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventRegionDevice(List<String> xData, List<Integer> onlineData,List<Integer> offlineData,String subtext,String xName, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateRegionDeviceOption(xData,onlineData,offlineData,subtext,xName);
|
||||
public String drawEventRegionDevice(List<String> xData, List<Integer> onlineData, List<Integer> offlineData, String subtext, String xName, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateRegionDeviceOption(xData, onlineData, offlineData, subtext, xName);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
|
||||
@@ -320,8 +343,8 @@ public class DrawPicUtil {
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventFrequency(List<String> xData, List<Integer> dip,List<Integer> interruptions,List<Integer> rise,String subtext,String xName) {
|
||||
return drawEventFrequency(xData,dip,interruptions,rise,subtext,xName, 0, 0);
|
||||
public String drawEventFrequency(List<String> xData, List<Integer> dip, List<Integer> interruptions, List<Integer> rise, String subtext, String xName) {
|
||||
return drawEventFrequency(xData, dip, interruptions, rise, subtext, xName, 0, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -330,8 +353,10 @@ public class DrawPicUtil {
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
public String drawEventFrequency(List<String> xData, List<Integer> dip,List<Integer> interruptions,List<Integer> rise,String subtext,String xName, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateFrequencyOption(xData,dip,interruptions,rise,subtext,xName);
|
||||
public String drawEventFrequency(List<String> xData, List<Integer> dip, List<Integer> interruptions, List<Integer> rise, String subtext, String xName, int width, int height) {
|
||||
String eventDensityJson = LineGenerator.generateFrequencyOption(xData, dip, interruptions, rise, subtext, xName);
|
||||
return drawPic(eventDensityJson, width, height);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -108,5 +108,10 @@ public interface OssPath {
|
||||
*/
|
||||
String RESPONSIBILITY_USER_RESULT_DATA="advance/responsibility/userData/result/";
|
||||
|
||||
/***
|
||||
* 事件的波形图片
|
||||
*/
|
||||
String EVENT_WAVE_PIC="event/wave/";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<module>common-huawei</module>
|
||||
<module>common-oss</module>
|
||||
<module>common-mq</module>
|
||||
<module>common-event</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
||||
Reference in New Issue
Block a user