From 316317942e29a2a432cebfbe1a665c27b89b6c18 Mon Sep 17 00:00:00 2001
From: hongawen <83944980@qq.com>
Date: Wed, 21 Jun 2023 15:51:30 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pqs-common/common-echarts/pom.xml | 5 +-
.../com/njcn/echarts/bar/BarOptionUtil.java | 84 ---
.../com/njcn/echarts/json/LineGenerator.java | 175 ++++++
.../com/njcn/echarts/line/LineOptionUtil.java | 78 ---
.../njcn/echarts/pojo/bo/TolerateData.java | 29 +
.../echarts/pojo/constant/PicCommonData.java | 14 +
.../njcn/echarts/util/BusinessDataUtil.java | 107 ++++
.../com/njcn/echarts/util/DrawPicUtil.java | 106 +++-
pqs-event/event-boot/pom.xml | 1 +
.../majornetwork/Impl/ReportServiceImpl.java | 575 +++++-------------
10 files changed, 589 insertions(+), 585 deletions(-)
delete mode 100644 pqs-common/common-echarts/src/main/java/com/njcn/echarts/bar/BarOptionUtil.java
create mode 100644 pqs-common/common-echarts/src/main/java/com/njcn/echarts/json/LineGenerator.java
delete mode 100644 pqs-common/common-echarts/src/main/java/com/njcn/echarts/line/LineOptionUtil.java
create mode 100644 pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/bo/TolerateData.java
create mode 100644 pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/BusinessDataUtil.java
diff --git a/pqs-common/common-echarts/pom.xml b/pqs-common/common-echarts/pom.xml
index 39bdeba13..65c865508 100644
--- a/pqs-common/common-echarts/pom.xml
+++ b/pqs-common/common-echarts/pom.xml
@@ -33,8 +33,9 @@
${project.version}
- com.github.abel533
- ECharts
+ org.icepear.echarts
+ echarts-java
+ 1.0.7
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/bar/BarOptionUtil.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/bar/BarOptionUtil.java
deleted file mode 100644
index f9c39aec3..000000000
--- a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/bar/BarOptionUtil.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.njcn.echarts.bar;
-
-import cn.hutool.json.JSONObject;
-import com.github.abel533.echarts.Grid;
-import com.github.abel533.echarts.axis.AxisLabel;
-import com.github.abel533.echarts.axis.CategoryAxis;
-import com.github.abel533.echarts.axis.SplitLine;
-import com.github.abel533.echarts.axis.ValueAxis;
-import com.github.abel533.echarts.code.AxisType;
-import com.github.abel533.echarts.code.SeriesType;
-import com.github.abel533.echarts.json.GsonOption;
-import com.github.abel533.echarts.series.Bar;
-import com.njcn.common.pojo.response.HttpResult;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- *
- * 用于组装柱状图的option数据
- *
- * @author hongawen
- * @version 1.0.0
- * @date 2022年08月18日 10:58
- */
-public class BarOptionUtil {
-
-
- public static void main(String[] args) {
- JSONObject optionJson = testEchart();
- RestTemplate restTemplate = new RestTemplate();
- ResponseEntity forEntity = restTemplate.getForEntity("http://192.168.1.13:8910?opt={1}&width={2}&height={3}", HttpResult.class, optionJson.toString(), 714, 300);
- //返回图片对应的base64
- System.out.println(forEntity.getBody().getData());
- System.out.println(1);
-
- }
-
- public static JSONObject testEchart() {
- List xName = Stream.of("江苏省", "四川省", "海南省").collect(Collectors.toList());
- GsonOption option = new GsonOption();
- // 大标题、位置
- String title = "区域统计";
- option.title().text(title).x("center");
- // 提示工具
- // 在轴上触发提示数据
- option.tooltip().show(false);
- // 工具栏
- // 显示,保存为图片
- option.toolbox().show(false);
- // 图例
- option.color("#FF7E50");
- option.legend("暂降次数");
- //控制图标在dataroom中的位置大小
- option.grid(new Grid().left("3%").right("15%").bottom("5%").containLabel(true));
- // 轴分类
- CategoryAxis xAxis = new CategoryAxis();
- xAxis.data(xName.toArray());
- xAxis.splitLine(new SplitLine().show(false));
- xAxis.name("地区\n(监测点数)");
- xAxis.axisLabel(new AxisLabel().interval(0).show(true));
- // 起始和结束两端空白策略
- xAxis.boundaryGap(true);
- // x轴
- option.xAxis(xAxis);
- //循环数据
- Bar bar = new Bar();
- bar.setType(SeriesType.bar);
- bar.barMaxWidth(30);
- bar.data(30, 48, 66);
- option.series(bar);
- // y轴
- ValueAxis yAxis = new ValueAxis();
- yAxis.name("(次)").type(AxisType.value);
- option.yAxis(yAxis);
- String optionStr = option.toString().replace(" ", "");
- return new JSONObject(optionStr);
- }
-
-
-}
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/json/LineGenerator.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/json/LineGenerator.java
new file mode 100644
index 000000000..5c0da6bd0
--- /dev/null
+++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/json/LineGenerator.java
@@ -0,0 +1,175 @@
+package com.njcn.echarts.json;
+
+import com.njcn.echarts.pojo.bo.TolerateData;
+import com.njcn.echarts.pojo.constant.PicCommonData;
+import org.icepear.echarts.Option;
+import org.icepear.echarts.charts.bar.BarSeries;
+import org.icepear.echarts.charts.line.LineSeries;
+import org.icepear.echarts.charts.scatter.ScatterSeries;
+import org.icepear.echarts.components.coord.AxisNameTextStyle;
+import org.icepear.echarts.components.coord.SplitLine;
+import org.icepear.echarts.components.coord.ValueAxisLabel;
+import org.icepear.echarts.components.coord.cartesian.CategoryAxis;
+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.title.Title;
+import org.icepear.echarts.components.tooltip.Tooltip;
+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月21日 10:05
+ */
+public class LineGenerator {
+
+ private final static Engine ENGINE = new Engine();
+
+
+ /***
+ * 生成ITIC曲线
+ * @author hongawen
+ * @date 2023/6/21 10:06
+ */
+ public static String generateIticOption(TolerateData tolerateData) {
+ Option iticOption = new Option();
+ //取消渲染动画
+ iticOption.setAnimation(false);
+ //背景色
+ iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
+ //标题
+ iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("ITIC曲线"));
+ //上下左右的图内间距
+ iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("40px").setBottom("10%"));
+ //设置图例
+ iticOption.setLegend(new Legend().setData(new String[]{"上限", "下限", "可容忍事件", "不可容忍事件"}).setTop("26px").setLeft(0).setBottom("94%"));
+ //设置图例对应的颜色
+ iticOption.setColor(new String[]{"#FF8C00", "#00BFFF", "green", "red"});
+ //横坐标
+ iticOption.setXAxis(new LogAxis().setMin("0.001").setMax("1000").setSplitLine(new SplitLine().setShow(false)).setName("s"));
+ //纵坐标
+ iticOption.setYAxis(new ValueAxis().setName("%").setMinInterval(3).setSplitNumber(10));
+ //处理上限配置
+ LineSeries upperLimit = new LineSeries()
+ .setName("上限")
+ .setData(new float[][]{{0.001f, 200}, {0.003f, 140}, {0.003f, 120}, {0.5f, 120}, {0.5f, 110}, {10, 110}, {1000, 110}})
+ .setShowSymbol(false)
+ .setTooltip(new Tooltip().setShow(false));
+
+ //处理下限配置
+ LineSeries lowerLimit = new LineSeries()
+ .setName("下限")
+ .setData(new float[][]{{0.02f, 0}, {0.02f, 70}, {0.5f, 70}, {0.5f, 80}, {10, 80}, {10, 90}, {1000, 90}})
+ .setShowSymbol(false)
+ .setTooltip(new Tooltip().setShow(false));
+ //配置可容忍点数据
+ ScatterSeries tolerate = new ScatterSeries()
+ .setName("可容忍事件")
+ .setSymbol("circle")
+ .setData(tolerateData.getTolerateData());
+ //配置不可容忍点数据
+ ScatterSeries unTolerate = new ScatterSeries()
+ .setName("不可容忍事件")
+ .setSymbol("circle")
+ .setData(tolerateData.getUnTolerateData());
+ iticOption.setSeries(new SeriesOption[]{upperLimit, lowerLimit, tolerate, unTolerate});
+ return ENGINE.renderJsonOption(iticOption);
+ }
+
+
+ /***
+ * 生成F47曲线
+ * @author hongawen
+ * @date 2023/6/21 10:06
+ */
+ public static String generateF47Option(TolerateData tolerateData) {
+ Option iticOption = new Option();
+ //取消渲染动画
+ iticOption.setAnimation(false);
+ //背景色
+ iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
+ //标题
+ iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("SEMI F47曲线"));
+ //上下左右的图内间距
+ iticOption.setGrid(new Grid().setTop("80px").setLeft("40px").setRight("40px").setBottom("10%"));
+ //设置图例
+ iticOption.setLegend(new Legend().setData(new String[]{"边界线", "可容忍事件", "不可容忍事件"}).setTop("26px").setLeft(0).setBottom("94%"));
+ //设置图例对应的颜色
+ iticOption.setColor(new String[]{"yellow", "green", "red"});
+ //横坐标
+ iticOption.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));
+ //处理边界线
+ LineSeries borderLimit = new LineSeries()
+ .setName("边界线")
+ .setData(new float[][]{{0.05f, 0}, {0.05f, 50}, {0.2f, 50}, {0.2f, 70}, {0.5f, 70}, {0.5f, 80}, {10, 80}, {10, 90}, {1000, 90}})
+ .setShowSymbol(false)
+ .setTooltip(new Tooltip().setShow(false));
+ //配置可容忍点数据
+ ScatterSeries tolerate = new ScatterSeries()
+ .setName("可容忍事件")
+ .setSymbol("circle")
+ .setData(tolerateData.getTolerateData());
+ //配置不可容忍点数据
+ ScatterSeries unTolerate = new ScatterSeries()
+ .setName("不可容忍事件")
+ .setSymbol("circle")
+ .setData(tolerateData.getUnTolerateData());
+ iticOption.setSeries(new SeriesOption[]{borderLimit, tolerate, unTolerate});
+ return ENGINE.renderJsonOption(iticOption);
+ }
+
+
+ /***
+ * 生成暂降幅值
+ * @author hongawen
+ * @date 2023/6/21 10:06
+ */
+ public static String generateEventAmplitudeOption(List ylinedata, List ybardata) {
+ Option iticOption = new Option();
+ //取消渲染动画
+ iticOption.setAnimation(false);
+ //背景色
+ iticOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
+ //标题
+ iticOption.setTitle(new Title().setLeft(PicCommonData.CENTER).setText("暂降幅值的概率分布"));
+ //设置图例
+ iticOption.setLegend(new Legend().setData(new String[]{"概率分布", "占比"}).setLeft(10).setShow(true));
+ //横坐标
+ iticOption.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[]{
+ new ValueAxis()
+ .setName("%")
+ .setNameTextStyle(new AxisNameTextStyle().setFontStyle("15px"))
+ .setAxisLabel(new ValueAxisLabel().setFormatter("{value}%"))
+ });
+
+ //配置概率分布
+ LineSeries probability = new LineSeries()
+ .setName("概率分布")
+ .setData(ylinedata);
+ //配置占比
+ BarSeries proportion = new BarSeries()
+ .setName("占比")
+ .setBarWidth(30)
+ .setData(ybardata);
+
+ iticOption.setSeries(new SeriesOption[]{probability, proportion});
+ return ENGINE.renderJsonOption(iticOption);
+ }
+
+
+}
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/line/LineOptionUtil.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/line/LineOptionUtil.java
deleted file mode 100644
index 1757cee76..000000000
--- a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/line/LineOptionUtil.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.njcn.echarts.line;
-
-import cn.hutool.json.JSONObject;
-import com.github.abel533.echarts.Grid;
-import com.github.abel533.echarts.axis.AxisLabel;
-import com.github.abel533.echarts.axis.CategoryAxis;
-import com.github.abel533.echarts.axis.SplitLine;
-import com.github.abel533.echarts.axis.ValueAxis;
-import com.github.abel533.echarts.code.AxisType;
-import com.github.abel533.echarts.code.NameLocation;
-import com.github.abel533.echarts.code.SeriesType;
-import com.github.abel533.echarts.json.GsonOption;
-import com.github.abel533.echarts.series.Bar;
-import com.github.abel533.echarts.series.Line;
-import com.njcn.common.pojo.response.HttpResult;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * @author hongawen
- * @version 1.0.0
- * @date 2022年08月18日 14:39
- */
-public class LineOptionUtil {
-
-
- public static void main(String[] args) {
- JSONObject optionJson = testEchart();
- RestTemplate restTemplate = new RestTemplate();
- ResponseEntity forEntity = restTemplate.getForEntity("http://192.168.1.13:8910?opt={1}&width={2}&height={3}", HttpResult.class, optionJson.toString(), 714, 300);
- //返回图片对应的base64
- System.out.println(forEntity.getBody().getData());
- System.out.println(1);
-
- }
-
- public static JSONObject testEchart() {
- List xName = Stream.of("0", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%").collect(Collectors.toList());
- GsonOption option = new GsonOption();
- option.backgroundColor("#F9F9F9");
- // 大标题、位置
- String title = "暂降幅值的概率分布函数";
- option.title().text(title).x("center");
- // 提示工具
- // 在轴上触发提示数据
- option.tooltip().show(false);
- // 工具栏
- // 显示,保存为图片
- option.toolbox().show(false);
- // 图例
- option.color("#FF7E50");
- //控制图标在dataroom中的位置大小
- option.grid(new Grid().left("3%").right("11%").bottom("5%").containLabel(true));
- // 轴分类
- CategoryAxis xAxis = new CategoryAxis();
- xAxis.data(xName.toArray());
- xAxis.nameGap(5);
- xAxis.name("暂降幅值");
- // 起始和结束两端空白策略
- xAxis.boundaryGap(false);
- // x轴
- option.xAxis(xAxis);
- Line line = new Line("暂降幅值");
- line.setType(SeriesType.line);
- line.data(0, 10, 11, 15, 16, 30, 48, 66, 75, 89);
- option.series(line);
- // y轴
- ValueAxis yAxis = new ValueAxis();
- yAxis.name("概率分布").type(AxisType.value).nameGap(50).nameLocation(NameLocation.middle).axisLabel(new AxisLabel().formatter("{value} %"));
- option.yAxis(yAxis);
- String optionStr = option.toString().replace(" ", "");
- return new JSONObject(optionStr);
- }
-}
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/bo/TolerateData.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/bo/TolerateData.java
new file mode 100644
index 000000000..54b989945
--- /dev/null
+++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/bo/TolerateData.java
@@ -0,0 +1,29 @@
+package com.njcn.echarts.pojo.bo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author hongawen
+ * @version 1.0.0
+ * @date 2023年06月21日 11:05
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TolerateData {
+
+ /***
+ * 可容忍数据
+ */
+ List> tolerateData = new ArrayList<>();
+
+ /***
+ * 不可容忍数据
+ */
+ List> unTolerateData = new ArrayList<>();
+}
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/constant/PicCommonData.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/constant/PicCommonData.java
index 356986fca..de0f1d053 100644
--- a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/constant/PicCommonData.java
+++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/pojo/constant/PicCommonData.java
@@ -33,8 +33,22 @@ public interface PicCommonData {
Integer COMMON_POI_MAP_HEIGHT = 210;
+ /**
+ * 图片背景色
+ */
+ String PIC_BACK_COLOR = "#FFF";
+ /**
+ * 绘图定位
+ */
+ String CENTER = "center";
+
+
+ /***
+ * png base64固定前缀
+ */
+ String PNG_PREFIX = "data:image/png;base64,";
}
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/BusinessDataUtil.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/BusinessDataUtil.java
new file mode 100644
index 000000000..2a12739c6
--- /dev/null
+++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/BusinessDataUtil.java
@@ -0,0 +1,107 @@
+package com.njcn.echarts.util;
+
+import com.njcn.echarts.pojo.bo.TolerateData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 业务数据处理方法
+ *
+ * @author hongawen
+ * @version 1.0.0
+ * @date 2023年06月21日 11:04
+ */
+public class BusinessDataUtil {
+
+
+ /***
+ * 处理itic数据
+ * @author hongawen
+ * @date 2023/6/21 11:05
+ */
+ public static TolerateData dealIticData(List> originData) {
+ List> tolerateData = new ArrayList<>();
+ List> unTolerateData = new ArrayList<>();
+ for (List list : originData) {
+ //是否超过上限
+ if (list.get(0) <= 0.03) {
+ int line = 230 - 30000 * list.get(0).intValue();
+ if (list.get(1) > line) {
+ unTolerateData.add(list);
+ } else {
+ tolerateData.add(list);
+ }
+ } else if (list.get(0) <= 0.02) {
+ if (list.get(1) > 120) {
+ unTolerateData.add(list);
+ } else {
+ tolerateData.add(list);
+ }
+ } else if (list.get(0) <= 0.5) {
+ if (list.get(1) > 120 || list.get(1) < 70) {
+ unTolerateData.add(list);
+ } else {
+ tolerateData.add(list);
+ }
+ } else if (list.get(0) <= 10) {
+ if (list.get(1) > 110 || list.get(1) < 80) {
+ unTolerateData.add(list);
+ } else {
+ tolerateData.add(list);
+ }
+ } else {
+ if (list.get(1) > 110 || list.get(1) < 90) {
+ unTolerateData.add(list);
+ } else {
+ tolerateData.add(list);
+ }
+ }
+ }
+ return new TolerateData(tolerateData, unTolerateData);
+ }
+
+
+ /***
+ * 处理F47数据
+ * @author hongawen
+ * @date 2023/6/21 11:05
+ */
+ public static TolerateData dealF47Data(List> originData) {
+ List> tolerateData = new ArrayList<>();
+ List> unTolerateData = new ArrayList<>();
+ for (int i = 0; i < originData.size(); i++) {
+ List list = originData.get(i);
+ //是否超过上限
+ if (list.get(0) < 0.05) {
+ tolerateData.add(list);
+ } else if (list.get(0) < 0.2) {
+ if (list.get(1) > 50) {
+ tolerateData.add(list);
+ } else {
+ unTolerateData.add(list);
+ }
+ } else if (list.get(0) < 0.5) {
+ if (list.get(1) > 70) {
+ tolerateData.add(list);
+ } else {
+ unTolerateData.add(list);
+ }
+ } else if (list.get(0) < 10) {
+ if (list.get(1) > 80) {
+ tolerateData.add(list);
+ } else {
+ unTolerateData.add(list);
+ }
+ } else {
+ if (list.get(1) > 90) {
+ tolerateData.add(list);
+ } else {
+ unTolerateData.add(list);
+ }
+ }
+ }
+ return new TolerateData(tolerateData, unTolerateData);
+ }
+}
+
diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java
index c26474b03..0a4782e60 100644
--- a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java
+++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java
@@ -1,16 +1,15 @@
package com.njcn.echarts.util;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpStatus;
-import com.njcn.common.pojo.exception.BusinessException;
-import com.njcn.common.pojo.response.HttpResult;
-import com.njcn.echarts.pojo.enums.EchartResponseEnum;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.njcn.echarts.json.LineGenerator;
+import com.njcn.web.utils.RestTemplateUtil;
import lombok.RequiredArgsConstructor;
-import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+import java.util.List;
import java.util.Objects;
/**
@@ -22,25 +21,104 @@ import java.util.Objects;
@RequiredArgsConstructor
public class DrawPicUtil {
- private final RestTemplate restTemplate;
+ //目前写死,后续作为配置
+ private final String URL = "http://192.168.1.18:5174/picture";
/**
* 请求目标服务器绘制echart图
- * @param url 目标url,例:http://192.168.1.13:8910?opt={1}&width={2}&height={3}
+ *
+ * @param option 图形参数
+ * @return 图形的base64数据
+ */
+ private String drawPic(String option) {
+ return drawPic(option, 0, 0);
+ }
+
+ /**
+ * 请求目标服务器绘制echart图
+ *
* @param option 图形参数
* @param width 图形宽度
* @param height 图形高度
* @return 图形的base64数据
*/
- public String drawPic(String url,String option,int width,int height){
- ResponseEntity result = restTemplate.getForEntity(url, HttpResult.class, option, width, height);
- if(result.getStatusCodeValue() != HttpStatus.HTTP_OK || Objects.isNull(Objects.requireNonNull(result.getBody()).getData())){
- throw new BusinessException(EchartResponseEnum.ECHART_COMMON_ERROR);
- }
- return result.getBody().getData().toString();
+ 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 : width);
+ jsonObject.set("option", JSONUtil.parseObj(option));
+ ResponseEntity picResult = RestTemplateUtil.post(URL, jsonObject, String.class);
+ return Objects.requireNonNull(picResult.getBody()).indexOf("image/png") > 0 ? picResult.getBody() : "";
}
+ /***
+ * 绘制itic曲线图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ * @param originData 原始数据
+ */
+ public String drawItic(List> originData) {
+ return drawItic(originData, 0, 0);
+ }
+
+ /***
+ * 绘制itic曲线图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ * @param originData 原始数据
+ */
+ public String drawItic(List> originData, int width, int height) {
+ String iticJson = LineGenerator.generateIticOption(BusinessDataUtil.dealIticData(originData));
+ return drawPic(iticJson, width, height);
+ }
+
+ /***
+ * 绘制f47曲线图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ * @param originData 原始数据
+ */
+ public String drawF47(List> originData) {
+ return drawF47(originData, 0, 0);
+ }
+
+ /***
+ * 绘制f47曲线图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ * @param originData 原始数据
+ */
+ public String drawF47(List> originData, int width, int height) {
+ String f47Json = LineGenerator.generateF47Option(BusinessDataUtil.dealF47Data(originData));
+ return drawPic(f47Json, width, height);
+ }
+
+ /***
+ * 绘制概率分布图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ */
+ public String drawEventAmplitude(List ylinedata, List ybardata) {
+ return drawEventAmplitude(ylinedata, ybardata, 0, 0);
+ }
+
+ /***
+ * 绘制概率分布图
+ * @author hongawen
+ * @date 2023/6/21 11:01
+ * @return String base64数据
+ */
+ public String drawEventAmplitude(List ylinedata, List ybardata, int width, int height) {
+ String eventAmplitudeJson = LineGenerator.generateEventAmplitudeOption(ylinedata, ybardata);
+ return drawPic(eventAmplitudeJson, width, height);
+ }
+
}
diff --git a/pqs-event/event-boot/pom.xml b/pqs-event/event-boot/pom.xml
index c7315fd54..5d99a0dee 100644
--- a/pqs-event/event-boot/pom.xml
+++ b/pqs-event/event-boot/pom.xml
@@ -83,6 +83,7 @@
${project.version}
+
diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java
index 096b5e5c3..9e072b852 100644
--- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java
+++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java
@@ -5,24 +5,12 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.text.CharPool;
+import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.abel533.echarts.Label;
-import com.github.abel533.echarts.Title;
-import com.github.abel533.echarts.axis.AxisLabel;
-import com.github.abel533.echarts.axis.CategoryAxis;
-import com.github.abel533.echarts.axis.SplitLine;
-import com.github.abel533.echarts.axis.ValueAxis;
-import com.github.abel533.echarts.code.AxisType;
-import com.github.abel533.echarts.code.SeriesType;
-import com.github.abel533.echarts.json.GsonOption;
-import com.github.abel533.echarts.series.Bar;
-import com.github.abel533.echarts.style.ItemStyle;
-import com.github.abel533.echarts.style.TextStyle;
-import com.github.abel533.echarts.style.itemstyle.Normal;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -40,6 +28,8 @@ import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
+import com.njcn.echarts.pojo.constant.PicCommonData;
+import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
@@ -67,6 +57,7 @@ import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import freemarker.template.TemplateException;
+
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -84,6 +75,7 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
+
import lombok.RequiredArgsConstructor;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
@@ -141,44 +133,28 @@ public class ReportServiceImpl implements ReportService {
private final ReportMapper reportMapper;
- public List getED(DeviceInfoParam.BusinessParam businessParam,String id) {
+ private final DrawPicUtil drawPicUtil;
+
+ public List getED(DeviceInfoParam.BusinessParam businessParam, String id) {
List info = new ArrayList<>();
List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List lineIds = deviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
- if(CollectionUtil.isNotEmpty(lineIds)){
+ if (CollectionUtil.isNotEmpty(lineIds)) {
//数据暂降查询
List eventDetails = eventDetailService.list(new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(RmpEventDetailPO::getEventType, id)
- .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
+ .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
);
info = BeanUtil.copyToList(eventDetails, EventDetail.class);
- }else{
+ } else {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
return info;
}
- public List getED2(DeviceInfoParam.BusinessParam businessParam) {
- List info = new ArrayList<>();
- List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
- List lineIds = deviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
- if(CollectionUtil.isNotEmpty(lineIds)){
- //数据暂降查询
- List eventDetails = eventDetailService.list(new LambdaQueryWrapper()
- .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
- .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
- .le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
- );
- info = BeanUtil.copyToList(eventDetails, EventDetailNew.class);
- }else{
- throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
- }
-
- return info;
- }
/**
* 暂态统计(区域)
@@ -190,7 +166,7 @@ public class ReportServiceImpl implements ReportService {
public List getGeneralSituation(DeviceInfoParam.BusinessParam businessParam) {
//获取事件类型
List dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
- if(CollectionUtil.isEmpty(dictType)){
+ if (CollectionUtil.isEmpty(dictType)) {
return new ArrayList<>();
}
Map dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
@@ -200,7 +176,7 @@ public class ReportServiceImpl implements ReportService {
HashMap condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
- condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
+ condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
@@ -212,10 +188,10 @@ public class ReportServiceImpl implements ReportService {
GeneralVO generalVO;
List list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
- generalVO= new GeneralVO();
+ generalVO = new GeneralVO();
generalVO.setName(dto.getName());
- if(CollUtil.isNotEmpty(dto.getLineIndexes())){
+ if (CollUtil.isNotEmpty(dto.getLineIndexes())) {
List collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
@@ -227,7 +203,7 @@ public class ReportServiceImpl implements ReportService {
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
- }else{
+ } else {
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
@@ -251,17 +227,17 @@ public class ReportServiceImpl implements ReportService {
public List getVoltage(DeviceInfoParam.BusinessParam businessParam) {
//获取事件类型
List dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
- if(CollectionUtil.isEmpty(dictType)){
+ if (CollectionUtil.isEmpty(dictType)) {
return new ArrayList<>();
}
Map dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
//查电压
- List data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
+ List data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
HashMap condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
- condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
+ condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
@@ -273,10 +249,10 @@ public class ReportServiceImpl implements ReportService {
GeneralVO generalVO;
List list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
- generalVO= new GeneralVO();
+ generalVO = new GeneralVO();
generalVO.setName(dto.getName());
- if(CollUtil.isNotEmpty(dto.getLineIndexes())){
+ if (CollUtil.isNotEmpty(dto.getLineIndexes())) {
List collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
@@ -288,7 +264,7 @@ public class ReportServiceImpl implements ReportService {
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
- }else{
+ } else {
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
@@ -299,7 +275,7 @@ public class ReportServiceImpl implements ReportService {
list.add(generalVO);
}
- list.forEach(item -> item.setVol(Double.parseDouble(item.getName().substring(0,item.getName().indexOf("k")))));
+ list.forEach(item -> item.setVol(Double.parseDouble(item.getName().substring(0, item.getName().indexOf("k")))));
List sortedList = list.stream().sorted(Comparator.comparing(GeneralVO::getVol)).collect(Collectors.toList());
return sortedList;
}
@@ -316,16 +292,16 @@ public class ReportServiceImpl implements ReportService {
List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List lineIds = deviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
List info = new ArrayList<>();
- if(CollectionUtil.isNotEmpty(lineIds)){
+ if (CollectionUtil.isNotEmpty(lineIds)) {
//数据暂降查询
List eventDetails = eventDetailService.list(new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
- .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
+ .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getSeverity).last(" limit 20")
);
info = BeanUtil.copyToList(eventDetails, EventDetailNew.class);
- }else{
+ } else {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
if (CollectionUtil.isNotEmpty(info)) {
@@ -360,7 +336,7 @@ public class ReportServiceImpl implements ReportService {
public List getReason(DeviceInfoParam.BusinessParam businessParam) {
//获取暂降字典信息
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
- if(ObjectUtil.isNull(dictData)){
+ if (ObjectUtil.isNull(dictData)) {
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List result = new ArrayList<>();
@@ -418,28 +394,28 @@ public class ReportServiceImpl implements ReportService {
public Page getContinueTime(WaveTypeParam waveTypeParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
- if(ObjectUtil.isNull(voltageData)){
+ if (ObjectUtil.isNull(voltageData)) {
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
- List lineIds =new ArrayList<>();
+ List lineIds = new ArrayList<>();
List result = new ArrayList<>();
- if(waveTypeParam.getType()==0){
+ if (waveTypeParam.getType() == 0) {
//pq系统
List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
- lineIds =deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
- }else if(waveTypeParam.getType()==1){
+ lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
+ } else if (waveTypeParam.getType() == 1) {
//pms系统
- PmsDeviceInfoParam param=new PmsDeviceInfoParam();
+ PmsDeviceInfoParam param = new PmsDeviceInfoParam();
param.setDeptIndex(waveTypeParam.getDeptIndex());
param.setStatisticalType(waveTypeParam.getStatisticalType());
List data = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(param).getData();
- lineIds =data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
- }else{
- PmsDeviceInfoParam param=new PmsDeviceInfoParam();
+ lineIds = data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
+ } else {
+ PmsDeviceInfoParam param = new PmsDeviceInfoParam();
param.setDeptIndex(waveTypeParam.getDeptIndex());
param.setStatisticalType(waveTypeParam.getStatisticalType());
List data = pmsGeneralDeviceInfoClient.getPwPmsDeviceInfoWithOrgId(param).getData();
- lineIds =data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
+ lineIds = data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
}
if (CollectionUtil.isEmpty(lineIds)) {
@@ -447,12 +423,12 @@ public class ReportServiceImpl implements ReportService {
}
Page pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
- .eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
- .ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
+ .eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
+ .ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
- List info =BeanUtil.copyToList(pageInfo.getRecords(),EventDetailNew.class);
+ List info = BeanUtil.copyToList(pageInfo.getRecords(), EventDetailNew.class);
if (CollectionUtil.isNotEmpty(info)) {
ArrayList idlist = new ArrayList<>();
for (EventDetailNew eventDetail : info) {
@@ -461,8 +437,8 @@ public class ReportServiceImpl implements ReportService {
result.add(vo);
idlist.add(eventDetail.getLineId());
}
- if(CollUtil.isNotEmpty(idlist)){
- if(waveTypeParam.getType()==0){
+ if (CollUtil.isNotEmpty(idlist)) {
+ if (waveTypeParam.getType() == 0) {
//pq系统
HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List data = AreaInfo.getData();
@@ -474,7 +450,7 @@ public class ReportServiceImpl implements ReportService {
}
}
- }else{
+ } else {
//pms系统
List monitorInfo = monitorClient.getMonitorList(idlist).getData();
for (DetailVO detailVO : result) {
@@ -503,7 +479,7 @@ public class ReportServiceImpl implements ReportService {
}
}
}
- Page page = BeanUtil.copyProperties(pageInfo,Page.class);
+ Page page = BeanUtil.copyProperties(pageInfo, Page.class);
page.setRecords(result);
return page;
@@ -527,7 +503,7 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
- Page detail = reportMapper.getSagTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()),lineIds,waveTypeParam.getSearchBeginTime(),waveTypeParam.getSearchEndTime(),dictdata.getId());
+ Page detail = reportMapper.getSagTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
List detailVO = detail.getRecords();
/*Page pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
@@ -557,7 +533,7 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
- if(CollUtil.isNotEmpty(idlist)){
+ if (CollUtil.isNotEmpty(idlist)) {
HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
@@ -581,7 +557,7 @@ public class ReportServiceImpl implements ReportService {
}
}
- Page page = BeanUtil.copyProperties(detail,Page.class);
+ Page page = BeanUtil.copyProperties(detail, Page.class);
page.setRecords(detailVO);
return page;
@@ -606,7 +582,7 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
- Page detail = reportMapper.getUpTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()),lineIds,waveTypeParam.getSearchBeginTime(),waveTypeParam.getSearchEndTime(),dictdata.getId());
+ Page detail = reportMapper.getUpTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
List detailVO = detail.getRecords();
/*Page pageInfo = eventDetailService.page(
new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()),
@@ -641,7 +617,7 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
- if(CollUtil.isNotEmpty(idlist)){
+ if (CollUtil.isNotEmpty(idlist)) {
HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
@@ -664,7 +640,7 @@ public class ReportServiceImpl implements ReportService {
}
}
}
- Page page = BeanUtil.copyProperties(detail,Page.class);
+ Page page = BeanUtil.copyProperties(detail, Page.class);
page.setRecords(detailVO);
return page;
@@ -690,7 +666,7 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
- Page detail = reportMapper.getBreakTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()),lineIds,waveTypeParam.getSearchBeginTime(),waveTypeParam.getSearchEndTime(),dictdata.getId());
+ Page detail = reportMapper.getBreakTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
List detailVO = detail.getRecords();
/* Page pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper()
@@ -724,7 +700,7 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
- if(CollUtil.isNotEmpty(idlist)){
+ if (CollUtil.isNotEmpty(idlist)) {
HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List data = AreaInfo.getData();
/* for (DetailVO detailVO : result) {
@@ -748,7 +724,7 @@ public class ReportServiceImpl implements ReportService {
}
}
- Page page = BeanUtil.copyProperties(detail,Page.class);
+ Page page = BeanUtil.copyProperties(detail, Page.class);
page.setRecords(detailVO);
return page;
@@ -887,12 +863,12 @@ public class ReportServiceImpl implements ReportService {
bodyFont.setFontHeightInPoints((short) 9);
bodyStyle.setFont(bodyFont);
- sheet2(sheets,cellStyle,bodyStyle,businessParam);
- sheet3(sheets,cellStyle,bodyStyle,businessParam);
- sheet4(sheets,cellStyle,bodyStyle,businessParam);
- sheet5(sheets,cellStyle,bodyStyle,businessParam);
- sheet6(sheets,cellStyle,bodyStyle,businessParam);
- sheet7(sheets,cellStyle,bodyStyle,businessParam);
+ sheet2(sheets, cellStyle, bodyStyle, businessParam);
+ sheet3(sheets, cellStyle, bodyStyle, businessParam);
+ sheet4(sheets, cellStyle, bodyStyle, businessParam);
+ sheet5(sheets, cellStyle, bodyStyle, businessParam);
+ sheet6(sheets, cellStyle, bodyStyle, businessParam);
+ sheet7(sheets, cellStyle, bodyStyle, businessParam);
ArrayList online = new ArrayList<>();
@@ -1077,7 +1053,8 @@ public class ReportServiceImpl implements ReportService {
drawingPatriarch.createPicture(anchor3, sheets.addPicture(bytes4, HSSFWorkbook.PICTURE_TYPE_JPEG));
PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response);
}
- public void sheet2(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
+
+ public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("暂态严重度统计");
HSSFSheet sheetAt = sheets.getSheetAt(1);
sheetAt.setColumnWidth(0, 24 * 256);
@@ -1155,20 +1132,21 @@ public class ReportServiceImpl implements ReportService {
cell8.setCellStyle(bodyStyle);
cell9.setCellStyle(bodyStyle);
- cell0.setCellValue(i+1);
+ cell0.setCellValue(i + 1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
- cell7.setCellValue(vo.getFeatureAmplitude()*100);
+ cell7.setCellValue(vo.getFeatureAmplitude() * 100);
cell8.setCellValue(vo.getDuration());
cell9.setCellValue(BigDecimal.valueOf(vo.getSeverity()).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
- public void sheet3(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
+
+ public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
sheets.createSheet("暂态原因统计");
HSSFSheet sheetAt = sheets.getSheetAt(2);
sheetAt.setColumnWidth(0, 40 * 256);
@@ -1216,7 +1194,7 @@ public class ReportServiceImpl implements ReportService {
cellR0.setCellStyle(bodyStyle);
for (ReasonsVO reasonsVO : reason) {
- if(ObjectUtil.equals(reasonsVO.getReason(),"短路故障")) {
+ if (ObjectUtil.equals(reasonsVO.getReason(), "短路故障")) {
HSSFCell cell1 = row.createCell(1);
HSSFCell cellR1 = row2.createCell(1);
cell1.setCellStyle(bodyStyle);
@@ -1224,7 +1202,7 @@ public class ReportServiceImpl implements ReportService {
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
- if(ObjectUtil.equals(reasonsVO.getReason(),"变压器激磁")) {
+ if (ObjectUtil.equals(reasonsVO.getReason(), "变压器激磁")) {
HSSFCell cell1 = row.createCell(2);
HSSFCell cellR1 = row2.createCell(2);
cell1.setCellStyle(bodyStyle);
@@ -1232,7 +1210,7 @@ public class ReportServiceImpl implements ReportService {
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
- if(ObjectUtil.equals(reasonsVO.getReason(),"电压扰动")) {
+ if (ObjectUtil.equals(reasonsVO.getReason(), "电压扰动")) {
HSSFCell cell1 = row.createCell(3);
HSSFCell cellR1 = row2.createCell(3);
cell1.setCellStyle(bodyStyle);
@@ -1240,7 +1218,7 @@ public class ReportServiceImpl implements ReportService {
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
- if(ObjectUtil.equals(reasonsVO.getReason(),"大型感应电动机启动")) {
+ if (ObjectUtil.equals(reasonsVO.getReason(), "大型感应电动机启动")) {
HSSFCell cell1 = row.createCell(4);
HSSFCell cellR1 = row2.createCell(4);
cell1.setCellStyle(bodyStyle);
@@ -1248,7 +1226,7 @@ public class ReportServiceImpl implements ReportService {
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
- if(ObjectUtil.equals(reasonsVO.getReason(),"其他")) {
+ if (ObjectUtil.equals(reasonsVO.getReason(), "其他")) {
HSSFCell cell1 = row.createCell(5);
HSSFCell cellR1 = row2.createCell(5);
cell1.setCellStyle(bodyStyle);
@@ -1273,7 +1251,8 @@ public class ReportServiceImpl implements ReportService {
}
- public void sheet4(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
+
+ public void sheet4(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("详细事件列表");
HSSFSheet sheetAt = sheets.getSheetAt(3);
sheetAt.setColumnWidth(0, 24 * 256);
@@ -1353,21 +1332,22 @@ public class ReportServiceImpl implements ReportService {
cell9.setCellStyle(bodyStyle);
cell10.setCellStyle(bodyStyle);
- cell0.setCellValue(i+1);
+ cell0.setCellValue(i + 1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
- cell7.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
- cell8.setCellValue(vo.getFeatureAmplitude()*100);
+ cell7.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
+ cell8.setCellValue(vo.getFeatureAmplitude() * 100);
cell9.setCellValue(vo.getDuration());
cell10.setCellValue(vo.getAdvanceType());
}
}
- public void sheet5(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
+
+ public void sheet5(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("暂降次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(4);
sheetAt.setColumnWidth(0, 24 * 256);
@@ -1403,7 +1383,7 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r1Cell5, "供电公司", cellStyle);
setCellStyle(r1Cell6, "暂降次数", cellStyle);
DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
- List severity = sheetList(businessParam,dictdata.getId());
+ List severity = sheetList(businessParam, dictdata.getId());
for (int i = 0; i < severity.size(); i++) {
DetailVO vo = severity.get(i);
@@ -1424,17 +1404,18 @@ public class ReportServiceImpl implements ReportService {
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
- cell0.setCellValue(i+1);
+ cell0.setCellValue(i + 1);
cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType());
- cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
+ cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes());
}
}
- public void sheet6(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
+
+ public void sheet6(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("暂升次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(5);
sheetAt.setColumnWidth(0, 24 * 256);
@@ -1470,7 +1451,7 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r1Cell5, "供电公司", cellStyle);
setCellStyle(r1Cell6, "暂升次数", cellStyle);
DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
- List severity = sheetList(businessParam,dictdata.getId());
+ List severity = sheetList(businessParam, dictdata.getId());
for (int i = 0; i < severity.size(); i++) {
DetailVO vo = severity.get(i);
@@ -1491,17 +1472,18 @@ public class ReportServiceImpl implements ReportService {
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
- cell0.setCellValue(i+1);
+ cell0.setCellValue(i + 1);
cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType());
- cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
+ cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes());
}
}
- public void sheet7(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
+
+ public void sheet7(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("短时中断次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(6);
sheetAt.setColumnWidth(0, 24 * 256);
@@ -1537,7 +1519,7 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r1Cell5, "供电公司", cellStyle);
setCellStyle(r1Cell6, "短时中断次数", cellStyle);
DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
- List severity = sheetList(businessParam,dictdata.getId());
+ List severity = sheetList(businessParam, dictdata.getId());
for (int i = 0; i < severity.size(); i++) {
DetailVO vo = severity.get(i);
@@ -1558,17 +1540,18 @@ public class ReportServiceImpl implements ReportService {
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
- cell0.setCellValue(i+1);
+ cell0.setCellValue(i + 1);
cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType());
- cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
+ cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes());
}
}
- private List sheetList(DeviceInfoParam.BusinessParam businessParam,String id){
+
+ private List sheetList(DeviceInfoParam.BusinessParam businessParam, String id) {
List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(lineIds)) {
@@ -1580,7 +1563,7 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : listCount) {
idlist.add(vo.getLineId());
}
- if(CollUtil.isNotEmpty(idlist)){
+ if (CollUtil.isNotEmpty(idlist)) {
HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List data = AreaInfo.getData();
for (DetailVO v : listCount) {
@@ -1595,60 +1578,59 @@ public class ReportServiceImpl implements ReportService {
}
-
/**
* sheet 详细数据列表
*/
- private List sheetDetailed(DeviceInfoParam.BusinessParam businessParam){
+ private List sheetDetailed(DeviceInfoParam.BusinessParam businessParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
- if(ObjectUtil.isNull(voltageData)){
+ if (ObjectUtil.isNull(voltageData)) {
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List result = new ArrayList<>();
//pq系统
List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
- List lineIds =deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
+ List lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
- List info = eventDetailService.list( new LambdaQueryWrapper()
+ List info = eventDetailService.list(new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
- .eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
- .ge(StringUtils.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
+ .eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
+ .ge(StringUtils.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
if (CollectionUtil.isNotEmpty(info)) {
- ArrayList idlist = new ArrayList<>();
- for (RmpEventDetailPO eventDetail : info) {
- DetailVO vo = new DetailVO();
- vo.setStartTime( eventDetail.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)));
- BeanUtils.copyProperties(eventDetail, vo);
- result.add(vo);
- idlist.add(eventDetail.getLineId());
- }
- if(CollUtil.isNotEmpty(idlist)){
- //pq系统
- HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
- List data = AreaInfo.getData();
- for (DetailVO detailVO : result) {
- for (AreaLineInfoVO vo : data) {
- if (vo.getLineId().equals(detailVO.getLineId())) {
- BeanUtils.copyProperties(vo, detailVO);
- }
- }
- }
- HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
- List type = reason.getData();
- for (DetailVO detailVO : result) {
- for (DictData dictData : type) {
- if (dictData.getId().equals(detailVO.getAdvanceType())) {
- detailVO.setAdvanceType(dictData.getName());
- }
+ ArrayList idlist = new ArrayList<>();
+ for (RmpEventDetailPO eventDetail : info) {
+ DetailVO vo = new DetailVO();
+ vo.setStartTime(eventDetail.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)));
+ BeanUtils.copyProperties(eventDetail, vo);
+ result.add(vo);
+ idlist.add(eventDetail.getLineId());
+ }
+ if (CollUtil.isNotEmpty(idlist)) {
+ //pq系统
+ HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
+ List data = AreaInfo.getData();
+ for (DetailVO detailVO : result) {
+ for (AreaLineInfoVO vo : data) {
+ if (vo.getLineId().equals(detailVO.getLineId())) {
+ BeanUtils.copyProperties(vo, detailVO);
}
}
}
+ HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
+ List type = reason.getData();
+ for (DetailVO detailVO : result) {
+ for (DictData dictData : type) {
+ if (dictData.getId().equals(detailVO.getAdvanceType())) {
+ detailVO.setAdvanceType(dictData.getName());
+ }
+ }
+ }
+ }
}
return result;
}
@@ -1786,7 +1768,7 @@ public class ReportServiceImpl implements ReportService {
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
- if(exportParam.getType()==0){
+ if (exportParam.getType() == 0) {
HttpResult lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId());
if (ObjectUtil.isNull(lineDetailData)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
@@ -1801,7 +1783,7 @@ public class ReportServiceImpl implements ReportService {
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getData().getDevCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getData().getShortCapacity() + "");
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getData().getPtType());
- }else{
+ } else {
HttpResult> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
if (ObjectUtil.isNull(monitorList)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
@@ -1815,7 +1797,7 @@ public class ReportServiceImpl implements ReportService {
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
insertRow(doc, table, centerParagraph, false, "设备容量", monitorList.getData().get(0).getPowerSupplyEqCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
- insertRow(doc, table, centerParagraph, false, "接线方式",dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName() );
+ insertRow(doc, table, centerParagraph, false, "接线方式", dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
}
i++;
}
@@ -1834,7 +1816,7 @@ public class ReportServiceImpl implements ReportService {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
- insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude()*100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
+ insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
@@ -1845,13 +1827,13 @@ public class ReportServiceImpl implements ReportService {
int two = 1;
if (exportParam.isSjdITIC()) {
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
- String itic = getITIC(ass);
+ String itic = drawPicUtil.drawItic(ass);
createPic(doc, itic, "ITIC曲线");
two++;
}
if (exportParam.isSjdF47()) {
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
- String f47 = getF47(ass);
+ String f47 = drawPicUtil.drawF47(ass);
createPic(doc, f47, "SEMI F47曲线");
two++;
}
@@ -1867,7 +1849,7 @@ public class ReportServiceImpl implements ReportService {
if (exportParam.isMdtx()) {
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
List coords = eventReportService.getCoords(info);
- Integer[][] a=new Integer[87][];
+ Integer[][] a = new Integer[87][];
HashMap map = new HashMap<>();
map.put("data", JSONArray.fromObject(coords).toString());
String str = getStr("bar10.ftl", map);
@@ -1920,7 +1902,7 @@ public class ReportServiceImpl implements ReportService {
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
List ybardata = probabilityVO.getPereventvalue();
List ylinedata = probabilityVO.getEventvalue();
- String fz = getFZ(ylinedata, ybardata);
+ String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
createPic(doc, fz, "暂降幅值的概率分布函数");
two++;
}
@@ -2098,11 +2080,11 @@ public class ReportServiceImpl implements ReportService {
List info = eventDetailService.list(new LambdaQueryWrapper()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.in(RmpEventDetailPO::getEventType, typeIds)
- .ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
+ .ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
- return BeanUtil.copyToList(info,EventDetail.class);
+ return BeanUtil.copyToList(info, EventDetail.class);
// //构建sql语句
// StringBuffer stringResult = new StringBuffer();
// stringResult.append(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE)
@@ -2122,10 +2104,6 @@ public class ReportServiceImpl implements ReportService {
return EchartsUtil.generateEchartsBase64(s, "8910");
}
- public String getPicName(JSONObject jsonObject) {
- ResponseEntity forEntity = restTemplate.getForEntity("http://192.168.1.13:8910?opt={1}&width={2}&height={3}", HttpResult.class, jsonObject.toString(), 714, 300);
- return forEntity.getBody().getData().toString();
- }
public String getR(List xname, List map2, String barname) throws TemplateException, IOException {
HashMap map = new HashMap<>();
@@ -2175,177 +2153,6 @@ public class ReportServiceImpl implements ReportService {
return str;
}
- public JSONObject getBar1(List xdata, List ydata, String tl, String title, String xname, String yname) {
- //初始化option
- GsonOption option = new GsonOption();
- //设置标头
- Title title1 = new Title();
- TextStyle textStyle1 = new TextStyle();
-
- textStyle1.setFontWeight(700);
- title1.text(title).x("center");
- title1.setTextStyle(textStyle1);
- option.title(title1);
- //图例
- option.legend().data(tl).x("left");
- option.color("#FF7E50");
-
- CategoryAxis axis = new CategoryAxis();
- axis.data(xdata.toArray());
- axis.axisLabel(new AxisLabel().interval(0).show(true));
- // 起始和结束两端空白策略
- axis.boundaryGap(true);
- axis.splitLine(new SplitLine().show(false));
- axis.name(xname);
- option.xAxis(axis);
-
- Bar bar = new Bar(tl);
- bar.setType(SeriesType.bar);
- bar.data(ydata.toArray());
- bar.barMaxWidth(30);
- setPosition(bar, "top", "#FF7E50");
- option.series(bar);
-
- ValueAxis valueAxis = new ValueAxis();
- valueAxis.name(yname).type(AxisType.value);
- option.yAxis(valueAxis);
-
- String replace = option.toString().replace(" ", "");
-
- return new JSONObject(replace);
- }
-
- public String getITIC(List> xbardata) throws TemplateException, IOException {
- List> point = new ArrayList<>();
- List> pointno = new ArrayList<>();
-
- for (int i = 0; i < xbardata.size(); i++) {
- List list = xbardata.get(i);
- //是否超过上限
- if (list.get(0) <= 0.03) {
- int line = 230 - 30000 * list.get(0).intValue();
- if (list.get(1) > line) {
- pointno.add(list);
- } else {
- point.add(list);
- }
- } else if (list.get(0) <= 0.02) {
- if (list.get(1) > 120) {
- pointno.add(list);
- } else {
- point.add(list);
- }
- } else if (list.get(0) <= 0.5) {
- if (list.get(1) > 120 || list.get(1) < 70) {
- pointno.add(list);
- } else {
- point.add(list);
- }
- } else if (list.get(0) <= 10) {
- if (list.get(1) > 110 || list.get(1) < 80) {
- pointno.add(list);
- } else {
- point.add(list);
- }
- } else {
- if (list.get(1) > 110 || list.get(1) < 90) {
- pointno.add(list);
- } else {
- point.add(list);
- }
- }
- }
-
- HashMap map = new HashMap<>();
- map.put("point", JSONArray.fromObject(point).toString());
- map.put("pointno", JSONArray.fromObject(pointno).toString());
- String str = getStr("bar3.ftl", map);
- return str;
- }
-
- public String getF47(List> xbardata) throws TemplateException, IOException {
- List> point = new ArrayList<>();
- double[][] part = new double[8][2];
- part[0][0] = 0.05;
- part[0][1] = 0;
- part[1][0] = 0.05;
- part[1][1] = 50;
- part[2][0] = 0.2;
- part[2][1] = 50;
- part[3][0] = 0.2;
- part[3][1] = 70;
- part[4][0] = 0.5;
- part[4][1] = 70;
- part[5][0] = 0.5;
- part[5][1] = 80;
- part[6][0] = 10;
- part[6][1] = 80;
- part[7][0] = 1000;
- part[7][1] = 80;
-
- double max = 0.0;
- for (int i = 0; i < part.length; i++) {
- if (part[i][1] > max) {
- max = part[i][1];
- }
- }
-
- List> pointno = new ArrayList<>();
- for (int i = 0; i < xbardata.size(); i++) {
- List list = xbardata.get(i);
- //是否超过上限
- if (list.get(0) < 0.05) {
- pointno.add(list);
- } else if (list.get(0) < 0.2) {
- if (list.get(1) > 50) {
- point.add(list);
- } else {
- pointno.add(list);
- }
- } else if (list.get(0) < 0.5) {
- if (list.get(1) > 70) {
- point.add(list);
- } else {
- pointno.add(list);
- }
- } else {
- if (list.get(1) > 80) {
- point.add(list);
- } else {
- pointno.add(list);
- }
- }
- }
-
- HashMap map = new HashMap<>();
- map.put("zdz", max);
- map.put("bjx", JSONArray.fromObject(part).toString());
- map.put("point", JSONArray.fromObject(point).toString());
- map.put("pointno", JSONArray.fromObject(pointno).toString());
- String str = getStr("bar4.ftl", map);
- return str;
- }
-
- /**
- * @param bar
- * @param position 位置
- * @param color 颜色
- */
- public void setPosition(Bar bar, String position, String color) {
- //设置标签
- Label label = new Label();
- label.show(true);
- label.position(position);
- TextStyle textStyle = new TextStyle();
- textStyle.setColor(color);
- ItemStyle itemStyle = new ItemStyle();
- label.setTextStyle(textStyle);
- Normal normal = new Normal();
- normal.label(label);
- itemStyle.setNormal(normal);
- bar.setItemStyle(itemStyle);
- }
-
/**
* 表格插入行数据
*
@@ -2377,8 +2184,10 @@ public class ReportServiceImpl implements ReportService {
public void createPic(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException, InvalidFormatException {
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
- BASE64Decoder decoder = new BASE64Decoder();
- byte[] bytes = decoder.decodeBuffer(image);
+ if (image.contains(PicCommonData.PNG_PREFIX)) {
+ image = image.replace(PicCommonData.PNG_PREFIX, "");
+ }
+ byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}
@@ -2512,7 +2321,7 @@ public class ReportServiceImpl implements ReportService {
}
}
- page=BeanUtil.copyProperties(pageInfo,Page.class);
+ page = BeanUtil.copyProperties(pageInfo, Page.class);
page.setRecords(eventDetailList);
}
@@ -2521,7 +2330,6 @@ public class ReportServiceImpl implements ReportService {
}
-
/**
* 获取区域报告
*
@@ -4835,7 +4643,7 @@ public class ReportServiceImpl implements ReportService {
r13.setFontSize(11);//字体大小
- String itic = getITIC(list);
+ String itic = drawPicUtil.drawItic(list);
createPic(doc, itic, "ITIC曲线");
@@ -4909,8 +4717,7 @@ public class ReportServiceImpl implements ReportService {
r13.setText(" F47曲线中可容忍" + typeName + "记录为:" + result.get(0) + "条;不可容忍" + typeName + "记录为:" + result.get(1) + "条,具体见下表(图):");
r13.setFontSize(11);//字体大小
-
- String f47 = getF47(list);
+ String f47 = drawPicUtil.drawF47(list);
createPic(doc, f47, "SEMI F47曲线");
/**
@@ -4940,7 +4747,7 @@ public class ReportServiceImpl implements ReportService {
r13.setFontSize(11);//字体大小
- String f47 = getF47(list);
+ String f47 = drawPicUtil.drawF47(list);
createPic(doc, f47, "SEMI F47曲线");
@@ -5072,13 +4879,13 @@ public class ReportServiceImpl implements ReportService {
r12.setFontSize(11);//字体大小
- createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "幅值的概率分布函数", "标题 3", 400, 11);
+ createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "幅值的概率分布", "标题 3", 400, 11);
List ybardata = probabilityDistributionArea.getPereventvalue();
List ylinedata = probabilityDistributionArea.getEventvalue();
String fz = getFZ(ylinedata, ybardata);
- createPic(doc, fz, "" + typeName + "幅值的概率分布函数");
+ createPic(doc, fz, "" + typeName + "幅值的概率分布");
//序号计数进行++
@@ -5673,8 +5480,8 @@ public class ReportServiceImpl implements ReportService {
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(lineIndexes)) {
//数据统计
- Integer eventDetailCount = getEventDetailCount(areaReportParam,lineIndexes);
- areaCount1.put(generalDeviceDTO.getName(),eventDetailCount);
+ Integer eventDetailCount = getEventDetailCount(areaReportParam, lineIndexes);
+ areaCount1.put(generalDeviceDTO.getName(), eventDetailCount);
// StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes);
// //查询sql语句总条数
@@ -5764,8 +5571,8 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(EventResponseEnum.NOT_LINEID);
}
List eventDetailList = getEventDetailListInfo(areaReportParam, lineIds);
- if(CollectionUtil.isEmpty(eventDetailList)){
- throw new BusinessException(CommonResponseEnum.NO_DATA);
+ if (CollectionUtil.isEmpty(eventDetailList)) {
+ throw new BusinessException(CommonResponseEnum.NO_DATA);
}
//电压集合(统计类型:电压)根据监测点数据进行电压分组
@@ -8053,7 +7860,7 @@ public class ReportServiceImpl implements ReportService {
r13.setFontSize(11);//字体大小
- String itic = getITIC(list);
+ String itic = drawPicUtil.drawItic(list);
createPic(doc, itic, "ITIC曲线");
@@ -8128,7 +7935,7 @@ public class ReportServiceImpl implements ReportService {
r13.setFontSize(11);//字体大小
- String f47 = getF47(list);
+ String f47 = drawPicUtil.drawF47(list);
createPic(doc, f47, "SEMI F47曲线");
/**
@@ -8157,8 +7964,7 @@ public class ReportServiceImpl implements ReportService {
r13.setText(" F47曲线中可容忍" + typeName + "降记录为:" + result.get(0) + "条;不可容忍" + typeName + "记录为:" + result.get(1) + "条,具体见下表(图):");
r13.setFontSize(11);//字体大小
-
- String f47 = getF47(list);
+ String f47 = drawPicUtil.drawF47(list);
createPic(doc, f47, "SEMI F47曲线");
@@ -8890,8 +8696,8 @@ public class ReportServiceImpl implements ReportService {
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(lineIndexes)) {
//数据统计
- Integer eventDetailCount = getEventDetailCount(areaReportParam,lineIndexes);
- areaCount1.put(generalDeviceDTO.getName(),eventDetailCount);
+ Integer eventDetailCount = getEventDetailCount(areaReportParam, lineIndexes);
+ areaCount1.put(generalDeviceDTO.getName(), eventDetailCount);
// StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes);
//
@@ -9476,49 +9282,6 @@ public class ReportServiceImpl implements ReportService {
return result;
}
- //区域sql结果集(暂态)
- public List TableInfo(AreaTableParam areaTableParam) {
-
- StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE).
- append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaTableParam.getStartTime()))).append("' and ").append("time <= '")
- .append(DateUtil.endOfDay(DateUtil.parse(areaTableParam.getEndTime())))
- .append("' and ").append(areaTableParam.getStringBuilder()).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')");
-
-
- //结果集
- QueryResult query = influxDbUtils.query(stringResult.toString());
-
-
- InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
- List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class);
-
- return info;
- }
-
- //区域sql结果集(暂降)
- public List TableInfo1(AreaTableParam areaTableParam) {
-
- StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE).
- append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaTableParam.getStartTime()))).append("' and ").append("time <= '")
- .append(DateUtil.endOfDay(DateUtil.parse(areaTableParam.getEndTime())))
- .append("' and ").append(areaTableParam.getStringBuilder()).append(" tz('Asia/Shanghai')");
-
-
- //结果集
- QueryResult query = influxDbUtils.query(stringResult.toString());
-
-
- InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
- List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class);
-
- return info;
- }
-
- //重写ITIC曲线图
- public List getPlotArea(AreaTableParam areaTableParam) {
-
- return areaTableParam.getInfo();
- }
//获取区域幅值
public ProbabilityVO getProbabilityDistributionArea(AreaTableParam areaTableParam) {
@@ -10001,24 +9764,24 @@ public class ReportServiceImpl implements ReportService {
//获取事件类型(短时中断 电压暂降 电压暂升 扰动 其他)
List dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
- || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
- || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
- || DicDataEnum.OTHER.getCode().equals(x.getCode())
- || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
- )
+ || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
+ || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
+ || DicDataEnum.OTHER.getCode().equals(x.getCode())
+ || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
+ )
.map(DictData::getId).collect(Collectors.toList());
//数据暂降查询
List info = eventDetailService.list(new LambdaQueryWrapper()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.in(RmpEventDetailPO::getEventType, typeIds)
- .ge(StrUtil.isNotBlank(areaReportParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime())))
+ .ge(StrUtil.isNotBlank(areaReportParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(areaReportParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime())))
);
- if(CollUtil.isEmpty(info)){
+ if (CollUtil.isEmpty(info)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
}
- return BeanUtil.copyToList(info,EventDetailNew.class);
+ return BeanUtil.copyToList(info, EventDetailNew.class);
// StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
// //查询sql语句总条数
@@ -10043,11 +9806,11 @@ public class ReportServiceImpl implements ReportService {
//获取事件类型(短时中断 电压暂降 电压暂升 扰动 其他)
List dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
- || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
- || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
- || DicDataEnum.OTHER.getCode().equals(x.getCode())
- || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
- )
+ || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
+ || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
+ || DicDataEnum.OTHER.getCode().equals(x.getCode())
+ || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
+ )
.map(DictData::getId).collect(Collectors.toList());
//数据暂降查询
@@ -10062,8 +9825,6 @@ public class ReportServiceImpl implements ReportService {
}
-
-
/**
* wr(公共查询条数)
*