From 2d3d21504bb086824cbd28e7f8d6ef97646592f7 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Thu, 21 Sep 2023 16:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9A=82=E6=80=81=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=B3=A2=E5=BD=A2=E5=9B=BE=E5=90=8E=E5=8F=B0=E7=BB=98?= =?UTF-8?q?=E5=9B=BE=E5=B9=B6=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/njcn/echarts/json/LineGenerator.java | 91 +- .../echarts/pojo/constant/PicCommonData.java | 5 + .../com/njcn/echarts/util/DrawPicUtil.java | 73 +- .../java/com/njcn/oss/constant/OssPath.java | 5 + pqs-common/pom.xml | 1 + pqs-event/event-api/pom.xml | 5 + .../njcn/event/enums/EventResponseEnum.java | 4 - .../njcn/event/pojo/dto/wave/AnalogDTO.java | 46 - .../event/pojo/dto/wave/ComtradeCfgDTO.java | 50 - .../njcn/event/pojo/dto/wave/DigitalDTO.java | 30 - .../event/pojo/dto/wave/EigenvalueDTO.java | 28 - .../njcn/event/pojo/dto/wave/MutationDTO.java | 27 - .../com/njcn/event/pojo/dto/wave/RateDTO.java | 24 - .../njcn/event/pojo/dto/wave/WaveDataDTO.java | 39 - pqs-event/event-boot/pom.xml | 2 +- .../majornetwork/AutonomeWaveController.java | 10 +- .../majornetwork/TransientController.java | 4 +- .../majornetwork/AutonomeWaveService.java | 2 +- .../majornetwork/EventAnalysisService.java | 3 - .../Impl/AutonomeWaveServiceImpl.java | 16 +- .../Impl/EventAnalysisServiceImpl.java | 3 +- .../Impl/TransientServiceImpl.java | 52 +- .../majornetwork/TransientService.java | 4 +- .../java/com/njcn/event/utils/WaveUtil.java | 1286 ----------------- .../njcn/event/EventBootApplicationTest.java | 17 +- 25 files changed, 183 insertions(+), 1644 deletions(-) delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/AnalogDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/ComtradeCfgDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/DigitalDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/EigenvalueDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/MutationDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/RateDTO.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/WaveDataDTO.java delete mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/WaveUtil.java 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 index 08d2f44f8..17c739632 100644 --- 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 @@ -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 xData, List onlineData,List offlineData,String subtext,String xName) { + public static String generateRegionDeviceOption(List xData, List onlineData, List 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 xData, List dip,List interruptions,List rise,String subtext,String xName) { + public static String generateFrequencyOption(List xData, List dip, List interruptions, List 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> aValue, List> bValue, List> cValue, String unit, Float max, Float min, String a, String b, String c, List 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); + } } 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 de0f1d053..3259adfb9 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 @@ -44,6 +44,11 @@ public interface PicCommonData { */ String CENTER = "center"; + /** + * 绘图定位 + */ + String LEFT = "left"; + /*** * png base64固定前缀 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 43a944039..f0c591af4 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 @@ -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> aValue, List> bValue, List> cValue, String unit, Float max, Float min, String a, String b, String c, List 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> aValue, List> bValue, List> cValue, String unit, Float max, Float min, String a, String b, String c, List 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 xName, List 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 xName, List 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 xname, List> map2) { - return drawReason(xname, map2, 0, 0); + public String drawReason(List xname, List> 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 xname, List> map2, int width, int height) { - String monthJson = PieGenerator.generateReasonOption(xname, map2); + public String drawReason(List xname, List> 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 xname, List> map2) { - return drawType(xname, map2, 0, 0); + public String drawType(List xname, List> 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 xname, List> map2, int width, int height) { - String monthJson = PieGenerator.generateTypeOption(xname, map2); + public String drawType(List xname, List> 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 xData, List 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 xData, List 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 eventValue, List pereventValue, List 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 eventValue, List pereventValue, List 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 xData, List 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 xData, List 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 xData, List onlineData,List offlineData,String subtext,String xName) { - return drawEventRegionDevice(xData,onlineData,offlineData,subtext,xName, 0, 0); + public String drawEventRegionDevice(List xData, List onlineData, List 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 xData, List onlineData,List offlineData,String subtext,String xName, int width, int height) { - String eventDensityJson = LineGenerator.generateRegionDeviceOption(xData,onlineData,offlineData,subtext,xName); + public String drawEventRegionDevice(List xData, List onlineData, List 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 xData, List dip,List interruptions,List rise,String subtext,String xName) { - return drawEventFrequency(xData,dip,interruptions,rise,subtext,xName, 0, 0); + public String drawEventFrequency(List xData, List dip, List interruptions, List 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 xData, List dip,List interruptions,List rise,String subtext,String xName, int width, int height) { - String eventDensityJson = LineGenerator.generateFrequencyOption(xData,dip,interruptions,rise,subtext,xName); + public String drawEventFrequency(List xData, List dip, List interruptions, List rise, String subtext, String xName, int width, int height) { + String eventDensityJson = LineGenerator.generateFrequencyOption(xData, dip, interruptions, rise, subtext, xName); return drawPic(eventDensityJson, width, height); } + + } diff --git a/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java b/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java index 6d29bd5bc..84f68c79e 100644 --- a/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java +++ b/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java @@ -108,5 +108,10 @@ public interface OssPath { */ String RESPONSIBILITY_USER_RESULT_DATA="advance/responsibility/userData/result/"; + /*** + * 事件的波形图片 + */ + String EVENT_WAVE_PIC="event/wave/"; + } diff --git a/pqs-common/pom.xml b/pqs-common/pom.xml index a6a99b498..861e0c84f 100644 --- a/pqs-common/pom.xml +++ b/pqs-common/pom.xml @@ -25,6 +25,7 @@ common-huawei common-oss common-mq + common-event diff --git a/pqs-event/event-api/pom.xml b/pqs-event/event-api/pom.xml index bdd2fa9dd..85b06eec7 100644 --- a/pqs-event/event-api/pom.xml +++ b/pqs-event/event-api/pom.xml @@ -32,6 +32,11 @@ common-microservice ${project.version} + + com.njcn + common-event + ${project.version} + com.njcn pq-device-api diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java index 3c132e2f7..470281f94 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java @@ -16,10 +16,6 @@ public enum EventResponseEnum { */ EVENT_COMMON_ERROR("A00650","暂降模块异常"), EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"), - ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到"), - WAVE_DATA_INVALID("A00654","波形文件数据缺失"), - DAT_DATA_ERROR("A00653","dat文件数据读取失败"), - RMS_DATA_ERROR("A00653","rms数据读取失败"), /** diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/AnalogDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/AnalogDTO.java deleted file mode 100644 index e135eb0ae..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/AnalogDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 模拟量通道记录类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AnalogDTO implements Serializable { - - // 通道序号 - private Integer nIndex; - // 通道名称 - private String szChannleName; - // 相位名称 - private String szPhasicName; - // 监视的通道名称 - private String szMonitoredChannleName; - // 通道的单位 - private String szUnitName; - // 通道的系数 - private Float fCoefficent; - // 通道的便宜量 - private Float fOffset; - // 起始采样时间的偏移量 - private Float fTimeOffset; - // 采样值的最小值 - private Integer nMin; - // 采样值的最大值 - private Integer nMax; - // 一次变比 - private Float fPrimary; - // 二次变比 - private Float fSecondary; - // 一次值还是二次值标志 - private String szValueType; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/ComtradeCfgDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/ComtradeCfgDTO.java deleted file mode 100644 index d583823b5..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/ComtradeCfgDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * CFG配置文件总类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ComtradeCfgDTO implements Serializable { - private Integer nChannelNum; - private Integer nPhasic;// 模拟量通道的个数 yxb 2020-12-15 - private Integer nAnalogNum;// 模拟量通道的个数 WW 2013-05-15 - private Integer nDigitalNum;// 数字量通道的个数 WW 2013-05-15 - private Date timeStart;// 暂态记录时间 yxb 2022-06-06 - private Date timeTrige;// 暂态触发时间 yxb 2022-06-06 - - private List lstAnalogDTO;//模拟量通道记录 - private List lstDigitalDTO;//数字量通道记录 - - public Integer nRates;//对应采样次数 - public List lstRate;//采样率合集 - - // add by sw 暂降触发时间 - private Date firstTime; // 暂降触发第一次 - private Integer firstMs; // 暂降触发第一次毫秒 - - // 波形前推周波束 - private Integer nPush = 0; - // 最终采样率,计算的时候只用一个采样率 - private Long finalSampleRate; - // 整个波形大小 - private Long nAllWaveNum = 0L; - - /*** - * 赋值编码格式(二进制) - */ - private String strBinType; - -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/DigitalDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/DigitalDTO.java deleted file mode 100644 index 32c6d4c95..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/DigitalDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 数字量通道记录类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DigitalDTO implements Serializable { - - // 通道序号 - private Integer nIndex; - // 通道名称 - private String szChannleName; - // 相位名称 - private String szPhasicName; - // 监视的通道名称 - private String szMonitoredChannleName; - // 通道的单位 - private Integer Initial; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/EigenvalueDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/EigenvalueDTO.java deleted file mode 100644 index e4faf5d4f..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/EigenvalueDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 特征值计算类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class EigenvalueDTO implements Serializable { - - //是特征幅值(残余电压百分比) - private float amplitude; - //是特征幅值(残余电压) - private float residualVoltage; - //额定定压(动态电压) - private float ratedVoltage; - //持续时间 - private float durationTime; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/MutationDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/MutationDTO.java deleted file mode 100644 index 10c24f928..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/MutationDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 突变量计算类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class MutationDTO implements Serializable { - - private List> listRms_Offline = new ArrayList<>();//离线数据RMS有效值数据 - private List> listTBL_Offline = new ArrayList<>();//离线数据突变量数据 - private double fMinMagA = 99999d; - private double fMinMagB = 99999d; - private double fMinMagC = 99999d; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/RateDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/RateDTO.java deleted file mode 100644 index 6fdbce05a..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/RateDTO.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 采样率类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class RateDTO implements Serializable { - - // 1秒钟内的采样点数 - private Long nOneSample; - // 总采样点数 - private Long nSampleNum; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/WaveDataDTO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/WaveDataDTO.java deleted file mode 100644 index ada34ad7b..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/dto/wave/WaveDataDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.njcn.event.pojo.dto.wave; - - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.List; - -/** - * @author yxb - * @version 1.0.0 - * @date 2022年06月02日 20:03 - * 返回波形数据类 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class WaveDataDTO implements Serializable { - - private ComtradeCfgDTO comtradeCfgDTO;//CFG实体类 - //波形对应的标题 - private List waveTitle; - //波形对应的值 - private List> listWaveData; - //波形RMS值 - private List> listRmsData; - //RMS最小值 - private List> listRmsMinData; - //波形对应的相别数量 - private Integer iPhasic; - //接线方式(0.星型接法;1.三角型接法;2.开口三角型接法) - private Integer ptType; - //PT变比 - private Double pt; - //CT变比" - private Double ct; -} diff --git a/pqs-event/event-boot/pom.xml b/pqs-event/event-boot/pom.xml index 390f9241c..7111b7028 100644 --- a/pqs-event/event-boot/pom.xml +++ b/pqs-event/event-boot/pom.xml @@ -35,7 +35,7 @@ com.njcn system-api - ${project.version} + 1.0.0 com.njcn diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/AutonomeWaveController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/AutonomeWaveController.java index 3afb7bb35..d7d803a31 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/AutonomeWaveController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/AutonomeWaveController.java @@ -5,24 +5,18 @@ import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; -import com.njcn.device.pq.pojo.param.LargeScreenParam; -import com.njcn.device.pq.pojo.vo.*; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.service.majornetwork.AutonomeWaveService; -import com.njcn.event.service.majornetwork.LargeScreenService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.util.List; /** * @version 1.0.0 @@ -45,7 +39,7 @@ public class AutonomeWaveController extends BaseController { @PostMapping("/uploadFileAndViewWave") @ApiOperation("上传文件并且展示波形") public HttpResult uploadFileAndViewWave(@ApiParam(value = "文件1", required = true) @RequestPart("file1") MultipartFile file1, - @ApiParam(value = "文件2", required = true) @RequestPart("file2") MultipartFile file2) throws IOException { + @ApiParam(value = "文件2", required = true) @RequestPart("file2") MultipartFile file2) throws IOException { String methodDescribe = getMethodDescribe("uploadFileAndViewWave"); WaveDataDTO result = autonomeWaveService.uploadFileAndViewWave(file1, file2); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/TransientController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/TransientController.java index 88321d91d..2b75a1946 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/TransientController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/TransientController.java @@ -8,16 +8,14 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.device.pms.pojo.param.MonitorTerminalParam; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.pojo.param.TransientParam; -import com.njcn.event.pojo.param.WaveFileParam; import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.service.majornetwork.TransientService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/AutonomeWaveService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/AutonomeWaveService.java index f163f5ca4..6c4449991 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/AutonomeWaveService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/AutonomeWaveService.java @@ -1,6 +1,6 @@ package com.njcn.event.service.majornetwork; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventAnalysisService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventAnalysisService.java index 2a2f82e40..08a7103d7 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventAnalysisService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventAnalysisService.java @@ -1,12 +1,9 @@ package com.njcn.event.service.majornetwork; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; import com.njcn.event.pojo.param.*; -import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.vo.*; -import javax.servlet.http.HttpServletResponse; import java.text.ParseException; import java.util.List; diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/AutonomeWaveServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/AutonomeWaveServiceImpl.java index 56e122b3f..415d2ed82 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/AutonomeWaveServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/AutonomeWaveServiceImpl.java @@ -1,10 +1,10 @@ package com.njcn.event.service.majornetwork.Impl; import com.njcn.common.config.GeneralInfo; -import com.njcn.event.pojo.dto.wave.AnalogDTO; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.file.pojo.dto.AnalogDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; +import com.njcn.event.file.component.WaveFileComponent; import com.njcn.event.service.majornetwork.AutonomeWaveService; -import com.njcn.event.utils.WaveUtil; import com.njcn.oss.constant.GeneralConstant; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -32,7 +32,7 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService { private final GeneralInfo generalInfo; - private final WaveUtil waveUtil; + private final WaveFileComponent waveFileComponent; @Override public WaveDataDTO uploadFileAndViewWave(MultipartFile file1, MultipartFile file2) throws IOException { @@ -59,8 +59,8 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService { datPath = dir + File.separator + fileName2; InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath)); InputStream datInputStream = Files.newInputStream(Paths.get(datPath)); - WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1); - WaveDataDTO validData = waveUtil.getValidData(comtrade); + WaveDataDTO comtrade = waveFileComponent.getComtrade(cfgInputStream, datInputStream, 1); + WaveDataDTO validData = waveFileComponent.getValidData(comtrade); return countPtCt(validData); } else { //使用本地的波形文件进行测试 @@ -72,8 +72,8 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService { datPath = dir + File.separator + fileName1; InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath)); InputStream datInputStream = Files.newInputStream(Paths.get(datPath)); - WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1); - WaveDataDTO validData = waveUtil.getValidData(comtrade); + WaveDataDTO comtrade = waveFileComponent.getComtrade(cfgInputStream, datInputStream, 1); + WaveDataDTO validData = waveFileComponent.getValidData(comtrade); return countPtCt(validData); } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java index bdc0498da..34ad81dd1 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java @@ -14,6 +14,7 @@ import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.event.enums.EventResponseEnum; +import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.pojo.constant.Param; import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.po.EventDetail; @@ -1953,7 +1954,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService { // TODO 1 if (!srcCFGFile.exists() && !srcDATFile.exists()) { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); } // TODO 1 diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java index 7737aa77c..08963c151 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java @@ -3,7 +3,6 @@ package com.njcn.event.service.majornetwork.Impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -13,13 +12,13 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.PubUtils; import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.pojo.param.MonitorTerminalParam; -import com.njcn.device.pms.pojo.po.Monitor; import com.njcn.device.pms.pojo.vo.MonitorVO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; +import com.njcn.event.file.component.WaveFileComponent; +import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper; import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.pojo.po.RmpEventDetailPO; -import com.njcn.event.pojo.vo.RmpEventDetailVO; -import com.njcn.event.service.majornetwork.RmpEventDetailService; import com.njcn.oss.constant.GeneralConstant; import com.njcn.oss.constant.OssPath; import com.njcn.device.pq.api.GeneralDeviceInfoClient; @@ -29,18 +28,13 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.mapper.majornetwork.TransientMapper; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; import com.njcn.event.pojo.param.TransientParam; -import com.njcn.event.pojo.param.WaveFileParam; import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.service.majornetwork.TransientService; -import com.njcn.event.utils.WaveUtil; -import com.njcn.huawei.obs.util.OBSUtil; -import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.oss.utils.FileStorageUtil; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; @@ -48,18 +42,14 @@ import com.njcn.system.pojo.po.DictData; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.influxdb.dto.QueryResult; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; -import java.math.RoundingMode; import java.text.DecimalFormat; -import java.time.Instant; import java.time.LocalDateTime; -import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -90,7 +80,7 @@ public class TransientServiceImpl implements TransientService { private final GeneralInfo generalInfo; - private final WaveUtil waveUtil; + private final WaveFileComponent waveFileComponent; private final MonitorClient monitorClient; @@ -184,9 +174,6 @@ public class TransientServiceImpl implements TransientService { @Override public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) { WaveDataDTO waveDataDTO; - //原始数据 - WaveDataDTO originalData; - //获取暂降事件 RmpEventDetailPO eventDetail = rmpEventDetailMapper.getByEventId(param.getId()); LineDetailDataVO lineDetailData = new LineDetailDataVO(); @@ -200,39 +187,34 @@ public class TransientServiceImpl implements TransientService { monitorVO = monitorClient.getMonitorTerminal(param).getData(); ip = monitorVO.getIp(); } - - - System.out.println(eventDetail.getEventId()); String waveName = eventDetail.getWavePath(); String cfgPath, datPath; if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) { cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG; datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT; - InputStream cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath); - InputStream datStream = waveUtil.getFileInputStreamByFilePath(datPath); + InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath); + InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath); if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); } - originalData = waveUtil.getComtrade(cfgStream, datStream, 1); -// } else if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1); } else { cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG; datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT; System.out.println("波形路径-------------------" + cfgPath); try ( - InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath); InputStream datStream = fileStorageUtil.getFileStream(datPath) ) { if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); } - originalData = waveUtil.getComtrade(cfgStream, datStream, 1); + waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1); } catch (Exception e) { - throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID); + throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID); } } - waveDataDTO = waveUtil.getValidData(originalData); + waveDataDTO = waveFileComponent.getValidData(waveDataDTO); if (param.getSystemType() == 0) { waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType())); double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]); @@ -435,10 +417,10 @@ public class TransientServiceImpl implements TransientService { if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) { cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG; datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT; - cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath); - datStream = waveUtil.getFileInputStreamByFilePath(datPath); + cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath); + datStream = waveFileComponent.getFileInputStreamByFilePath(datPath); if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); } } else { cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG; @@ -449,7 +431,7 @@ public class TransientServiceImpl implements TransientService { datStream = fileStorageUtil.downloadStream(datPath); if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); } } @@ -468,7 +450,7 @@ public class TransientServiceImpl implements TransientService { writeFile(datStream, fileDat); } catch (Exception e) { - throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID); + throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID); } finally { try { if (cfgStream != null) { diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/TransientService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/TransientService.java index 3d758b196..bb56acf1e 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/TransientService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/TransientService.java @@ -2,10 +2,8 @@ package com.njcn.event.service.majornetwork; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.device.pms.pojo.param.MonitorTerminalParam; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.pojo.param.TransientParam; -import com.njcn.event.pojo.param.WaveFileParam; -import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.TransientVO; diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WaveUtil.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WaveUtil.java deleted file mode 100644 index 080390d09..000000000 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WaveUtil.java +++ /dev/null @@ -1,1286 +0,0 @@ -package com.njcn.event.utils; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.common.pojo.enums.response.CommonResponseEnum; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.common.utils.wave.BitConverter; -import com.njcn.event.enums.EventResponseEnum; -import com.njcn.event.pojo.dto.wave.*; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.io.*; -import java.nio.file.Files; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * @author hongawen - * @version 1.0.0 - * @date 2023年03月03日 10:01 - */ -@Slf4j -@Component -@RequiredArgsConstructor -public class WaveUtil { - - - /****************************************** - * 调用读取comtrate文件方法 - * param strFilePath 波形.cfg文件路径 - * param iType == 0 高级算法的要求,采样率只能是32-128 - * iType == 1 普通展示,采样率按照cfg里面最小的(大于32) - * iType == 2 App抽点要求,采样率抽点成32 - * iType == 3 高级算法原始波形(大于32) - ******************************************/ - public WaveDataDTO getComtrade(InputStream cfgStream, InputStream datStream, int iType) { - WaveDataDTO waveDataDTO = new WaveDataDTO(); - // 首先判断文件路径是否为空 - // 读取cfg文件 - ComtradeCfgDTO comtradeCfgDTO = getComtradeCfg(cfgStream); - // 为空或者未找到结束符号 - if (comtradeCfgDTO == null || !"BINARY".equalsIgnoreCase(comtradeCfgDTO.getStrBinType())) { - return waveDataDTO; - } - /*****根据通道号计算相别** add by yexb -----Start**** - * 1、判断是否是3的倍数,是3的倍数则是3相 - * 2、假如不是3的倍数 ,是1的倍数则是单相 - ********************************************************/ - if (comtradeCfgDTO.getNAnalogNum() % 3 == 0) { - comtradeCfgDTO.setNPhasic(3); - } else { - comtradeCfgDTO.setNPhasic(1); - } - // 给相别幅值 - waveDataDTO.setIPhasic(comtradeCfgDTO.getNPhasic()); - // 组装解析抬头 - List lstWaveTitle = getWaveTitle(comtradeCfgDTO); - // 解析.dat文件 - List> listWaveData = getComtradeDat(comtradeCfgDTO, datStream, iType); - waveDataDTO.setComtradeCfgDTO(comtradeCfgDTO); - waveDataDTO.setWaveTitle(lstWaveTitle); - waveDataDTO.setListWaveData(listWaveData); - - /*****根据通道号计算相别** add by yexb -----end****/ - - return waveDataDTO; - } - - /********************************* - * 根据波形数据算出rms值数据 - * param waveDataDTO 瞬时波形(包含了CFG配置文件) - * List> 返回RMS波形 - **********************************/ - @SuppressWarnings("unused") - public WaveDataDTO getValidData(WaveDataDTO waveDataDTO) { - //CFG 配置文件 - ComtradeCfgDTO comtradeCfgDTO = waveDataDTO.getComtradeCfgDTO(); - //瞬时波形值 - List> lstWave = waveDataDTO.getListWaveData(); - //返回rms的值 - List> listRms = new ArrayList<>(); - /*float fs = nOneWaveNum; - int nWaveNum = (int) nAllWaveNum;*/ - - // 全波有效值 (int)fs / 2;//半波有效值 - int halfTs = comtradeCfgDTO.getFinalSampleRate().intValue(); - // 计算有效值算法 - /********************************* - * modify by yexibao 2020-10-29 - * 增加多波形算法 ---------start - ********************************/ - double iWave; - // 相别 - int nPhasic; - //存放RMS值的最小值 - List> listRmsMin = new ArrayList<>(); - if (lstWave.size() > 0) { - nPhasic = comtradeCfgDTO.getNPhasic(); - //ComtradeCfg.nAnalogNum为值的个数(-1的原因是一个存的是时间) - iWave = Math.floor((lstWave.get(0).size() - 1) / (double) nPhasic); - List tmpListRms; - List tmpListRmsMin; - //增加RMS的最小值 - double fMinTime = 0.0, fMinValue = 0.0; - //每一项一项计算 - for (int j = 0; j < iWave; j++) { - // 实例化 - tmpListRmsMin = new ArrayList<>(); - double fSumA = 0.0, fSumB = 0.0, fSumC = 0.0; - double fValidA, fValidB, fValidC; - //循环原始数据 - for (int i = 0; i < lstWave.size(); i++) { - // 当第一次循环的时候实例化,其余的获取已有的List//获取每一项的值 - List tmpListValue = lstWave.get(i); - if (j == 0) { - tmpListRms = new ArrayList<>(); - //获取时间 - tmpListRms.add(tmpListValue.get(0)); - listRms.add(tmpListRms); - } else { - tmpListRms = listRms.get(i); - } - - //包含了时间、电压(A、B、C)三相、电流(A、B、C)三相 - if (tmpListValue.size() >= 2) { - //电压有效值算法,根据相别进行处理 - switch (comtradeCfgDTO.getNPhasic()) { - case 1: - fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2); - // 计算有效值 - if (i >= halfTs) { - //获取前推周波的值 - List forwardListValue = lstWave.get(i - halfTs); - fSumA -= Math.pow(forwardListValue.get(1 + nPhasic * j), 2); - } - fValidA = Math.sqrt(fSumA / halfTs); - tmpListRms.add((float) (Math.round(fValidA * 100)) / 100); - listRms.set(i, tmpListRms); - // 最小值判断 - if (i >= halfTs) { - if (i == halfTs) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } else { - if (fValidA < fMinValue) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } - } - } - break; - case 2: - fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2); - fSumB += Math.pow(tmpListValue.get(2 + nPhasic * j), 2); - // 计算有效值 - if (i >= halfTs) { - //获取前推周波的值 - List forwardListValue = lstWave.get(i - halfTs); - fSumA -= Math.pow(forwardListValue.get(1 + nPhasic * j), 2); - fSumB -= Math.pow(forwardListValue.get(2 + nPhasic * j), 2); - } - fValidA = Math.sqrt(fSumA / halfTs); - fValidB = Math.sqrt(fSumB / halfTs); - - tmpListRms.add((float) (Math.round(fValidA * 100)) / 100); - tmpListRms.add((float) (Math.round(fValidB * 100)) / 100); - listRms.set(i, tmpListRms); - - // 最小值判断 - if (i >= halfTs) { - if (i == halfTs) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } else { - if (fValidA < fMinValue) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } - if (fValidB < fMinValue) { - fMinValue = fValidB; - fMinTime = tmpListValue.get(0); - } - } - } - break; - case 3: - fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2); - fSumB += Math.pow(tmpListValue.get(2 + nPhasic * j), 2); - fSumC += Math.pow(tmpListValue.get(3 + nPhasic * j), 2); - // 计算有效值 - if (i >= halfTs) { - //获取前推周波的值 - List forwardListValue = lstWave.get(i - halfTs); - fSumA -= Math.pow(forwardListValue.get(1 + nPhasic * j), 2); - fSumB -= Math.pow(forwardListValue.get(2 + nPhasic * j), 2); - fSumC -= Math.pow(forwardListValue.get(3 + nPhasic * j), 2); - } - fValidA = Math.sqrt(fSumA / halfTs); - fValidB = Math.sqrt(fSumB / halfTs); - fValidC = Math.sqrt(fSumC / halfTs); - - tmpListRms.add((float) (Math.round(fValidA * 100)) / 100); - tmpListRms.add((float) (Math.round(fValidB * 100)) / 100); - tmpListRms.add((float) (Math.round(fValidC * 100)) / 100); - listRms.set(i, tmpListRms); - - // 最小值判断 - if (i >= halfTs) { - if (i == halfTs) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } else { - if (fValidA < fMinValue) { - fMinValue = fValidA; - fMinTime = tmpListValue.get(0); - } - if (fValidB < fMinValue) { - fMinValue = fValidB; - fMinTime = tmpListValue.get(0); - } - if (fValidC < fMinValue) { - fMinValue = fValidC; - fMinTime = tmpListValue.get(0); - } - } - } - break; - default: - break; - } - } - } - //增加最小值时间,最小值//获取时间 - tmpListRmsMin.add((float) fMinTime); - //获取时间 - tmpListRmsMin.add((float) (Math.round(fMinValue * 100)) / 100); - listRmsMin.add(tmpListRmsMin); - } - - //过滤前一个周波 - //HalfTs表示一个周波 - try { - for (int i = 0; i < halfTs; i++) { - //电压有效值算法 //没相具体的值 - List tmpNewListRms = new ArrayList<>(); - for (int j = 0; j < iWave; j++) { - if (j == 0) { - //获取时间 - tmpNewListRms.add(listRms.get(i).get(0)); - } - switch (nPhasic) { - case 1: - tmpNewListRms.add(listRms.get(i + halfTs).get(1 + nPhasic * j)); - break; - case 2: - tmpNewListRms.add(listRms.get(i + halfTs).get(1 + nPhasic * j)); - tmpNewListRms.add(listRms.get(i + halfTs).get(2 + nPhasic * j)); - break; - case 3: - tmpNewListRms.add(listRms.get(i + halfTs).get(1 + nPhasic * j)); - tmpNewListRms.add(listRms.get(i + halfTs).get(2 + nPhasic * j)); - tmpNewListRms.add(listRms.get(i + halfTs).get(3 + nPhasic * j)); - break; - default: - break; - } - } - //重新赋值 - listRms.set(i, tmpNewListRms); - } - } catch (Exception e) { - throw new BusinessException(EventResponseEnum.RMS_DATA_ERROR); - } - } - waveDataDTO.setListRmsData(listRms); - //RMS最小值 - waveDataDTO.setListRmsMinData(listRmsMin); - - return waveDataDTO; - } - - /***************************** - *获取暂降特征值,包含离线 - * param waveDataDTO 波形返回参数 - * param blType 计算方式 true:浮动门槛 false:固定门槛 - *****************************/ - public List getEigenvalue(WaveDataDTO waveDataDTO, boolean blType) { - //CFG 配置文件 - ComtradeCfgDTO comtradeCfgDTO = waveDataDTO.getComtradeCfgDTO(); - // 瞬时波形值 - List> lstWave = waveDataDTO.getListWaveData(); - //获取最终采样率 - Long finalSampleRate = comtradeCfgDTO.getFinalSampleRate(); - // 返回值 - List lstEigenvalueDTO = new ArrayList<>(); - - // 必须包含了瞬时波形 - if (lstWave.size() > 0) { - MutationDTO mutationDTO = getMutationValue(lstWave, finalSampleRate); - //获取突变量和RMS值 - if (mutationDTO.getListRms_Offline().size() > 0 && mutationDTO.getListTBL_Offline().size() > 0) { - lstEigenvalueDTO = getEventValue(lstWave, mutationDTO, comtradeCfgDTO, blType); - } - } else { - lstEigenvalueDTO = null; - } - return lstEigenvalueDTO; - } - - /*** - * 获取波形文件流,存在则返回inputStream,不存在则返回null - * 为null时,这抛出波形文件不存在异常 - * @author hongawen - * @date 2023/3/3 14:03 - */ - public InputStream getFileInputStreamByFilePath(String filePath) { - File file = new File(filePath); - if (file.isFile() && file.exists()) { - InputStream inputStream; - try { - inputStream = Files.newInputStream(file.toPath()); - if (inputStream.available() < 1) { - throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID); - } - return inputStream; - } catch (IOException e) { - throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID); - } - } else { - throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); - } - } - - /********************************* - * 读取cfg方法 - * param strFilePath 文件路径 - * return 返回bool为是否解析出错 - **********************************/ - private ComtradeCfgDTO getComtradeCfg(InputStream cfgStream) { - ComtradeCfgDTO comtradeCfgDTO = new ComtradeCfgDTO(); - InputStreamReader read = null; - BufferedReader bufferedReader = null; - try { - // 将.cfg文件转换为管道流 - read = new InputStreamReader(cfgStream, CharsetUtil.CHARSET_GBK); - bufferedReader = new BufferedReader(read); - //WW 2019-11-14 - float nFreq; - // 第一行不关心仅仅是一些描述类的信息 - String strFileLine = bufferedReader.readLine(); - // 第二行需要关心第二个(模拟量的个数)和第三个参数(开关量的个数) - strFileLine = bufferedReader.readLine(); - // 按“,”进行分割 - String[] strTempArray = strFileLine.split(StrUtil.COMMA); - // 按“,”进行分割 - for (int i = 0; i < strTempArray.length; i++) { - switch (i) { - // 总个数 - case 0: - comtradeCfgDTO.setNChannelNum(Integer.parseInt(strTempArray[i])); - break; - // 模拟量的个数 - case 1: - comtradeCfgDTO.setNAnalogNum(Integer.parseInt(strTempArray[i].substring(0, strTempArray[i].length() - 1))); - break; - // 开关量的个数 - case 2: - comtradeCfgDTO.setNDigitalNum(Integer.parseInt(strTempArray[i].substring(0, strTempArray[i].length() - 1))); - break; - default: - break; - } - } - - // 从第三行到第ComtradeCfg.nChannelNum + 3行是模拟量通道和数字量通道 - List lstAnalogDTO = new ArrayList<>(); - comtradeCfgDTO.setLstAnalogDTO(lstAnalogDTO); - for (int i = 0; i < comtradeCfgDTO.getNChannelNum(); i++) { - AnalogDTO analogDTO = new AnalogDTO(); - lstAnalogDTO.add(analogDTO); - strFileLine = bufferedReader.readLine(); - strTempArray = strFileLine.split(StrUtil.COMMA); - // 配置总共13项 - for (int j = 0; j < strTempArray.length; j++) { - switch (j) { - // 通道序号 - case 0: - analogDTO.setNIndex(Integer.parseInt(strTempArray[j])); - break; - // 通道名称 - case 1: - analogDTO.setSzChannleName(strTempArray[j]); - break; - // 相位名称 - case 2: - analogDTO.setSzPhasicName(strTempArray[j]); - break; - // 监视的通道名称 - case 3: - analogDTO.setSzMonitoredChannleName(strTempArray[j]); - break; - // 通道的单位 - case 4: - analogDTO.setSzUnitName(strTempArray[j]); - break; - // 通道的系数 - case 5: - analogDTO.setFCoefficent(Float.parseFloat(strTempArray[j])); - break; - // 通道的偏移量 - case 6: - analogDTO.setFOffset(Float.parseFloat(strTempArray[j])); - break; - // 起始采样时间的偏移量 - case 7: - analogDTO.setFTimeOffset(Float.parseFloat(strTempArray[j])); - break; - // 采样值的最小值 - case 8: - analogDTO.setNMin(Integer.parseInt(strTempArray[j])); - break; - // 采样值的最大值 - case 9: - analogDTO.setNMax(Integer.parseInt(strTempArray[j])); - break; - // 一次变比 - case 10: - analogDTO.setFPrimary(Float.parseFloat(strTempArray[j])); - break; - // 二次变比 - case 11: - analogDTO.setFSecondary(Float.parseFloat(strTempArray[j])); - break; - // 一次值还是二次值标志 - case 12: - analogDTO.setSzValueType(strTempArray[j]); - break; - default: - break; - } - } - } - //WW 2019-11-14 // 采样频率 - nFreq = Float.parseFloat(bufferedReader.readLine()); - // 获取采样段数 - strFileLine = bufferedReader.readLine(); - int nRates = Integer.parseInt(strFileLine); - comtradeCfgDTO.setNRates(nRates); - // 获得每段的采样率 //采样率 - List lstRate = new ArrayList<>(); - long nOffset = 0; - for (int i = 0; i < nRates; i++) { - strFileLine = bufferedReader.readLine(); - strTempArray = strFileLine.split(StrUtil.COMMA); - RateDTO rateDTO = new RateDTO(); - // 单周波采样点数 //WW 2019-11-14 - rateDTO.setNOneSample((long) (Float.parseFloat(strTempArray[0]) / nFreq)); - // 总点数 //这里的strTemp是一个偏移量 - rateDTO.setNSampleNum((long) (Float.parseFloat(strTempArray[1]) - nOffset)); - lstRate.add(rateDTO); - } - comtradeCfgDTO.setLstRate(lstRate); - // 增加读取波形起始时间个结束时间 - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); - // 波形起始时间 - strFileLine = bufferedReader.readLine(); - strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(StrUtil.COMMA, StrUtil.SPACE); - comtradeCfgDTO.setTimeStart(sdf.parse(strFileLine)); - // 暂态触发时间 - strFileLine = bufferedReader.readLine(); - strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(StrUtil.COMMA, StrUtil.SPACE); - comtradeCfgDTO.setTimeTrige(sdf.parse(strFileLine)); - // 获取触发时间的时间 + 毫秒 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(comtradeCfgDTO.getTimeTrige()); - comtradeCfgDTO.setFirstMs(calendar.get(Calendar.MILLISECOND)); - comtradeCfgDTO.setFirstTime(calendar.getTime()); - - long a = comtradeCfgDTO.getTimeStart().getTime(); - long b = comtradeCfgDTO.getTimeTrige().getTime(); - int c = (int) (b - a); - if (c >= 90 && c <= 110) { - comtradeCfgDTO.setNPush(100); - } else if (c >= 190 && c <= 210) { - comtradeCfgDTO.setNPush(200); - } - // 赋值编码格式(二进制) - comtradeCfgDTO.setStrBinType(bufferedReader.readLine().toUpperCase()); - } catch (Exception e) { - // 解析.cfg文件出错 - comtradeCfgDTO = null; - } finally { - try { - bufferedReader.close(); - } catch (IOException e) { - throw new BusinessException(CommonResponseEnum.CLOSE_RESOURCE_ERROR); - } - try { - read.close(); - } catch (IOException e) { - throw new BusinessException(CommonResponseEnum.CLOSE_RESOURCE_ERROR); - } - } - return comtradeCfgDTO; - } - - /********************************* - * 读取dat方法 - * param strFilePath .dat访问路径 - * param strFilePath .dat访问路径 - * param iType 访问波形类型 - * List> 返回波形瞬时值 - **********************************/ - private List> getComtradeDat(ComtradeCfgDTO comtradeCfgDTO, InputStream datStream, int iType) { - //返回数据 - List> listWaveData = new ArrayList<>(); - // 波形文件路径由 .cfg 换成 .dat - //初始化xValue的值 - float xValueAll = 0; - //判断是否首次登陆 - boolean blxValue = false; - byte[] datArray; - try { - datArray = IoUtil.readBytes(datStream); - if (ArrayUtil.isEmpty(datArray)) { - return listWaveData; - } - // 计算每个单独的数据块的大小 4个字节的序号 4个字节的时间 2个字节的值 - // 示例中的排布是 4个字节的序号 4个字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节) IC(2字节) - int nDigSize = (comtradeCfgDTO.getNDigitalNum() % 16) > 0 ? (comtradeCfgDTO.getNDigitalNum() / 16 + 1) * 2 : comtradeCfgDTO.getNDigitalNum() / 16 * 2; - int nBlockSize = 2 * Integer.SIZE / 8 + comtradeCfgDTO.getNAnalogNum() * 2 + nDigSize; - // 总长度除以每个快的大小 - int nBlockNum = datArray.length / nBlockSize; - // 获取采样率 - long finalSampleRate = getFinalWaveSample(comtradeCfgDTO.getLstRate(), iType); - if (finalSampleRate != -1) { - //设置最终采样率 - comtradeCfgDTO.setFinalSampleRate(finalSampleRate); - // 计算转换后的采样率 - int nnInd = 0; - // 抽点后总共多少点数据 - long nWaveNum; - //抽点后新的的采样率 - List newLstRate = new ArrayList<>(); - for (int iRate = 0; iRate < comtradeCfgDTO.getNRates(); iRate++) { - if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) { - // 计算本段录波总共有多少波形 - nWaveNum = comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum() / comtradeCfgDTO.getLstRate().get(iRate).getNOneSample(); - //设置总波形大小 - comtradeCfgDTO.setNAllWaveNum(comtradeCfgDTO.getNAllWaveNum() + nWaveNum); - // 将最低采样率替换到本段录波内 - RateDTO tmpRateDTO = new RateDTO(); - newLstRate.add(tmpRateDTO); - //iFlag =3 一定不进行抽点算法 - if (iType != 3) { - //true 抽点算法(当前采样率跟统一采样率不一样则是抽点,否则是未抽点) - if (!Objects.equals(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample(), comtradeCfgDTO.getFinalSampleRate())) { - newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getFinalSampleRate()); - // 计算本段录波按照最低采样点应该有多少录波 - newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getFinalSampleRate() * nWaveNum); - } else { - newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample()); - // 计算本段录波按照最低采样点应该有多少录波 - newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum); - } - } else { - newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample()); - // 计算本段录波按照最低采样点应该有多少录波 - newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum); - } - - // 正常的配置中采样率 - comtradeCfgDTO.getLstRate().get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample()); - comtradeCfgDTO.getLstRate().get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum()); - nnInd++; - } - } - // 偏移量,采样间隔 - long nOffSet = 0, nWaveSpan; - //两个点之间的时间差 - float fValue, dfValue; - // 计算不同块的采样率 - int nIndex = 0; - // 将最低采样率替换到本段录波内 - // .CFG中采样率 - RateDTO tmpRateDTO; - // nBlockNum 总循环次数 - for (int i = 0; i < nBlockNum; i++) { - tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex); - // 计算本段抽点采样间隔 - nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample(); - // 判断是否进入下一段 - if (i == tmpRateDTO.getNSampleNum() + nOffSet) { - nOffSet += tmpRateDTO.getNSampleNum(); - nIndex++; - if (nIndex == nnInd) { - break; - } - } - dfValue = (float) 20 / tmpRateDTO.getNOneSample(); - // 判断是否到了需要抽的采样点 - if (i % nWaveSpan == 0) { - // 计算每个通道的值 - //存储局部数据集合,包含了时间,A,B,C三相 - List tmpWaveData = new ArrayList<>(); - AnalogDTO tmpAnalogDTO; - for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) { - tmpAnalogDTO = comtradeCfgDTO.getLstAnalogDTO().get(j); - //数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据 - if ("N".equalsIgnoreCase(tmpAnalogDTO.getSzPhasicName())) { - break; - } - float fCoef = tmpAnalogDTO.getFCoefficent(); - fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef; - - //WW 2019-11-14//P是一次值 S是二次值 - if ("S".equalsIgnoreCase(tmpAnalogDTO.getSzValueType())) { - //判断单位是V还是kV - if ("KV".equalsIgnoreCase(tmpAnalogDTO.getSzUnitName())) { - fValue = fValue * 1000.0f; - } - } - //P是一次值 S是二次值 - else if ("P".equalsIgnoreCase(tmpAnalogDTO.getSzValueType())) { - //判断单位是V还是kV - if ("V".equalsIgnoreCase(tmpAnalogDTO.getSzUnitName())) { - //根据cfg内的变比,将一次值转换成二次值 - if (tmpAnalogDTO.getFPrimary() != 0.0f) { - fValue = fValue * tmpAnalogDTO.getFSecondary() / tmpAnalogDTO.getFPrimary(); - } - - } - //判断单位是V还是kV - else if ("KV".equalsIgnoreCase(tmpAnalogDTO.getSzUnitName())) { - //根据cfg内的变比,将一次值转换成二次值 - if (tmpAnalogDTO.getFPrimary() != 0.0f) { - fValue = fValue * 1000.0f * tmpAnalogDTO.getFSecondary() / tmpAnalogDTO.getFPrimary(); - } - } - //还有可能是电流,单位是A - else { - //根据cfg内的变比,将一次值转换成二次值 - if (tmpAnalogDTO.getFPrimary() != 0.0f) { - fValue = tmpAnalogDTO.getFSecondary() / tmpAnalogDTO.getFPrimary(); - } - } - } - - //ComtradeCfg.OneChannleCfg.get(j) - - //xValue前移量,假如是第一次时候则需要前移 - if (!blxValue && j == 0) { - xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush(); - blxValue = true; - //只增加一个xValue的值 //增加时间值 - tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100); - } else if (j == 0) { - xValueAll += (float) nWaveSpan * dfValue; - //只增加一个xValue的值 //增加时间值 - tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100); - } - - //不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值 - tmpWaveData.add((float) (Math.round(fValue * 100)) / 100); - } - //把每个单独的值赋予到整体里面去 - listWaveData.add(tmpWaveData); - } - } - } - } catch (Exception e) { - throw new BusinessException(EventResponseEnum.DAT_DATA_ERROR); - } - - return listWaveData; - } - - - /********************************* - * 获取最小(最终)采样率方法 - * @param lstRate cfg中关于采样率参数 - * @return 返回最小采样率 - **********************************/ - private long getFinalWaveSample(List lstRate, int iType) { - // 最终返回采样率 - long nFinalOneSample = -1; - // 最小采样率 - long nMinOneSample = -1; - if (lstRate.size() > 0) { - nMinOneSample = lstRate.get(0).getNOneSample(); - long tmpOneSample; - for (RateDTO rateDTO : lstRate) { - tmpOneSample = rateDTO.getNOneSample(); - if (tmpOneSample >= 32) { - if (nMinOneSample > tmpOneSample) { - nMinOneSample = tmpOneSample; - } - } - } - } - /******************************************************** - * iFlag == 0 高级算法的要求,采样率只能是32-128 - * iFlag == 1 普通展示,采样率按照cfg里面最小的(大于32) - * iFlag == 2 App抽点要求,采样率抽点成32 - * iFlag == 3 高级算法原始波形(大于32) - ********************************************************/ - switch (iType) { - case 0: - if (nMinOneSample < 32) { - nFinalOneSample = 32; - } else if (nMinOneSample > 128) { - nFinalOneSample = 128; - } - break; - case 2: - nFinalOneSample = 32; - break; - - default: - nFinalOneSample = nMinOneSample; - break; - - } - return nFinalOneSample; - } - - - /********************************* - * 离线波形导入时获取突变量算法 - * param tmpListWave 波形原始数据 - * param finalSampleRate 最终采样率 - **********************************/ - private MutationDTO getMutationValue(List> lstWave, float finalSampleRate) { - MutationDTO mutationDTO = new MutationDTO(); - // 计算有效值 - double fSumA = 0.0, fSumB = 0.0, fSumC = 0.0; - double fValidA, fValidB, fValidC; - double fValue = 0.0; - // 全波有效值 ; (int)fs / 2;//半波有效值 - int HalfTs = (int) finalSampleRate; - //瞬时波形数据_瞬时---前推周波的值_瞬时----周波的值_突变量----前推周波的值_突变量 - List tmpRealValue, forwardRealValue, tblValue, forwardTblValue; - // 计算有效值算法 - for (int i = 0; i < lstWave.size(); i++) { - //获取每一项的值 - tmpRealValue = lstWave.get(i); - //包含了时间、A、B、C三相 - if (tmpRealValue.size() >= 4) { - fSumA += Math.pow(tmpRealValue.get(1), 2); - fSumB += Math.pow(tmpRealValue.get(2), 2); - fSumC += Math.pow(tmpRealValue.get(3), 2); - // 计算有效值 - List tmpRmsValue = new ArrayList<>(); - if (i >= finalSampleRate) { - forwardRealValue = lstWave.get(i - HalfTs); - fSumA -= Math.pow(forwardRealValue.get(1), 2); - fSumB -= Math.pow(forwardRealValue.get(2), 2); - fSumC -= Math.pow(forwardRealValue.get(3), 2); - } - // 计算突变量值 - List tmpTblValue = new ArrayList<>(); - //获取时间 - tmpTblValue.add(tmpRealValue.get(0)); - if (i >= HalfTs) { - //获取前推周波的值 - tblValue = lstWave.get(i); - //获取前推周波的值 - forwardTblValue = lstWave.get(i - HalfTs); - tmpTblValue.add(tblValue.get(1) - forwardTblValue.get(1)); - tmpTblValue.add(tblValue.get(2) - forwardTblValue.get(2)); - tmpTblValue.add(tblValue.get(3) - forwardTblValue.get(3)); - } else { - tmpTblValue.add(0f); - tmpTblValue.add(0f); - tmpTblValue.add(0f); - } - fValidA = Math.sqrt(fSumA / HalfTs); - fValidB = Math.sqrt(fSumB / HalfTs); - fValidC = Math.sqrt(fSumC / HalfTs); - - if (i >= finalSampleRate) { - if (fValidA < mutationDTO.getFMinMagA()) { - mutationDTO.setFMinMagA(fValidA); - } - if (fValidB < mutationDTO.getFMinMagB()) { - mutationDTO.setFMinMagB(fValidB); - } - if (fValidC < mutationDTO.getFMinMagC()) { - mutationDTO.setFMinMagC(fValidC); - } - } - //RMS获取//获取时间 - tmpRmsValue.add(tmpRealValue.get(0)); - tmpRmsValue.add((float) fValidA); - tmpRmsValue.add((float) fValidB); - tmpRmsValue.add((float) fValidC); - mutationDTO.getListRms_Offline().add(tmpRmsValue); - - //RMS获取 - mutationDTO.getListTBL_Offline().add(tmpTblValue); - } - } - return mutationDTO; - } - - /********************************* - * 离线波形导入时获取暂降特征值的算法 - * param lstWave 波形原始数据 - * param tblWave 突变量波形数据 - * param rmstWave RMS数据 - * param comtradeCfgDTO 波形CFG配置参数 - * param blType 计算方式 - * List> 返回暂降数据 - **********************************/ - private List getEventValue(List> lstWave, MutationDTO mutationDTO, ComtradeCfgDTO comtradeCfgDTO, boolean blType) { - List> tblWave = mutationDTO.getListTBL_Offline(); - List> rmstWave = mutationDTO.getListRms_Offline(); - //额定电压 - float fBase = 57.74f; - //假如所选的是380V,那么PT变比是1:1,因此额定电压要选220 //模拟量通道记录 - List lstAnalogDTO = comtradeCfgDTO.getLstAnalogDTO(); - if (lstAnalogDTO.size() > 0) { - if (lstAnalogDTO.get(0).getFPrimary() / lstAnalogDTO.get(0).getFSecondary() <= 1) { - fBase = 220f; - } - } - //采样率 - int nSJ = comtradeCfgDTO.getFinalSampleRate().intValue(); - /********************************* - * 0是特征幅值(残余电压百分比) - * 1是特征幅值(残余电压) - * 2额定定压(动态电压) - * 3是持续时间 - **********************************/ - //ABC三相分析结果 - List lstEigenvalueDTO = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - //低电压和郭电压标识值 - int iDDY = 0, iGDY; - //某一项分析结果 - EigenvalueDTO eigenvalueDTO = new EigenvalueDTO(); - iDDY = App_Disturb_DDY1(lstWave, tblWave, rmstWave, nSJ, i, blType); - if (Disturb_Val == 0 && Disturb_SJ == 0) { - //判断A相的暂态事件类型是否为短时中断或电压暂降 - iGDY = App_Disturb_GDY1(lstWave, tblWave, rmstWave, nSJ, i, blType); - if (iGDY != 0) { - if (Disturb_Val != 0) { - if (blType) { - //征幅值(残余电压百分比) - eigenvalueDTO.setAmplitude(Disturb_Val / rmstWave.get(nSJ + 2).get(i + 1)); - //特征幅值(残余电压) - eigenvalueDTO.setResidualVoltage(Disturb_Val); - //额定定压(动态电压) - eigenvalueDTO.setRatedVoltage(rmstWave.get(nSJ + 2).get(i + 1)); - } else { - //征幅值(残余电压百分比) - eigenvalueDTO.setAmplitude(Disturb_Val / 57.74f); - //特征幅值(残余电压) - eigenvalueDTO.setResidualVoltage(Disturb_Val); - //额定定压(动态电压) - eigenvalueDTO.setRatedVoltage(57.74f); - } - } - } - //如果都没有找到,那么需要从曲线里面找出比较小的值来计算 - else { - double rate = 0f; - //残余电压 - double residualVoltage = 0.f; - switch (i) { - case 0: - residualVoltage = mutationDTO.getFMinMagA(); - break; - case 1: - residualVoltage = mutationDTO.getFMinMagB(); - break; - case 2: - residualVoltage = mutationDTO.getFMinMagC(); - break; - default: - break; - } - - if (residualVoltage != -1) { - rate = residualVoltage / fBase > 1 ? 1.0f : residualVoltage / fBase; - } - //征幅值(残余电压百分比) - eigenvalueDTO.setAmplitude((float) rate); - //特征幅值(残余电压) - eigenvalueDTO.setResidualVoltage((float) residualVoltage); - //额定定压(动态电压) - eigenvalueDTO.setRatedVoltage(fBase); - } - } else { - if (Disturb_Val != 0) { - if (blType) { - //征幅值(残余电压百分比) - eigenvalueDTO.setAmplitude(Disturb_Val / rmstWave.get(nSJ + 2).get(i + 1)); - //特征幅值(残余电压) - eigenvalueDTO.setResidualVoltage(Disturb_Val); - //额定定压(动态电压) - eigenvalueDTO.setRatedVoltage(rmstWave.get(nSJ + 2).get(i + 1)); - } else { - //征幅值(残余电压百分比) - eigenvalueDTO.setAmplitude(Disturb_Val / 57.74f); - //特征幅值(残余电压) - eigenvalueDTO.setResidualVoltage(Disturb_Val); - //额定定压(动态电压) - eigenvalueDTO.setRatedVoltage(57.74f); - } - } - } - //持续时间 - eigenvalueDTO.setDurationTime(Disturb_SJ / nSJ * 20.0f); - lstEigenvalueDTO.add(eigenvalueDTO); - } - return lstEigenvalueDTO; - } - - /*** - * 暂降幅值 - */ - private float Disturb_Val = 0; - /*** - * 持续时间 - */ - private double Disturb_Time = 0; - /*** - * 暂态启动点号 - */ - private float Disturb_SJ = 0; - - /*** - * 暂降幅值90% - */ - private float Un09 = (0.90f * 57.74f); - /*** - * 暂降幅值2% - */ - private float Un002 = (0.02f * 57.74f); - /*** - * 暂降幅值110% - */ - private float Un110 = (1.10f * 57.74f); - - /************************************ - *低电压的判据 包含了暂降和中断 - * @param realWave 原始波形数据 - * @param tblWave 突变量波形数据 - * @param rmstWave RMS波形数据 - * @param nCirclePoint 采样率 - * @param nType 类别 0:A相,1:B相,2:C相 - * @param blFlag 浮动门槛和固定门槛 - * @return - *************************************/ - private int App_Disturb_DDY1(List> realWave, List> tblWave, List> rmstWave, int nCirclePoint, int nType, boolean blFlag) { - Disturb_Val = 0; - Disturb_Time = 0; - Disturb_SJ = 0; - - /**************************** - * ADC 临时的突变量判据 - * Disturb_JS_Val 事件启动点时刻的有效值 - ****************************/ - double temp, ADC, Disturb_JS_Val = 0; - int iTbl = 0; - long Disturb_QD = 0; - //nSJ就是全波的采样率,nHalfSJ是半波的采样率 - int nSJ = nCirclePoint, nHalfSJ = nCirclePoint / 2; - //定义90%和20%额定电压 - float fUN09 = Un09, fUN002 = Un002; - //增加浮动门槛判断 - if (blFlag) { - /**************************** - * 计算值去掉一个前一个周波后 - * 取第二个周波的第二个有效值 - * 第一个值是时间、A,B,C三相 - ****************************/ - if (rmstWave.size() > nSJ + 2) { - fUN09 = rmstWave.get(nSJ + 2).get(nType + 1) * 0.9f; - fUN002 = rmstWave.get(nSJ + 2).get(nType + 1) * 0.02f; - } - } - /**************************** - * 从第二个周波开始 - ****************************/ - for (int i = nSJ; i < realWave.size(); i++) { - //获取RMS有效值 - float rmsValue = rmstWave.get(i).get(nType + 1); - //电压扰动启动判别 - if (Disturb_QD == 0) { - //有效值小于90% - if (rmsValue < fUN09) { - Disturb_QD = 0xff; - Disturb_Val = rmsValue; - Disturb_JS_Val = rmsValue; - //寻找突变点 - for (int j = 0; j < nHalfSJ; j++) { - //临时的突变量 - ADC = tblWave.get(i - nHalfSJ + j).get(nType + 1); - //临时的突变量小于0的时候取绝对值 - if (ADC < 0) { - ADC = 0 - ADC; - } - if (ADC > fUN002) { - Disturb_SJ += (nHalfSJ - j); - iTbl = (i - nHalfSJ + j); - break; - } - } - } - } - //电压扰动返回判别 - else { - if (rmsValue < (fUN09 + fUN002)) { - Disturb_SJ++; - if (Disturb_Val > rmsValue) { - Disturb_Val = rmsValue; - } - Disturb_JS_Val = rmsValue; - } else { - if (Disturb_SJ >= (nSJ + nHalfSJ)) { - //20%突变量标志 - int iFlag = 0; - for (int j = 0; j < nHalfSJ; j++) { - iFlag = j; - //临时的突变量 - ADC = tblWave.get(i - nHalfSJ + j).get(nType + 1); - //临时的突变量小于0的时候取绝对值 - if (ADC < 0) { - ADC = 0 - ADC; - } - if (ADC > fUN002) { - break; - } - } - Disturb_SJ -= (nHalfSJ - iFlag); - Disturb_Time = ((double) Disturb_SJ) * 20 / nSJ; - return iTbl; - } else { - Disturb_SJ++; - ADC = realWave.get(i).get(nType + 1); - if (ADC < 0) { - ADC = 0 - ADC; - } - temp = rmsValue - Disturb_JS_Val; - if (temp < 0) { - temp = 0 - temp; - } - if ((ADC > 100) && (temp < 0.1)) { - Disturb_SJ -= (nHalfSJ + 1); - Disturb_Time = ((double) Disturb_SJ) * 20 / nSJ + 1; - return iTbl; - } - } - Disturb_JS_Val = rmsValue; - } - } - } - return iTbl; - } - - - /************************************ - *过电压的判据 - * @param realWave 原始波形数据 - * @param tblWave 突变量波形数据 - * @param rmstWave RMS波形数据 - * @param nCirclePoint 采样率 - * @param nType 类别 0:A相,1:B相,2:C相 - * @param blFlag 浮动门槛和固定门槛 - * @return - *************************************/ - private int App_Disturb_GDY1(List> realWave, List> tblWave, List> rmstWave, int nCirclePoint, int nType, boolean blFlag) { - Disturb_Val = 0; - Disturb_Time = 0; - Disturb_SJ = 0; - - /**************************** - * ADC 临时的突变量判据 - * Disturb_JS_Val 事件启动点时刻的有效值 - ****************************/ - double temp, ADC, Disturb_JS_Val = 0; - int iTbl = 0; - long Disturb_QD = 0; - //nSJ就是全波的采样率,nHalfSJ是半波的采样率 - int nSJ = nCirclePoint, nHalfSJ = nCirclePoint / 2; - //定义110%和20%额定电压 - float fUN110 = Un110, fUN002 = Un002; - //增加浮动门槛判断 - if (blFlag) { - /**************************** - * 计算值去掉一个前一个周波后 - * 取第二个周波的第二个有效值 - * 第一个值是时间、A,B,C三相 - ****************************/ - if (rmstWave.size() > nSJ + 2) { - fUN110 = rmstWave.get(nSJ + 2).get(nType + 1) * 1.1f; - fUN002 = rmstWave.get(nSJ + 2).get(nType + 1) * 0.02f; - } - } - /**************************** - * 从第二个周波开始 - ****************************/ - for (int i = nSJ; i < realWave.size(); i++) { - //获取RMS有效值 - float rmsValue = rmstWave.get(i).get(nType + 1); - //电压扰动启动判别 - if (Disturb_QD == 0) { - if (rmsValue > fUN110) { - Disturb_QD = 0xff; - Disturb_Val = rmsValue; - Disturb_JS_Val = rmsValue; - //寻找突变点 - for (int j = 0; j < nHalfSJ; j++) { - //临时的突变量 - ADC = tblWave.get(i - nHalfSJ + j).get(nType + 1); - //临时的突变量小于0时候取绝对值 - if (ADC < 0) { - ADC = 0 - ADC; - } - if (ADC > fUN002) { - Disturb_SJ += (nHalfSJ - j); - iTbl = (int) (i - nHalfSJ + j); - break; - } - } - } - } - //电压扰动返回判别 - else { - if (rmsValue > (fUN110 - fUN002)) { - Disturb_SJ++; - if (Disturb_Val < rmsValue) { - Disturb_Val = rmsValue; - } - Disturb_JS_Val = rmsValue; - } else { - if (Disturb_SJ >= (nSJ + nHalfSJ)) { - int iFlag = 0; - for (int j = 0; j < nHalfSJ; j++) { - iFlag = j; - ADC = tblWave.get(i - nHalfSJ + j).get(nType + 1); - if (ADC < 0) { - ADC = 0 - ADC; - } - if (ADC > fUN002) { - break; - } - } - Disturb_SJ -= (nHalfSJ - iFlag); - Disturb_Time = (double) Disturb_SJ * 20 / nSJ; - return iTbl; - } else { - Disturb_SJ++; - ADC = realWave.get(i).get(nType + 1); - if (ADC < 0) { - ADC = 0 - ADC; - } - temp = rmsValue - Disturb_JS_Val; - if (temp < 0) { - temp = 0 - temp; - } - if ((ADC > 100) && (temp < 0.1)) { - Disturb_SJ -= (nHalfSJ + 1); - Disturb_Time = Disturb_SJ * 20 / nSJ + 1; - return iTbl; - } - } - Disturb_JS_Val = rmsValue; - } - } - } - return iTbl; - } - - - /********************************* - * 获取波形标题的方法 - * param tmpComtradeCfgDTO 文件路径 - * return 返回List返回数据格式说明 - **********************************/ - private List getWaveTitle(ComtradeCfgDTO comtradeCfgDTO) { - //编辑数据标题 YXB2020-10-09 去除相别为N相的数据//存储数据标题 - List tmpWaveTitle = new ArrayList<>(); - // 模拟量通道记录类 - AnalogDTO analogDTO; - tmpWaveTitle.add("Time"); - String strUnit; - for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) { - analogDTO = comtradeCfgDTO.getLstAnalogDTO().get(j); - // 假如为N相则跳过 - if (!StrUtil.equals(analogDTO.getSzPhasicName().toUpperCase(), "N")) { - if ("A".equalsIgnoreCase(analogDTO.getSzUnitName())) { - strUnit = "I"; - } else { - strUnit = "U"; - } - tmpWaveTitle.add(strUnit + analogDTO.getSzPhasicName().toUpperCase() + "相"); - } - } - return tmpWaveTitle; - } - - /********************************* - * 由.cfg 路径更换成 .dat - * param strFilePath 文件路径 - * return String返回.dat文件的路径 - **********************************/ - private String getDatFilePath(String strFilePath) { - String strDatFilePath; - //替换前的 - String strOriginally = ".cfg"; - //替换后的 - String strReplace = ".dat"; - //截取.之后字符串 - String strIntercept = strFilePath.substring(strFilePath.lastIndexOf(".") + 1); - switch (strIntercept) { - case "cfg": - strOriginally = ".cfg"; - strReplace = ".dat"; - break; - case "CFG": - strOriginally = ".CFG"; - strReplace = ".DAT"; - break; - case "Cfg": - strOriginally = ".Cfg"; - strReplace = ".Dat"; - break; - case "CFg": - strOriginally = ".CFg"; - strReplace = ".DAt"; - break; - case "cFg": - strOriginally = ".cFg"; - strReplace = ".dAt"; - break; - case "cFG": - strOriginally = ".cFG"; - strReplace = ".dAT"; - break; - default: - break; - } - //把.cfg换成.dat - strDatFilePath = strFilePath.replace(strOriginally, strReplace); - return strDatFilePath; - } - - public static void main(String[] args) { - /******************************************************** - * iFlag == 0 高级算法的要求,采样率只能是32-128 - * iFlag == 1 普通展示,采样率按照cfg里面最小的(大于32) - * iFlag == 2 App抽点要求,采样率抽点成32 - * iFlag == 3 高级算法原始波形(大于32) - ********************************************************/ - /** 输出格式: 2014-5-05 00:00:00 大写H为24小时制 */ - DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String s; - Date d = new Date(); - s = sdf.format(d); - System.out.println(s); - WaveUtil waveUtil = new WaveUtil(); - InputStream cfgStream = waveUtil.getFileInputStreamByFilePath("D:\\comtrade\\00-B7-8D-00-B7-25\\1_20200629_164016_234.CFG"); - InputStream datStream = waveUtil.getFileInputStreamByFilePath("D:\\comtrade\\00-B7-8D-00-B7-25\\1_20200629_164016_234.DAT"); - // 获取瞬时波形 //获取原始波形值 - WaveDataDTO waveDataDTO = waveUtil.getComtrade(cfgStream,datStream, 1); - d = new Date(); - s = sdf.format(d); - System.out.println(s); - // 获取RMS波形 - WaveDataDTO waveDataDTO1 = waveUtil.getValidData(waveDataDTO); - d = new Date(); - s = sdf.format(d); - System.out.println(s); - // 获取特征值 - List lstEigenvalueDTO = waveUtil.getEigenvalue(waveDataDTO, true); - } - -} diff --git a/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java b/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java index b42944989..4e5d19c81 100644 --- a/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java +++ b/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java @@ -1,12 +1,13 @@ package com.njcn.event; import com.njcn.event.enums.EventResponseEnum; +import com.njcn.event.file.component.WaveFileComponent; +import com.njcn.event.file.pojo.dto.EigenvalueDTO; +import com.njcn.event.file.pojo.dto.WaveDataDTO; +import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.pojo.PqsEventDetail; import com.njcn.event.pojo.PqsOnlinerateAggregate; import com.njcn.event.pojo.PqsEventDetailCount; -import com.njcn.event.pojo.dto.wave.EigenvalueDTO; -import com.njcn.event.pojo.dto.wave.WaveDataDTO; -import com.njcn.event.utils.WaveUtil; import com.njcn.huawei.obs.util.OBSUtil; import com.njcn.influxdb.config.InfluxDbConfig; import com.njcn.influxdb.utils.InfluxDbUtils; @@ -50,7 +51,7 @@ public class EventBootApplicationTest { private InfluxDbUtils influxDbUtils; @Autowired - private WaveUtil waveUtil; + private WaveFileComponent waveFileComponent; @Autowired private OBSUtil obsUtil; @@ -145,17 +146,17 @@ public class EventBootApplicationTest { InputStream datStream =obsUtil.downloadStream(datPath); if(Objects.isNull(cfgStream) || Objects.isNull(datStream)){ - throw new FileNotFoundException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND.getMessage()); + throw new FileNotFoundException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND.getMessage()); } // 获取瞬时波形 //获取原始波形值 - WaveDataDTO waveDataDTO = waveUtil.getComtrade(cfgStream,datStream, 1); + WaveDataDTO waveDataDTO = waveFileComponent.getComtrade(cfgStream,datStream, 1); // 获取RMS波形 - WaveDataDTO waveDataDTO1 = waveUtil.getValidData(waveDataDTO); + WaveDataDTO waveDataDTO1 = waveFileComponent.getValidData(waveDataDTO); // 获取特征值 - List lstEigenvalueDTO = waveUtil.getEigenvalue(waveDataDTO, true); + List lstEigenvalueDTO = waveFileComponent.getEigenvalue(waveDataDTO, true); System.out.println(1); }