From 232e84aad31b773ac1f3f5220b163eb842d86e92 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Wed, 15 Apr 2026 10:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A2=E5=BD=A2=E8=A7=A3=E6=9E=90=E7=9A=84?= =?UTF-8?q?=E7=94=B5=E6=B5=81=E4=B8=80=E6=AC=A1=E5=80=BC=E8=BD=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E5=80=BC=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/dto/waveAnalysis/AnalyWave.java | 270 +++++++++--------- .../file/component/WaveFileComponent.java | 4 +- 2 files changed, 131 insertions(+), 143 deletions(-) diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/waveAnalysis/AnalyWave.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/waveAnalysis/AnalyWave.java index 6675bfdac..9c1317d87 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/waveAnalysis/AnalyWave.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/waveAnalysis/AnalyWave.java @@ -26,8 +26,6 @@ import java.util.*; public class AnalyWave { - - /***************************************** * 解析comtrate文件工具类 * author yexb根据Ww算法装换 @@ -94,7 +92,7 @@ public class AnalyWave { ** ** strFilePath *** cfg文件路径 * *** auth *** 读取方式 null则使用本地读取方式读取 ******************************************/ - public AnalyWaveModel.tagDataValue readComtrade(List temCfgList,byte[] array, int iFlag) { + public AnalyWaveModel.tagDataValue readComtrade(List temCfgList, byte[] array, int iFlag) { //初始化参数 ComtradeCfg = new AnalyWaveModel.tagComtradeCfg(); RatesCfg = new AnalyWaveModel.tagRates(); @@ -163,148 +161,145 @@ public class AnalyWave { iterable.next(); String[] strTempArray;// 读取cfg文件 try { - nFreq = 0f;//WW 2019-11-14 - String strFileLine = iterable.next(); + nFreq = 0f;//WW 2019-11-14 + String strFileLine = iterable.next(); + strTempArray = strFileLine.split(","); + + for (int i = 0; i < strTempArray.length; i++) { + switch (i) { + case 0:// 总个数 + ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]); + break; + case 1:// 模拟量的个数 + { + String str = strTempArray[i].substring(0, strTempArray[i].length() - 1); + ComtradeCfg.nAnalogNum = Integer.parseInt(str); + } + break; + case 2:// 开关量的个数 + { + String str = strTempArray[i].substring(0, strTempArray[i].length() - 1); + ComtradeCfg.nDigitalNum = Integer.parseInt(str); + } + break; + } + } + + // 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道 + for (int i = 0; i < ComtradeCfg.nChannelNum; i++) { + AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg(); + ComtradeCfg.OneChannleCfg.add(OneChannlecfg); + + strFileLine = iterable.next(); + strTempArray = strFileLine.split(","); + // 配置总共13项 + for (int j = 0; j < strTempArray.length; j++) { + switch (j) { + case 0:// 通道序号 + OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]); + break; + case 1:// 通道名称 + OneChannlecfg.szChannleName = strTempArray[j]; + break; + case 2:// 相位名称 + OneChannlecfg.szPhasicName = strTempArray[j]; + break; + case 3:// 监视的通道名称 + OneChannlecfg.szMonitoredChannleName = strTempArray[j]; + break; + case 4:// 通道的单位 + OneChannlecfg.szUnitName = strTempArray[j]; + break; + case 5:// 通道的系数 + OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]); + break; + case 6:// 通道的偏移量 + OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]); + break; + case 7:// 起始采样时间的偏移量 + OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]); + break; + case 8:// 采样值的最小值 + OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]); + break; + case 9:// 采样值的最大值 + OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]); + break; + case 10:// 一次变比 + OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]); + break; + case 11:// 二次变比 + OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]); + break; + case 12:// 一次值还是二次值标志 + OneChannlecfg.szValueType = strTempArray[j]; + break; + } + } + } + // 采样频率 + strFileLine = iterable.next(); + float fFreq = Float.parseFloat(strFileLine); + nFreq = (float) fFreq;//WW 2019-11-14 + // 采样段数 + strFileLine = iterable.next(); + int nRates = Integer.parseInt(strFileLine); + RatesCfg.nRates = nRates; + // 获得每段的采样率 + long nOffset = 0; + for (int i = 0; i < nRates; i++) { + strFileLine = iterable.next(); strTempArray = strFileLine.split(","); - for (int i = 0; i < strTempArray.length; i++) { - switch (i) { - case 0:// 总个数 - ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]); + AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate(); + RatesCfg.OneRate.add(OneRate); + + for (int j = 0; j < strTempArray.length; j++) { + + switch (j) { + case 0:// 单周波采样点数 + OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14 + break; + case 1:// 总点数 //这里的strTemp是一个偏移量 + OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset); + nOffset += OneRate.nSampleNum; break; - case 1:// 模拟量的个数 - { - String str = strTempArray[i].substring(0, strTempArray[i].length() - 1); - ComtradeCfg.nAnalogNum = Integer.parseInt(str); - } - break; - case 2:// 开关量的个数 - { - String str = strTempArray[i].substring(0, strTempArray[i].length() - 1); - ComtradeCfg.nDigitalNum = Integer.parseInt(str); - } - break; } } + } - // 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道 - for (int i = 0; i < ComtradeCfg.nChannelNum; i++) { - AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg(); - ComtradeCfg.OneChannleCfg.add(OneChannlecfg); - - strFileLine = iterable.next(); - strTempArray = strFileLine.split(","); - // 配置总共13项 - for (int j = 0; j < strTempArray.length; j++) { - switch (j) { - case 0:// 通道序号 - OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]); - break; - case 1:// 通道名称 - OneChannlecfg.szChannleName = strTempArray[j]; - break; - case 2:// 相位名称 - OneChannlecfg.szPhasicName = strTempArray[j]; - break; - case 3:// 监视的通道名称 - OneChannlecfg.szMonitoredChannleName = strTempArray[j]; - break; - case 4:// 通道的单位 - OneChannlecfg.szUnitName = strTempArray[j]; - break; - case 5:// 通道的系数 - OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]); - break; - case 6:// 通道的偏移量 - OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]); - break; - case 7:// 起始采样时间的偏移量 - OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]); - break; - case 8:// 采样值的最小值 - OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]); - break; - case 9:// 采样值的最大值 - OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]); - break; - case 10:// 一次变比 - OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]); - break; - case 11:// 二次变比 - OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]); - break; - case 12:// 一次值还是二次值标志 - OneChannlecfg.szValueType = strTempArray[j]; - break; - } - } - } - // 采样频率 - strFileLine = iterable.next(); - float fFreq = Float.parseFloat(strFileLine); - nFreq = (float) fFreq;//WW 2019-11-14 - // 采样段数 - strFileLine = iterable.next(); - int nRates = Integer.parseInt(strFileLine); - RatesCfg.nRates = nRates; - // 获得每段的采样率 - long nOffset = 0; - for (int i = 0; i < nRates; i++) { - strFileLine = iterable.next(); - strTempArray = strFileLine.split(","); - - AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate(); - RatesCfg.OneRate.add(OneRate); - - for (int j = 0; j < strTempArray.length; j++) { - - switch (j) { - case 0:// 单周波采样点数 - OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14 - break; - case 1:// 总点数 //这里的strTemp是一个偏移量 - OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset); - nOffset += OneRate.nSampleNum; - break; - } - } - } - - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); - // 波形起始时间 - strFileLine = iterable.next(); - strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " "); - TimeTrige = sdf.parse(strFileLine); - // 暂态触发时间 - strFileLine = iterable.next(); - strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " "); - TimeWave = sdf.parse(strFileLine); - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(TimeWave); - firstMs = calendar.get(Calendar.MILLISECOND); - firstTime = calendar.getTime(); - - long a = TimeWave.getTime(); - long b = TimeTrige.getTime(); - int c = (int) (a - b); - if (c >= 90 && c <= 110) { - iPush = 100; - } else if (c >= 190 && c <= 210) { - iPush = 200; - } - // 赋值编码格式(二进制) - strBinType = iterable.next().toUpperCase(); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); + // 波形起始时间 + strFileLine = iterable.next(); + strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " "); + TimeTrige = sdf.parse(strFileLine); + // 暂态触发时间 + strFileLine = iterable.next(); + strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " "); + TimeWave = sdf.parse(strFileLine); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(TimeWave); + firstMs = calendar.get(Calendar.MILLISECOND); + firstTime = calendar.getTime(); + long a = TimeWave.getTime(); + long b = TimeTrige.getTime(); + int c = (int) (a - b); + if (c >= 90 && c <= 110) { + iPush = 100; + } else if (c >= 190 && c <= 210) { + iPush = 200; + } + // 赋值编码格式(二进制) + strBinType = iterable.next().toUpperCase(); } catch (Exception e) { e.printStackTrace(); - logger.error("读取文件内容出错"+e.getMessage()); + logger.error("读取文件内容出错" + e.getMessage()); return false; - }finally { - + } finally { } @@ -319,15 +314,8 @@ public class AnalyWave { private List> AnalyseComtradeDat(byte[] array, int iFlag) { float xValueAll = 0;//初始化xValue的值 boolean blxValue = false;//判断是否首次登陆 - List> listWaveData = new ArrayList<>();//返回数据 - - try { - - - - // 计算每个单独的数据块的大小 4字节的序号 4字节的时间 2字节的值 // 示例中的排布是 4字节的序号 4字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节) // IC(2字节) @@ -470,7 +458,7 @@ public class AnalyWave { { if (ComtradeCfg.OneChannleCfg.get(j).fPrimary != 0.0f)//根据cfg内的变比,将一次值转换成二次值 { - fValue = ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary; + fValue = fValue * ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary; } else { fValue = fValue; } @@ -500,7 +488,7 @@ public class AnalyWave { } catch (Exception e) { logger.error("读取文件出错:" + e.getMessage()); return listWaveData; - }finally { + } finally { } diff --git a/pqs-common/common-event/src/main/java/com/njcn/event/file/component/WaveFileComponent.java b/pqs-common/common-event/src/main/java/com/njcn/event/file/component/WaveFileComponent.java index b96ce7124..412328635 100644 --- a/pqs-common/common-event/src/main/java/com/njcn/event/file/component/WaveFileComponent.java +++ b/pqs-common/common-event/src/main/java/com/njcn/event/file/component/WaveFileComponent.java @@ -641,7 +641,7 @@ public class WaveFileComponent { { //根据cfg内的变比,将一次值转换成二次值 if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) { - fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary(); + fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary(); } else { fValue = fValue; } @@ -724,7 +724,7 @@ public class WaveFileComponent { { //根据cfg内的变比,将一次值转换成二次值 if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) { - fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary(); + fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary(); } else { fValue = fValue; }