Compare commits
40 Commits
4e95159e01
...
2026-04
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eed647d3d1 | ||
|
|
4a5fde6a47 | ||
|
|
82ab1de5b9 | ||
|
|
ecc56dd2f6 | ||
| 39ae7412a8 | |||
| 52677f84dc | |||
| abdb855919 | |||
| 64bcbfff91 | |||
|
|
499eee6784 | ||
|
|
c58bd87a78 | ||
|
|
0902f92838 | ||
| 87818db6f3 | |||
|
|
850b3174a2 | ||
| aad5943d64 | |||
| 9c467310d5 | |||
| ca3b125424 | |||
|
|
0c5c9bf067 | ||
|
|
c692282ea4 | ||
| 232e84aad3 | |||
| 59f2588488 | |||
|
|
46f521c7a7 | ||
|
|
6d69027e16 | ||
|
|
1afed2c9a4 | ||
|
|
9bb250bdb9 | ||
|
|
d33b3637a5 | ||
|
|
f50f11b159 | ||
| 30984aa908 | |||
|
|
39cfffbf7e | ||
|
|
1aad1aa86b | ||
| fa500ca600 | |||
| 7b9fb1628b | |||
| fcddc064f6 | |||
| 37c5e9cbf8 | |||
| a08c7db24d | |||
| 9225e82edb | |||
| e8cd6da8a0 | |||
| 559620ab66 | |||
| f0b3b81e65 | |||
| 475ca820c8 | |||
|
|
c0db2cf961 |
3
pom.xml
3
pom.xml
@@ -39,6 +39,7 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<spring.profiles.active>sjzx</spring.profiles.active>
|
||||
<!--中间件目标地址-->
|
||||
<!-- <middle.server.url>10.95.53.49</middle.server.url>-->
|
||||
<middle.server.url>192.168.1.103</middle.server.url>
|
||||
@@ -51,7 +52,7 @@
|
||||
<!--nacos开启鉴权后的用户名-->
|
||||
<nacos.username>nacos</nacos.username>
|
||||
<!--nacos的ip:port-->
|
||||
<nacos.password>nacos</nacos.password>
|
||||
<nacos.password>njcnpqs</nacos.password>
|
||||
<!--服务器发布内容为空-->
|
||||
<nacos.namespace>hswbpm</nacos.namespace>
|
||||
<!-- <nacos.namespace>30c701c4-2a94-49d9-82e1-76aa9456573f</nacos.namespace>-->
|
||||
|
||||
@@ -2,8 +2,14 @@ package com.njcn.advance.api;
|
||||
|
||||
import com.njcn.advance.api.fallback.EventWaveAnalysisFeignClientFallbackFactory;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
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 io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -27,4 +33,7 @@ public interface EventWaveAnalysisFeignClient {
|
||||
*/
|
||||
@PostMapping("analysis")
|
||||
HttpResult<EntityAdvancedData> analysis(@RequestParam("eventIndex") String eventIndex);
|
||||
|
||||
@PostMapping("analysisWlEvent")
|
||||
HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ public class EventWaveAnalysisFeignClientFallbackFactory implements FallbackFact
|
||||
log.error("{}异常,降级处理,异常为:{}", "波形高级分析", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<EntityAdvancedData> analysisWlEvent(String eventIndex) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "物联测点波形高级分析异常", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,10 @@ public class EventAnalysisDTO {
|
||||
* 1 正常计算
|
||||
*/
|
||||
private Integer typeFlag = 1;
|
||||
|
||||
/**
|
||||
* 文件全路径
|
||||
* 适配物联的暂态事件解析 物联那边事件的路径是全路径,不需要拼接,这个参数可为空
|
||||
*/
|
||||
private String wlFilePath;
|
||||
}
|
||||
|
||||
@@ -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<String> temCfgList,byte[] array, int iFlag) {
|
||||
public AnalyWaveModel.tagDataValue readComtrade(List<String> 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<List<Float>> AnalyseComtradeDat(byte[] array, int iFlag) {
|
||||
float xValueAll = 0;//初始化xValue的值
|
||||
boolean blxValue = false;//判断是否首次登陆
|
||||
|
||||
List<List<Float>> 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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,13 @@ public class CauseStruct extends Structure {
|
||||
public static class ByValue extends CauseStruct implements Structure.ByValue {
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected List<String> getFieldOrder() { // 返回值填入的顺序
|
||||
// return Arrays.asList(new String[] { "cause", "no_cal" });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() { // 返回值填入的顺序
|
||||
return Arrays.asList(new String[] { "cause", "no_cal" });
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "threshold", "cause", "no_cal");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,13 @@ public class Rect extends Structure {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected List<String> getFieldOrder() {
|
||||
// return Arrays.asList(new String[] { "evt_num","evt_buf" });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "evt_num","evt_buf" });
|
||||
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "evt_num", "evt_buf");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public class EventWaveAnalysisController extends BaseController {
|
||||
|
||||
private final EventWaveAnalysisService eventWaveAnalysisService;
|
||||
|
||||
|
||||
@PostMapping("analysis")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("波形高级分析")
|
||||
@@ -43,6 +42,15 @@ public class EventWaveAnalysisController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("analysis");
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysis(eventIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("analysisWlEvent")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("物联事件波形高级分析")
|
||||
@ApiImplicitParam(name = "eventIndex", value = "暂降事件id", required = true)
|
||||
public HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex) {
|
||||
String methodDescribe = getMethodDescribe("analysisWlEvent");
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysisWlEvent(eventIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.njcn.advance.event.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.advance.enums.EnumEvt;
|
||||
import com.njcn.advance.event.cause.jna.QvvrCauseDLL;
|
||||
import com.njcn.advance.event.cause.model.DataFeature;
|
||||
import com.njcn.advance.event.type.jna.*;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.advance.event.service.IEventAdvanceService;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.Rect;
|
||||
import com.njcn.advance.utils.Utils;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.event.file.component.WaveFileComponent;
|
||||
@@ -18,6 +21,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@@ -44,11 +48,12 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
public EventAnalysisDTO analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
|
||||
WaveDataDTO waveDataDTO;
|
||||
String waveName = eventAnalysis.getWaveName();
|
||||
String wlFilePath = eventAnalysis.getWlFilePath();
|
||||
String cfgPath, datPath, cfgPath2, datPath2;
|
||||
String ip = eventAnalysis.getIp();
|
||||
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;
|
||||
cfgPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
|
||||
datPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
|
||||
log.info("本地磁盘波形文件路径----" + cfgPath);
|
||||
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
|
||||
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
|
||||
@@ -57,11 +62,11 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
||||
} else {
|
||||
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||
cfgPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
|
||||
datPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
|
||||
//适配文件后缀小写
|
||||
cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
|
||||
datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
|
||||
cfgPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase() : wlFilePath + GeneralConstant.CFG.toLowerCase();
|
||||
datPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase() : wlFilePath + GeneralConstant.DAT.toLowerCase();
|
||||
log.info("文件服务器波形文件路径----" + cfgPath);
|
||||
try (
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
||||
@@ -70,7 +75,7 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
||||
waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
||||
@@ -122,6 +127,21 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
}
|
||||
}
|
||||
}
|
||||
String str = WriteData2File(typeDataStruct);
|
||||
if (Objects.isNull(wlFilePath)) {
|
||||
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH;
|
||||
String hdrName = waveName + GeneralConstant.HDR_LOWER;
|
||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||
} else {
|
||||
// comtrade/00:B7:8D:00:A8:7A/PQMonitor_PQM1_00100_20260204_162453_071_WAV.hdr
|
||||
String fullPath = wlFilePath + GeneralConstant.HDR_LOWER;
|
||||
int lastSlashIndex = fullPath.lastIndexOf('/');
|
||||
String hdrPath = fullPath.substring(0, lastSlashIndex + 1);
|
||||
String hdrName = fullPath.substring(lastSlashIndex + 1);
|
||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||
}
|
||||
|
||||
//上传HR
|
||||
eventAnalysis.setType(globalFaultType);
|
||||
} else {
|
||||
eventAnalysis.setType(DataFeature.TYPE10);
|
||||
@@ -158,4 +178,306 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
System.out.println("cause:" + eventAnalysis);
|
||||
return eventAnalysis;
|
||||
}
|
||||
|
||||
public String WriteData2File(QvvrDLL.QvvrDataStruct rect) throws Exception {
|
||||
StringBuilder stringBuilder = new StringBuilder("{" + EnumEvt.NEWLINE.getProperty());
|
||||
|
||||
/**
|
||||
* @写入返回事件总数
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.EVT_NUM.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_num), 1));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.EVT_BUF.getProperty()) + "[");
|
||||
|
||||
/**
|
||||
* @写入返回事件参数
|
||||
*/
|
||||
for (int i = 0; i < rect.evt_num; i++) {
|
||||
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(2));
|
||||
/**
|
||||
* @波形起始点
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_A.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_a), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_B.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_b), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_C.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_c), 3));
|
||||
/**
|
||||
* @跳变段电压变化率
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VA.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Va), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VB.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Vb), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VC.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Vc), 3));
|
||||
/**
|
||||
* @持续时间
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.HOLD_TIME_RMS.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].hold_time_rms), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.HOLD_TIME_DQ.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].hold_time_dq), 3));
|
||||
/**
|
||||
* @分段数目
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.SEG_T_NUM.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].SEG_T_num), 3));
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.SEG_T_IDX.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(3));
|
||||
|
||||
for (int j = 0; j < rect.evt_buf[i].SEG_T_num; j++) {
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(Utils.int2String(j)));
|
||||
|
||||
if (rect.evt_buf[i].SEG_T_num - 1 == j) {
|
||||
stringBuilder.append(Utils.int2String(rect.evt_buf[i].SEG_T_idx[j]));
|
||||
} else {
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].SEG_T_idx[j]), 4));
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @特征幅值
|
||||
*/
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.U_MIN_NUM.getProperty()));
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].u_min_num), 3));
|
||||
|
||||
/**
|
||||
* @最小值位置
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ORDER_MIN_IDX.getProperty(), null,
|
||||
rect.evt_buf[i].order_min_idx[k]);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @A相电压特征值
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.UA_MIN.getProperty(), rect.evt_buf[i].ua_min[k], null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @B相电压特征值
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.UB_MIN.getProperty(), rect.evt_buf[i].ub_min[k], null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @C相电压特征值
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.UC_MIN.getProperty(), rect.evt_buf[i].uc_min[k], null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @三相电压特征值
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.U3_MIN.getProperty(), rect.evt_buf[i].u3_min[k], null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @A相相位正跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_AP.getProperty(), rect.evt_buf[i].angle_diff_ap[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @B相相位正跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_BP.getProperty(), rect.evt_buf[i].angle_diff_bp[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @C相相位正跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_CP.getProperty(), rect.evt_buf[i].angle_diff_cp[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @A相相位负跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_AN.getProperty(), rect.evt_buf[i].angle_diff_an[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @B相相位负跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_BN.getProperty(), rect.evt_buf[i].angle_diff_bn[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @C相相位负跳变
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_CN.getProperty(), rect.evt_buf[i].angle_diff_cn[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @不平衡度
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.BPH_MAX_VALUE.getProperty(), rect.evt_buf[i].bph_max_value[k],
|
||||
null);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @暂降原因
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_CATA_CAUSE.getProperty(), null,
|
||||
rect.evt_buf[i].qvvr_cata_cause[k]);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @暂降类型
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_CATA_TYPE.getProperty(), null,
|
||||
rect.evt_buf[i].qvvr_cata_type[k]);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
|
||||
|
||||
/**
|
||||
* @暂降相别
|
||||
*/
|
||||
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
|
||||
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_PHASETYPE.getProperty(), null,
|
||||
rect.evt_buf[i].qvvr_phasetype[k]);
|
||||
|
||||
if (rect.evt_buf[i].u_min_num - 1 == k) {
|
||||
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setClose(3));
|
||||
|
||||
if (rect.evt_num - 1 == i) {
|
||||
stringBuilder.append(EnumEvt.setClose(2));
|
||||
stringBuilder.append("]" + EnumEvt.ENTER.getProperty());
|
||||
} else {
|
||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(2), 2));
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append("}");
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* @特征值处理
|
||||
*/
|
||||
public void setEigenVlaue(int len, StringBuilder stringBuilder, String string, Float f, Integer integer) {
|
||||
if (0 == len) {
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(string));
|
||||
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(3));
|
||||
}
|
||||
|
||||
stringBuilder.append(EnumEvt.setEvtProperty(Integer.toString(len)));
|
||||
|
||||
if (null == f) {
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(integer.intValue()), 4));
|
||||
} else {
|
||||
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(f.floatValue()), 4));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
public interface EventWaveAnalysisService {
|
||||
|
||||
EntityAdvancedData analysis(String eventIndex);
|
||||
|
||||
EntityAdvancedData analysisWlEvent(String eventIndex);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.njcn.advance.service.impl;
|
||||
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.advance.enums.EnumEvt;
|
||||
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.*;
|
||||
|
||||
import com.njcn.advance.service.EventWaveAnalysisService;
|
||||
import com.njcn.advance.utils.*;
|
||||
import com.njcn.advance.utils.JnaCallBalance;
|
||||
import com.njcn.advance.utils.JnaCallDllOrSo;
|
||||
import com.njcn.advance.utils.Utils;
|
||||
import com.njcn.advance.utils.WaveUtils;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
@@ -26,7 +29,10 @@ import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -170,17 +176,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
causeStruct.smp_len = pitchList.size();
|
||||
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
|
||||
|
||||
String hdrStr = waveUtils.getFile(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.HDR);
|
||||
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
||||
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
||||
|
||||
|
||||
if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
//如果存在三个文件但是没有调用dll/so计算
|
||||
|
||||
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +216,171 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
return entityAdvancedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityAdvancedData analysisWlEvent(String eventIndex) {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
//调用方法获取暂降事件详情
|
||||
RmpEventDetailPO rmpEventDetailPO = rmpEventAdvanceMapper.selectById(eventIndex);
|
||||
EntityAdvancedData entityAdvancedData;
|
||||
|
||||
if (Objects.isNull(rmpEventDetailPO.getFileFlag())) {
|
||||
throw new BusinessException("系统检测到波形文件未从装置招到本地,请联系管理员");
|
||||
}
|
||||
|
||||
if (rmpEventDetailPO.getFileFlag() == 1) {
|
||||
//获取所有暂态原因
|
||||
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
Map<Integer, DictData> eventTypeMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
|
||||
InputStream inputStreamCfg;
|
||||
InputStream inputStreamDat;
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath()+ GeneralConstant.CFG);
|
||||
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
|
||||
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
|
||||
} catch (Exception e1) {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
//读取
|
||||
BufferedReader bufferedReader;
|
||||
InputStreamReader read = null;
|
||||
String strFileLine;
|
||||
byte[] array = {};
|
||||
List<String> temCfgList = new ArrayList<>();
|
||||
try {
|
||||
// 判断文件是否存在
|
||||
array = IoUtil.readBytes(inputStreamDat);
|
||||
// 考虑到编码格式
|
||||
read = new InputStreamReader(inputStreamCfg, StandardCharsets.UTF_8);
|
||||
bufferedReader = new BufferedReader(read);
|
||||
|
||||
while ((strFileLine = bufferedReader.readLine()) != null) {
|
||||
temCfgList.add(strFileLine);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (read != null) {
|
||||
read.close();
|
||||
}
|
||||
if (inputStreamDat != null) {
|
||||
inputStreamDat.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//原始波形
|
||||
WaveData waveOriginalData = getWavedata(rmpEventDetailPO, temCfgList, array, 3);
|
||||
List<List<Float>> originalList = waveOriginalData.getSunData();
|
||||
|
||||
entityAdvancedData = new EntityAdvancedData(originalList.size());
|
||||
|
||||
for (int i = 0; i < originalList.size(); i++) {
|
||||
//坐标轴
|
||||
entityAdvancedData.smp_x[i] = originalList.get(i).get(0);
|
||||
entityAdvancedData.smp_a[i] = originalList.get(i).get(1);
|
||||
entityAdvancedData.smp_b[i] = originalList.get(i).get(2);
|
||||
entityAdvancedData.smp_c[i] = originalList.get(i).get(3);
|
||||
}
|
||||
entityAdvancedData.smp_len = originalList.size();
|
||||
|
||||
//抽点方法计算波形
|
||||
WaveData wavePitchData = getWavedata(rmpEventDetailPO, temCfgList, array, 0);
|
||||
List<List<Float>> pitchList = wavePitchData.getSunData();
|
||||
|
||||
// 将获取到的数据填充到结构体内
|
||||
Rect rect = new Rect();
|
||||
CauseStruct causeStruct = new CauseStruct();
|
||||
|
||||
for (int i = 0; i < pitchList.size(); i++) {
|
||||
rect.smp_va[i] = pitchList.get(i).get(1);
|
||||
causeStruct.smp_va[i] = pitchList.get(i).get(1);
|
||||
|
||||
rect.smp_vb[i] = pitchList.get(i).get(2);
|
||||
causeStruct.smp_vb[i] = pitchList.get(i).get(2);
|
||||
|
||||
rect.smp_vc[i] = pitchList.get(i).get(3);
|
||||
causeStruct.smp_vc[i] = pitchList.get(i).get(3);
|
||||
}
|
||||
|
||||
rect.smp_len = pitchList.size();
|
||||
|
||||
//超过60s的波形直接抛异常给上面处理
|
||||
/*
|
||||
* 波形最大值计算
|
||||
*/
|
||||
int MAX_LENGTH = 128 * 3000;
|
||||
if (rect.smp_len >= MAX_LENGTH) {
|
||||
throw new BusinessException("波形超过60S");
|
||||
}
|
||||
|
||||
rect.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
causeStruct.smp_len = pitchList.size();
|
||||
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
|
||||
if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
//如果存在三个文件但是没有调用dll/so计算
|
||||
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
} else {
|
||||
//已经处理过了,那就根据id获取暂降原因
|
||||
String reason = rmpEventDetailPO.getAdvanceReason();
|
||||
List<DictData> reasonList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||
Map<String, DictData> eventReasonMap = reasonList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
if (ObjectUtil.isNotNull(eventReasonMap.get(reason))) {
|
||||
entityAdvancedData.sagReason[0] = eventReasonMap.get(reason).getName();
|
||||
}
|
||||
}
|
||||
|
||||
String hdrStr = null;
|
||||
try {
|
||||
hdrStr = waveUtils.getFile(rmpEventDetailPO.getWavePath() + GeneralConstant.HDR.toLowerCase());
|
||||
} catch (Exception e) {
|
||||
log.error("读取文件服务器波形数据异常:{}",e.getMessage());
|
||||
}
|
||||
if (hdrStr != null) {
|
||||
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
||||
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
||||
}
|
||||
|
||||
// if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
// //如果存在三个文件但是没有调用dll/so计算
|
||||
// getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
// }
|
||||
|
||||
/****************************************************************
|
||||
* 根据返回的结果计算,获取暂降类型描述
|
||||
****************************************************************/
|
||||
if (entityAdvancedData.backNumber > 0) {
|
||||
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||
entityAdvancedData.sagType[i] = eventTypeMap.get(entityAdvancedData.evt_buf[i].qvvr_cata_type[0]).getName();
|
||||
switch (entityAdvancedData.evt_buf[i].qvvr_phasetype[0]) {
|
||||
case 1:
|
||||
entityAdvancedData.sagPhaseType[i] = "单相";
|
||||
break;
|
||||
case 2:
|
||||
entityAdvancedData.sagPhaseType[i] = "两相";
|
||||
break;
|
||||
case 3:
|
||||
entityAdvancedData.sagPhaseType[i] = "三相";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
log.info("高级算法波形计算" + timeInterval.interval());
|
||||
return entityAdvancedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件未进行高级算法处理:系统调用dll处理并保存结果
|
||||
@@ -358,7 +525,7 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
if (StrUtil.isBlank(rmpEventDetailPOQuery.getAdvanceReason())) {
|
||||
|
||||
//暂降原因计算
|
||||
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_dll_cause");
|
||||
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_cause_dll");
|
||||
jnaCallDllReason.setPath();
|
||||
|
||||
JnaCallBalance.Balancelibrary CAUSE = JnaCallBalance.Balancelibrary.INSTANTCE;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.njcn.advance.utils;
|
||||
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -20,21 +20,20 @@ public class JnaCallDllOrSo {
|
||||
|
||||
public JnaCallDllOrSo(String name) {
|
||||
super();
|
||||
String suffix = ".dll";
|
||||
try {
|
||||
String os = System.getProperty("os.name");
|
||||
// windows操作系统为1 否则为0
|
||||
int beginIndex = os != null && os.startsWith("Windows") ? 1 : 0;
|
||||
String nameDll;
|
||||
if (beginIndex == 0) {
|
||||
//linux操作系统
|
||||
nameDll = "lib" + name + "_dll";
|
||||
suffix = ".so";
|
||||
nameDll = "lib" + name + ".so";
|
||||
} else {
|
||||
nameDll = name;
|
||||
if (!name.endsWith(".dll")) {
|
||||
nameDll = name + ".dll";
|
||||
}
|
||||
}
|
||||
|
||||
String tem = "/usr/local/dllFile/"+ nameDll.concat(suffix);
|
||||
String tem = "/usr/local/dllFile/"+ nameDll;
|
||||
File dockerFile = new File(tem);
|
||||
if(!dockerFile.exists()){
|
||||
boolean f = dockerFile.getParentFile().mkdirs();
|
||||
@@ -42,7 +41,11 @@ public class JnaCallDllOrSo {
|
||||
System.out.println("文件夹创建:"+f);
|
||||
System.out.println("文件创建:"+d);
|
||||
|
||||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(nameDll.concat(suffix))) {
|
||||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(nameDll)) {
|
||||
if (inputStream == null) {
|
||||
log.error("找不到资源文件: {}", nameDll);
|
||||
throw new FileNotFoundException("找不到资源文件: " + nameDll);
|
||||
}
|
||||
try (FileOutputStream outputStream = new FileOutputStream(dockerFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
@@ -53,9 +56,11 @@ public class JnaCallDllOrSo {
|
||||
}
|
||||
}
|
||||
this.path = dockerFile.getAbsolutePath();
|
||||
System.out.println("动态库路径: " + this.path);
|
||||
} catch (Exception e) {
|
||||
log.error("调用高级算法文件异常,异常信息如下:");
|
||||
log.error(e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException("加载动态库失败: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
56
pqs-advance/advance-boot/src/main/resources/bootstrap-jb.yml
Normal file
56
pqs-advance/advance-boot/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10211
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.advance.pojo
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10211
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.advance.pojo
|
||||
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
@@ -1,57 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10211
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.advance.pojo
|
||||
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
profiles:
|
||||
active: sjzx
|
||||
52
pqs-auth/src/main/resources/bootstrap-jb.yml
Normal file
52
pqs-auth/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10214
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.user.pojo
|
||||
|
||||
57
pqs-auth/src/main/resources/bootstrap-sjzx.yml
Normal file
57
pqs-auth/src/main/resources/bootstrap-sjzx.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10214
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.user.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
@@ -1,53 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10214
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.user.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
71
pqs-bpm/bpm-boot/src/main/resources/bootstrap-jb.yml
Normal file
71
pqs-bpm/bpm-boot/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,71 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10321
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: Asia/Shanghai
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
flowable:
|
||||
database-schema-update: false
|
||||
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
|
||||
check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程
|
||||
history-level: full # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数
|
||||
async-executor-activate: false
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.bpm.pojo
|
||||
|
||||
gw:
|
||||
url: dwzyywzt-pms3-proxy.com
|
||||
code: 13B9B47F1E483324E05338297A0A0595
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
76
pqs-bpm/bpm-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
76
pqs-bpm/bpm-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
@@ -0,0 +1,76 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10321
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: Asia/Shanghai
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: bpm-config.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
flowable:
|
||||
database-schema-update: false
|
||||
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
|
||||
check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程
|
||||
history-level: full # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数
|
||||
async-executor-activate: false
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.bpm.pojo
|
||||
|
||||
gw:
|
||||
url: dwzyywzt-pms3-proxy.com
|
||||
code: 13B9B47F1E483324E05338297A0A0595
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10321
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: Asia/Shanghai
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: bpm-config.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
flowable:
|
||||
database-schema-update: false
|
||||
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
|
||||
check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程
|
||||
history-level: full # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数
|
||||
async-executor-activate: false
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.bpm.pojo
|
||||
|
||||
gw:
|
||||
url: dwzyywzt-pms3-proxy.com
|
||||
code: 13B9B47F1E483324E05338297A0A0595
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
@@ -97,11 +97,11 @@
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<!--mqtt相关依赖-->
|
||||
<dependency>
|
||||
<groupId>com.github.tocrhz</groupId>
|
||||
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- <!–mqtt相关依赖–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.tocrhz</groupId>-->
|
||||
<!-- <artifactId>mqtt-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
@@ -32,6 +33,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
@@ -281,6 +283,30 @@ public class PubUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于获取对象中,前缀一样,后缀为2~50的属性值
|
||||
*
|
||||
* @param methodPrefix 方法前缀
|
||||
* @param number 方法后缀
|
||||
* @return 对象属性值
|
||||
*/
|
||||
public static Double getValueByMethodDouble(List data ,Class clazz, String methodPrefix, Integer number) {
|
||||
try {
|
||||
Method method = clazz.getMethod(methodPrefix + number);
|
||||
OptionalDouble average = data.stream().mapToDouble(temp -> {
|
||||
try {
|
||||
return (Double) method.invoke(temp);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
|
||||
}
|
||||
}).average();
|
||||
return average.orElse(0.0);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getStartTimeEndTime(String beginDate, String endDate) throws Exception {
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ public class DrawPicUtil {
|
||||
|
||||
|
||||
/***
|
||||
* 绘制波形图
|
||||
* @author hongawen
|
||||
* 绘制波形图
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
|
||||
@@ -3,11 +3,9 @@ package com.njcn.event.file.component;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
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.file.pojo.dto.*;
|
||||
@@ -16,11 +14,13 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -81,6 +81,46 @@ public class WaveFileComponent {
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
public WaveDataDTO getComtradeNoAddPoints(InputStream cfgStream, InputStream datStream, int iType) {
|
||||
WaveDataDTO waveDataDTO = new WaveDataDTO();
|
||||
// 首先判断文件路径是否为空
|
||||
// 读取cfg文件
|
||||
ComtradeCfgDTO comtradeCfgDTO = getComtradeCfgNoAddPoints(cfgStream);
|
||||
// 为空或者未找到结束符号
|
||||
if (comtradeCfgDTO == null || !"BINARY".equalsIgnoreCase(comtradeCfgDTO.getStrBinType())) {
|
||||
throw new BusinessException(WaveFileResponseEnum.CFG_DATA_ERROR);
|
||||
}
|
||||
|
||||
/*****根据通道号计算相别** 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());
|
||||
|
||||
// 组装解析抬头
|
||||
getWaveTitle(waveDataDTO, comtradeCfgDTO);
|
||||
|
||||
// 解析.dat文件
|
||||
List<List<Float>> listWaveData = getComtradeDatNoAddPoints(comtradeCfgDTO, datStream, iType);
|
||||
|
||||
waveDataDTO.setComtradeCfgDTO(comtradeCfgDTO);
|
||||
|
||||
waveDataDTO.setListWaveData(listWaveData);
|
||||
|
||||
//add by hongawen,将暂态触发起始时间记录下来
|
||||
waveDataDTO.setTime(DateUtil.format(comtradeCfgDTO.getTimeTrige(), DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||
/*****根据通道号计算相别** add by yexb -----end****/
|
||||
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* 根据波形数据算出rms值数据
|
||||
* param waveDataDTO 瞬时波形(包含了CFG配置文件)
|
||||
@@ -472,6 +512,127 @@ public class WaveFileComponent {
|
||||
return comtradeCfgDTO;
|
||||
}
|
||||
|
||||
private ComtradeCfgDTO getComtradeCfgNoAddPoints(InputStream cfgStream) {
|
||||
ComtradeCfgDTO comtradeCfgDTO = new ComtradeCfgDTO();
|
||||
try (InputStreamReader read = new InputStreamReader(cfgStream, CharsetUtil.CHARSET_GBK); BufferedReader bufferedReader = new BufferedReader(read);) {
|
||||
// 第一行不关心仅仅是一些描述类的信息
|
||||
String strFileLine = bufferedReader.readLine();
|
||||
|
||||
// 第二行需要关心第二个(模拟量的个数)和第三个参数(开关量的个数)
|
||||
strFileLine = bufferedReader.readLine();
|
||||
// 按“,”进行分割
|
||||
String[] strTempArray = strFileLine.split(StrUtil.COMMA);
|
||||
// 总个数
|
||||
comtradeCfgDTO.setNChannelNum(Integer.parseInt(strTempArray[0]));
|
||||
// 模拟量的个数
|
||||
comtradeCfgDTO.setNAnalogNum(Integer.parseInt(strTempArray[1].substring(0, strTempArray[1].length() - 1)));
|
||||
// 开关量的个数
|
||||
comtradeCfgDTO.setNDigitalNum(Integer.parseInt(strTempArray[2].substring(0, strTempArray[2].length() - 1)));
|
||||
|
||||
// 从第三行开始的ComtradeCfg.nChannelNum行是模拟量通道和数字量通道
|
||||
List<AnalogDTO> 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);
|
||||
//通道序号
|
||||
analogDTO.setNIndex(Integer.parseInt(strTempArray[0]));
|
||||
// 通道名称
|
||||
analogDTO.setSzChannleName(strTempArray[1]);
|
||||
// 相位名称
|
||||
analogDTO.setSzPhasicName(strTempArray[2]);
|
||||
// 监视的通道名称
|
||||
analogDTO.setSzMonitoredChannleName(strTempArray[3]);
|
||||
// 通道的单位
|
||||
analogDTO.setSzUnitName(strTempArray[4]);
|
||||
// 通道的系数
|
||||
analogDTO.setFCoefficent(Float.parseFloat(strTempArray[5]));
|
||||
// 通道的偏移量
|
||||
analogDTO.setFOffset(Float.parseFloat(strTempArray[6]));
|
||||
// 起始采样时间的偏移量
|
||||
analogDTO.setFTimeOffset(Float.parseFloat(strTempArray[7]));
|
||||
// 采样值的最小值
|
||||
analogDTO.setNMin(Integer.parseInt(strTempArray[8]));
|
||||
// 采样值的最大值
|
||||
analogDTO.setNMax(Integer.parseInt(strTempArray[9]));
|
||||
// 一次变比
|
||||
analogDTO.setFPrimary(Float.parseFloat(strTempArray[10]));
|
||||
// 二次变比
|
||||
analogDTO.setFSecondary(Float.parseFloat(strTempArray[11]));
|
||||
// 一次值还是二次值标志
|
||||
analogDTO.setSzValueType(strTempArray[12]);
|
||||
}
|
||||
|
||||
//WW 2019-11-14 // 采样频率
|
||||
String freqLine = bufferedReader.readLine();
|
||||
int nFreq;
|
||||
try {
|
||||
// 先尝试解析为double再四舍五入为整数,以兼容"50.00"这样的格式
|
||||
nFreq = (int) Math.round(Double.parseDouble(freqLine));
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果失败则使用原来的整数解析方式
|
||||
nFreq = Integer.parseInt(freqLine);
|
||||
}
|
||||
|
||||
// 获取采样段数
|
||||
strFileLine = bufferedReader.readLine();
|
||||
int nRates = Integer.parseInt(strFileLine);
|
||||
comtradeCfgDTO.setNRates(nRates);
|
||||
// 获得每段的采样率 //采样率
|
||||
List<RateDTO> lstRate = new ArrayList<>();
|
||||
int 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
|
||||
double doubleValue = Double.parseDouble(strTempArray[0]); // 解析为 double
|
||||
int result = (int) (doubleValue / nFreq); // 强制转换为 int
|
||||
rateDTO.setNOneSample(result);
|
||||
// 总点数 //这里的strTemp是一个偏移量
|
||||
rateDTO.setNSampleNum((Integer.parseInt(strTempArray[1]) - nOffset));
|
||||
nOffset = rateDTO.getNSampleNum();
|
||||
lstRate.add(rateDTO);
|
||||
}
|
||||
comtradeCfgDTO.setLstRate(lstRate);
|
||||
// 增加读取波形起始时间个结束时间
|
||||
String timeFormat = "dd/MM/yyyy,HH:mm:ss.SSS";
|
||||
// 波形起始时间
|
||||
strFileLine = bufferedReader.readLine();
|
||||
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
|
||||
comtradeCfgDTO.setTimeStart(DateUtil.parse(strFileLine, timeFormat));
|
||||
|
||||
// 暂态触发时间
|
||||
strFileLine = bufferedReader.readLine();
|
||||
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
|
||||
comtradeCfgDTO.setTimeTrige(DateUtil.parse(strFileLine, timeFormat));
|
||||
|
||||
// 获取触发时间的时间 + 毫秒
|
||||
Calendar calendar = DateUtil.calendar(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;
|
||||
}
|
||||
return comtradeCfgDTO;
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* 读取dat方法
|
||||
* param strFilePath .dat访问路径
|
||||
@@ -511,13 +672,14 @@ public class WaveFileComponent {
|
||||
//抽点后新的的采样率
|
||||
List<RateDTO> 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();
|
||||
// C# 原实现中 bool 默认是 false,16~31 点/周波段也应按普通抽点处理
|
||||
tmpRateDTO.bRMSFlag = false;
|
||||
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
|
||||
if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
||||
//YXB 2025-08-27
|
||||
@@ -547,12 +709,299 @@ public class WaveFileComponent {
|
||||
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
|
||||
}
|
||||
|
||||
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);
|
||||
// 判断是否进入下一段
|
||||
if (i == tmpRateDTO.getNSampleNum() + nOffSet) {
|
||||
nOffSet += tmpRateDTO.getNSampleNum();
|
||||
nIndex++;
|
||||
if (nIndex == nnInd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
||||
// C# 原实现中 RMS 段与普通抽点是两条独立控制流,不能挂在同一个取模条件下
|
||||
if (Boolean.TRUE.equals(newLstRate.get(nIndex).bRMSFlag)) {
|
||||
//计算本段补点采样间隔
|
||||
nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
|
||||
// 计算有多少个周波
|
||||
long allWaveTemp = newLstRate.get(nIndex).getNSampleNum() / newLstRate.get(nIndex).getNOneSample();
|
||||
// 本段需要补多少点
|
||||
long allempSample = newLstRate.get(nIndex).getNOneSample();
|
||||
int segmentEndIndex = (int) (nOffSet + tmpRateDTO.getNSampleNum() - 1);
|
||||
for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
|
||||
for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
|
||||
// 2 点/周波时,半周波位置需要切换到该周波的第二个原始采样点
|
||||
if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
|
||||
i++;
|
||||
}
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
List<Float> tmpWaveData = new ArrayList<>();
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||
break;
|
||||
}
|
||||
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||
//WW 2019-11-14
|
||||
/*************************
|
||||
* 1、接口返回的默认是二次值
|
||||
* 2、P是一次值 S是二次值
|
||||
* 3、S(二次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
* 4、P(一次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
*************************/
|
||||
//P是一次值 S是二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
fValue = fValue * 1000.0f;
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//P是一次值 S是二次值
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//判断单位是V还是kV
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
} else //还有可能是 电流,单位是A
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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) dfValue / nWaveSpan;
|
||||
//只增加一个xValue的值 //增加时间值
|
||||
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
||||
}
|
||||
|
||||
//不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值
|
||||
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
|
||||
}
|
||||
//把每个单独的值赋予到整体里面去
|
||||
listWaveData.add(tmpWaveData);
|
||||
}
|
||||
// 本周波处理完成后,推进到下一周波的原始采样点
|
||||
if (iWaveTemp < (allWaveTemp - 1)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// 某些文件的段点数并不是原始每周波点数的整倍数。
|
||||
// RMS 段处理完成后,强制把原始游标对齐到当前段末尾,
|
||||
// 这样外层 for 的下一次自增才能稳定落到下一段起点,避免重复进入同一 RMS 段。
|
||||
i = segmentEndIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 计算本段抽点采样间隔
|
||||
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
// 判断是否到了需要抽的采样点
|
||||
if (i % nWaveSpan == 0) {
|
||||
// 计算每个通道的值
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
List<Float> tmpWaveData = new ArrayList<>();
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
//数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||
break;
|
||||
}
|
||||
|
||||
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||
|
||||
//WW 2019-11-14
|
||||
/**************************
|
||||
* 1、接口返回的默认是二次值
|
||||
* 2、P是一次值 S是二次值
|
||||
* 3、S(二次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
* 4、P(一次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
**************************/
|
||||
//P是一次值 S是二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
fValue = fValue * 1000.0f;
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//P是一次值 S是二次值
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//判断单位是V还是kV
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
} else //还有可能是 电流,单位是A
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
//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) {
|
||||
e.printStackTrace();
|
||||
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
||||
}
|
||||
|
||||
return listWaveData;
|
||||
}
|
||||
|
||||
private List<List<Float>> getComtradeDatNoAddPoints(ComtradeCfgDTO comtradeCfgDTO, InputStream datStream, int iType) {
|
||||
//返回数据,如果仅仅做展示后期考虑换String类型,降低内存开销
|
||||
List<List<Float>> listWaveData = new ArrayList<>();
|
||||
//初始化xValue的值
|
||||
float xValueAll = 0;
|
||||
//判断是否首次登陆
|
||||
boolean blxValue = false;
|
||||
byte[] datArray;
|
||||
try {
|
||||
datArray = IoUtil.readBytes(datStream);
|
||||
if (ArrayUtil.isEmpty(datArray)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
||||
}
|
||||
// 计算每个单独的数据块的大小 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 = (int)Math.floor(datArray.length / nBlockSize);
|
||||
|
||||
// 获取采样率
|
||||
int finalSampleRate = getFinalWaveSample(comtradeCfgDTO.getLstRate(), iType);
|
||||
if (finalSampleRate != -1) {
|
||||
//设置最终采样率
|
||||
comtradeCfgDTO.setFinalSampleRate(finalSampleRate);
|
||||
// 计算转换后的采样率
|
||||
int nnInd = 0;
|
||||
// 抽点后总共多少点数据
|
||||
int nWaveNum;
|
||||
//抽点后新的的采样率
|
||||
List<RateDTO> 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();
|
||||
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
|
||||
// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
||||
// //YXB 2025-08-27
|
||||
// tmpRateDTO.bRMSFlag = false;
|
||||
// }
|
||||
// //如果采样是全波有效值或者半波有效值,需要去补足周波点数 YXB 2025-08-27
|
||||
// else if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() <= 2) {
|
||||
// //YXB 2025-08-27
|
||||
// tmpRateDTO.bRMSFlag = true;
|
||||
// }
|
||||
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());*/
|
||||
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;
|
||||
@@ -574,15 +1023,16 @@ public class WaveFileComponent {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||
//YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
||||
if (newLstRate.get(nIndex).bRMSFlag == true) {
|
||||
//计算本段补点采样间隔
|
||||
nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
|
||||
} else {
|
||||
// 计算本段抽点采样间隔
|
||||
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
}
|
||||
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
// tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||
// //YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
||||
// if (newLstRate.get(nIndex).bRMSFlag == true) {
|
||||
// //计算本段补点采样间隔
|
||||
// nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
|
||||
// } else {
|
||||
// // 计算本段抽点采样间隔
|
||||
// nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
// }
|
||||
|
||||
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
||||
// 判断是否到了需要抽的采样点
|
||||
@@ -590,182 +1040,82 @@ public class WaveFileComponent {
|
||||
// 计算每个通道的值
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
List<Float> tmpWaveData = new ArrayList<>();
|
||||
//YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
||||
if (newLstRate.get(nIndex).bRMSFlag == true) {
|
||||
// 计算有多少个周波
|
||||
long allWaveTemp = newLstRate.get(nIndex).getNSampleNum() / newLstRate.get(nIndex).getNOneSample();
|
||||
// 本段需要补多少点
|
||||
long allempSample = newLstRate.get(nIndex).getNOneSample();
|
||||
//int iStartWaveTemp = i ;// 开始补点的起点
|
||||
for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
|
||||
for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
|
||||
//最多只有半波有效值,也就是每周波是1个或者2个点,然后去补最少16个点
|
||||
if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
|
||||
i++;
|
||||
}
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
tmpWaveData = new ArrayList<>();
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
//数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||
break;
|
||||
}
|
||||
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
//数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||
break;
|
||||
}
|
||||
|
||||
if((i * nBlockSize + 2 * 4 + j * 2) == 2437568){
|
||||
System.out.println(55);
|
||||
}
|
||||
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||
//WW 2019-11-14
|
||||
/*************************
|
||||
* 1、接口返回的默认是二次值
|
||||
* 2、P是一次值 S是二次值
|
||||
* 3、S(二次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
* 4、P(一次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
*************************/
|
||||
//P是一次值 S是二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
fValue = fValue * 1000.0f;
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//P是一次值 S是二次值
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//判断单位是V还是kV
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
} else //还有可能是 电流,单位是A
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||
|
||||
//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) dfValue / nWaveSpan;
|
||||
//只增加一个xValue的值 //增加时间值
|
||||
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
||||
}
|
||||
|
||||
//不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值
|
||||
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
|
||||
}
|
||||
//把每个单独的值赋予到整体里面去
|
||||
listWaveData.add(tmpWaveData);
|
||||
}
|
||||
// 把每个单独的值赋予到整体里面去
|
||||
if (iWaveTemp < (allWaveTemp - 1)) {
|
||||
i++;
|
||||
//WW 2019-11-14
|
||||
/**************************
|
||||
* 1、接口返回的默认是二次值
|
||||
* 2、P是一次值 S是二次值
|
||||
* 3、S(二次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
* 4、P(一次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
**************************/
|
||||
//P是一次值 S是二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
fValue = fValue * 1000.0f;
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
//数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||
break;
|
||||
}
|
||||
|
||||
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||
|
||||
//WW 2019-11-14
|
||||
/**************************
|
||||
* 1、接口返回的默认是二次值
|
||||
* 2、P是一次值 S是二次值
|
||||
* 3、S(二次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
* 4、P(一次值)情况下:
|
||||
* ①、单位为"V"时候则直接等于;
|
||||
* ②、单位为"kV"时候需要乘以1000
|
||||
**************************/
|
||||
//P是一次值 S是二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
fValue = fValue * 1000.0f;
|
||||
//P是一次值 S是二次值
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//P是一次值 S是二次值
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||
//判断单位是V还是kV
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
//判断单位是V还是kV
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
//判断单位是V还是kV
|
||||
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
} else //还有可能是 电流,单位是A
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
} else //还有可能是 电流,单位是A
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = fValue *comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
}
|
||||
//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);
|
||||
//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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1370,10 +1720,10 @@ public class WaveFileComponent {
|
||||
s = sdf.format(d);
|
||||
System.out.println(s);
|
||||
WaveFileComponent waveFileComponent = new WaveFileComponent();
|
||||
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("F:\\PQ_PQLD3_9_20250821_081038_640.cfg");
|
||||
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("F:\\PQ_PQLD3_9_20250821_081038_640.dat");
|
||||
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.CFG");
|
||||
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.DAT");
|
||||
// 获取瞬时波形 //获取原始波形值
|
||||
WaveDataDTO waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
WaveDataDTO waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
|
||||
d = new Date();
|
||||
s = sdf.format(d);
|
||||
System.out.println(s);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.microservice.listener;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.joran.JoranConfigurator;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -34,33 +36,46 @@ public class NacosLogbackConfigLoader implements SpringApplicationRunListener, A
|
||||
|
||||
@Override
|
||||
public void environmentPrepared(ConfigurableEnvironment environment) {
|
||||
/* String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
|
||||
String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
|
||||
String projectName = environment.getProperty("microservice.ename");
|
||||
String logLevel = environment.getProperty("logging.level.root");
|
||||
String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("cndl408125hawen", "lanxia201");
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||
if (response.getStatusCode().is2xxSuccessful()) {
|
||||
String logbackConfigContent = response.getBody();
|
||||
//替换项目名称
|
||||
logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
|
||||
logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
|
||||
// 应用获取到的Logback配置
|
||||
applyLogbackConfig(logbackConfigContent);
|
||||
}*/
|
||||
String active = environment.getProperty("spring.profiles.active");
|
||||
if(!"jb".equalsIgnoreCase(active)){
|
||||
String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
|
||||
String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
|
||||
String projectName = environment.getProperty("microservice.ename");
|
||||
String logLevel = environment.getProperty("logging.level.root");
|
||||
String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("cndl408125hawen", "lanxia201");
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||
if (response.getStatusCode().is2xxSuccessful()) {
|
||||
String logbackConfigContent = response.getBody();
|
||||
//替换项目名称
|
||||
logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
|
||||
logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
|
||||
// 应用获取到的Logback配置
|
||||
applyLogbackConfig(logbackConfigContent,logLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyLogbackConfig(String logbackConfigContent) {
|
||||
private void applyLogbackConfig(String logbackConfigContent,String logLevel) {
|
||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
JoranConfigurator configurator = new JoranConfigurator();
|
||||
configurator.setContext(context);
|
||||
context.reset();
|
||||
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(logbackConfigContent.getBytes(StandardCharsets.UTF_8))) {
|
||||
configurator.doConfigure(inputStream);
|
||||
Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
if("debug".equalsIgnoreCase(logLevel)){
|
||||
root.setLevel(Level.DEBUG);
|
||||
}
|
||||
if("info".equalsIgnoreCase(logLevel)){
|
||||
root.setLevel(Level.INFO);
|
||||
}
|
||||
if("error".equalsIgnoreCase(logLevel)){
|
||||
root.setLevel(Level.ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -81,6 +81,29 @@ public interface BusinessTopic {
|
||||
|
||||
String RMP_EVENT_DETAIL_TOPIC = "rmpEventDetailTopic";
|
||||
|
||||
// /**
|
||||
// * 云前置文件信息请求主题
|
||||
// */
|
||||
// String FILE_INFO_REQUEST_TOPIC = "fileInfoRequestTopic";
|
||||
//
|
||||
// /**
|
||||
// * 云前置文件信息响应主题
|
||||
// */
|
||||
// String FILE_INFO_RESPONSE_TOPIC = "fileInfoResponseTopic";
|
||||
//
|
||||
// /**
|
||||
// * 云前置文件下载请求主题
|
||||
// */
|
||||
// String FILE_DOWNLOAD_REQUEST_TOPIC = "fileDownloadRequestTopic";
|
||||
// /**
|
||||
// * 云前置文件下载响应主题
|
||||
// */
|
||||
// String FILE_DOWNLOAD_RESPONSE_TOPIC = "fileDownloadResponseTopic";
|
||||
|
||||
String CLOUD_TOPIC = "Cloud_Topic";
|
||||
|
||||
String CLOUD_REPLY_TOPIC = "Cloud_Reply_Topic";
|
||||
|
||||
|
||||
interface AppDataTag {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessResource;
|
||||
@@ -25,7 +25,7 @@ public class BZEventMessageTemplate extends RocketMQEnhanceTemplate {
|
||||
public SendResult sendMember(Object message, String tag) {
|
||||
BaseMessage baseMessage = new BaseMessage();
|
||||
baseMessage.setSource(BusinessResource.WEB_RESOURCE);
|
||||
baseMessage.setMessageBody(new Gson().toJson(message));
|
||||
baseMessage.setMessageBody(JSON.toJSONString(message));
|
||||
return send(BusinessTopic.ASK_RECALL_TOPIC,tag,baseMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.google.gson.Gson;
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessResource;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.google.gson.Gson;
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessResource;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.google.gson.Gson;
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessResource;
|
||||
|
||||
@@ -169,4 +169,14 @@ public interface OssPath {
|
||||
*/
|
||||
String CONFIGURATIONNAME = "configuration.json";
|
||||
|
||||
/**
|
||||
* APP 稳态报告路径
|
||||
*/
|
||||
String APP_HARMONIC_REPORT = "app/report/harmonic/";
|
||||
|
||||
/**
|
||||
* APP 暂态报告路径
|
||||
*/
|
||||
String APP_EVENT_REPORT = "app/report/event/";
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.njcn.oss.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.njcn.ali.oss.config.AliYunOssConfig;
|
||||
import com.njcn.ali.oss.util.AliYunOssUtils;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.huawei.obs.config.HuaweiObsProperties;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
@@ -12,6 +15,8 @@ import com.njcn.minioss.util.MinIoUtils;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import com.obs.services.ObsClient;
|
||||
import com.obs.services.model.PutObjectRequest;
|
||||
import io.minio.*;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -70,6 +75,11 @@ public class FileStorageUtil {
|
||||
*/
|
||||
private final AliYunOssUtils aliYunOssUtils;
|
||||
|
||||
private final HuaweiObsProperties huaweiObsProperties;
|
||||
|
||||
private final OSS ossClient;
|
||||
private final AliYunOssConfig ossConfig;
|
||||
|
||||
|
||||
/***
|
||||
* 上传MultipartFile文件,
|
||||
@@ -442,4 +452,62 @@ public class FileStorageUtil {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void mkdir(String directoryPath) {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
this.createDirectoryHW(directoryPath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
minIoUtils.createDirectory(minIossProperties.getBucket(), directoryPath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
this.createDirectoryAli(directoryPath);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 华为文件服务器创建空目录
|
||||
*
|
||||
* @param dirPath
|
||||
*/
|
||||
private void createDirectoryHW(String dirPath) {
|
||||
ObsClient obsClient = null;
|
||||
try {
|
||||
obsClient = this.huaweiObsProperties.getInstance();
|
||||
String bucketName = this.huaweiObsProperties.getObs().getBucket();
|
||||
|
||||
// 确保路径以 / 结尾
|
||||
String directoryKey = dirPath.endsWith("/") ? dirPath : dirPath + "/";
|
||||
|
||||
// 创建空对象作为目录占位符
|
||||
InputStream emptyStream = new ByteArrayInputStream(new byte[0]);
|
||||
PutObjectRequest request = new PutObjectRequest(bucketName, directoryKey, emptyStream);
|
||||
obsClient.putObject(request);
|
||||
|
||||
log.info("已创建目录占位符:" + directoryKey);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("创建目录失败" + dirPath, e);
|
||||
} finally {
|
||||
this.huaweiObsProperties.destroy(obsClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 阿里云文件服务器创建空目录
|
||||
*
|
||||
* @param dirPath
|
||||
*/
|
||||
public void createDirectoryAli(String dirPath) {
|
||||
try {
|
||||
// 确保路径以 / 结尾,表示目录
|
||||
String directoryKey = dirPath.endsWith("/") ? dirPath : dirPath + "/";
|
||||
|
||||
// 创建空输入流作为目录占位符
|
||||
ByteArrayInputStream emptyStream = new ByteArrayInputStream(new byte[0]);
|
||||
|
||||
this.ossClient.putObject(this.ossConfig.getBucket(), directoryKey, emptyStream);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("创建目录失败:" + dirPath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,4 +115,8 @@ public interface AppRedisKey {
|
||||
* 补召文件
|
||||
*/
|
||||
String MAKE_UP_FILES = "makeUpFilesKey:";
|
||||
|
||||
String COMMON_REQUEST = "commonRequestKey:";
|
||||
|
||||
String COMMON_RESOPNSE = "commonResponseKey:";
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.njcn.redis.utils;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -325,8 +323,25 @@ public class RedisUtil {
|
||||
* @return
|
||||
*/
|
||||
public List<?> getLikeListAllValues(String key) {
|
||||
List<Object> info=new ArrayList<>();
|
||||
for (String s : redisTemplate.keys(key + "*")) {
|
||||
List<Object> info = new ArrayList<>();
|
||||
// 使用 SCAN 替代 keys,解决 Tair 禁用 KEYS 命令的问题
|
||||
Set<String> keys = redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
||||
Set<String> keySet = new HashSet<>();
|
||||
ScanOptions options = ScanOptions.scanOptions()
|
||||
.match(key + "*")
|
||||
.count(1000)
|
||||
.build();
|
||||
|
||||
try (Cursor<byte[]> cursor = connection.scan(options)) {
|
||||
while (cursor.hasNext()) {
|
||||
keySet.add(new String(cursor.next()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Redis SCAN 模糊查询失败", e);
|
||||
}
|
||||
return keySet;
|
||||
});
|
||||
for (String s : keys) {
|
||||
info.add(redisTemplate.opsForValue().get(s));
|
||||
}
|
||||
return info;
|
||||
|
||||
@@ -59,6 +59,7 @@ public class Knife4jSwaggerConfig {
|
||||
"com.njcn.prepare.harmonic.controller",
|
||||
"com.njcn.prepare.event.controller",
|
||||
"com.njcn.device.pq.controller",
|
||||
"com.njcn.device.terminal.controller",
|
||||
"com.njcn.device.pms.controller",
|
||||
"com.njcn.auth.controller",
|
||||
"com.njcn.system.controller",
|
||||
@@ -74,6 +75,7 @@ public class Knife4jSwaggerConfig {
|
||||
"com.njcn.cswarn.controller",
|
||||
"com.njcn.csharmonic.controller",
|
||||
"com.njcn.cssystem.controller",
|
||||
"com.njcn.csreport.controller",
|
||||
"com.njcn.advance.controller",
|
||||
"com.njcn.stat.controller",
|
||||
"com.njcn.rt.controller",
|
||||
@@ -86,7 +88,9 @@ public class Knife4jSwaggerConfig {
|
||||
"com.njcn.dataProcess",
|
||||
"com.njcn.migration",
|
||||
"com.njcn.harmonic.rstatlimitrate.controller",
|
||||
"com.njcn.device.device.controller"
|
||||
"com.njcn.device.device.controller",
|
||||
"com.njcn.device.userledger.controller",
|
||||
"com.njcn.migration.read.controller"
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
List<GrantType> grantTypes = new ArrayList<>();
|
||||
|
||||
67
pqs-device/device-boot/src/main/resources/bootstrap-jb.yml
Normal file
67
pqs-device/device-boot/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10202
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
#上传文件总的最大值
|
||||
max-request-size: 200MB
|
||||
#上传文件的最大值
|
||||
max-file-size: 200MB
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
|
||||
|
||||
#是否是冀北设备台账树
|
||||
isJb: false
|
||||
|
||||
oracle:
|
||||
isSync: false
|
||||
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
|
||||
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
|
||||
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine
|
||||
72
pqs-device/device-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
72
pqs-device/device-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
@@ -0,0 +1,72 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10202
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
#上传文件总的最大值
|
||||
max-request-size: 200MB
|
||||
#上传文件的最大值
|
||||
max-file-size: 200MB
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
|
||||
|
||||
#是否是冀北设备台账树
|
||||
isJb: false
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
oracle:
|
||||
isSync: false
|
||||
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
|
||||
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
|
||||
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine
|
||||
@@ -1,68 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10202
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
#上传文件总的最大值
|
||||
max-request-size: 200MB
|
||||
#上传文件的最大值
|
||||
max-file-size: 200MB
|
||||
|
||||
#项目日志的配置
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
|
||||
|
||||
#是否是冀北设备台账树
|
||||
isJb: false
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
oracle:
|
||||
isSync: false
|
||||
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
|
||||
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
|
||||
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.device.pq.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -17,6 +19,7 @@ import java.io.Serializable;
|
||||
public class DeviceProcess implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//设备id
|
||||
@TableId("Id")
|
||||
private String id;
|
||||
//设备设备所在前置机进程号
|
||||
private Integer processNo;
|
||||
|
||||
@@ -105,6 +105,9 @@ public class LineDetailVO implements Serializable {
|
||||
@ApiModelProperty(name = "终端厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(name = "终端厂家")
|
||||
private String objId;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -59,4 +59,7 @@ public class RunTimeVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "onlineEvaluate",value = "在线率评价")
|
||||
private Double onlineEvaluate;
|
||||
|
||||
@ApiModelProperty(name = "objName",value = "用户对象名称")
|
||||
private String objName;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ public class DeviceOnlineRate {
|
||||
@ApiModelProperty("监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty("监测对象")
|
||||
private String objName;
|
||||
|
||||
@ApiModelProperty("监测点运行状态")
|
||||
private String runFlag;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.device.pq.pojo.vo.dataClean;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -72,6 +73,12 @@ public class DataVerifyExcel implements Serializable {
|
||||
@Excel(name = "厂商")
|
||||
private String manufacturer;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电网标志")
|
||||
@Excel(name = "电网标志")
|
||||
@ApiModelProperty(name = "powerFlag",value = "电网标志")
|
||||
private String powerFlag;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "总指标异常时间")
|
||||
@Excel(name = "总指标异常时间")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.njcn.device.pq.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.CityDataExcel;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.LineDataExcel;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DataLineExcelUtil {
|
||||
List<List<Object>> result = new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(data)){
|
||||
for (LineDataExcel datum : data) {
|
||||
ArrayList<Object> row = Lists.newArrayList(datum.getLineNum(),
|
||||
ArrayList<Object> row = ListUtil.toList(datum.getLineNum(),
|
||||
datum.getLineName(),
|
||||
datum.getDeptName(),
|
||||
datum.getPowerSubstationName(),
|
||||
@@ -89,7 +89,7 @@ public class DataLineExcelUtil {
|
||||
List<List<Object>> result = new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(data)){
|
||||
for (CityDataExcel datum : data) {
|
||||
ArrayList<Object> row = Lists.newArrayList(datum.getDeptName(),
|
||||
ArrayList<Object> row = ListUtil.toList(datum.getDeptName(),
|
||||
datum.getDeviceNum(),
|
||||
datum.getLineNum(),
|
||||
datum.getOnlineRate(),
|
||||
|
||||
@@ -132,8 +132,9 @@ public class FixedDynamicExcelExport {
|
||||
head.add(Collections.singletonList("监测对象名称"));
|
||||
head.add(Collections.singletonList("电网侧变电站"));
|
||||
head.add(Collections.singletonList("厂商"));
|
||||
head.add(Collections.singletonList("电网标志"));
|
||||
head.add(Collections.singletonList("总指标异常时间"));
|
||||
List<String> sortedFields = allFields.subList(10, allFields.size());
|
||||
List<String> sortedFields = allFields.subList(11, allFields.size());
|
||||
for (String field : sortedFields) {
|
||||
// 每个列名单独封装成List,EasyExcel才能识别为不同列
|
||||
head.add(Collections.singletonList(DataVerifyExcel.FIELD_COLUMN_MAP.get(field)));
|
||||
@@ -209,6 +210,7 @@ public class FixedDynamicExcelExport {
|
||||
fieldAlls.add("objName");
|
||||
fieldAlls.add("powerSubstationName");
|
||||
fieldAlls.add("manufacturer");
|
||||
fieldAlls.add("powerFlag");
|
||||
fieldAlls.add("allTime");
|
||||
fieldAlls.addAll(fields);
|
||||
return fieldAlls;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.device.pq.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -156,8 +157,10 @@ public class DataVerifyController extends BaseController {
|
||||
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
monitorBaseParam.setSearchBeginTime(DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())).toString());
|
||||
monitorBaseParam.setSearchEndTime(DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())).toString());
|
||||
if(StrUtil.isNotBlank(monitorBaseParam.getSearchBeginTime())&&StrUtil.isNotBlank(monitorBaseParam.getSearchEndTime())){
|
||||
monitorBaseParam.setSearchBeginTime(DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())).toString());
|
||||
monitorBaseParam.setSearchEndTime(DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())).toString());
|
||||
}
|
||||
iPqDataVerifyBakService.dataVerifyExcel(response, monitorBaseParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,17 @@ public class RunManageController extends BaseController {
|
||||
|
||||
private final RunManageService runManageService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLineLedgerComm")
|
||||
@ApiOperation("监测点台账信息")
|
||||
@ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true)
|
||||
public HttpResult<Page<RunManageVO>> getLineLedgerComm(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
String methodDescribe = getMethodDescribe("getLineLedgerComm");
|
||||
Page<RunManageVO> res = runManageService.getLineLedgerComm(runManageParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLineLedger")
|
||||
@ApiOperation("监测点台账信息")
|
||||
@@ -54,18 +65,18 @@ public class RunManageController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getRuntimeData")
|
||||
@ApiOperation("终端台账信息")
|
||||
@ApiOperation("终端台账信息(通用)")
|
||||
@ApiImplicitParam(name = "runManageParam", value = "终端台账参数", required = true)
|
||||
public HttpResult<List<RunTimeVO>> getRuntimeData(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
public HttpResult<Page<RunTimeVO>> getRuntimeData(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
String methodDescribe = getMethodDescribe("getRuntimeData");
|
||||
List<RunTimeVO> result = runManageService.getRuntimeDetail(runManageParam);
|
||||
Page<RunTimeVO> result = runManageService.getRuntimeDetail(runManageParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDeviceLedger")
|
||||
@ApiOperation("获取基本的终端台账信息")
|
||||
@ApiOperation("获取基本的终端台账信息(冀北)")
|
||||
@ApiImplicitParam(name = "runManageParam", value = "终端台账参数", required = true)
|
||||
public HttpResult<Page<RunTimeVO>> getDeviceLedger(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
String methodDescribe = getMethodDescribe("getRuntimeData");
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.njcn.device.node.mapper.NodeMapper;
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.po.DeviceProcess;
|
||||
import com.njcn.device.pq.pojo.po.Node;
|
||||
import com.njcn.message.constant.RedisKeyPrefix;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -63,8 +65,17 @@ public class DeviceComflagTasks {
|
||||
pqsCommunicateDto.setTime(LocalDateTimeUtil.now().format(DatePattern.NORM_DATETIME_FORMATTER));
|
||||
pqsCommunicateDto.setDevId(temp);
|
||||
pqsCommunicateDto.setType(0);
|
||||
//获取之前设备状态
|
||||
String devFalg =redisUtil.getStringByKey(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(temp));
|
||||
|
||||
if(StringUtils.isBlank(devFalg)||(!Objects.equals(Integer.valueOf(devFalg),pqsCommunicateDto.getType()))){
|
||||
//状态翻转
|
||||
redisUtil.saveByKey(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(temp),pqsCommunicateDto.getType()+"");
|
||||
pqsCommunicateFeignClient.insertion(pqsCommunicateDto) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
pqsCommunicateFeignClient.insertion(pqsCommunicateDto) ;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import java.util.List;
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
public interface RunManageService {
|
||||
|
||||
Page<RunManageVO> getLineLedgerComm(RunManageParam runManageParam);
|
||||
|
||||
/**
|
||||
* 获取监测点台账信息
|
||||
* @param runManageParam 参数
|
||||
@@ -27,7 +30,7 @@ public interface RunManageService {
|
||||
* @param runManageParam 参数
|
||||
* @return 结果
|
||||
*/
|
||||
List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam);
|
||||
Page<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam);
|
||||
|
||||
|
||||
Page<RunTimeVO> getDeviceLedger(RunManageParam runManageParam);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
@Override
|
||||
public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) {
|
||||
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
|
||||
if(CollectionUtils.isEmpty(monitorIds)){
|
||||
if (CollectionUtils.isEmpty(monitorIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<PqDataVerifyBak> dataVerifyList = baseDataVerifyQuery(monitorIds, monitorBaseParam);
|
||||
@@ -435,6 +435,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName());
|
||||
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName());
|
||||
dataVerifyExcel.setIp(areaLineInfoVO.getIp());
|
||||
dataVerifyExcel.setPowerFlag(areaLineInfoVO.getPowerFlag() == 0 ? "电网侧" : "非电网侧");
|
||||
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,11 @@ import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
|
||||
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
|
||||
import com.njcn.device.pq.service.IRStatIntegrityDService;
|
||||
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
|
||||
import com.njcn.device.userledger.service.UserLedgerService;
|
||||
import com.njcn.supervision.pojo.param.user.UserReportParam;
|
||||
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -61,6 +65,7 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
private final LineDetailMapper lineDetailMapper;
|
||||
private final GeneralDeviceService deviceService;
|
||||
private final LineService lineService;
|
||||
private final UserLedgerService userLedgerService;
|
||||
|
||||
@Override
|
||||
public Float getTotalIntegrityByLineIds(LineBaseQueryParam param) {
|
||||
@@ -160,6 +165,9 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
List<DeviceOnlineRate.CitDetail> citDetailList = new ArrayList<>();
|
||||
DeviceOnlineRate.CitDetail citDetail;
|
||||
DeviceOnlineRate.LineDetail detail;
|
||||
//用户侧监测点 监测对象
|
||||
List<UserLedgerVO> userLedgerVOS = userLedgerService.selectUserList(new UserReportParam());
|
||||
Map<String, String> objMap = userLedgerVOS.stream().collect(Collectors.toMap(UserLedgerVO::getId, UserLedgerVO::getProjectName));
|
||||
for (GeneralDeviceDTO dto : deviceInfo) {
|
||||
//获取部门终端集合
|
||||
List<RStatIntegrityVO> citDevOnRate = lineIntegrityRateInfo.stream().filter(x -> dto.getLineIndexes().contains(x.getLineIndex())).collect(Collectors.toList());
|
||||
@@ -184,6 +192,8 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
detail.setRunFlag(RunFlagEnum.getRunFlagRemarkByStatus(Integer.valueOf(line.getLineRunType())));
|
||||
detail.setLineId(line.getLineId());
|
||||
detail.setLineName(line.getLineName());
|
||||
//用户侧监测点 监测对象
|
||||
detail.setObjName(StringUtils.isBlank(line.getObjId())?"/":objMap.get(line.getObjId()));
|
||||
detail.setLatestTime(line.getTimeID());
|
||||
detail.setIntegrity(onlineRateByDevMap.getOrDefault(line.getLineId(), BigDecimal.valueOf(0)).doubleValue()>100.0?BigDecimal.valueOf(100.0):onlineRateByDevMap.getOrDefault(line.getLineId(), BigDecimal.valueOf(0)));
|
||||
detailList.add(detail);
|
||||
|
||||
@@ -72,6 +72,33 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
|
||||
private final UserLedgerService userLedgerService;
|
||||
|
||||
|
||||
/**
|
||||
* 通用监测点台账,区别冀北版本的
|
||||
* @author cdf
|
||||
* @date 2026/3/22
|
||||
*/
|
||||
@Override
|
||||
public Page<RunManageVO> getLineLedgerComm(RunManageParam runManageParam) {
|
||||
Page<RunManageVO> pageResult = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam));
|
||||
List<String> lineIndexes ;
|
||||
if(CollUtil.isNotEmpty(runManageParam.getIds())){
|
||||
lineIndexes =runManageParam.getIds();
|
||||
}else{
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
|
||||
deviceInfoParam.setServerName("pqs-common");
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
||||
lineIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
|
||||
}
|
||||
if(CollectionUtil.isEmpty(lineIndexes)){
|
||||
return pageResult;
|
||||
}
|
||||
pageResult = deviceMapper.getRunManageCommList(new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam)),lineIndexes, runManageParam.getComFlag(),Objects.isNull(runManageParam.getRunFlag())?new ArrayList<>():runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<RunManageVO> getLineLedger(RunManageParam runManageParam) {
|
||||
List<RunManageVO> resultList = new ArrayList<>();
|
||||
@@ -103,34 +130,18 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
|
||||
List<RunTimeVO> runManageDevList = new ArrayList<>();
|
||||
public Page<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
|
||||
deviceInfoParam.setServerName("pqs-common");
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
|
||||
|
||||
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
||||
List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||
DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (StrUtil.isNotBlank(runManageParam.getSearchBeginTime()) && StrUtil.isNotBlank(runManageParam.getSearchEndTime())) {
|
||||
runManageParam.setSearchBeginTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchBeginTime()))));
|
||||
runManageParam.setSearchEndTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchEndTime()))));
|
||||
}
|
||||
|
||||
List<String> manuList = runManageParam.getManufacturer().stream().map(SimpleDTO::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(devIndexes)) {
|
||||
runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(), manuList, runManageParam.getSearchValue());
|
||||
List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVOList = deviceMapper.getOnlineEvaluate(devIndexes, runManageParam.getSearchBeginTime(), runManageParam.getSearchEndTime());
|
||||
Map<String, LineInfluxDbOnlineVO> map = lineInfluxDbOnlineVOList.stream().collect(Collectors.toMap(LineInfluxDbOnlineVO::getDevIndex, Function.identity()));
|
||||
runManageDevList = runManageDevList.stream().peek(item -> item.setOnlineEvaluate(!map.containsKey(item.getId()) ? 3.14159 : NumberUtil.round(map.get(item.getId()).getOnlineRate(), 4).doubleValue())).collect(Collectors.toList());
|
||||
String evaluate = runManageParam.getEvaluate();
|
||||
if (StrUtil.isNotBlank(evaluate)) {
|
||||
runManageDevList = runManageDevList.stream().filter(x -> filterOnlineEvaluate(evaluate, x.getOnlineEvaluate())).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isEmpty(devIndexes)) {
|
||||
return new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam));
|
||||
}
|
||||
}
|
||||
return runManageDevList;
|
||||
return deviceMapper.getRunManageDevList(new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam)),devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(), manuList, runManageParam.getSearchValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -193,13 +193,16 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
});
|
||||
|
||||
UserLedgerVO userReportPO = userLedgerVOMap.get(objId);
|
||||
if (Objects.isNull(userReportPO)) {
|
||||
System.out.println(map);
|
||||
}
|
||||
TerminalTree terminalTree = new TerminalTree();
|
||||
terminalTree.setName(userReportPO.getProjectName());
|
||||
terminalTree.setId(userReportPO.getId());
|
||||
terminalTree.setPid(userReportPO.getStationId());
|
||||
if (Objects.isNull(userReportPO)) {
|
||||
terminalTree.setName("用户对象缺失");
|
||||
terminalTree.setId(objId);
|
||||
terminalTree.setPid("");
|
||||
}else {
|
||||
terminalTree.setName(userReportPO.getProjectName());
|
||||
terminalTree.setId(userReportPO.getId());
|
||||
terminalTree.setPid(userReportPO.getStationId());
|
||||
}
|
||||
terminalTree.setPowerFlag(1);
|
||||
terminalTree.setLevel(LineBaseEnum.USER_LEVEL.getCode());
|
||||
terminalTree.setChildren(temDevList);
|
||||
|
||||
@@ -853,7 +853,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
if (!Objects.equals(lineDetail.getCt1(), lineDetailRes.getCt1()) || !Objects.equals(lineDetail.getCt2(), lineDetailRes.getCt2())
|
||||
|| !Objects.equals(lineDetail.getPt1(), lineDetailRes.getPt1()) || !Objects.equals(lineDetail.getPt2(), lineDetailRes.getPt2())
|
||||
|| !Objects.equals(lineDetail.getDevCapacity(), lineDetailRes.getDevCapacity()) || !Objects.equals(lineDetail.getShortCapacity(), lineDetailRes.getShortCapacity())
|
||||
|| !Objects.equals(lineDetail.getStandardCapacity(), lineDetailRes.getStandardCapacity()) || !Objects.equals(lineDetail.getDealCapacity(), lineDetailRes.getDealCapacity())) {
|
||||
|| !Objects.equals(lineDetail.getStandardCapacity(), lineDetailRes.getStandardCapacity()) || !Objects.equals(lineDetail.getDealCapacity(), lineDetailRes.getDealCapacity())
|
||||
|| !Objects.equals(lineDetail.getPtType(), lineDetailRes.getPtType())) {
|
||||
//获取用户信息
|
||||
String index = RequestUtil.getUserIndex();
|
||||
queryUpdateAndInsertLog(userName, index, lineDetail, lineDetailRes);
|
||||
@@ -885,11 +886,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
private void coderM3d(Device deviceDetail, Boolean updateFlag) {
|
||||
if (updateFlag) {
|
||||
Device deviceRes = deviceMapper.selectById(deviceDetail.getId());
|
||||
if (StrUtil.isNotBlank(deviceDetail.getDevKey()) && !deviceRes.getDevKey().equals(deviceDetail.getDevKey())) {
|
||||
if (!Objects.equals(deviceRes.getDevKey(),deviceDetail.getDevKey())) {
|
||||
deviceDetail.setDevKey(DeviceUtil.encodeString(devCD, deviceDetail.getDevKey()));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(deviceDetail.getSeries()) && !deviceRes.getSeries().equals(deviceDetail.getSeries())) {
|
||||
if (!Objects.equals(deviceRes.getSeries(),deviceDetail.getSeries())) {
|
||||
deviceDetail.setSeries(DeviceUtil.encodeString(devCD, deviceDetail.getSeries()));
|
||||
}
|
||||
} else {
|
||||
@@ -900,7 +900,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
deviceDetail.setSeries(DeviceUtil.encodeString(devCD, deviceDetail.getSeries()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void decoderM3d(Device deviceDetail) {
|
||||
@@ -961,6 +960,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
sbNew.append("协议容量: ").append(newLine.getDealCapacity()).append(";");
|
||||
sbOld.append("协议容量: ").append(oldLine.getDealCapacity()).append(";");
|
||||
}
|
||||
//接线方式
|
||||
if (!Objects.equals(newLine.getPtType(), oldLine.getPtType())) {
|
||||
sbNew.append("接线方式: ").append(newLine.getPtType()).append(";");
|
||||
sbOld.append("接线方式: ").append(oldLine.getPtType()).append(";");
|
||||
}
|
||||
sb.append(sbNew).append(sbOld);
|
||||
HttpResult<DictData> dicDataByCode = dicDataFeignClient.getDicDataByCode(DicDataEnum.LINE_PARAMETER.getCode());
|
||||
DictData data = dicDataByCode.getData();
|
||||
@@ -3853,14 +3857,29 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
}
|
||||
//设备删除找不到设备名称,重日志截取
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
String temLos = "%s名称:%s;前置信息:%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String devName = strings.get(1); // 设备名称
|
||||
String nodeName = strings.get(2); // 进程名称
|
||||
pqsTerminalPushLogDTO.setDevName(devName);
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
//删除有2种情况,1.设备删除,2,设备状态修改;
|
||||
if (lineMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.containsKey(nodeId)?nodeMap.get(nodeId).getName():"删除前置");
|
||||
|
||||
}else {
|
||||
if(temp.getTerminalDescribe().contains("前置信息")){
|
||||
String temLos = "%s名称:%s;前置信息:%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String devName = strings.get(1); // 设备名称
|
||||
String nodeName = strings.get(2); // 进程名称
|
||||
pqsTerminalPushLogDTO.setDevName(devName);
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
//如果存在说明设备未被删除,不存在说明有一条删除日志,直接return;
|
||||
if (lineMap.containsKey(deviceId)) {
|
||||
|
||||
@@ -3,9 +3,6 @@ package com.njcn.device.device.controller;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
@@ -27,12 +24,10 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -57,132 +52,132 @@ public class DeviceController extends BaseController {
|
||||
|
||||
private final GeneralDeviceService generalDeviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketLine")
|
||||
@ApiOperation("获取监测点定值信息")
|
||||
public HttpResult<String> socketLine(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
String methodDescribe = getMethodDescribe("socketLine");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentLine(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateSocketLine")
|
||||
@ApiOperation("修改监测点定值信息")
|
||||
public HttpResult<String> updateSocketLine(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
String methodDescribe = getMethodDescribe("updateSocketLine");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentLineData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDev")
|
||||
@ApiOperation("获取终端定值信息")
|
||||
public HttpResult<String> socketDev(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
String methodDescribe = getMethodDescribe("socketDev");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentDev(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateSocketDev")
|
||||
@ApiOperation("修改终端定值信息")
|
||||
public HttpResult<String> updateSocketDev(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
String methodDescribe = getMethodDescribe("updateSocketDev");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentDevData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDevProperty")
|
||||
@ApiOperation("获取终端性能信息")
|
||||
public HttpResult<String> socketDevProperty(String devID) {
|
||||
String methodDescribe = getMethodDescribe("socketDevProperty");
|
||||
String s = iDeviceService.socketDevProperty(devID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDevPropertyClose")
|
||||
@ApiOperation("终端性能关闭")
|
||||
public HttpResult<String> socketDevPropertyClose(String devID) {
|
||||
String methodDescribe = getMethodDescribe("socketDevPropertyClose");
|
||||
String s = iDeviceService.socketDevPropertyClose(devID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/realTimeData")
|
||||
@ApiOperation("监测点实时数据查看")
|
||||
public HttpResult<String> realTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("realTimeData");
|
||||
String s = iDeviceService.realTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/heartRealTimeData")
|
||||
@ApiOperation("监测实施数据心跳")
|
||||
public HttpResult<String> heartRealTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("heartRealTimeData");
|
||||
String s = iDeviceService.heartRealTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/closeRealTimeData")
|
||||
@ApiOperation("监测点实施数据关闭")
|
||||
public HttpResult<String> closeRealTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("closeRealTimeData");
|
||||
String s = iDeviceService.closeRealTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getDevUpgrades")
|
||||
@ApiOperation("终端版本升级")
|
||||
public HttpResult<String> getDevUpgrades(@RequestBody @Validated ConstantValueParam.Upgrades param) {
|
||||
String methodDescribe = getMethodDescribe("getDevUpgrades");
|
||||
String s = iDeviceService.getDevUpgrades(param.getList(),param.getEdIndex());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/closeUpgrades")
|
||||
@ApiOperation("终端升级取消")
|
||||
public HttpResult<String> closeUpgrades(@RequestBody List<String> devList) {
|
||||
String methodDescribe = getMethodDescribe("closeUpgrades");
|
||||
String s = iDeviceService.closeUpgrades(devList);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/restartDev")
|
||||
@ApiOperation("重启装置命令")
|
||||
public HttpResult<String> restartDev(@RequestBody List<String> devList) {
|
||||
String methodDescribe = getMethodDescribe("restartDev");
|
||||
String s = iDeviceService.restartDev(devList);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
@MqttSubscribe(value = "/zl/devData/{devID}",qos = 1)
|
||||
public void responseRtData(String topic, @NamedValue("devID") String pageId, MqttMessage message, @Payload String payload) {
|
||||
Console.log("receive from : {}", topic);
|
||||
Console.log("receive from : {}", pageId);
|
||||
Console.log("message : {}", message.getPayload());
|
||||
Console.log("message payload : {}", new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
Console.log("string payload : {}", payload);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketLine")
|
||||
// @ApiOperation("获取监测点定值信息")
|
||||
// public HttpResult<String> socketLine(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
// String methodDescribe = getMethodDescribe("socketLine");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentLine(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/updateSocketLine")
|
||||
// @ApiOperation("修改监测点定值信息")
|
||||
// public HttpResult<String> updateSocketLine(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
// String methodDescribe = getMethodDescribe("updateSocketLine");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentLineData(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDev")
|
||||
// @ApiOperation("获取终端定值信息")
|
||||
// public HttpResult<String> socketDev(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
// String methodDescribe = getMethodDescribe("socketDev");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentDev(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/updateSocketDev")
|
||||
// @ApiOperation("修改终端定值信息")
|
||||
// public HttpResult<String> updateSocketDev(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
// String methodDescribe = getMethodDescribe("updateSocketDev");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentDevData(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDevProperty")
|
||||
// @ApiOperation("获取终端性能信息")
|
||||
// public HttpResult<String> socketDevProperty(String devID) {
|
||||
// String methodDescribe = getMethodDescribe("socketDevProperty");
|
||||
// String s = iDeviceService.socketDevProperty(devID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDevPropertyClose")
|
||||
// @ApiOperation("终端性能关闭")
|
||||
// public HttpResult<String> socketDevPropertyClose(String devID) {
|
||||
// String methodDescribe = getMethodDescribe("socketDevPropertyClose");
|
||||
// String s = iDeviceService.socketDevPropertyClose(devID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/realTimeData")
|
||||
// @ApiOperation("监测点实时数据查看")
|
||||
// public HttpResult<String> realTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("realTimeData");
|
||||
// String s = iDeviceService.realTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/heartRealTimeData")
|
||||
// @ApiOperation("监测实施数据心跳")
|
||||
// public HttpResult<String> heartRealTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("heartRealTimeData");
|
||||
// String s = iDeviceService.heartRealTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/closeRealTimeData")
|
||||
// @ApiOperation("监测点实施数据关闭")
|
||||
// public HttpResult<String> closeRealTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("closeRealTimeData");
|
||||
// String s = iDeviceService.closeRealTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/getDevUpgrades")
|
||||
// @ApiOperation("终端版本升级")
|
||||
// public HttpResult<String> getDevUpgrades(@RequestBody @Validated ConstantValueParam.Upgrades param) {
|
||||
// String methodDescribe = getMethodDescribe("getDevUpgrades");
|
||||
// String s = iDeviceService.getDevUpgrades(param.getList(),param.getEdIndex());
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/closeUpgrades")
|
||||
// @ApiOperation("终端升级取消")
|
||||
// public HttpResult<String> closeUpgrades(@RequestBody List<String> devList) {
|
||||
// String methodDescribe = getMethodDescribe("closeUpgrades");
|
||||
// String s = iDeviceService.closeUpgrades(devList);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/restartDev")
|
||||
// @ApiOperation("重启装置命令")
|
||||
// public HttpResult<String> restartDev(@RequestBody List<String> devList) {
|
||||
// String methodDescribe = getMethodDescribe("restartDev");
|
||||
// String s = iDeviceService.restartDev(devList);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
// @MqttSubscribe(value = "/zl/devData/{devID}",qos = 1)
|
||||
// public void responseRtData(String topic, @NamedValue("devID") String pageId, MqttMessage message, @Payload String payload) {
|
||||
// Console.log("receive from : {}", topic);
|
||||
// Console.log("receive from : {}", pageId);
|
||||
// Console.log("message : {}", message.getPayload());
|
||||
// Console.log("message payload : {}", new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
// Console.log("string payload : {}", payload);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateDevCheckTime")
|
||||
|
||||
@@ -36,6 +36,19 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
List<Device> getDeviceBySubId(@Param("subId") String subId,@Param("ip") String ip,@Param("port") Integer port,@Param("devId")String devId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取监测点台账信息
|
||||
* @param list 监测点集合
|
||||
* @param comFlag 状态
|
||||
* @param searchValue
|
||||
* @return 结果
|
||||
*/
|
||||
Page<RunManageVO> getRunManageCommList(@Param("page")Page<RunTimeVO> page,
|
||||
@Param("list") List<String> list,
|
||||
@Param("comFlag") List<Integer> comFlag,
|
||||
@Param("runFlag") List<Integer> runFlag,
|
||||
@Param("searchValue") String searchValue);
|
||||
|
||||
/**
|
||||
* 获取监测点台账信息
|
||||
* @param list 监测点集合
|
||||
@@ -57,7 +70,8 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
* @param searchValue
|
||||
* @return 结果
|
||||
*/
|
||||
List<RunTimeVO> getRunManageDevList(@Param("list") List<String> list,
|
||||
Page<RunTimeVO> getRunManageDevList(@Param("page")Page<RunTimeVO> page,
|
||||
@Param("list") List<String> list,
|
||||
@Param("comFlag") List<Integer> comFlag,
|
||||
@Param("runFlag") List<Integer> runFlag,
|
||||
@Param("manufacturers") List<String> manufacturer,
|
||||
|
||||
@@ -16,6 +16,128 @@
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getRunManageCommList" resultType="com.njcn.device.pq.pojo.vo.RunManageVO">
|
||||
SELECT
|
||||
linedetail.Num AS id,
|
||||
line.NAME AS lineName,
|
||||
area.NAME AS areaName,
|
||||
gd.NAME AS gdName,
|
||||
sub.NAME AS bdName,
|
||||
scaleId.Name as scale,
|
||||
manufacturerId.name as manufacturer,
|
||||
dev.name as devName,
|
||||
device.IP as ip,
|
||||
case linedetail.Run_Flag
|
||||
when 0 then '投运'
|
||||
when 1 then '检修'
|
||||
when 2 then '停运'
|
||||
when 3 then '调试'
|
||||
when 4 then '退运'
|
||||
end as runFlag,
|
||||
case device.Com_Flag
|
||||
when 0 then '中断'
|
||||
when 1 then '正常'
|
||||
end as comFlag,
|
||||
loadtypeId.Name as loadType,
|
||||
businesstypeId.name as businessType,
|
||||
IFNULL(obj.project_name,'/') as objName,
|
||||
case linedetail.PT_Type
|
||||
when 0 then '星型接线'
|
||||
when 1 then '三角型接线'
|
||||
when 2 then '开口三角型接线'
|
||||
end as ptType,
|
||||
CONCAT(linedetail.PT1,'/', linedetail.PT2) as pt,
|
||||
CONCAT(linedetail.CT1,'/', linedetail.CT2) as ct,
|
||||
linedetail.Standard_Capacity as standardCapacity,
|
||||
linedetail.Short_Capacity as shortCapacity,
|
||||
linedetail.Dev_Capacity as devCapacity,
|
||||
linedetail.Deal_Capacity as dealCapacity,
|
||||
overlimit.Freq_Dev as freqDev,
|
||||
overlimit.Voltage_Dev as voltageDev,
|
||||
overlimit.Uvoltage_Dev as uvoltageDev,
|
||||
overlimit.Ubalance as ubalance,
|
||||
overlimit.I_Neg as iNeg,
|
||||
overlimit.Flicker as flicker,
|
||||
overlimit.Uaberrance as uaberrance,
|
||||
overlimit.Uharm_3 as oddHarm,
|
||||
overlimit.Uharm_2 as evenHarm,
|
||||
overlimit.Iharm_2 as iharm2,
|
||||
overlimit.Iharm_3 as iharm3,
|
||||
overlimit.Iharm_4 as iharm4,
|
||||
overlimit.Iharm_5 as iharm5,
|
||||
overlimit.Iharm_6 as iharm6,
|
||||
overlimit.Iharm_7 as iharm7,
|
||||
overlimit.Iharm_8 as iharm8,
|
||||
overlimit.Iharm_9 as iharm9,
|
||||
overlimit.Iharm_10 as iharm10,
|
||||
overlimit.Iharm_11 as iharm11,
|
||||
overlimit.Iharm_12 as iharm12,
|
||||
overlimit.Iharm_13 as iharm13,
|
||||
overlimit.Iharm_14 as iharm14,
|
||||
overlimit.Iharm_15 as iharm15,
|
||||
overlimit.Iharm_16 as iharm16,
|
||||
overlimit.Iharm_17 as iharm17,
|
||||
overlimit.Iharm_18 as iharm18,
|
||||
overlimit.Iharm_19 as iharm19,
|
||||
overlimit.Iharm_20 as iharm20,
|
||||
overlimit.Iharm_21 as iharm21,
|
||||
overlimit.Iharm_22 as iharm22,
|
||||
overlimit.Iharm_23 as iharm23,
|
||||
overlimit.Iharm_24 as iharm24,
|
||||
overlimit.Iharm_25 as iharm25,
|
||||
overlimit.InUharm_1 as inUharm,
|
||||
overlimit.InUharm_16 as inUharm16
|
||||
FROM pq_line line
|
||||
inner join pq_line_detail detail on line.id = detail.id
|
||||
left join supervision_user_report obj on obj.id = detail.obj_id
|
||||
INNER JOIN pq_line vol ON vol.Id = line.Pid
|
||||
INNER JOIN pq_line dev ON dev.Id = vol.Pid
|
||||
INNER JOIN pq_line sub ON sub.Id = dev.Pid
|
||||
INNER JOIN pq_line gd ON gd.Id = sub.Pid
|
||||
INNER JOIN pq_line areaId ON areaId.Id = gd.Pid
|
||||
INNER JOIN sys_area area ON area.Id = areaId.NAME
|
||||
INNER JOIN pq_overlimit overlimit ON overlimit.Id = line.Id
|
||||
INNER JOIN pq_voltage voltage ON voltage.Id = vol.Id
|
||||
INNER JOIN sys_dict_data scaleId ON scaleId.Id = voltage.Scale
|
||||
INNER JOIN pq_device device ON device.Id = dev.Id
|
||||
INNER JOIN sys_dict_data manufacturerId ON manufacturerId.Id = device.Manufacturer
|
||||
INNER JOIN pq_line_detail linedetail ON linedetail.Id = line.Id
|
||||
INNER JOIN sys_dict_data loadtypeId ON loadtypeId.Id = linedetail.Load_Type
|
||||
INNER JOIN sys_dict_data businesstypeId ON businesstypeId.Id = linedetail.Business_Type
|
||||
WHERE line.Id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="comFlag.size()!=0">
|
||||
and device.Com_Flag in
|
||||
<foreach item="item2" collection="comFlag" open="(" separator="," close=")">
|
||||
#{item2}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="runFlag.size()!=0">
|
||||
and linedetail.run_Flag in
|
||||
<foreach item="item" collection="runFlag" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="searchValue != '' and searchValue != null ">
|
||||
<bind name="searchValueLike" value="'%'+searchValue+'%'"/>
|
||||
AND (sub.NAME LIKE #{searchValueLike}
|
||||
OR dev.name LIKE #{searchValueLike}
|
||||
OR line.NAME LIKE #{searchValueLike}
|
||||
OR loadtypeId.Name LIKE #{searchValueLike}
|
||||
OR manufacturerId.name LIKE #{searchValueLike}
|
||||
OR obj.project_name LIKE #{searchValueLike}
|
||||
)
|
||||
</if>
|
||||
ORDER BY
|
||||
gdName,
|
||||
bdName,
|
||||
devNAME,
|
||||
objName
|
||||
</select>
|
||||
|
||||
<select id="getRunManageList" resultType="com.njcn.device.pq.pojo.vo.RunManageVO">
|
||||
SELECT
|
||||
linedetail.Num AS id,
|
||||
@@ -137,10 +259,12 @@
|
||||
|
||||
<select id="getRunManageDevList" resultType="com.njcn.device.pq.pojo.vo.RunTimeVO">
|
||||
SELECT
|
||||
DISTINCT
|
||||
dev.Id AS id,
|
||||
area.NAME AS areaName,
|
||||
gd.NAME AS gdName,
|
||||
sub.NAME AS bdName,
|
||||
obj.project_name objName,
|
||||
manufacturerId.NAME AS manufacturer,
|
||||
dev.NAME AS devName,
|
||||
device.IP AS ip,
|
||||
@@ -152,7 +276,7 @@
|
||||
WHEN 0 THEN
|
||||
'投运'
|
||||
WHEN 1 THEN
|
||||
'热备用'
|
||||
'检修'
|
||||
WHEN 2 THEN
|
||||
'停运'
|
||||
END AS runFlag,
|
||||
@@ -165,8 +289,12 @@
|
||||
END AS comFlag,
|
||||
device.Update_Time AS updateTime
|
||||
FROM
|
||||
pq_line dev
|
||||
INNER JOIN pq_line sub ON sub.Id = dev.Pid
|
||||
pq_line line
|
||||
left join pq_line_detail detail on line.id = detail.id
|
||||
left join supervision_user_report obj on obj.id = detail.obj_id
|
||||
inner join pq_line busBar on line.pid = busBar.id
|
||||
inner join pq_line dev on busBar.pid = dev.id
|
||||
INNER JOIN pq_line sub ON sub.id = dev.Pid
|
||||
INNER JOIN pq_line gd ON gd.Id = sub.Pid
|
||||
INNER JOIN pq_line areaId ON areaId.Id = gd.Pid
|
||||
INNER JOIN sys_area area ON area.Id = areaId.NAME
|
||||
@@ -197,10 +325,13 @@
|
||||
</if>
|
||||
<if test="searchValue != '' and searchValue != null ">
|
||||
<bind name="searchValueLike" value="'%'+searchValue+'%'"/>
|
||||
AND sub.NAME LIKE #{searchValueLike}
|
||||
AND
|
||||
(sub.NAME LIKE #{searchValueLike}
|
||||
OR dev.NAME LIKE #{searchValueLike}
|
||||
OR devT.Name LIKE #{searchValueLike}
|
||||
OR device.IP LIKE #{searchValueLike}
|
||||
OR obj.project_name LIKE #{searchValueLike}
|
||||
)
|
||||
</if>
|
||||
ORDER BY
|
||||
gdName,
|
||||
|
||||
@@ -19,113 +19,113 @@ import java.util.List;
|
||||
public interface IDeviceService extends IService<Device> {
|
||||
|
||||
|
||||
/***
|
||||
* @Description: mqtt获取外部定值
|
||||
* @param param
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 10:17
|
||||
*/
|
||||
String sentLine(ConstantValueParam.Constant param);
|
||||
|
||||
/***
|
||||
* @Description: mqtt修改外部定值
|
||||
* @param param
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 11:07
|
||||
*/
|
||||
String sentLineData(ConstantValueParam.ValueData param);
|
||||
|
||||
/**
|
||||
* @param param
|
||||
* @Description: mqtt获取内部定值
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 14:51
|
||||
*/
|
||||
String sentDev(ConstantValueParam.Constant param);
|
||||
|
||||
/**
|
||||
* @param param
|
||||
* @Description: mqtt修改内部定值
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 14:51
|
||||
*/
|
||||
String sentDevData(ConstantValueParam.ValueData param);
|
||||
|
||||
/**
|
||||
* @param devID
|
||||
* @Description: 终端性能查看
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 11:27
|
||||
*/
|
||||
String socketDevProperty(String devID);
|
||||
|
||||
/**
|
||||
* @param devID
|
||||
* @Description: 终端性能关闭
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:13
|
||||
*/
|
||||
String socketDevPropertyClose(String devID);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测点实时数据查看
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:13
|
||||
*/
|
||||
String realTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测实施数据心跳
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:14
|
||||
*/
|
||||
String heartRealTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测点实施数据关闭
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:14
|
||||
*/
|
||||
String closeRealTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* 终端版本升级,批量升级条件必须是相同终端系列的终端才能升级
|
||||
*
|
||||
* @param list
|
||||
* @param edIndex
|
||||
* @return
|
||||
*/
|
||||
String getDevUpgrades(List<String> list, String edIndex);
|
||||
|
||||
/**
|
||||
* @param devList
|
||||
* @Description: 终端升级取消
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/17 9:24
|
||||
*/
|
||||
String closeUpgrades(List<String> devList);
|
||||
|
||||
/**
|
||||
* @param devList
|
||||
* @Description: 重启装置命令
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/17 9:24
|
||||
*/
|
||||
String restartDev(List<String> devList);
|
||||
// /***
|
||||
// * @Description: mqtt获取外部定值
|
||||
// * @param param
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 10:17
|
||||
// */
|
||||
// String sentLine(ConstantValueParam.Constant param);
|
||||
//
|
||||
// /***
|
||||
// * @Description: mqtt修改外部定值
|
||||
// * @param param
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 11:07
|
||||
// */
|
||||
// String sentLineData(ConstantValueParam.ValueData param);
|
||||
//
|
||||
// /**
|
||||
// * @param param
|
||||
// * @Description: mqtt获取内部定值
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 14:51
|
||||
// */
|
||||
// String sentDev(ConstantValueParam.Constant param);
|
||||
//
|
||||
// /**
|
||||
// * @param param
|
||||
// * @Description: mqtt修改内部定值
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 14:51
|
||||
// */
|
||||
// String sentDevData(ConstantValueParam.ValueData param);
|
||||
//
|
||||
// /**
|
||||
// * @param devID
|
||||
// * @Description: 终端性能查看
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 11:27
|
||||
// */
|
||||
// String socketDevProperty(String devID);
|
||||
//
|
||||
// /**
|
||||
// * @param devID
|
||||
// * @Description: 终端性能关闭
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:13
|
||||
// */
|
||||
// String socketDevPropertyClose(String devID);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测点实时数据查看
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:13
|
||||
// */
|
||||
// String realTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测实施数据心跳
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:14
|
||||
// */
|
||||
// String heartRealTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测点实施数据关闭
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:14
|
||||
// */
|
||||
// String closeRealTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * 终端版本升级,批量升级条件必须是相同终端系列的终端才能升级
|
||||
// *
|
||||
// * @param list
|
||||
// * @param edIndex
|
||||
// * @return
|
||||
// */
|
||||
// String getDevUpgrades(List<String> list, String edIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param devList
|
||||
// * @Description: 终端升级取消
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/17 9:24
|
||||
// */
|
||||
// String closeUpgrades(List<String> devList);
|
||||
//
|
||||
// /**
|
||||
// * @param devList
|
||||
// * @Description: 重启装置命令
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/17 9:24
|
||||
// */
|
||||
// String restartDev(List<String> devList);
|
||||
|
||||
/**
|
||||
* @param devId 装置id
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.njcn.device.device.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -14,16 +10,11 @@ import com.njcn.device.device.mapper.DeviceMapper;
|
||||
import com.njcn.device.device.service.IDeviceService;
|
||||
import com.njcn.device.device.service.ProgramVersionService;
|
||||
import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.pq.pojo.advanced.*;
|
||||
import com.njcn.device.pq.pojo.param.ConstantValueParam;
|
||||
import com.njcn.device.pq.pojo.po.DevVersion;
|
||||
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import com.njcn.device.pq.pojo.po.Version;
|
||||
|
||||
import com.njcn.device.pq.pojo.vo.DevStatusNumVO;
|
||||
import com.njcn.device.pq.pojo.vo.DeviceIpRVO;
|
||||
import com.njcn.device.utils.SocketClient;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -45,360 +36,360 @@ import java.util.stream.Collectors;
|
||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements IDeviceService {
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
private final SocketClient socketClient;
|
||||
// private final SocketClient socketClient;
|
||||
private final DevVersionMapper devVersionMapper;
|
||||
private final ProgramVersionService programVersionService;
|
||||
|
||||
@Value("${socket.port:60000}")
|
||||
private Integer socketPort;
|
||||
|
||||
@Override
|
||||
public String sentLine(ConstantValueParam.Constant param) {
|
||||
try {
|
||||
//获取根据监测点获取终端信息
|
||||
UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
//拼接属性
|
||||
ContValueRVO upParamVO = new ContValueRVO();
|
||||
ContValueVO valueVO = new ContValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setLineid(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "获取定值失败";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentLineData(ConstantValueParam.ValueData param) {
|
||||
try {
|
||||
//获取根据监测点获取终端信息
|
||||
UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
ContUpdateValueRVO upParamVO = new ContUpdateValueRVO();
|
||||
ContUpdateValueVO valueVO = new ContUpdateValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setLineid(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
float[] intArr;
|
||||
if (StrUtil.isBlank(param.getInterValue())) {
|
||||
intArr = new float[0];
|
||||
} else {
|
||||
String[] valueArr = param.getInterValue().split(",");
|
||||
intArr = new float[valueArr.length];
|
||||
for (int i = 0; i < valueArr.length; i++) {
|
||||
intArr[i] = Float.parseFloat(valueArr[i]);
|
||||
}
|
||||
}
|
||||
valueVO.setValue(intArr);
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "运行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentDev(ConstantValueParam.Constant param) {
|
||||
try {
|
||||
Line line = lineMapper.selectById(param.getId());
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(line.getId());
|
||||
upDevVO.setDevName(line.getName());
|
||||
String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
ContValueRVO upParamVO = new ContValueRVO();
|
||||
ContValueVO valueVO = new ContValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setIndex(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "获取定值失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentDevData(ConstantValueParam.ValueData param) {
|
||||
try {
|
||||
Line line = lineMapper.selectById(param.getId());
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(line.getId());
|
||||
upDevVO.setDevName(line.getName());
|
||||
String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
ContUpdateDevValueRVO upParamVO = new ContUpdateDevValueRVO();
|
||||
ContUpdateDevValueVO valueVO = new ContUpdateDevValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setIndex(line.getId());
|
||||
valueVO.setHander(String.valueOf(param.getHander()));
|
||||
int[] intArr;
|
||||
if (StrUtil.isBlank(param.getInterValue())) {
|
||||
intArr = new int[0];
|
||||
} else {
|
||||
String[] valueArr = param.getInterValue().split(",");
|
||||
intArr = new int[valueArr.length];
|
||||
for (int i = 0; i < valueArr.length; i++) {
|
||||
intArr[i] = Integer.parseInt(valueArr[i]);
|
||||
}
|
||||
}
|
||||
valueVO.setInterValue(intArr);
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "运行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String socketDevProperty(String devID) {
|
||||
String host = lineMapper.getNodeIp(devID,1);
|
||||
if(StrUtil.isBlank(host)){
|
||||
return "前置ip获取失败";
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("type","190");
|
||||
map.put("index",devID);
|
||||
map.put("hander","1");
|
||||
jsonObject.set("data", map);
|
||||
Integer len = jsonObject.get("data").toString().length();
|
||||
jsonObject.set("len", len.toString());
|
||||
socketClient.showProperty(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
return "终端性能获取成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String socketDevPropertyClose(String devID) {
|
||||
String host = lineMapper.getNodeIp(devID,1);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "190");
|
||||
map.put("index", devID);
|
||||
map.put("hander", "0");
|
||||
jsonObject.set("data", map);
|
||||
Integer len = jsonObject.get("data").toString().length();
|
||||
jsonObject.set("len", len.toString());
|
||||
socketClient.closeDevSocket(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
return "执行成功";
|
||||
}catch (Exception e){
|
||||
return "执行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String realTimeData(String lineIndex) {
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
if(StrUtil.isBlank(host)){
|
||||
return "设备前置机服务器配置异常,请联系管理员";
|
||||
}else {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("LineId", lineIndex);
|
||||
jsonObject.set("type", 0);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len",0);
|
||||
jsonObject1.set("data",jsonObject);
|
||||
socketClient.realTimeData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
}
|
||||
return "请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String heartRealTimeData(String lineIndex) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("LineId", lineIndex);
|
||||
jsonObject.set("type", 1);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
socketClient.heartRealData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
return "实时数据心跳请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeRealTimeData(String lineIndex) {
|
||||
socketClient.closeRealData(lineIndex);
|
||||
return "关闭实时数据请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDevUpgrades(List<String> list, String edIndex) {
|
||||
List<DeviceIpRVO> resTemlist = new ArrayList<>();
|
||||
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(list);
|
||||
//判断设备版本号
|
||||
Integer isExit = devVersionMapper.selectCount(new LambdaQueryWrapper<DevVersion>()
|
||||
.eq(DevVersion::getVersionId,edIndex)
|
||||
.in(DevVersion::getLineId,list)
|
||||
.eq(DevVersion::getState,1)
|
||||
);
|
||||
if (isExit > 0) {
|
||||
return "请勿选择相同版本号升级";
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(relist)) {
|
||||
Version version = programVersionService.getById(edIndex);
|
||||
String series = version.getDevType();
|
||||
//判断设备是否存在相同型号
|
||||
for (DeviceIpRVO deviceIpRVO : relist) {
|
||||
if (!series.equals(deviceIpRVO.getDevSeries())) {
|
||||
return "当前装置版本系列与目标版本系列不相同";
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否断开
|
||||
if (relist.stream().filter(w -> w.getComFlag() == 0).findAny().isPresent()) {
|
||||
return "存在通讯中断设备";
|
||||
}
|
||||
|
||||
|
||||
Set<String> set = new HashSet<>();
|
||||
for (DeviceIpRVO d : relist) {
|
||||
set.add(d.getIp());
|
||||
}
|
||||
Iterator<String> iterator = set.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
List<UpDevVO> devIndex = new ArrayList<>();
|
||||
DeviceIpRVO deviceIpRVO = new DeviceIpRVO();
|
||||
String ip = iterator.next();
|
||||
for (DeviceIpRVO d : relist) {
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(d.getDevIndex());
|
||||
upDevVO.setDevName(d.getDevName());
|
||||
if (ip.equals(d.getIp())) {
|
||||
devIndex.add(upDevVO);
|
||||
}
|
||||
}
|
||||
deviceIpRVO.setIp(ip);
|
||||
deviceIpRVO.setDevlist(devIndex);
|
||||
resTemlist.add(deviceIpRVO);
|
||||
}
|
||||
} else {
|
||||
return "存在未知错误";
|
||||
}
|
||||
for (DeviceIpRVO deviceIpRVO : resTemlist) {
|
||||
String ip = deviceIpRVO.getIp();
|
||||
List<UpDevVO> devlist = deviceIpRVO.getDevlist();
|
||||
UpDataVO upDataVO = new UpDataVO();
|
||||
UpParamVO upParamVO = new UpParamVO();
|
||||
upDataVO.setTerminal(devlist);
|
||||
upDataVO.setType("180");
|
||||
upDataVO.setEdIndex(edIndex);
|
||||
upDataVO.setUserIndex(RequestUtil.getUserIndex());
|
||||
JSONObject jsonstr = new JSONObject(upDataVO);
|
||||
Integer len = jsonstr.toString().length();
|
||||
upParamVO.setData(upDataVO);
|
||||
upParamVO.setLen(len.toString());
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
socketClient.sentUpgrades(str, ip, socketPort, RequestUtil.getLoginName(), edIndex, devlist);
|
||||
}
|
||||
return "运行成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeUpgrades(List<String> devList) {
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
if(CollectionUtil.isEmpty(relist)){
|
||||
return "前置机为空";
|
||||
}else {
|
||||
List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
for(String ip: nodeIp){
|
||||
List<DeviceIpRVO> devLl= relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(devLl)){
|
||||
return "出错啦";
|
||||
}
|
||||
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
for(DeviceIpRVO devRVO:devLl){
|
||||
JSONObject dev = new JSONObject();
|
||||
dev.put("devIndex",devRVO.getDevIndex());
|
||||
dev.put("devName",devRVO.getDevName());
|
||||
list.add(dev);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("terminal", list);
|
||||
jsonObject.set("type", 182);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
socketClient.cancelUp(jsonObject1.toString(),ip,socketPort,devLl.size());
|
||||
}
|
||||
}
|
||||
return "取消命令发送成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String restartDev(List<String> devList) {
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
if(CollUtil.isEmpty(relist)){
|
||||
return "前置机为空";
|
||||
}else {
|
||||
List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
for(String ip: nodeIp){
|
||||
List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(devLl)){
|
||||
return "出错啦";
|
||||
}
|
||||
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
List<String> devIn = new ArrayList<>();
|
||||
for(DeviceIpRVO devRVO:devLl){
|
||||
devIn.add(devRVO.getDevIndex());
|
||||
JSONObject dev = new JSONObject();
|
||||
dev.set("devIndex", devRVO.getDevIndex());
|
||||
dev.set("devName", devRVO.getDevName());
|
||||
list.add(dev);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("terminal", list);
|
||||
jsonObject.set("type", 181);
|
||||
jsonObject.set("userIndex", RequestUtil.getUserIndex());
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
|
||||
socketClient.restartDev(jsonObject1.toString(),ip,socketPort,devIn);
|
||||
}
|
||||
}
|
||||
return "命令发送成功";
|
||||
}
|
||||
// @Override
|
||||
// public String sentLine(ConstantValueParam.Constant param) {
|
||||
// try {
|
||||
// //获取根据监测点获取终端信息
|
||||
// UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
// //拼接属性
|
||||
// ContValueRVO upParamVO = new ContValueRVO();
|
||||
// ContValueVO valueVO = new ContValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setLineid(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "获取定值失败";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentLineData(ConstantValueParam.ValueData param) {
|
||||
// try {
|
||||
// //获取根据监测点获取终端信息
|
||||
// UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
// ContUpdateValueRVO upParamVO = new ContUpdateValueRVO();
|
||||
// ContUpdateValueVO valueVO = new ContUpdateValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setLineid(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// float[] intArr;
|
||||
// if (StrUtil.isBlank(param.getInterValue())) {
|
||||
// intArr = new float[0];
|
||||
// } else {
|
||||
// String[] valueArr = param.getInterValue().split(",");
|
||||
// intArr = new float[valueArr.length];
|
||||
// for (int i = 0; i < valueArr.length; i++) {
|
||||
// intArr[i] = Float.parseFloat(valueArr[i]);
|
||||
// }
|
||||
// }
|
||||
// valueVO.setValue(intArr);
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "运行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentDev(ConstantValueParam.Constant param) {
|
||||
// try {
|
||||
// Line line = lineMapper.selectById(param.getId());
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(line.getId());
|
||||
// upDevVO.setDevName(line.getName());
|
||||
// String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
// ContValueRVO upParamVO = new ContValueRVO();
|
||||
// ContValueVO valueVO = new ContValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setIndex(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "获取定值失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentDevData(ConstantValueParam.ValueData param) {
|
||||
// try {
|
||||
// Line line = lineMapper.selectById(param.getId());
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(line.getId());
|
||||
// upDevVO.setDevName(line.getName());
|
||||
// String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
// ContUpdateDevValueRVO upParamVO = new ContUpdateDevValueRVO();
|
||||
// ContUpdateDevValueVO valueVO = new ContUpdateDevValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setIndex(line.getId());
|
||||
// valueVO.setHander(String.valueOf(param.getHander()));
|
||||
// int[] intArr;
|
||||
// if (StrUtil.isBlank(param.getInterValue())) {
|
||||
// intArr = new int[0];
|
||||
// } else {
|
||||
// String[] valueArr = param.getInterValue().split(",");
|
||||
// intArr = new int[valueArr.length];
|
||||
// for (int i = 0; i < valueArr.length; i++) {
|
||||
// intArr[i] = Integer.parseInt(valueArr[i]);
|
||||
// }
|
||||
// }
|
||||
// valueVO.setInterValue(intArr);
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
//
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "运行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String socketDevProperty(String devID) {
|
||||
// String host = lineMapper.getNodeIp(devID,1);
|
||||
// if(StrUtil.isBlank(host)){
|
||||
// return "前置ip获取失败";
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// Map<String,String> map = new HashMap<>();
|
||||
// map.put("type","190");
|
||||
// map.put("index",devID);
|
||||
// map.put("hander","1");
|
||||
// jsonObject.set("data", map);
|
||||
// Integer len = jsonObject.get("data").toString().length();
|
||||
// jsonObject.set("len", len.toString());
|
||||
// socketClient.showProperty(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
// return "终端性能获取成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String socketDevPropertyClose(String devID) {
|
||||
// String host = lineMapper.getNodeIp(devID,1);
|
||||
// try {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// Map<String, String> map = new HashMap<>();
|
||||
// map.put("type", "190");
|
||||
// map.put("index", devID);
|
||||
// map.put("hander", "0");
|
||||
// jsonObject.set("data", map);
|
||||
// Integer len = jsonObject.get("data").toString().length();
|
||||
// jsonObject.set("len", len.toString());
|
||||
// socketClient.closeDevSocket(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
// return "执行成功";
|
||||
// }catch (Exception e){
|
||||
// return "执行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String realTimeData(String lineIndex) {
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
// if(StrUtil.isBlank(host)){
|
||||
// return "设备前置机服务器配置异常,请联系管理员";
|
||||
// }else {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("LineId", lineIndex);
|
||||
// jsonObject.set("type", 0);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len",0);
|
||||
// jsonObject1.set("data",jsonObject);
|
||||
// socketClient.realTimeData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
// }
|
||||
// return "请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String heartRealTimeData(String lineIndex) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("LineId", lineIndex);
|
||||
// jsonObject.set("type", 1);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
// String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
// socketClient.heartRealData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
// return "实时数据心跳请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String closeRealTimeData(String lineIndex) {
|
||||
// socketClient.closeRealData(lineIndex);
|
||||
// return "关闭实时数据请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDevUpgrades(List<String> list, String edIndex) {
|
||||
// List<DeviceIpRVO> resTemlist = new ArrayList<>();
|
||||
//
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(list);
|
||||
// //判断设备版本号
|
||||
// Integer isExit = devVersionMapper.selectCount(new LambdaQueryWrapper<DevVersion>()
|
||||
// .eq(DevVersion::getVersionId,edIndex)
|
||||
// .in(DevVersion::getLineId,list)
|
||||
// .eq(DevVersion::getState,1)
|
||||
// );
|
||||
// if (isExit > 0) {
|
||||
// return "请勿选择相同版本号升级";
|
||||
// }
|
||||
// if (!CollectionUtil.isEmpty(relist)) {
|
||||
// Version version = programVersionService.getById(edIndex);
|
||||
// String series = version.getDevType();
|
||||
// //判断设备是否存在相同型号
|
||||
// for (DeviceIpRVO deviceIpRVO : relist) {
|
||||
// if (!series.equals(deviceIpRVO.getDevSeries())) {
|
||||
// return "当前装置版本系列与目标版本系列不相同";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //判断是否断开
|
||||
// if (relist.stream().filter(w -> w.getComFlag() == 0).findAny().isPresent()) {
|
||||
// return "存在通讯中断设备";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Set<String> set = new HashSet<>();
|
||||
// for (DeviceIpRVO d : relist) {
|
||||
// set.add(d.getIp());
|
||||
// }
|
||||
// Iterator<String> iterator = set.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// List<UpDevVO> devIndex = new ArrayList<>();
|
||||
// DeviceIpRVO deviceIpRVO = new DeviceIpRVO();
|
||||
// String ip = iterator.next();
|
||||
// for (DeviceIpRVO d : relist) {
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(d.getDevIndex());
|
||||
// upDevVO.setDevName(d.getDevName());
|
||||
// if (ip.equals(d.getIp())) {
|
||||
// devIndex.add(upDevVO);
|
||||
// }
|
||||
// }
|
||||
// deviceIpRVO.setIp(ip);
|
||||
// deviceIpRVO.setDevlist(devIndex);
|
||||
// resTemlist.add(deviceIpRVO);
|
||||
// }
|
||||
// } else {
|
||||
// return "存在未知错误";
|
||||
// }
|
||||
// for (DeviceIpRVO deviceIpRVO : resTemlist) {
|
||||
// String ip = deviceIpRVO.getIp();
|
||||
// List<UpDevVO> devlist = deviceIpRVO.getDevlist();
|
||||
// UpDataVO upDataVO = new UpDataVO();
|
||||
// UpParamVO upParamVO = new UpParamVO();
|
||||
// upDataVO.setTerminal(devlist);
|
||||
// upDataVO.setType("180");
|
||||
// upDataVO.setEdIndex(edIndex);
|
||||
// upDataVO.setUserIndex(RequestUtil.getUserIndex());
|
||||
// JSONObject jsonstr = new JSONObject(upDataVO);
|
||||
// Integer len = jsonstr.toString().length();
|
||||
// upParamVO.setData(upDataVO);
|
||||
// upParamVO.setLen(len.toString());
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// socketClient.sentUpgrades(str, ip, socketPort, RequestUtil.getLoginName(), edIndex, devlist);
|
||||
// }
|
||||
// return "运行成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String closeUpgrades(List<String> devList) {
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
// if(CollectionUtil.isEmpty(relist)){
|
||||
// return "前置机为空";
|
||||
// }else {
|
||||
// List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
// for(String ip: nodeIp){
|
||||
// List<DeviceIpRVO> devLl= relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
// if(CollectionUtil.isEmpty(devLl)){
|
||||
// return "出错啦";
|
||||
// }
|
||||
//
|
||||
// List<JSONObject> list = new ArrayList<>();
|
||||
// for(DeviceIpRVO devRVO:devLl){
|
||||
// JSONObject dev = new JSONObject();
|
||||
// dev.put("devIndex",devRVO.getDevIndex());
|
||||
// dev.put("devName",devRVO.getDevName());
|
||||
// list.add(dev);
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("terminal", list);
|
||||
// jsonObject.set("type", 182);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
// socketClient.cancelUp(jsonObject1.toString(),ip,socketPort,devLl.size());
|
||||
// }
|
||||
// }
|
||||
// return "取消命令发送成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String restartDev(List<String> devList) {
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
// if(CollUtil.isEmpty(relist)){
|
||||
// return "前置机为空";
|
||||
// }else {
|
||||
// List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
// for(String ip: nodeIp){
|
||||
// List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
// if(CollUtil.isEmpty(devLl)){
|
||||
// return "出错啦";
|
||||
// }
|
||||
//
|
||||
// List<JSONObject> list = new ArrayList<>();
|
||||
// List<String> devIn = new ArrayList<>();
|
||||
// for(DeviceIpRVO devRVO:devLl){
|
||||
// devIn.add(devRVO.getDevIndex());
|
||||
// JSONObject dev = new JSONObject();
|
||||
// dev.set("devIndex", devRVO.getDevIndex());
|
||||
// dev.set("devName", devRVO.getDevName());
|
||||
// list.add(dev);
|
||||
// }
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("terminal", list);
|
||||
// jsonObject.set("type", 181);
|
||||
// jsonObject.set("userIndex", RequestUtil.getUserIndex());
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
//
|
||||
// socketClient.restartDev(jsonObject1.toString(),ip,socketPort,devIn);
|
||||
// }
|
||||
// }
|
||||
// return "命令发送成功";
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||
|
||||
@@ -1559,7 +1559,8 @@
|
||||
vg.Scale as voltageLevel,
|
||||
voltage.name as volName,
|
||||
lineDetail.Power_Flag powerFlag,
|
||||
lineDetail.Run_Flag lineRunType
|
||||
lineDetail.Run_Flag lineRunType,
|
||||
lineDetail.Obj_Id objId
|
||||
FROM
|
||||
pq_line voltage,
|
||||
pq_line device,
|
||||
|
||||
@@ -13,10 +13,12 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.common.mapper.SuperDataMapper;
|
||||
import com.njcn.device.common.service.GeneralDeviceService;
|
||||
import com.njcn.device.device.mapper.DevFuctionMapper;
|
||||
import com.njcn.device.device.service.DeviceProcessService;
|
||||
import com.njcn.device.device.service.IDevMealService;
|
||||
import com.njcn.device.device.service.IDevStrategyService;
|
||||
import com.njcn.device.device.service.IDeviceService;
|
||||
import com.njcn.device.line.service.LineService;
|
||||
import com.njcn.device.pq.constant.Param;
|
||||
import com.njcn.device.pq.enums.LineBaseEnum;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.*;
|
||||
@@ -84,6 +86,7 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
||||
|
||||
private final CldStatisticsFlowMapper cldStatisticsFlowMapper;
|
||||
private final LineService lineService;
|
||||
private final DeviceProcessService deviceProcessService;
|
||||
|
||||
@Override
|
||||
public List<TerminalMaintainVO> getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) {
|
||||
@@ -205,7 +208,19 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
||||
terminalLogsNew.setObjIndex(device.getId());
|
||||
terminalLogsNew.setTerminalDescribe(sb.toString());
|
||||
terminalLogsNew.setIsPush(0);
|
||||
terminalLogsNew.setOperateType("update");
|
||||
if(device.getRunFlag() == 0&&device1.getRunFlag()!=0){
|
||||
terminalLogsNew.setOperateType(Param.DEL);
|
||||
|
||||
}
|
||||
if(device1.getRunFlag() == 0&&device.getRunFlag()!=0){
|
||||
terminalLogsNew.setOperateType(Param.ADD);
|
||||
//判断device是否绑定进程号;
|
||||
DeviceProcess deviceProcess = new DeviceProcess();
|
||||
deviceProcess.setId(device1.getId());
|
||||
deviceProcess.setProcessNo(1);
|
||||
|
||||
deviceProcessService.saveOrUpdate(deviceProcess);
|
||||
}
|
||||
terminalLogsNew.setLogsType(data.getId());
|
||||
terminalLogsNew.setTerminalType(LineBaseEnum.DEVICE_LEVEL.getCode());
|
||||
terminalLogsNew.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,8 @@
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--mqtt相关依赖-->
|
||||
<dependency>
|
||||
<groupId>com.github.tocrhz</groupId>
|
||||
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
|
||||
@@ -143,7 +143,7 @@ public class AreaInfoServiceImpl implements AreaInfoService {
|
||||
)
|
||||
.ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
.le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime));
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime).last("limit 100"));
|
||||
EventDetailNew eventDetailNew;
|
||||
for (RmpEventDetailPO eventDetail : eventDetails) {
|
||||
eventDetailNew = BeanUtil.copyProperties(eventDetail, EventDetailNew.class);
|
||||
|
||||
48
pqs-event/event-boot/src/main/resources/bootstrap-jb.yml
Normal file
48
pqs-event/event-boot/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10203
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.event.pojo
|
||||
|
||||
|
||||
52
pqs-event/event-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
52
pqs-event/event-boot/src/main/resources/bootstrap-sjzx.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10203
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.event.pojo
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
@@ -1,48 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10203
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.event.pojo
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
@@ -36,6 +36,12 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
<version>2.7.12</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.pojo.param.ExportParam;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
@@ -7,6 +8,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -24,4 +26,11 @@ public interface CommMonitorEventReportService {
|
||||
* @param index
|
||||
*/
|
||||
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException;
|
||||
|
||||
/**
|
||||
* 暂态事件报告存储,返回文件路径
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map, String fileName);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,20 @@ public interface WaveService {
|
||||
*/
|
||||
WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
|
||||
|
||||
/**
|
||||
* 用于云平台设备获取波形数据
|
||||
* @param eventDetail
|
||||
* @param line
|
||||
* @return
|
||||
*/
|
||||
WaveDataDTO getWavedata2(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
|
||||
|
||||
|
||||
List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType);
|
||||
|
||||
/**
|
||||
* 用于云平台设备获取数据
|
||||
* @return
|
||||
*/
|
||||
List<EventEigDetail> eventDetailEigenvalue2(String eventDetailIndex,Integer ptType);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
@@ -14,12 +16,12 @@ import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.common.service.CommMonitorEventReportService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventReportService;
|
||||
import com.njcn.event.common.service.WaveService;
|
||||
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||
import com.njcn.event.common.utils.WordUtil;
|
||||
import com.njcn.event.common.utils.WordUtils;
|
||||
import com.njcn.event.file.component.WavePicComponent;
|
||||
@@ -31,6 +33,7 @@ import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -47,7 +50,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
@@ -80,6 +85,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
private final WavePicComponent wavePicComponent;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
|
||||
|
||||
/**
|
||||
@@ -650,4 +656,68 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "导出暂降事件报告异常");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map, String fileName) {
|
||||
WordUtil wordUtil = new WordUtil();
|
||||
for (String index : eventIndex) {
|
||||
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
||||
AreaLineInfoVO line = map.get(index);
|
||||
|
||||
//判断hdr文件是否存在,不存在先生成hdr文件
|
||||
String fullPath = detail.getWavePath();
|
||||
EventAnalysisDTO eventAnalysis = new EventAnalysisDTO();
|
||||
int lastSlashIndex = fullPath.lastIndexOf('/');
|
||||
eventAnalysis.setWaveName(fullPath.substring(lastSlashIndex + 1));
|
||||
eventAnalysis.setWlFilePath(fullPath);
|
||||
eventCauseFeignClient.analysisCauseAndType(eventAnalysis);
|
||||
|
||||
WaveDataDTO waveData = waveService.getWavedata2(detail, line);
|
||||
//数据筛选,如果是双路电压的话,会存在 2 个波形数据
|
||||
List<WaveDataDetail> waveDataDetails = WaveUtil.filterWaveData(waveData);
|
||||
if (ObjUtil.isNull(waveData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
|
||||
} else {
|
||||
//获取瞬时波形
|
||||
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
|
||||
InputStream instantStream = fileStorageUtil.getFileStream(instantPath);
|
||||
String imageShun64 = cn.hutool.core.codec.Base64.encode(instantStream);
|
||||
|
||||
wordUtil.translateShun(index, imageShun64);
|
||||
//获取 rms 波形
|
||||
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
|
||||
InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath);
|
||||
String rmsShun64 = cn.hutool.core.codec.Base64.encode(rmsStream);
|
||||
wordUtil.translateRms(index, rmsShun64);
|
||||
|
||||
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
|
||||
eventInfoList.setLineName(line.getLineName());
|
||||
eventInfoList.setGdName(line.getGdName());
|
||||
eventInfoList.setBdzName(line.getSubName());
|
||||
eventInfoList.setDevName(line.getDeviceName());
|
||||
eventInfoList.setScale(line.getVoltageScale());
|
||||
eventInfoList.setIp(line.getIp());
|
||||
eventInfoList.setEventDetailIndex(detail.getEventId());
|
||||
eventInfoList.setTimeID(detail.getStartTime());
|
||||
eventInfoList.setPersistTime(detail.getDuration());
|
||||
eventInfoList.setMs(detail.getFirstMs());
|
||||
eventInfoList.setEventValue(detail.getFeatureAmplitude());
|
||||
wordUtil.setEventInfoList(index, eventInfoList);
|
||||
List<EventEigDetail> eventDetailEigenvalue = waveService.eventDetailEigenvalue2(index,line.getPtType());
|
||||
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
|
||||
}
|
||||
}
|
||||
try {
|
||||
InputStream inputStream = wordUtil.createReport2(eventIndex);
|
||||
String filePath;
|
||||
if (Objects.isNull(fileName)) {
|
||||
filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, null);
|
||||
} else {
|
||||
filePath = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.APP_EVENT_REPORT, fileName);
|
||||
}
|
||||
return filePath;
|
||||
} catch (IOException | InvalidFormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
//import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
@@ -18,6 +18,7 @@ import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.websocket.WebSocketServer;
|
||||
import com.njcn.event.pojo.vo.SendEventVO;
|
||||
import com.njcn.event.utils.EventUtil;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
@@ -29,7 +30,9 @@ import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
@@ -44,6 +47,7 @@ import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
@@ -57,11 +61,14 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final MqttPublisher publisher;
|
||||
// private final MqttPublisher publisher;
|
||||
|
||||
private final WebSocketServer webSocketServer;
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
@Override
|
||||
@@ -168,37 +175,40 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
//如果不为空,说明是二次上传波形文件了;
|
||||
String reason,type;
|
||||
if(!StringUtils.isEmpty(rmpEventDetailPO.getWavePath())){
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||
String ip = lineDetailData.getIp();
|
||||
EventAnalysisDTO eventAnalysisDTO = new EventAnalysisDTO();
|
||||
eventAnalysisDTO.setIp(ip);
|
||||
eventAnalysisDTO.setWaveName(rmpEventDetailPO.getWavePath());
|
||||
try {
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||
String ip = lineDetailData.getIp();
|
||||
EventAnalysisDTO eventAnalysisDTO = new EventAnalysisDTO();
|
||||
eventAnalysisDTO.setIp(ip);
|
||||
eventAnalysisDTO.setWaveName(rmpEventDetailPO.getWavePath());
|
||||
|
||||
EventAnalysisDTO result = eventCauseFeignClient.analysisCauseAndType(eventAnalysisDTO).getData();
|
||||
if(Objects.isNull(result.getCause())){
|
||||
reason =reasonReflection(0);
|
||||
EventAnalysisDTO result = eventCauseFeignClient.analysisCauseAndType(eventAnalysisDTO).getData();
|
||||
if(Objects.isNull(result.getCause())){
|
||||
reason =reasonReflection(0);
|
||||
|
||||
}else {
|
||||
reason =reasonReflection(result.getCause());
|
||||
}else {
|
||||
reason =reasonReflection(result.getCause());
|
||||
|
||||
}
|
||||
if(Objects.isNull(result.getType())){
|
||||
type =advanceTypeReflection(10);
|
||||
}
|
||||
if(Objects.isNull(result.getType())){
|
||||
type =advanceTypeReflection(10);
|
||||
|
||||
}else {
|
||||
type =advanceTypeReflection(result.getType());
|
||||
}else {
|
||||
type =advanceTypeReflection(result.getType());
|
||||
|
||||
}
|
||||
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||
if(Objects.equals(result.getCauseFlag(),1)&&Objects.equals(result.getTypeFlag(),1)){
|
||||
rmpEventDetailPO.setDealFlag(1);
|
||||
}else {
|
||||
}
|
||||
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||
if(Objects.equals(result.getCauseFlag(),1)&&Objects.equals(result.getTypeFlag(),1)){
|
||||
rmpEventDetailPO.setDealFlag(1);
|
||||
}else {
|
||||
rmpEventDetailPO.setDealFlag(0);
|
||||
}
|
||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
}catch (Exception e){
|
||||
rmpEventDetailPO.setDealFlag(0);
|
||||
}
|
||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
|
||||
}
|
||||
//默认都是其他
|
||||
// DictData reason = dicDataFeignClient.getDicDataByCode(DicDataEnum.RESON_REST.getCode()).getData();
|
||||
@@ -306,6 +316,9 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
String[] idsArray = deptInfo.getPids().split(",");
|
||||
dept.addAll(Arrays.asList(idsArray));
|
||||
});
|
||||
List<String> deptList = dept.stream().collect(Collectors.toList());
|
||||
|
||||
List<User> data = userFeignClient.getUserInfoByDeptIds(deptList).getData();
|
||||
SendEventVO vo = new SendEventVO();
|
||||
vo.setDeptList(dept);
|
||||
vo.setTime(po.getStartTime());
|
||||
@@ -317,7 +330,10 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
vo.setLineName(lineInfoVOList.get(0).getLineName());
|
||||
vo.setPowerCompany(lineInfoVOList.get(0).getGdName());
|
||||
vo.setSubstation(lineInfoVOList.get(0).getSubName());
|
||||
publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
|
||||
for (User datum : data) {
|
||||
webSocketServer.sendMessageToUser(datum.getId(),PubUtils.obj2json(vo));
|
||||
}
|
||||
// publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,43 @@ public class WaveServiceImpl implements WaveService {
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveDataDTO getWavedata2(RmpEventDetailPO eventDetail, AreaLineInfoVO line) {
|
||||
WaveDataDTO waveDataDTO = null;
|
||||
if (ObjectUtil.isNotEmpty(line)) {
|
||||
String waveName = eventDetail.getWavePath();
|
||||
if (StrUtil.isBlank(waveName)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
try (
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(waveName + GeneralConstant.CFG);
|
||||
InputStream datStream = fileStorageUtil.getFileStream(waveName + GeneralConstant.DAT)
|
||||
) {
|
||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
InputStream cfgStreamLower = fileStorageUtil.getFileStream(waveName + GeneralConstant.CFG_LOWER);
|
||||
InputStream datStreamLower = fileStorageUtil.getFileStream(waveName + GeneralConstant.DAT_LOWER);
|
||||
if (Objects.isNull(cfgStreamLower) || Objects.isNull(datStreamLower)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStreamLower, datStreamLower, 1);
|
||||
} catch (Exception e1) {
|
||||
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
||||
}
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
|
||||
waveDataDTO.setPtType(line.getPtType());
|
||||
waveDataDTO.setPt(line.getPt1() * 1.0 / line.getPt2());
|
||||
waveDataDTO.setCt(line.getCt1() * 1.0 / line.getCt2());
|
||||
waveDataDTO.setMonitorName(line.getLineName());
|
||||
}
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType) {
|
||||
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
|
||||
@@ -121,5 +158,42 @@ public class WaveServiceImpl implements WaveService {
|
||||
return eventInfoDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventEigDetail> eventDetailEigenvalue2(String eventDetailIndex,Integer ptType) {
|
||||
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisFeignClient.analysisWlEvent(eventDetailIndex).getData() ;
|
||||
if (entityAdvancedData.backNumber != -1) {
|
||||
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||
EventEigDetail eventEigDetail = new EventEigDetail();
|
||||
eventEigDetail.setHold_time_dq(entityAdvancedData.evt_buf[i].hold_time_dq * 1000);
|
||||
eventEigDetail.setPow_a(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_a));
|
||||
eventEigDetail.setPow_b(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_b));
|
||||
eventEigDetail.setPow_c(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_c));
|
||||
|
||||
eventEigDetail.setVoltagechange_Va(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Va / 1000));
|
||||
eventEigDetail.setVoltagechange_Vb(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vb / 1000));
|
||||
eventEigDetail.setVoltagechange_Vc(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vc / 1000));
|
||||
|
||||
|
||||
eventEigDetail.setUa_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||
eventEigDetail.setUb_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ub_min[0]));
|
||||
eventEigDetail.setUc_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||
|
||||
eventEigDetail.setAngle_diff_ap(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_ap[0]));
|
||||
eventEigDetail.setAngle_diff_bp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_bp[0]));
|
||||
eventEigDetail.setAngle_diff_cp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_cp[0]));
|
||||
|
||||
eventEigDetail.setBph_max_value(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].bph_max_value[0]));
|
||||
eventEigDetail.setSagReason(entityAdvancedData.sagReason[0]);//暂降原因,暂降原因都一样
|
||||
eventEigDetail.setSagType(entityAdvancedData.sagType[i]);//暂降类型
|
||||
eventInfoDetails.add(eventEigDetail);
|
||||
eventEigDetail.setPttype(ptType);
|
||||
}
|
||||
} else {
|
||||
eventInfoDetails = null;
|
||||
}
|
||||
return eventInfoDetails;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
@@ -152,6 +153,89 @@ public class WordUtil {
|
||||
System.out.println("11");
|
||||
}
|
||||
|
||||
public InputStream createReport2(List<String> eventIndex) throws IOException, InvalidFormatException {
|
||||
setHeadingStyle(this.document);
|
||||
|
||||
// 添加标题
|
||||
XWPFParagraph titleParagraph = getCenterParagraph(this.document);
|
||||
addLine(titleParagraph, 11);
|
||||
// 设置段落居中
|
||||
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphBigRun, "宋体", 28, "000000", "暂降事件报告", true);
|
||||
addLine(titleParagraph, 17);
|
||||
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 16, "000000", "南京灿能电力自动化股份有限公司", false);
|
||||
addLine(titleParagraph, 1);
|
||||
titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "生成时间:" + getRightNow(), false);
|
||||
addLine(titleParagraph, 8);
|
||||
titleParagraph = getLeftParagraph(this.document);
|
||||
titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
|
||||
for (int m = 0; m < eventIndex.size(); m++) {
|
||||
String eventId = eventIndex.get(m);
|
||||
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(eventId);
|
||||
String time = eventInfoList.get(eventId).getTimeID().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
createTitle(document, (m + 1) + ". " + time, "标题 1", 0, 20);
|
||||
createTitle(document, (m + 1) + "." + "1. 基本信息", "标题 2", 0, 15);
|
||||
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
|
||||
introductionContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
|
||||
addParagraph(introductionContentRun, "宋体", 11, "000000", eventInfoList.get(eventId).getGdName() + "," + eventInfoList.get(eventId).getBdzName() + ",网络参数:" + eventInfoList.get(eventId).getIp() + "," + eventInfoList.get(eventId).getLineName() + "于" + time + "发生暂降事件,特征幅值:" + (eventInfoList.get(eventId).getEventValue()) + "%,持续时间:" + eventInfoList.get(eventId).getPersistTime() + "s。", false);
|
||||
createTitle(document, (m + 1) + "." + "2. 波形图", "标题 2", 0, 15);
|
||||
createTitle(document, (m + 1) + "." + "2.1 瞬时波形图", "标题 3", 200, 11);
|
||||
for (int shun = 0; shun < listShunPic.get(eventId).size(); shun++) {
|
||||
createPic(document, "瞬时波形" + (shun), listShunPic.get(eventId).get(shun));
|
||||
}
|
||||
createTitle(document, (m + 1) + "." + "2.2 RMS 波形图", "标题 3", 200, 11);
|
||||
for (int rms = 0; rms < listRmsPic.get(eventId).size(); rms++) {
|
||||
createPic(document, "RMS 波形" + (eventId), listRmsPic.get(eventId).get(rms));
|
||||
}
|
||||
createTitle(document, (m + 1) + "." + "3. 多特征值", "标题 2", 0, 15);
|
||||
|
||||
XWPFParagraph value = getLeftParagraph(document);
|
||||
XWPFRun valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "事件总分段数:" + eventDetailEigenvaluetmp.size(), false);
|
||||
addLine(value, 1);
|
||||
|
||||
if (eventDetailEigenvaluetmp.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "暂降原因:" + eventDetailEigenvaluetmp.get(0).getSagReason(), false);
|
||||
addLine(value, 1);
|
||||
|
||||
for (int i = 0; i < eventDetailEigenvaluetmp.size(); i++) {
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "波形起始点相位 (°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getPow_a() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getPow_b() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getPow_c())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "跳变段电压变化率 (V/ms):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "相位跳变 (°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "不平衡度 (%):" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(), false);
|
||||
addLine(value, 1);
|
||||
}
|
||||
addLine(value, 1);
|
||||
}
|
||||
|
||||
// 将文档写入 ByteArrayOutputStream
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
document.write(baos);
|
||||
document.close();
|
||||
// 创建 ByteArrayInputStream 并返回
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
public void createPic(XWPFDocument document, String name, byte[] base64Info) throws IOException, InvalidFormatException {
|
||||
XWPFParagraph picParagraph = getCenterParagraph(document);
|
||||
XWPFRun createRun = picParagraph.createRun();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.event.common.websocket;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 15:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通信文本消息和二进制缓存区大小
|
||||
* 避免对接 第三方 报文过大时,Websocket 1009 错误
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Bean
|
||||
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
||||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
||||
// 在此处设置bufferSize
|
||||
container.setMaxTextMessageBufferSize(10240000);
|
||||
container.setMaxBinaryMessageBufferSize(10240000);
|
||||
container.setMaxSessionIdleTimeout(15 * 60000L);
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.njcn.event.common.websocket;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 15:11【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ServerEndpoint(value = "/event/{userId}")
|
||||
public class WebSocketServer {
|
||||
|
||||
private static final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, Long> lastHeartbeatTime = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, ScheduledExecutorService> heartbeatExecutors = new ConcurrentHashMap<>();
|
||||
private static final long HEARTBEAT_TIMEOUT = 60; // 60秒超时
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("userId") String userId) {
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
sessions.put(userId, session);
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "连接成功");
|
||||
System.out.println("用户 " + userId + " 已连接");
|
||||
|
||||
// 启动心跳检测
|
||||
startHeartbeat(session, userId);
|
||||
} else {
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "用户ID不能为空"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session, @PathParam("userId") String userId) {
|
||||
if ("alive".equalsIgnoreCase(message)) {
|
||||
// 更新最后心跳时间
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "over");
|
||||
} else {
|
||||
// 处理业务消息
|
||||
System.out.println("收到用户 " + userId + " 的消息: " + message);
|
||||
// TODO: 处理业务逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session, CloseReason closeReason, @PathParam("userId") String userId) {
|
||||
// 移除用户并取消心跳检测
|
||||
sessions.remove(userId);
|
||||
lastHeartbeatTime.remove(userId);
|
||||
ScheduledExecutorService executor = heartbeatExecutors.remove(userId);
|
||||
if (executor != null) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
System.out.println("用户 " + userId + " 已断开连接,状态码: " + closeReason.getCloseCode());
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable throwable, @PathParam("userId") String userId) {
|
||||
System.out.println("用户 " + userId + " 发生错误: " + throwable.getMessage());
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "发生错误"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessageToUser(String userId, String message) {
|
||||
Session session = sessions.get(userId);
|
||||
if (session != null && session.isOpen()) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
System.out.println("webSocket用户 " + userId + " 不在线或会话已关闭");
|
||||
}
|
||||
}
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
public void sendMessageToAll(String message) {
|
||||
sessions.forEach((userId, session) -> {
|
||||
System.out.println("给用户推送消息" + userId);
|
||||
if (session.isOpen()) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendMessage(Session session, String message) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void startHeartbeat(Session session, String userId) {
|
||||
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
heartbeatExecutors.put(userId, executor);
|
||||
|
||||
// 定期检查心跳
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
long lastTime = lastHeartbeatTime.getOrDefault(userId, 0L);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
// 如果超过30秒没有收到心跳
|
||||
if (currentTime - lastTime > HEARTBEAT_TIMEOUT * 1000) {
|
||||
try {
|
||||
System.out.println("用户 " + userId + " 心跳超时,关闭连接");
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "心跳超时"));
|
||||
} catch (IOException e) {
|
||||
System.out.println("关闭用户 " + userId + " 连接时出错: " + e.getMessage());
|
||||
}
|
||||
executor.shutdown();
|
||||
heartbeatExecutors.remove(userId);
|
||||
}
|
||||
}, 0, 5, TimeUnit.SECONDS); // 每5秒检查一次
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.gateway.filter;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.nimbusds.jose.JWSObject;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.dto.UserTokenInfo;
|
||||
@@ -82,7 +82,7 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
}
|
||||
String blackUserKey = SecurityConstants.TOKEN_BLACKLIST_PREFIX + userIndex;
|
||||
List<UserTokenInfo> blackUsers = (List<UserTokenInfo>) redisUtil.getObjectByKey(blackUserKey);
|
||||
if (CollectionUtils.isNotEmpty(blackUsers)) {
|
||||
if (CollUtil.isNotEmpty(blackUsers)) {
|
||||
for (UserTokenInfo blackUser : blackUsers) {
|
||||
//存在当前的刷新token,则抛出业务异常
|
||||
if(blackUser.getAccessTokenJti().equalsIgnoreCase(jti)){
|
||||
|
||||
274
pqs-gateway/src/main/resources/bootstrap-jb.yml
Normal file
274
pqs-gateway/src/main/resources/bootstrap-jb.yml
Normal file
@@ -0,0 +1,274 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: "@name@"
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10215
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
gateway:
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowCredentials: true
|
||||
exposedHeaders: "Content-Disposition,Content-Type,Cache-Control"
|
||||
allowedHeaders: "*"
|
||||
allowedOrigins: "*"
|
||||
allowedMethods: "*"
|
||||
discovery:
|
||||
locator:
|
||||
# 开启自动代理 (自动装载从配置中心serviceId)
|
||||
enabled: true
|
||||
# 服务id为true --> 这样小写服务就可访问了
|
||||
lower-case-service-id: true
|
||||
routes:
|
||||
- id: pqs-auth
|
||||
uri: lb://pqs-auth
|
||||
predicates:
|
||||
- Path=/pqs-auth/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: user-boot
|
||||
uri: lb://user-boot
|
||||
predicates:
|
||||
- Path=/user-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: device-boot
|
||||
uri: lb://device-boot
|
||||
predicates:
|
||||
- Path=/device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: system-boot
|
||||
uri: lb://system-boot
|
||||
predicates:
|
||||
- Path=/system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-boot
|
||||
uri: lb://harmonic-boot
|
||||
predicates:
|
||||
- Path=/harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: energy-boot
|
||||
uri: lb://energy-boot
|
||||
predicates:
|
||||
- Path=/energy-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: event-boot
|
||||
uri: lb://event-boot
|
||||
predicates:
|
||||
- Path=/event-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: quality-boot
|
||||
uri: lb://quality-boot
|
||||
predicates:
|
||||
- Path=/quality-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-prepare
|
||||
uri: lb://harmonic-prepare
|
||||
predicates:
|
||||
- Path=/harmonic-prepare/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: process-boot
|
||||
uri: lb://process-boot
|
||||
predicates:
|
||||
- Path=/process-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: prepare-boot
|
||||
uri: lb://prepare-boot
|
||||
predicates:
|
||||
- Path=/prepare-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: algorithm-boot
|
||||
uri: lb://algorithm-boot
|
||||
predicates:
|
||||
- Path=/algorithm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: access-boot
|
||||
uri: lb://access-boot
|
||||
predicates:
|
||||
- Path=/access-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-device-boot
|
||||
uri: lb://cs-device-boot
|
||||
predicates:
|
||||
- Path=/cs-device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-system-boot
|
||||
uri: lb://cs-system-boot
|
||||
predicates:
|
||||
- Path=/cs-system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-warn-boot
|
||||
uri: lb://cs-warn-boot
|
||||
predicates:
|
||||
- Path=/cs-warn-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-harmonic-boot
|
||||
uri: lb://cs-harmonic-boot
|
||||
predicates:
|
||||
- Path=/cs-harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: advance-boot
|
||||
uri: lb://advance-boot
|
||||
predicates:
|
||||
- Path=/advance-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: bpm-boot
|
||||
uri: lb://bpm-boot
|
||||
predicates:
|
||||
- Path=/bpm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: supervision-boot
|
||||
uri: lb://supervision-boot
|
||||
predicates:
|
||||
- Path=/supervision-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-report-boot
|
||||
uri: lb://cs-report-boot
|
||||
predicates:
|
||||
- Path=/cs-report-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
#冀北influxDB转换程序
|
||||
- id: migration-influxdb-read-boot
|
||||
uri: lb://migration-influxdb-read-boot
|
||||
predicates:
|
||||
- Path=/migration-influxdb-read-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
whitelist:
|
||||
urls:
|
||||
- /user-boot/user/generateSm2Key
|
||||
- /user-boot/theme/getTheme
|
||||
- /user-boot/user/updateFirstPassword
|
||||
- /user-boot/appUser/authCode
|
||||
- /user-boot/appUser/register
|
||||
- /user-boot/appUser/resetPsd
|
||||
- /pqs-auth/oauth/logout
|
||||
- /pqs-auth/oauth/token
|
||||
- /pqs-auth/oauth/autoLogin
|
||||
- /pqs-auth/auth/getImgCode
|
||||
- /pqs-auth/oauth/getPublicKey
|
||||
- /pqs-auth/judgeToken/heBei
|
||||
- /pqs-auth/judgeToken/guangZhou
|
||||
|
||||
- /webjars/**
|
||||
- /actuator/**
|
||||
- /doc.html
|
||||
- /swagger-resources/**
|
||||
- /*/v2/api-docs
|
||||
- /favicon.ico
|
||||
- /system-boot/theme/getTheme
|
||||
- /system-boot/image/toStream
|
||||
- /system-boot/file/download
|
||||
- /cs-system-boot/appinfo/queryAppInfoByType
|
||||
- /system-boot/dictType/dictDataCache
|
||||
- /system-boot/file/**
|
||||
- /system-boot/area/**
|
||||
- /bpm-boot/**
|
||||
- /harmonic-boot/comAccess/getComAccessData
|
||||
- /harmonic-boot/harmonic/getHistoryResult
|
||||
- /event-boot/transient/getTransientAnalyseWave
|
||||
# - /**
|
||||
#开始
|
||||
# - /advance-boot/**
|
||||
# - /device-boot/**
|
||||
# - /system-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /energy-boot/**
|
||||
# - /event-boot/**
|
||||
# - /quality-boot/**
|
||||
# - /harmonic-prepare/**
|
||||
# - /process-boot/**
|
||||
# - /bpm-boot/**
|
||||
# - /system-boot/**
|
||||
# - /supervision-boot/**
|
||||
# - /user-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /cs-device-boot/**
|
||||
#结束
|
||||
- /user-boot/user/listAllUserByDeptId
|
||||
- /IndexAnalysis/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
279
pqs-gateway/src/main/resources/bootstrap-sjzx.yml
Normal file
279
pqs-gateway/src/main/resources/bootstrap-sjzx.yml
Normal file
@@ -0,0 +1,279 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: "@name@"
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10215
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
gateway:
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowCredentials: true
|
||||
exposedHeaders: "Content-Disposition,Content-Type,Cache-Control"
|
||||
allowedHeaders: "*"
|
||||
allowedOrigins: "*"
|
||||
allowedMethods: "*"
|
||||
discovery:
|
||||
locator:
|
||||
# 开启自动代理 (自动装载从配置中心serviceId)
|
||||
enabled: true
|
||||
# 服务id为true --> 这样小写服务就可访问了
|
||||
lower-case-service-id: true
|
||||
routes:
|
||||
- id: pqs-auth
|
||||
uri: lb://pqs-auth
|
||||
predicates:
|
||||
- Path=/pqs-auth/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: user-boot
|
||||
uri: lb://user-boot
|
||||
predicates:
|
||||
- Path=/user-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: device-boot
|
||||
uri: lb://device-boot
|
||||
predicates:
|
||||
- Path=/device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: system-boot
|
||||
uri: lb://system-boot
|
||||
predicates:
|
||||
- Path=/system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-boot
|
||||
uri: lb://harmonic-boot
|
||||
predicates:
|
||||
- Path=/harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: energy-boot
|
||||
uri: lb://energy-boot
|
||||
predicates:
|
||||
- Path=/energy-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: event-boot
|
||||
uri: lb://event-boot
|
||||
predicates:
|
||||
- Path=/event-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: quality-boot
|
||||
uri: lb://quality-boot
|
||||
predicates:
|
||||
- Path=/quality-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-prepare
|
||||
uri: lb://harmonic-prepare
|
||||
predicates:
|
||||
- Path=/harmonic-prepare/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: process-boot
|
||||
uri: lb://process-boot
|
||||
predicates:
|
||||
- Path=/process-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: prepare-boot
|
||||
uri: lb://prepare-boot
|
||||
predicates:
|
||||
- Path=/prepare-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: algorithm-boot
|
||||
uri: lb://algorithm-boot
|
||||
predicates:
|
||||
- Path=/algorithm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: access-boot
|
||||
uri: lb://access-boot
|
||||
predicates:
|
||||
- Path=/access-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-device-boot
|
||||
uri: lb://cs-device-boot
|
||||
predicates:
|
||||
- Path=/cs-device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-system-boot
|
||||
uri: lb://cs-system-boot
|
||||
predicates:
|
||||
- Path=/cs-system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-warn-boot
|
||||
uri: lb://cs-warn-boot
|
||||
predicates:
|
||||
- Path=/cs-warn-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-harmonic-boot
|
||||
uri: lb://cs-harmonic-boot
|
||||
predicates:
|
||||
- Path=/cs-harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: advance-boot
|
||||
uri: lb://advance-boot
|
||||
predicates:
|
||||
- Path=/advance-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: bpm-boot
|
||||
uri: lb://bpm-boot
|
||||
predicates:
|
||||
- Path=/bpm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: supervision-boot
|
||||
uri: lb://supervision-boot
|
||||
predicates:
|
||||
- Path=/supervision-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-report-boot
|
||||
uri: lb://cs-report-boot
|
||||
predicates:
|
||||
- Path=/cs-report-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
#冀北influxDB转换程序
|
||||
- id: migration-influxdb-read-boot
|
||||
uri: lb://migration-influxdb-read-boot
|
||||
predicates:
|
||||
- Path=/migration-influxdb-read-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
whitelist:
|
||||
urls:
|
||||
- /user-boot/user/generateSm2Key
|
||||
- /user-boot/theme/getTheme
|
||||
- /user-boot/user/updateFirstPassword
|
||||
- /user-boot/appUser/authCode
|
||||
- /user-boot/appUser/register
|
||||
- /user-boot/appUser/resetPsd
|
||||
- /pqs-auth/oauth/logout
|
||||
- /pqs-auth/oauth/token
|
||||
- /pqs-auth/oauth/autoLogin
|
||||
- /pqs-auth/auth/getImgCode
|
||||
- /pqs-auth/oauth/getPublicKey
|
||||
- /pqs-auth/judgeToken/heBei
|
||||
- /pqs-auth/judgeToken/guangZhou
|
||||
|
||||
- /webjars/**
|
||||
- /actuator/**
|
||||
- /doc.html
|
||||
- /swagger-resources/**
|
||||
- /*/v2/api-docs
|
||||
- /favicon.ico
|
||||
- /system-boot/theme/getTheme
|
||||
- /system-boot/image/toStream
|
||||
- /system-boot/file/download
|
||||
- /cs-system-boot/appinfo/queryAppInfoByType
|
||||
- /system-boot/dictType/dictDataCache
|
||||
- /system-boot/file/**
|
||||
- /system-boot/area/**
|
||||
- /bpm-boot/**
|
||||
- /harmonic-boot/comAccess/getComAccessData
|
||||
- /harmonic-boot/harmonic/getHistoryResult
|
||||
- /event-boot/transient/getTransientAnalyseWave
|
||||
# - /**
|
||||
#开始
|
||||
# - /advance-boot/**
|
||||
# - /device-boot/**
|
||||
# - /system-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /energy-boot/**
|
||||
# - /event-boot/**
|
||||
# - /quality-boot/**
|
||||
# - /harmonic-prepare/**
|
||||
# - /process-boot/**
|
||||
# - /bpm-boot/**
|
||||
# - /system-boot/**
|
||||
# - /supervision-boot/**
|
||||
# - /user-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /cs-device-boot/**
|
||||
#结束
|
||||
- /user-boot/user/listAllUserByDeptId
|
||||
- /IndexAnalysis/**
|
||||
#mqtt:
|
||||
# client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,15 +20,19 @@ spring:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
gateway:
|
||||
globalcors:
|
||||
@@ -186,17 +190,30 @@ spring:
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-report-boot
|
||||
uri: lb://cs-report-boot
|
||||
predicates:
|
||||
- Path=/cs-report-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
#河北国网总部调用省侧接口,路径总部统一规定
|
||||
- id: hb_pms_down
|
||||
uri: lb://harmonic-boot
|
||||
predicates:
|
||||
- Path=/IndexAnalysis/**
|
||||
- Path=/pms-tech-powerquality-start/**
|
||||
|
||||
- id: zl-event-boot
|
||||
uri: lb://zl-event-boot
|
||||
predicates:
|
||||
- Path=/zl-event-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
@@ -233,6 +250,7 @@ whitelist:
|
||||
- /harmonic-boot/comAccess/getComAccessData
|
||||
- /harmonic-boot/harmonic/getHistoryResult
|
||||
- /event-boot/transient/getTransientAnalyseWave
|
||||
# - /**
|
||||
#开始
|
||||
# - /advance-boot/**
|
||||
# - /device-boot/**
|
||||
@@ -252,8 +270,8 @@ whitelist:
|
||||
#结束
|
||||
- /user-boot/user/listAllUserByDeptId
|
||||
- /IndexAnalysis/**
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
#mqtt:
|
||||
# client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package com.njcn.harmonic.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据公共工具类
|
||||
*
|
||||
@@ -7,6 +15,7 @@ package com.njcn.harmonic.utils;
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/14 - 10:07
|
||||
*/
|
||||
|
||||
public class PublicDataUtils {
|
||||
/**
|
||||
* 功能:下划线命名转驼峰命名
|
||||
@@ -27,4 +36,91 @@ public class PublicDataUtils {
|
||||
}
|
||||
return under;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定月份的第一天 (格式:yyyy-MM-dd)
|
||||
* @param monthStr 月份字符串,格式为 yyyy-MM
|
||||
* @return 月份第一天的日期字符串
|
||||
*/
|
||||
public static String calculateMonthStart(String monthStr) {
|
||||
if (StrUtil.isBlank(monthStr)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date date = DateUtil.parse(monthStr, "yyyy-MM");
|
||||
Date firstDayOfMonth = DateUtil.beginOfMonth(date);
|
||||
return DateUtil.format(firstDayOfMonth, "yyyy-MM-dd");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("时间格式不正确,请使用 yyyy-MM 格式");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定月份的最后一天 (格式:yyyy-MM-dd)
|
||||
* @param monthStr 月份字符串,格式为 yyyy-MM
|
||||
* @return 月份最后一天的日期字符串
|
||||
*/
|
||||
public static String calculateMonthEnd(String monthStr) {
|
||||
if (StrUtil.isBlank(monthStr)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date date = DateUtil.parse(monthStr, "yyyy-MM");
|
||||
Date lastDayOfMonth = DateUtil.endOfMonth(date);
|
||||
return DateUtil.format(lastDayOfMonth, "yyyy-MM-dd");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("时间格式不正确,请使用 yyyy-MM 格式");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的月份字符串获取时间范围
|
||||
* 如果传入的月份是当前月份,返回该月1号到昨天
|
||||
* 如果传入的月份不是当前月份,返回该月的第一天和最后一天
|
||||
*
|
||||
* @param timeStr 月份字符串,格式:yyyy-MM
|
||||
* @return 包含 startTime 和 endTime 的数组,格式:yyyy-MM-dd
|
||||
*/
|
||||
/**
|
||||
* 根据传入的月份字符串获取时间范围
|
||||
* 如果传入的月份是当前月份,返回该月 1 号到昨天
|
||||
* 如果传入的月份不是当前月份,返回该月的第一天和最后一天
|
||||
*
|
||||
* @param timeStr 月份字符串,格式:yyyy-MM
|
||||
* @return 包含 startTime 和 endTime 的数组,格式:yyyy-MM-dd
|
||||
*/
|
||||
public static String[] calculateTimeRange(String timeStr) {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate inputMonth;
|
||||
|
||||
try {
|
||||
// 解析传入的月份
|
||||
inputMonth = LocalDate.parse(timeStr + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("时间格式不正确,请使用 yyyy-MM 格式");
|
||||
}
|
||||
|
||||
// 判断是否是当前月份
|
||||
boolean isCurrentMonth = inputMonth.getYear() == now.getYear() &&
|
||||
inputMonth.getMonthValue() == now.getMonthValue();
|
||||
|
||||
String startTime;
|
||||
String endTime;
|
||||
|
||||
startTime = inputMonth.withDayOfMonth(1).format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
if (isCurrentMonth) {
|
||||
// 如果今天是 1 号,则结束时间也为 1 号,避免时间范围无效
|
||||
endTime = now.minusDays(1).format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
// 确保结束时间不小于开始时间
|
||||
if (LocalDate.parse(endTime).isBefore(LocalDate.parse(startTime))) {
|
||||
endTime = startTime;
|
||||
}
|
||||
} else {
|
||||
// 如果不是当前月份,开始时间是该月 1 号,结束时间是该月最后一天
|
||||
endTime = inputMonth.withDayOfMonth(inputMonth.lengthOfMonth()).format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
}
|
||||
|
||||
return new String[]{startTime, endTime};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,12 +99,12 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.9</version>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>prepare-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>-->
|
||||
<!-- <dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>prepare-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>advance-api</artifactId>
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.njcn.harmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.harmonic.common.mapper.RStatDataHarmRateVDMapper;
|
||||
import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
|
||||
import com.njcn.harmonic.constant.Param;
|
||||
import com.njcn.harmonic.mapper.RStatDataHarmRateIDMapper;
|
||||
import com.njcn.harmonic.pojo.param.HarmInHarmParam;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateIDPO;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
|
||||
import com.njcn.harmonic.pojo.vo.HarmInHarmVO;
|
||||
import com.njcn.harmonic.service.HarmInHarmService;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
@@ -21,6 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -41,7 +50,8 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
||||
|
||||
private final IDataIService dataIService;
|
||||
|
||||
|
||||
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
|
||||
private final RStatDataIDMapper dataIDMapper;
|
||||
@Override
|
||||
public HarmInHarmVO getHarmInHarmData(HarmInHarmParam harmInHarmParam) {
|
||||
HarmInHarmVO harmInHarmVO = new HarmInHarmVO();
|
||||
@@ -77,33 +87,70 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
||||
List<Float> floatList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(lineId)) {
|
||||
if (harmState == 0) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||
influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
||||
.eq(DataHarmRateV::getLineId, lineId)
|
||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
||||
if (Objects.nonNull(dataHarmRateV)) {
|
||||
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||
// influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||
// .eq(DataHarmRateV::getLineId, lineId)
|
||||
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
// DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
||||
// if (Objects.nonNull(dataHarmRateV)) {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
||||
// }
|
||||
// }else {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(null);
|
||||
// }
|
||||
// }
|
||||
//转换成查mysql统计数据,分钟数据没有值
|
||||
List<RStatDataHarmrateVDPO> harmV = dataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
|
||||
.eq(RStatDataHarmrateVDPO::getLineId, lineId)
|
||||
.eq(RStatDataHarmrateVDPO::getValueType,"CP95")
|
||||
.in(RStatDataHarmrateVDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||
.ge(RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
|
||||
if (Objects.nonNull(harmV)) {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
||||
floatList.add(PubUtils.getValueByMethodDouble(harmV,RStatDataHarmrateVDPO.class, "getV", i).floatValue());
|
||||
}
|
||||
}else {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
||||
.eq(DataHarmRateV::getLineId, lineId)
|
||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
||||
if (Objects.nonNull(dataI)) {
|
||||
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
// influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||
// .eq(DataHarmRateV::getLineId, lineId)
|
||||
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
// DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
||||
// if (Objects.nonNull(dataI)) {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
||||
// }
|
||||
// }else {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(null);
|
||||
// }
|
||||
// }
|
||||
|
||||
//转换成查mysql统计数据,分钟数据没有值
|
||||
List<RStatDataIDPO> harmI = dataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
|
||||
.eq(RStatDataIDPO::getLineId, lineId)
|
||||
.eq(RStatDataIDPO::getValueType,"CP95")
|
||||
.in(RStatDataIDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||
.ge(RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
if (Objects.nonNull(harmI)) {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
||||
floatList.add(PubUtils.getValueByMethodDouble(harmI,RStatDataIDPO.class, "getI", i).floatValue());
|
||||
}
|
||||
}else {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -49,7 +50,9 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
|
||||
// 常量定义
|
||||
private static final String REPORT_TEMPLATE_PATH = "file/areaReportTemplate.docx";
|
||||
private static final String DEFAULT_PROVIDER_DEPT = "云网能源(曲靖)有限责任公司";
|
||||
|
||||
@Value("${areaReportTitle:上海电力有限公司电力科学研究院}")
|
||||
private String DEFAULT_PROVIDER_DEPT;
|
||||
private static final String NO_DATA_PLACEHOLDER = "无";
|
||||
private static final String UNKNOWN_VALUE = "/";
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10204
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.harmonic.pojo
|
||||
global-config:
|
||||
enable-sql-runner: true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10204
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
#数据中心使用
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
#PMS使用
|
||||
# - data-Id: share-config-harmonic-db.yaml
|
||||
# refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.harmonic.pojo
|
||||
global-config:
|
||||
enable-sql-runner: true
|
||||
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10204
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
#username: @nacos.username@
|
||||
#password: @nacos.password@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
#username: @nacos.username@
|
||||
#password: @nacos.password@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
#数据中心使用
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
#PMS使用
|
||||
# - data-Id: share-config-harmonic-db.yaml
|
||||
# refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.harmonic.pojo
|
||||
global-config:
|
||||
enable-sql-runner: true
|
||||
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.harmonic.common.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
@@ -19,6 +20,7 @@ import java.util.Map;
|
||||
* @author cdf
|
||||
* @date 2022/8/16
|
||||
*/
|
||||
@DS("sjzx")
|
||||
public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
|
||||
|
||||
Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
|
||||
|
||||
@@ -24,4 +24,10 @@ public interface CustomReportTableService {
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
void getCustomReport(ReportSearchParam reportSearchParam, Map<String,String> newMap, DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 存储稳态事件报表,并返回存储路径
|
||||
*/
|
||||
String saveStableEventReport(ReportSearchParam reportSearchParam, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
||||
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
|
||||
import com.njcn.harmonic.common.service.CustomReportTableService;
|
||||
@@ -29,6 +27,7 @@ import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -40,13 +39,14 @@ import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
@@ -69,18 +69,9 @@ import java.util.stream.Collectors;
|
||||
public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
|
||||
private final ExcelRptTempMapper excelRptTempMapper;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
|
||||
|
||||
private final String CELL_DATA = "celldata";
|
||||
@@ -113,8 +104,460 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveStableEventReport(ReportSearchParam reportSearchParam, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
String filePath = "";
|
||||
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
|
||||
if (Objects.isNull(excelRptTemp)) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
|
||||
} else {
|
||||
if (Objects.isNull(reportSearchParam.getCustomType())) {
|
||||
filePath = this.analyzeReport2(reportSearchParam, excelRptTemp, newMap, deviceUnitCommDTO);
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
private String analyzeReport2(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
//定义一个线程集合
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
//指标
|
||||
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
|
||||
//限值
|
||||
List<ReportTemplateDTO> reportLimitList = new ArrayList<>();
|
||||
//台账
|
||||
List<ReportTemplateDTO> terminalList = new ArrayList<>();
|
||||
JSONArray jsonArray;
|
||||
try (InputStream fileStream = fileStorageUtil.getFileStream(excelRptTemp.getContent())) {
|
||||
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
|
||||
} catch (Exception e) {
|
||||
if(e instanceof BusinessException){
|
||||
throw new BusinessException(e.getMessage());
|
||||
}else {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
}
|
||||
//查询不分相别的指标
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
if(Objects.isNull(dictData)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||
}
|
||||
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
|
||||
Map<String, String> tMap = new HashMap<>();
|
||||
eleEpdPqdList.forEach(item->{
|
||||
String phase;
|
||||
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||
phase = item.getPhase();
|
||||
} else {
|
||||
phase = PHASE_MAPPING.get(item.getPhase());
|
||||
}
|
||||
if (ObjectUtils.isNotNull(item.getHarmStart()) && ObjectUtils.isNotNull(item.getHarmEnd())) {
|
||||
for (int i = item.getHarmStart(); i <= item.getHarmEnd() + 1; i++) {
|
||||
tMap.put((item.getOtherName() + "_" + i + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
}
|
||||
} else {
|
||||
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
}
|
||||
});
|
||||
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
|
||||
//处理指标是否合格
|
||||
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
|
||||
//存放限值指标的map
|
||||
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
|
||||
|
||||
List<ReportTemplateDTO> endList = new CopyOnWriteArrayList<>();
|
||||
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
|
||||
//开始组织sql
|
||||
reportTemplateDTOList = new LinkedHashSet<>(reportTemplateDTOList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
Map<String, List<ReportTemplateDTO>> classMap = reportTemplateDTOList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getResourceId));
|
||||
//定义存放越限指标的map
|
||||
Map<String, ReportTemplateDTO> assNoPassMap = new HashMap<>();
|
||||
classMap.forEach((classKey, templateValue) -> {
|
||||
Map<String, List<ReportTemplateDTO>> valueTypeMap = templateValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod));
|
||||
//每张表开启一个独立线程查询
|
||||
futures.add(executorService.submit(() -> {
|
||||
DynamicDataSourceContextHolder.push("sjzx");
|
||||
//avg.max,min,cp95
|
||||
try {
|
||||
valueTypeMap.forEach((valueTypeKey, valueTypeVal) -> {
|
||||
//相别分组
|
||||
Map<String, List<ReportTemplateDTO>> phaseMap = valueTypeVal.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase));
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
DynamicDataSourceContextHolder.poll();
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
// 等待所有任务完成
|
||||
for (Future<?> future : futures) {
|
||||
try {
|
||||
future.get(); // 这会阻塞直到任务完成或抛出异常
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//处理指标最终判定合格还是不合格
|
||||
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
|
||||
}
|
||||
resultAssemble2(endList,reportSearchParam,newMap,deviceUnitCommDTO,jsonArray,dataMap);
|
||||
//存储自定义报表
|
||||
return saveReport(jsonArray,dataMap);
|
||||
}
|
||||
|
||||
public void resultAssemble2(List<ReportTemplateDTO> endList, ReportSearchParam reportSearchParam, Map<String, String> finalTerminalMap, DeviceUnitCommDTO deviceUnitCommDTO, JSONArray jsonArray,Map<String, Object> dataMap) {
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
Map<String, String> unit = this.unitMap(deviceUnitCommDTO);
|
||||
Map<String, List<ReportTemplateDTO>> assMap = (Map)endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
jsonArray.forEach((item) -> {
|
||||
JSONObject jsonObject = (JSONObject)item;
|
||||
JSONArray itemArr = (JSONArray)jsonObject.get("celldata");
|
||||
itemArr.forEach((it) -> {
|
||||
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
|
||||
JSONObject data = (JSONObject)it;
|
||||
JSONObject son = (JSONObject)data.get("v");
|
||||
if (son.containsKey("v")) {
|
||||
String v = son.getStr("v");
|
||||
String tem;
|
||||
List rDto;
|
||||
if (v.charAt(0) == '$' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("$", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
|
||||
son.set("v", tem);
|
||||
dataMap.put(v, tem);
|
||||
if (Objects.nonNull(((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag()) && ((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag() == 1) {
|
||||
son.set("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '%' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("%", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
|
||||
son.set("v", tem);
|
||||
dataMap.put(v, tem);
|
||||
if ("不合格".equals(tem)) {
|
||||
son.set("fc", "#990000");
|
||||
dataMap.put("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '&') {
|
||||
tem = v.replace("&", "").toUpperCase();
|
||||
if (finalTerminalMap.size() > 0) {
|
||||
if ("STATIS_TIME".equals(tem)) {
|
||||
String localTime = " 23:59:59";
|
||||
LocalDate localDate = LocalDateTimeUtil.parseDate(reportSearchParam.getEndTime(), "yyyy-MM-dd");
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
if (nowDate.isAfter(localDate)) {
|
||||
son.set("v", reportSearchParam.getStartTime() + " 00:00:00" + "_" + reportSearchParam.getEndTime() + localTime);
|
||||
dataMap.put(v, reportSearchParam.getStartTime() + " 00:00:00" + "_" + reportSearchParam.getEndTime() + localTime);
|
||||
} else {
|
||||
localTime = " " + LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
|
||||
son.set("v", reportSearchParam.getStartTime() + " 00:00:00" + "_" + nowDate + localTime);
|
||||
dataMap.put(v, reportSearchParam.getStartTime() + " 00:00:00" + "_" + nowDate + localTime);
|
||||
}
|
||||
} else {
|
||||
son.set("v", finalTerminalMap.getOrDefault(tem, "/"));
|
||||
dataMap.put(v, finalTerminalMap.getOrDefault(tem, "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
tem = v.replace("@", "");
|
||||
son.set("v", unit.getOrDefault(tem, "/"));
|
||||
dataMap.put(v, unit.getOrDefault(tem, "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String saveReport(JSONArray jsonArray, Map<String, Object> dataMap) {
|
||||
String filePath = "";
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String sheetName = jsonObject.getStr("name");
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
List<CellRangeAddress> mergeRegions = new ArrayList<>();
|
||||
List<MergedCellInfo> mergedCellInfos = new ArrayList<>();
|
||||
|
||||
if (data != null && !data.isEmpty()) {
|
||||
boolean hasMergeMark = false;
|
||||
|
||||
for (int j = 0; j < data.size(); j++) {
|
||||
Row row = sheet.createRow(j);
|
||||
JSONArray rowData = data.getJSONArray(j);
|
||||
|
||||
if (rowData != null) {
|
||||
for (int k = 0; k < rowData.size(); k++) {
|
||||
JSONObject cellObj = rowData.getJSONObject(k);
|
||||
|
||||
if (cellObj == null || cellObj.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject mc = cellObj.getJSONObject("mc");
|
||||
|
||||
if (mc != null && !mc.isEmpty()) {
|
||||
hasMergeMark = true;
|
||||
|
||||
Integer rs = mc.getInt("rs");
|
||||
Integer cs = mc.getInt("cs");
|
||||
Integer mr = mc.getInt("r");
|
||||
Integer mcCol = mc.getInt("c");
|
||||
|
||||
if (rs != null && cs != null && mr != null && mcCol != null) {
|
||||
if (mr == j && mcCol == k) {
|
||||
int endRow = j + rs - 1;
|
||||
int endCol = k + cs - 1;
|
||||
if (endRow > j || endCol > k) {
|
||||
mergeRegions.add(new CellRangeAddress(j, endRow, k, endCol));
|
||||
|
||||
MergedCellInfo info = new MergedCellInfo();
|
||||
info.row = j;
|
||||
info.col = k;
|
||||
info.cellObj = cellObj;
|
||||
mergedCellInfos.add(info);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cell cell = row.createCell(k);
|
||||
Object v = cellObj.get("v");
|
||||
|
||||
if (v != null) {
|
||||
Object vData = dataMap.get(v);
|
||||
if (vData != null) {
|
||||
setCellValue(cell, vData);
|
||||
} else {
|
||||
setCellValue(cell, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMergeMark) {
|
||||
detectAndMergeCells(data, mergeRegions, mergedCellInfos);
|
||||
}
|
||||
}
|
||||
|
||||
for (CellRangeAddress mergeRegion : mergeRegions) {
|
||||
try {
|
||||
sheet.addMergedRegion(mergeRegion);
|
||||
} catch (Exception e) {
|
||||
log.warn("添加合并单元格失败:{}", mergeRegion.formatAsString());
|
||||
}
|
||||
}
|
||||
|
||||
for (MergedCellInfo info : mergedCellInfos) {
|
||||
Row row = sheet.getRow(info.row);
|
||||
if (row != null) {
|
||||
Cell cell = row.getCell(info.col);
|
||||
if (cell != null) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
Font font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
style.setFont(font);
|
||||
style.setWrapText(true);
|
||||
|
||||
if (Objects.equals(cell.getStringCellValue(),"非谐波统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电压统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电流统计报表")) {
|
||||
font.setFontHeightInPoints((short) 18);
|
||||
font.setBold(true);
|
||||
}
|
||||
if (Objects.equals(cell.getStringCellValue(),"有效值")
|
||||
|| Objects.equals(cell.getStringCellValue(),"功率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"电压闪变")
|
||||
|| Objects.equals(cell.getStringCellValue(),"畸变率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"电压偏差")
|
||||
|| Objects.equals(cell.getStringCellValue(),"频率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"三相不平衡度")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电压含有率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电流幅值")) {
|
||||
font.setFontHeightInPoints((short) 15);
|
||||
font.setBold(true);
|
||||
}
|
||||
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
workbook.write(baos);
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
||||
}
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
filePath = fileStorageUtil.uploadStream(bais, OssPath.APP_HARMONIC_REPORT, "稳态报表.xlsx");
|
||||
try {
|
||||
bais.close();
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测并合并单元格(当没有 mc 标记时)
|
||||
*/
|
||||
private void detectAndMergeCells(JSONArray data, List<CellRangeAddress> mergeRegions,
|
||||
List<MergedCellInfo> mergedCellInfos) {
|
||||
int rows = data.size();
|
||||
if (rows == 0) return;
|
||||
|
||||
int cols = 0;
|
||||
JSONArray firstRow = data.getJSONArray(0);
|
||||
if (firstRow != null) {
|
||||
cols = firstRow.size();
|
||||
}
|
||||
|
||||
boolean[][] merged = new boolean[rows][cols];
|
||||
|
||||
for (int j = 0; j < rows; j++) {
|
||||
JSONArray rowData = data.getJSONArray(j);
|
||||
if (rowData == null) continue;
|
||||
|
||||
for (int k = 0; k < rowData.size(); k++) {
|
||||
if (merged[j][k]) continue;
|
||||
|
||||
JSONObject cellObj = rowData.getJSONObject(k);
|
||||
if (cellObj == null || cellObj.isEmpty()) continue;
|
||||
|
||||
Object v = cellObj.get("v");
|
||||
if (v == null || StrUtil.isBlank(v.toString())) continue;
|
||||
|
||||
int mergeEndRow = j;
|
||||
int mergeEndCol = k;
|
||||
|
||||
for (int r = j + 1; r < rows; r++) {
|
||||
JSONArray nextRow = data.getJSONArray(r);
|
||||
if (nextRow == null || k >= nextRow.size()) break;
|
||||
|
||||
JSONObject nextCellObj = nextRow.getJSONObject(k);
|
||||
if (nextCellObj == null || nextCellObj.isEmpty()) break;
|
||||
|
||||
Object nextV = nextCellObj.get("v");
|
||||
if (nextV == null || !String.valueOf(v).equals(String.valueOf(nextV))) break;
|
||||
|
||||
mergeEndRow = r;
|
||||
merged[r][k] = true;
|
||||
}
|
||||
|
||||
for (int c = k + 1; c < cols; c++) {
|
||||
if (j >= rowData.size()) break;
|
||||
|
||||
JSONObject rightCellObj = rowData.getJSONObject(c);
|
||||
if (rightCellObj == null || rightCellObj.isEmpty()) break;
|
||||
|
||||
Object rightV = rightCellObj.get("v");
|
||||
if (rightV == null || !String.valueOf(v).equals(String.valueOf(rightV))) break;
|
||||
|
||||
mergeEndCol = c;
|
||||
merged[j][c] = true;
|
||||
}
|
||||
|
||||
if (mergeEndRow > j || mergeEndCol > k) {
|
||||
mergeRegions.add(new CellRangeAddress(j, mergeEndRow, k, mergeEndCol));
|
||||
|
||||
MergedCellInfo info = new MergedCellInfo();
|
||||
info.row = j;
|
||||
info.col = k;
|
||||
info.cellObj = cellObj;
|
||||
mergedCellInfos.add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单元格值
|
||||
*/
|
||||
private void setCellValue(Cell cell, Object value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
cell.setCellValue((String) value);
|
||||
} else if (value instanceof Number) {
|
||||
cell.setCellValue(((Number) value).doubleValue());
|
||||
} else if (value instanceof Boolean) {
|
||||
cell.setCellValue((Boolean) value);
|
||||
} else if (value instanceof Date) {
|
||||
cell.setCellValue((Date) value);
|
||||
} else {
|
||||
cell.setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并单元格信息内部类
|
||||
*/
|
||||
private static class MergedCellInfo {
|
||||
int row;
|
||||
int col;
|
||||
JSONObject cellObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理
|
||||
*
|
||||
* @author cdf
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10232
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.supervision.pojo
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10232
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.supervision.pojo
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
@@ -1,48 +1,3 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10232
|
||||
max-http-header-size: 1048576
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.njcn.supervision.pojo
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
@@ -80,11 +80,11 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>energy-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
|
||||
@@ -1,112 +1,112 @@
|
||||
package com.njcn.system.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.service.IUserLogService;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.web.utils.EmailUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年07月13日 13:35
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MqttMessageHandler {
|
||||
|
||||
private final IUserLogService userLogService;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final EmailUtil emailUtil;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
|
||||
|
||||
|
||||
private JSONObject jsonObject = null;
|
||||
/**
|
||||
* 订阅审计日志的记录,并进行入库操作
|
||||
*/
|
||||
// @MqttSubscribe(value = "/userLog")
|
||||
public void subUserLog(String topic, MqttMessage message, @Payload String payload) {
|
||||
if(Objects.isNull(jsonObject)){
|
||||
jsonObject = (JSONObject) redisUtil.getObjectByKey(RedisKeyEnum.USER_ROLE_TYPE_KEY.getKey());
|
||||
if(Objects.isNull(jsonObject)){
|
||||
userFeignClient.userRoleList();
|
||||
jsonObject = (JSONObject) redisUtil.getObjectByKey(RedisKeyEnum.USER_ROLE_TYPE_KEY.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
LogInfoDTO logInfoDTO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER) && !logInfoDTO.getOperate().equals(LogInfo.UNKNOWN_OPERATE) && !logInfoDTO.getIp().equals(LogInfo.UNKNOWN_IP)){
|
||||
if("注销".equals(logInfoDTO.getOperateType()) || "认证".equals(logInfoDTO.getOperateType())){
|
||||
logInfoDTO.setType(1);
|
||||
}else {
|
||||
String loginName = logInfoDTO.getLoginName();
|
||||
if(StrUtil.isNotBlank(loginName) && jsonObject.containsKey(loginName)){
|
||||
if((Integer) jsonObject.get(loginName)==2){
|
||||
logInfoDTO.setType(0);
|
||||
}else {
|
||||
logInfoDTO.setType(1);
|
||||
};
|
||||
}else {
|
||||
logInfoDTO.setType(1);
|
||||
}
|
||||
}
|
||||
userLogService.addUserLog(logInfoDTO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅审计日志的记录,并进行入库操作
|
||||
*/
|
||||
// @MqttSubscribe(value = "/userLogEmailPush")
|
||||
public void subUserLogEmail(String topic, MqttMessage message, @Payload String payload) {
|
||||
LogInfoDTO auditLogVO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
List<User> data = userFeignClient.getUserListByRoleCode("audit_manager").getData();
|
||||
List<String> emails = data.stream()
|
||||
.filter(x -> Pattern.matches(PatternRegex.EMAIL_REGEX,x.getEmail()))
|
||||
.filter(x -> StrUtil.isNotBlank(x.getEmail()) && x.getEmailNotice() == 1)
|
||||
.map(User::getEmail).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(emails)){
|
||||
StringBuilder describe = new StringBuilder();
|
||||
describe.append(auditLogVO.getType() == 0 ? "业务事件 -> " : "系统事件 -> ");
|
||||
describe.append(auditLogVO.getUserName()).append("在")
|
||||
.append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(auditLogVO.getCreateTime()))
|
||||
.append("在")
|
||||
.append(auditLogVO.getIp())
|
||||
.append("执行了")
|
||||
.append(auditLogVO.getOperate())
|
||||
.append(",结果为");
|
||||
if (auditLogVO.getResult() == 1) {
|
||||
describe.append("成功");
|
||||
}
|
||||
if (auditLogVO.getResult() == 0) {
|
||||
describe.append("失败").append(",失败原因为").append(auditLogVO.getFailReason());
|
||||
}
|
||||
emailUtil.sendMultiple(emails,"告警消息",describe.toString(),false);
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.handler;
|
||||
//
|
||||
//import cn.hutool.core.collection.CollUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.json.JSONObject;
|
||||
//import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
//import com.njcn.common.pojo.constant.LogInfo;
|
||||
//import com.njcn.common.pojo.constant.PatternRegex;
|
||||
//import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
//import com.njcn.common.utils.PubUtils;
|
||||
//import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
//import com.njcn.redis.utils.RedisUtil;
|
||||
//import com.njcn.system.service.IUserLogService;
|
||||
//import com.njcn.user.api.UserFeignClient;
|
||||
//import com.njcn.user.pojo.po.User;
|
||||
//import com.njcn.web.utils.EmailUtil;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//import java.util.regex.Pattern;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * @author hongawen
|
||||
// * @version 1.0.0
|
||||
// * @date 2022年07月13日 13:35
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class MqttMessageHandler {
|
||||
//
|
||||
// private final IUserLogService userLogService;
|
||||
// private final UserFeignClient userFeignClient;
|
||||
// private final EmailUtil emailUtil;
|
||||
//
|
||||
// private final RedisUtil redisUtil;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// private JSONObject jsonObject = null;
|
||||
// /**
|
||||
// * 订阅审计日志的记录,并进行入库操作
|
||||
// */
|
||||
//// @MqttSubscribe(value = "/userLog")
|
||||
// public void subUserLog(String topic, MqttMessage message, @Payload String payload) {
|
||||
// if(Objects.isNull(jsonObject)){
|
||||
// jsonObject = (JSONObject) redisUtil.getObjectByKey(RedisKeyEnum.USER_ROLE_TYPE_KEY.getKey());
|
||||
// if(Objects.isNull(jsonObject)){
|
||||
// userFeignClient.userRoleList();
|
||||
// jsonObject = (JSONObject) redisUtil.getObjectByKey(RedisKeyEnum.USER_ROLE_TYPE_KEY.getKey());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// LogInfoDTO logInfoDTO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
// if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER) && !logInfoDTO.getOperate().equals(LogInfo.UNKNOWN_OPERATE) && !logInfoDTO.getIp().equals(LogInfo.UNKNOWN_IP)){
|
||||
// if("注销".equals(logInfoDTO.getOperateType()) || "认证".equals(logInfoDTO.getOperateType())){
|
||||
// logInfoDTO.setType(1);
|
||||
// }else {
|
||||
// String loginName = logInfoDTO.getLoginName();
|
||||
// if(StrUtil.isNotBlank(loginName) && jsonObject.containsKey(loginName)){
|
||||
// if((Integer) jsonObject.get(loginName)==2){
|
||||
// logInfoDTO.setType(0);
|
||||
// }else {
|
||||
// logInfoDTO.setType(1);
|
||||
// };
|
||||
// }else {
|
||||
// logInfoDTO.setType(1);
|
||||
// }
|
||||
// }
|
||||
// userLogService.addUserLog(logInfoDTO);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 订阅审计日志的记录,并进行入库操作
|
||||
// */
|
||||
//// @MqttSubscribe(value = "/userLogEmailPush")
|
||||
// public void subUserLogEmail(String topic, MqttMessage message, @Payload String payload) {
|
||||
// LogInfoDTO auditLogVO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
// List<User> data = userFeignClient.getUserListByRoleCode("audit_manager").getData();
|
||||
// List<String> emails = data.stream()
|
||||
// .filter(x -> Pattern.matches(PatternRegex.EMAIL_REGEX,x.getEmail()))
|
||||
// .filter(x -> StrUtil.isNotBlank(x.getEmail()) && x.getEmailNotice() == 1)
|
||||
// .map(User::getEmail).collect(Collectors.toList());
|
||||
// if(CollUtil.isNotEmpty(emails)){
|
||||
// StringBuilder describe = new StringBuilder();
|
||||
// describe.append(auditLogVO.getType() == 0 ? "业务事件 -> " : "系统事件 -> ");
|
||||
// describe.append(auditLogVO.getUserName()).append("在")
|
||||
// .append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(auditLogVO.getCreateTime()))
|
||||
// .append("在")
|
||||
// .append(auditLogVO.getIp())
|
||||
// .append("执行了")
|
||||
// .append(auditLogVO.getOperate())
|
||||
// .append(",结果为");
|
||||
// if (auditLogVO.getResult() == 1) {
|
||||
// describe.append("成功");
|
||||
// }
|
||||
// if (auditLogVO.getResult() == 0) {
|
||||
// describe.append("失败").append(",失败原因为").append(auditLogVO.getFailReason());
|
||||
// }
|
||||
// emailUtil.sendMultiple(emails,"告警消息",describe.toString(),false);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FrontLogsCleanTaskRunner implements TimerTaskRunner {
|
||||
QueryWrapper<PqFrontLogsChild> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<PqFrontLogs> pqFrontLogsQueryWrapper = new QueryWrapper<>();
|
||||
LocalDate calDate;
|
||||
if(StrUtil.isBlank(date)){
|
||||
if(!StrUtil.isBlank(date)){
|
||||
calDate = LocalDate.parse(date, DatePattern.NORM_DATE_FORMATTER);
|
||||
|
||||
}else {
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:母线算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class GeneraTrixTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
}else {
|
||||
baseParam.setDataDate(date);
|
||||
}
|
||||
liteFlowFeignClient.generaTrixExecutor(baseParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:母线算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class GeneraTrixTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// }else {
|
||||
// baseParam.setDataDate(date);
|
||||
// }
|
||||
// liteFlowFeignClient.generaTrixExecutor(baseParam);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user