项目集成华为obs查看波形文件
This commit is contained in:
@@ -36,4 +36,13 @@ public class GeneralInfo {
|
|||||||
@Value("${business.tempPath}")
|
@Value("${business.tempPath}")
|
||||||
private String businessTempPath;
|
private String businessTempPath;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 文件存储方式
|
||||||
|
* 1:本地磁盘
|
||||||
|
* 2:华为obs
|
||||||
|
* 3: minioss
|
||||||
|
*/
|
||||||
|
@Value("${business.file.storage}")
|
||||||
|
private int businessFileStorage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.common.pojo.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年03月06日 11:07
|
||||||
|
*/
|
||||||
|
public interface GeneralConstant {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 文件存储的3种方式
|
||||||
|
*/
|
||||||
|
Integer LOCAL_DISK = 1;
|
||||||
|
Integer HUAWEI_OBS = 2;
|
||||||
|
Integer MINIO_OSS = 3;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 波形文件的3种后缀
|
||||||
|
*/
|
||||||
|
String CFG =".CFG";
|
||||||
|
String DAT =".DAT";
|
||||||
|
String HDR =".HDR";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.njcn.common.pojo.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年03月03日 16:29
|
||||||
|
*/
|
||||||
|
public interface OssPath {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 波形文件
|
||||||
|
*/
|
||||||
|
String WAVE_DIR="comtrade/";
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 稳态报表
|
||||||
|
*/
|
||||||
|
String HARMONIC_EXCEL_REPORT="harmonic/excel/report";
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 稳态报表模板
|
||||||
|
*/
|
||||||
|
String HARMONIC_EXCEL_TEMPLATE="harmonic/excel/template";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -91,6 +91,7 @@ public enum CommonResponseEnum {
|
|||||||
ID_NOT_EXIST("A0100", "id不存在"),
|
ID_NOT_EXIST("A0100", "id不存在"),
|
||||||
|
|
||||||
TIME_ERROR("A0101","时间格式有误"),
|
TIME_ERROR("A0101","时间格式有误"),
|
||||||
|
CLOSE_RESOURCE_ERROR("A0102","关闭资源有误"),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.njcn.device.pms.controller.majornetwork;
|
|
||||||
|
|
||||||
|
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
|
||||||
import com.njcn.device.pms.service.majornetwork.TransientPmsService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂态事件列表(PMS暂用)
|
|
||||||
* @author hongawen
|
|
||||||
* @since 2022-10-14
|
|
||||||
*/
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/pms/transientStasticData")
|
|
||||||
@Api(tags = "暂态事件列表(PMS暂用)")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class TransientStasticDataController extends BaseController {
|
|
||||||
|
|
||||||
private final TransientPmsService transientPmsService;
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getTransientAnalyseWavePms")
|
|
||||||
@ApiOperation("暂态事件波形分析")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "timeId", value = "暂态时刻", required = true),
|
|
||||||
@ApiImplicitParam(name = "lineId", value = "暂态监测点Id", required = true),
|
|
||||||
@ApiImplicitParam(name = "lineType", value = "暂态监测点类型(1主网 2配网)", required = true)
|
|
||||||
})
|
|
||||||
public HttpResult<WaveDataDTO> getTransientAnalyseWavePms(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId, @RequestParam("lineType") Integer lineType){
|
|
||||||
String methodDescribe = getMethodDescribe("getTransientAnalyseWavePms");
|
|
||||||
WaveDataDTO wave = transientPmsService.getTransientAnalyseWavePms(timeId, lineId,lineType);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.njcn.device.pms.service.majornetwork;
|
|
||||||
|
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TransientPmsService
|
|
||||||
*
|
|
||||||
* @author qijian
|
|
||||||
* @version 1.0.0
|
|
||||||
* @createTime 2022/12/14 - 15:09
|
|
||||||
*/
|
|
||||||
public interface TransientPmsService {
|
|
||||||
/**
|
|
||||||
* 功能描述: 暂态事件波形分析
|
|
||||||
* @param timeId
|
|
||||||
* @param lineId
|
|
||||||
* @param lineType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
WaveDataDTO getTransientAnalyseWavePms(String timeId, String lineId, Integer lineType);
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package com.njcn.device.pms.service.majornetwork.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.njcn.common.config.GeneralInfo;
|
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
|
||||||
import com.njcn.common.utils.PubUtils;
|
|
||||||
import com.njcn.common.utils.wave.AnalyWave;
|
|
||||||
import com.njcn.device.pms.api.DistributionMonitorClient;
|
|
||||||
import com.njcn.device.pms.api.MonitorClient;
|
|
||||||
import com.njcn.device.pms.mapper.majornetwork.DistributionMonitorMapper;
|
|
||||||
import com.njcn.device.pms.mapper.majornetwork.MonitorMapper;
|
|
||||||
import com.njcn.device.pms.mapper.majornetwork.TerminalMapper;
|
|
||||||
import com.njcn.device.pms.pojo.po.DistributionMonitor;
|
|
||||||
import com.njcn.device.pms.pojo.po.Monitor;
|
|
||||||
import com.njcn.device.pms.pojo.po.PmsTerminal;
|
|
||||||
import com.njcn.device.pms.service.majornetwork.EventDetailPmsService;
|
|
||||||
import com.njcn.device.pms.service.majornetwork.IMonitorService;
|
|
||||||
import com.njcn.device.pms.service.majornetwork.TransientPmsService;
|
|
||||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
|
||||||
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
|
||||||
import com.njcn.event.enums.EventResponseEnum;
|
|
||||||
import com.njcn.event.pojo.param.TransientParam;
|
|
||||||
import com.njcn.event.pojo.param.WaveFileParam;
|
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
|
||||||
import com.njcn.event.pojo.po.EventDetailNew;
|
|
||||||
import com.njcn.event.pojo.vo.TransientVO;
|
|
||||||
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
|
||||||
import com.njcn.system.enums.DicDataTypeEnum;
|
|
||||||
import com.njcn.system.pojo.po.DictData;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.*;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/03/29 14:37
|
|
||||||
* @Description: <描述>
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class TransientPmsServiceImpl implements TransientPmsService {
|
|
||||||
|
|
||||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
|
||||||
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
|
||||||
|
|
||||||
private final EventDetailPmsService eventDetailPmsService;
|
|
||||||
|
|
||||||
private final GeneralInfo generalInfo;
|
|
||||||
|
|
||||||
private final DistributionMonitorMapper distributionMonitorMapper;
|
|
||||||
|
|
||||||
private final MonitorMapper monitorMapper;
|
|
||||||
|
|
||||||
private final TerminalMapper terminalMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WaveDataDTO getTransientAnalyseWavePms(String timeId, String lineId,Integer lineType) {
|
|
||||||
//初始化
|
|
||||||
WaveDataDTO waveDataDTO;
|
|
||||||
PmsTerminal pmsTerminal;
|
|
||||||
DictData dictData;
|
|
||||||
String ip = null;
|
|
||||||
String ptTypeName = null;
|
|
||||||
Float pt1 = null;
|
|
||||||
Float pt2 = null;
|
|
||||||
Float ct1 = null;
|
|
||||||
Float ct2 = null;
|
|
||||||
|
|
||||||
//根据监测点id获取信息(1主网 2配网)
|
|
||||||
if (lineType == 1){
|
|
||||||
Monitor monitor = monitorMapper.selectById(lineId);
|
|
||||||
//获取ip
|
|
||||||
pmsTerminal = terminalMapper.selectById(monitor.getTerminalId());
|
|
||||||
ip = pmsTerminal.getIp();
|
|
||||||
//获取接线方式
|
|
||||||
dictData = dicDataFeignClient.getDicDataById(monitor.getTerminalWiringMethod()).getData();
|
|
||||||
ptTypeName = dictData.getName();
|
|
||||||
//获取pt、ct
|
|
||||||
pt1 = monitor.getPt1();
|
|
||||||
pt2 = monitor.getPt1();
|
|
||||||
ct1 = monitor.getCt1();
|
|
||||||
ct2 = monitor.getCt2();
|
|
||||||
}else{
|
|
||||||
DistributionMonitor distributionMonitor = distributionMonitorMapper.selectById(lineId);
|
|
||||||
//获取ip
|
|
||||||
pmsTerminal = terminalMapper.selectById(distributionMonitor.getTerminalId());
|
|
||||||
ip = pmsTerminal.getIp();
|
|
||||||
//获取接线方式
|
|
||||||
dictData = dicDataFeignClient.getDicDataById(distributionMonitor.getTerminalWiringMethod()).getData();
|
|
||||||
ptTypeName = dictData.getName();
|
|
||||||
//获取pt、ct
|
|
||||||
pt1 = distributionMonitor.getPt1();
|
|
||||||
pt2 = distributionMonitor.getPt1();
|
|
||||||
ct1 = distributionMonitor.getCt1();
|
|
||||||
ct2 = distributionMonitor.getCt2();
|
|
||||||
}
|
|
||||||
|
|
||||||
EventDetail eventDetailByTime = eventDetailPmsService.getEventDetailByTime(lineId, timeId);
|
|
||||||
String waveName = eventDetailByTime.getWaveName();
|
|
||||||
|
|
||||||
AnalyWave analyWave = new AnalyWave();
|
|
||||||
WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
|
||||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
waveDataDTO = analyWave.getValidData(comtrade);
|
|
||||||
waveDataDTO.setPtType(PubUtils.ptTypeName(ptTypeName));
|
|
||||||
waveDataDTO.setPt((double) (pt1 / pt2));
|
|
||||||
waveDataDTO.setCt((double) (ct1 / ct2));
|
|
||||||
return waveDataDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,9 @@ public enum EventResponseEnum {
|
|||||||
EVENT_COMMON_ERROR("A00650","暂降模块异常"),
|
EVENT_COMMON_ERROR("A00650","暂降模块异常"),
|
||||||
EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"),
|
EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"),
|
||||||
ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到"),
|
ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到"),
|
||||||
|
WAVE_DATA_INVALID("A00654","波形文件数据缺失"),
|
||||||
|
DAT_DATA_ERROR("A00653","dat文件数据读取失败"),
|
||||||
|
RMS_DATA_ERROR("A00653","rms数据读取失败"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -41,6 +40,11 @@ public class ComtradeCfgDTO implements Serializable {
|
|||||||
// 最终采样率,计算的时候只用一个采样率
|
// 最终采样率,计算的时候只用一个采样率
|
||||||
private Long finalSampleRate;
|
private Long finalSampleRate;
|
||||||
// 整个波形大小
|
// 整个波形大小
|
||||||
private Long nAllWaveNum = 0l;
|
private Long nAllWaveNum = 0L;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 赋值编码格式(二进制)
|
||||||
|
*/
|
||||||
|
private String strBinType;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yxb
|
* @author yxb
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.common.pojo.dto.wave;
|
package com.njcn.event.pojo.dto.wave;
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.njcn.event.pojo.po;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/06/28 19:41
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Component
|
|
||||||
public class WavePath {
|
|
||||||
|
|
||||||
|
|
||||||
@Value("${business.wavePath}")
|
|
||||||
private String wavePath;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -72,6 +72,18 @@
|
|||||||
<artifactId>pq-device-api</artifactId>
|
<artifactId>pq-device-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>huawei-obs-springboot-starter</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okio</groupId>
|
||||||
|
<artifactId>okio</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.njcn.event.controller.majornetwork;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
@@ -202,24 +201,6 @@ public class MonitorPointController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*监测点事件波形分析
|
|
||||||
* @author zbj
|
|
||||||
* @date 2022/7/27
|
|
||||||
*/
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getMonitorEventAnalyseWave")
|
|
||||||
@ApiOperation("监测点事件波形分析")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "timeId", value = "时间Id", required = true),
|
|
||||||
@ApiImplicitParam(name = "lineId", value = "监测点Id", required = true)
|
|
||||||
})
|
|
||||||
public HttpResult<WaveDataDTO> getMonitorEventAnalyseWave(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId){
|
|
||||||
String methodDescribe = getMethodDescribe("getMonitorEventAnalyseWave");
|
|
||||||
WaveDataDTO wave = eventAnalysisService.getMonitorEventAnalyseWave(timeId, lineId);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*监测点事件波形下载
|
*监测点事件波形下载
|
||||||
* @author zbj
|
* @author zbj
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package com.njcn.event.controller.majornetwork;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.event.pojo.param.TransientParam;
|
import com.njcn.event.pojo.param.TransientParam;
|
||||||
import com.njcn.event.pojo.param.WaveFileParam;
|
import com.njcn.event.pojo.param.WaveFileParam;
|
||||||
import com.njcn.event.pojo.po.EventDetailNew;
|
import com.njcn.event.pojo.po.EventDetailNew;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.event.service.majornetwork;
|
package com.njcn.event.service.majornetwork;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.event.pojo.param.*;
|
import com.njcn.event.pojo.param.*;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
import com.njcn.event.pojo.vo.*;
|
import com.njcn.event.pojo.vo.*;
|
||||||
@@ -82,12 +82,7 @@ public interface EventAnalysisService {
|
|||||||
*/
|
*/
|
||||||
Page<WaveTypeVO> getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam);
|
Page<WaveTypeVO> getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam);
|
||||||
|
|
||||||
/**
|
|
||||||
*监测点事件波形分析
|
|
||||||
* @author zbj
|
|
||||||
* @date 2022/7/27
|
|
||||||
*/
|
|
||||||
WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*监测点事件波形下载
|
*监测点事件波形下载
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.common.utils.wave.AnalyWave;
|
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||||
import com.njcn.event.enums.EventResponseEnum;
|
import com.njcn.event.enums.EventResponseEnum;
|
||||||
import com.njcn.event.pojo.constant.Param;
|
import com.njcn.event.pojo.constant.Param;
|
||||||
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.event.pojo.param.*;
|
import com.njcn.event.pojo.param.*;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
import com.njcn.event.pojo.po.EventDetailNew;
|
import com.njcn.event.pojo.po.EventDetailNew;
|
||||||
@@ -1627,55 +1626,6 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 监测点事件波形分析
|
|
||||||
*
|
|
||||||
* @author zbj
|
|
||||||
* @date 2022/7/27
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId) {
|
|
||||||
WaveDataDTO waveDataDTO = new WaveDataDTO();
|
|
||||||
//根据监测点id获取监测点详情
|
|
||||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData();
|
|
||||||
EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId);
|
|
||||||
|
|
||||||
//暂时没有进行拼接
|
|
||||||
String ip = lineDetailData.getIp();
|
|
||||||
String waveName = eventDetailByTime.getWaveName();
|
|
||||||
/* if(StrUtil.isBlank(waveName)){
|
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
AnalyWave analyWave = new AnalyWave();
|
|
||||||
|
|
||||||
|
|
||||||
/*WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
|
||||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//测试用的本地路径
|
|
||||||
WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\CDF\\Desktop\\00-B7-8D-00-E7-15\\1_20220204_125513_383.cfg", 1);
|
|
||||||
|
|
||||||
|
|
||||||
waveDataDTO = analyWave.getValidData(comtrade);
|
|
||||||
|
|
||||||
|
|
||||||
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
|
||||||
double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]);
|
|
||||||
double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]);
|
|
||||||
double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]);
|
|
||||||
double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]);
|
|
||||||
|
|
||||||
waveDataDTO.setPt(pt1 / pt2);
|
|
||||||
waveDataDTO.setCt(ct1 / ct2);
|
|
||||||
|
|
||||||
|
|
||||||
return waveDataDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class EventDetailServiceImpl implements EventDetailService {
|
|||||||
}
|
}
|
||||||
stringBuilder.append(") order by time desc");
|
stringBuilder.append(") order by time desc");
|
||||||
int i = (pageNum - 1)*pageSize;
|
int i = (pageNum - 1)*pageSize;
|
||||||
stringBuilder.append("LIMIT ").append(pageSize).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')");
|
stringBuilder.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')");
|
||||||
//sql语句
|
//sql语句
|
||||||
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
|
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
|
||||||
System.out.println(sql);
|
System.out.println(sql);
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
import com.njcn.common.pojo.constant.GeneralConstant;
|
||||||
|
import com.njcn.common.pojo.constant.OssPath;
|
||||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.common.utils.wave.AnalyWave;
|
|
||||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
@@ -17,6 +17,7 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
|||||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||||
import com.njcn.event.enums.EventResponseEnum;
|
import com.njcn.event.enums.EventResponseEnum;
|
||||||
import com.njcn.event.mapper.majornetwork.TransientMapper;
|
import com.njcn.event.mapper.majornetwork.TransientMapper;
|
||||||
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.event.pojo.param.TransientParam;
|
import com.njcn.event.pojo.param.TransientParam;
|
||||||
import com.njcn.event.pojo.param.WaveFileParam;
|
import com.njcn.event.pojo.param.WaveFileParam;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
@@ -24,6 +25,8 @@ import com.njcn.event.pojo.po.EventDetailNew;
|
|||||||
import com.njcn.event.pojo.vo.TransientVO;
|
import com.njcn.event.pojo.vo.TransientVO;
|
||||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||||
import com.njcn.event.service.majornetwork.TransientService;
|
import com.njcn.event.service.majornetwork.TransientService;
|
||||||
|
import com.njcn.event.utils.WaveUtil;
|
||||||
|
import com.njcn.huawei.obs.util.OBSUtil;
|
||||||
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
||||||
@@ -75,6 +78,11 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
|
private final OBSUtil obsUtil;
|
||||||
|
|
||||||
|
private final WaveUtil waveUtil;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
||||||
Page<TransientVO> page = new Page<>();
|
Page<TransientVO> page = new Page<>();
|
||||||
@@ -86,7 +94,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
||||||
if (!CollectionUtils.isEmpty(deviceList)) {
|
if (!CollectionUtils.isEmpty(deviceList)) {
|
||||||
//获取按终端分类的监测点索引集合
|
//获取按终端分类的监测点索引集合
|
||||||
List<String> LineIndexes = deviceList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList());
|
List<String> LineIndexes = deviceList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(LineIndexes)) {
|
if (!CollectionUtils.isEmpty(LineIndexes)) {
|
||||||
//influxDB查询待分页数据总量
|
//influxDB查询待分页数据总量
|
||||||
@@ -96,7 +104,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
int pages = (int) Math.ceil(data.size() * 1.0 / transientParam.getPageSize());
|
int pages = (int) Math.ceil(data.size() * 1.0 / transientParam.getPageSize());
|
||||||
page.setPages(pages);*/
|
page.setPages(pages);*/
|
||||||
//influxDB分页查询
|
//influxDB分页查询
|
||||||
List<EventDetail> eventDetailData = eventDetailService.getEventDetailLimit(LineIndexes, transientParam.getSearchBeginTime(), transientParam.getSearchEndTime(), transientParam.getPageSize(), transientParam.getPageNum(),transientParam.getWaveType());
|
List<EventDetail> eventDetailData = eventDetailService.getEventDetailLimit(LineIndexes, transientParam.getSearchBeginTime(), transientParam.getSearchEndTime(), transientParam.getPageSize(), transientParam.getPageNum(), transientParam.getWaveType());
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(eventDetailData)) {
|
if (!CollectionUtils.isEmpty(eventDetailData)) {
|
||||||
List<String> lineIds = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
List<String> lineIds = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
||||||
@@ -168,23 +176,47 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
@Override
|
@Override
|
||||||
public WaveDataDTO getTransientAnalyseWave(String timeId, String lineId) {
|
public WaveDataDTO getTransientAnalyseWave(String timeId, String lineId) {
|
||||||
WaveDataDTO waveDataDTO;
|
WaveDataDTO waveDataDTO;
|
||||||
|
//原始数据
|
||||||
|
WaveDataDTO originalData;
|
||||||
//根据监测点id获取监测点详情
|
//根据监测点id获取监测点详情
|
||||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData();
|
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData();
|
||||||
EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId);
|
EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId);
|
||||||
String ip = lineDetailData.getIp();
|
String ip = lineDetailData.getIp();
|
||||||
String waveName = eventDetailByTime.getWaveName();
|
String waveName = eventDetailByTime.getWaveName();
|
||||||
AnalyWave analyWave = new AnalyWave();
|
String cfgPath, datPath;
|
||||||
// 从本地读取该事件的波形
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||||
WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
||||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
InputStream cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath);
|
||||||
|
InputStream datStream = waveUtil.getFileInputStreamByFilePath(datPath);
|
||||||
|
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||||
|
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
|
||||||
|
// } else if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
|
} else {
|
||||||
|
ip = "192.168.1.190";
|
||||||
|
waveName = "PQMonitor_PQM1_002438_20210508_092859_938";
|
||||||
|
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||||
|
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||||
|
try (
|
||||||
|
InputStream cfgStream = obsUtil.fileDownload(cfgPath);
|
||||||
|
InputStream datStream = obsUtil.fileDownload(datPath)
|
||||||
|
) {
|
||||||
|
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||||
|
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
waveDataDTO = analyWave.getValidData(comtrade);
|
waveDataDTO = waveUtil.getValidData(originalData);
|
||||||
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
||||||
double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]);
|
double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]);
|
||||||
double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]);
|
double pt2 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[1]);
|
||||||
double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]);
|
double ct1 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[0]);
|
||||||
double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]);
|
double ct2 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[1]);
|
||||||
waveDataDTO.setPt(pt1 / pt2);
|
waveDataDTO.setPt(pt1 / pt2);
|
||||||
waveDataDTO.setCt(ct1 / ct2);
|
waveDataDTO.setCt(ct1 / ct2);
|
||||||
return waveDataDTO;
|
return waveDataDTO;
|
||||||
@@ -227,7 +259,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EventDetailNew> getTransientValue(TransientParam transientParam){
|
public Page<EventDetailNew> getTransientValue(TransientParam transientParam) {
|
||||||
Page<EventDetailNew> page = new Page<>();
|
Page<EventDetailNew> page = new Page<>();
|
||||||
page.setSize(transientParam.getPageSize());
|
page.setSize(transientParam.getPageSize());
|
||||||
page.setCurrent(transientParam.getPageNum());
|
page.setCurrent(transientParam.getPageNum());
|
||||||
@@ -241,7 +273,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
if (!CollectionUtils.isEmpty(lineList)) {
|
if (!CollectionUtils.isEmpty(lineList)) {
|
||||||
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineList);
|
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineList);
|
||||||
//influxDB查询待分页数据总量
|
//influxDB查询待分页数据总量
|
||||||
Long total = getTransientDetail(stringBuilder,transientParam);
|
Long total = getTransientDetail(stringBuilder, transientParam);
|
||||||
page.setTotal(total);
|
page.setTotal(total);
|
||||||
//分页总页数
|
//分页总页数
|
||||||
int pages = (int) Math.ceil(transientParam.getPageNum() * 1.0 / transientParam.getPageSize());
|
int pages = (int) Math.ceil(transientParam.getPageNum() * 1.0 / transientParam.getPageSize());
|
||||||
@@ -259,8 +291,8 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
|
|
||||||
|
|
||||||
for (EventDetailNew eventDetail : eventDetailData) {
|
for (EventDetailNew eventDetail : eventDetailData) {
|
||||||
for(AreaLineInfoVO areaLineInfoVO : r){
|
for (AreaLineInfoVO areaLineInfoVO : r) {
|
||||||
if(eventDetail.getLineId().equals(areaLineInfoVO.getLineId())){
|
if (eventDetail.getLineId().equals(areaLineInfoVO.getLineId())) {
|
||||||
eventDetail.setLineId(areaLineInfoVO.getLineId());
|
eventDetail.setLineId(areaLineInfoVO.getLineId());
|
||||||
eventDetail.setLineName(areaLineInfoVO.getLineName());
|
eventDetail.setLineName(areaLineInfoVO.getLineName());
|
||||||
eventDetail.setGdName(areaLineInfoVO.getGdName());
|
eventDetail.setGdName(areaLineInfoVO.getGdName());
|
||||||
@@ -301,22 +333,22 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
/**
|
/**
|
||||||
* 查询数据库
|
* 查询数据库
|
||||||
*/
|
*/
|
||||||
private Long getTransientDetail(StringBuilder stringBuilder,TransientParam transientParam) {
|
private Long getTransientDetail(StringBuilder stringBuilder, TransientParam transientParam) {
|
||||||
Long total = 0L;
|
Long total = 0L;
|
||||||
//组装sql语句
|
//组装sql语句
|
||||||
stringBuilder.append(" and time >= '").append(DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(transientParam.getSearchEndTime()))).append("'").append(InfluxDBPublicParam.TIME_ZONE);
|
stringBuilder.append(" and time >= '").append(DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(transientParam.getSearchEndTime()))).append("'").append(InfluxDBPublicParam.TIME_ZONE);
|
||||||
//sql语句
|
//sql语句
|
||||||
String sql = "SELECT count(wave_type) FROM pqs_eventdetail WHERE " + stringBuilder;
|
String sql = "SELECT count(wave_type) FROM pqs_eventdetail WHERE " + stringBuilder;
|
||||||
System.out.println("sql------------->>>"+sql);
|
System.out.println("sql------------->>>" + sql);
|
||||||
//结果集
|
//结果集
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
QueryResult result = influxDbUtils.query(sql);
|
||||||
//结果集映射到对象中
|
//结果集映射到对象中
|
||||||
List<QueryResult.Series> series = result.getResults().get(0).getSeries();
|
List<QueryResult.Series> series = result.getResults().get(0).getSeries();
|
||||||
if(CollUtil.isNotEmpty(series)){
|
if (CollUtil.isNotEmpty(series)) {
|
||||||
Double tem =(Double)series.get(0).getValues().get(0).get(1);
|
Double tem = (Double) series.get(0).getValues().get(0).get(1);
|
||||||
total = tem.longValue();
|
total = tem.longValue();
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,31 +357,31 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
private List<EventDetailNew> getTransientDetailLimit(List<String> lineIndexes, TransientParam transientParam) {
|
private List<EventDetailNew> getTransientDetailLimit(List<String> lineIndexes, TransientParam transientParam) {
|
||||||
//查询数据是否为空,不为空拼接sql语句
|
//查询数据是否为空,不为空拼接sql语句
|
||||||
StringBuilder querySql = new StringBuilder();
|
StringBuilder querySql = new StringBuilder();
|
||||||
if(Objects.nonNull(transientParam.getEventValueMin())){
|
if (Objects.nonNull(transientParam.getEventValueMin())) {
|
||||||
querySql.append(" and event_value >=").append(transientParam.getEventValueMin());
|
querySql.append(" and event_value >=").append(transientParam.getEventValueMin());
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(transientParam.getEventValueMax())){
|
if (Objects.nonNull(transientParam.getEventValueMax())) {
|
||||||
querySql.append(" and event_value <=").append(transientParam.getEventValueMax());
|
querySql.append(" and event_value <=").append(transientParam.getEventValueMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Objects.nonNull(transientParam.getPersistMin())){
|
if (Objects.nonNull(transientParam.getPersistMin())) {
|
||||||
querySql.append(" and persist_time >=").append(transientParam.getPersistMin());
|
querySql.append(" and persist_time >=").append(transientParam.getPersistMin());
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(transientParam.getEventValueMax())){
|
if (Objects.nonNull(transientParam.getEventValueMax())) {
|
||||||
querySql.append(" and persist_time <=").append(transientParam.getPersistMax());
|
querySql.append(" and persist_time <=").append(transientParam.getPersistMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Objects.nonNull(transientParam.getSeverityMin())){
|
if (Objects.nonNull(transientParam.getSeverityMin())) {
|
||||||
querySql.append(" and severity >=").append(transientParam.getSeverityMin());
|
querySql.append(" and severity >=").append(transientParam.getSeverityMin());
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(transientParam.getSeverityMax())){
|
if (Objects.nonNull(transientParam.getSeverityMax())) {
|
||||||
querySql.append(" and severity <=").append(transientParam.getSeverityMax());
|
querySql.append(" and severity <=").append(transientParam.getSeverityMax());
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(transientParam.getFileFlag())){
|
if (Objects.nonNull(transientParam.getFileFlag())) {
|
||||||
querySql.append(" and file_flag = ").append(transientParam.getFileFlag());
|
querySql.append(" and file_flag = ").append(transientParam.getFileFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CollUtil.isNotEmpty(transientParam.getWaveType())) {
|
if (CollUtil.isNotEmpty(transientParam.getWaveType())) {
|
||||||
querySql.append(" and ( ");
|
querySql.append(" and ( ");
|
||||||
for (int i = 0; i < transientParam.getWaveType().size(); i++) {
|
for (int i = 0; i < transientParam.getWaveType().size(); i++) {
|
||||||
if (transientParam.getWaveType().size() - i != 1) {
|
if (transientParam.getWaveType().size() - i != 1) {
|
||||||
@@ -359,7 +391,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CollUtil.isNotEmpty(transientParam.getEventReason())) {
|
if (CollUtil.isNotEmpty(transientParam.getEventReason())) {
|
||||||
querySql.append(" and ( ");
|
querySql.append(" and ( ");
|
||||||
for (int i = 0; i < transientParam.getEventReason().size(); i++) {
|
for (int i = 0; i < transientParam.getEventReason().size(); i++) {
|
||||||
if (transientParam.getWaveType().size() - i != 1) {
|
if (transientParam.getWaveType().size() - i != 1) {
|
||||||
@@ -369,7 +401,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CollUtil.isNotEmpty(transientParam.getEventType())) {
|
if (CollUtil.isNotEmpty(transientParam.getEventType())) {
|
||||||
querySql.append(" and ( ");
|
querySql.append(" and ( ");
|
||||||
for (int i = 0; i < transientParam.getEventType().size(); i++) {
|
for (int i = 0; i < transientParam.getEventType().size(); i++) {
|
||||||
if (transientParam.getEventType().size() - i != 1) {
|
if (transientParam.getEventType().size() - i != 1) {
|
||||||
@@ -393,8 +425,8 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("') ");
|
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("') ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i = (transientParam.getPageNum() - 1)*transientParam.getPageSize();
|
int i = (transientParam.getPageNum() - 1) * transientParam.getPageSize();
|
||||||
stringBuilder.append("LIMIT ").append(transientParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')");
|
stringBuilder.append(" LIMIT ").append(transientParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')");
|
||||||
//sql语句
|
//sql语句
|
||||||
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
|
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.event.service.majornetwork;
|
package com.njcn.event.service.majornetwork;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.event.pojo.param.TransientParam;
|
import com.njcn.event.pojo.param.TransientParam;
|
||||||
import com.njcn.event.pojo.param.WaveFileParam;
|
import com.njcn.event.pojo.param.WaveFileParam;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.njcn.event.utils;
|
||||||
|
|
||||||
|
public class BitConverter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* byte数组转换为无符号short整数
|
||||||
|
* @param bytes byte数组
|
||||||
|
* @param off 开始位置
|
||||||
|
* @return short整数
|
||||||
|
*/
|
||||||
|
public static short byte2ToUnsignedShort(byte[] bytes, int off) {
|
||||||
|
int low = bytes[off]& 0xFF;
|
||||||
|
int high = bytes[off + 1]& 0xFF;
|
||||||
|
return (short)(((high & 0x00FF) << 8) | (0x00FF & low));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字节转换为浮点
|
||||||
|
*
|
||||||
|
* @param b 字节(至少4个字节)
|
||||||
|
* @param index 开始位置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static float byte4float(byte[] b, int index) {
|
||||||
|
/* b=new byte[4];
|
||||||
|
b[0]=-16;
|
||||||
|
b[1]=-1;
|
||||||
|
b[2]=117;
|
||||||
|
b[3]=66;*/
|
||||||
|
|
||||||
|
int l;
|
||||||
|
l = b[index + 0];
|
||||||
|
l &= 0xff;
|
||||||
|
l |= ((long) b[index + 1] << 8);
|
||||||
|
l &= 0xffff;
|
||||||
|
l |= ((long) b[index + 2] << 16);
|
||||||
|
l &= 0xffffff;
|
||||||
|
l |= ((long) b[index + 3] << 24);
|
||||||
|
return Float.intBitsToFloat(l);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* byte数组转换为int32整数
|
||||||
|
* @param bytes byte数组
|
||||||
|
* @param off 开始位置
|
||||||
|
* @return int整数
|
||||||
|
*/
|
||||||
|
public static int byte4ToInt(byte[] bytes, int off) {
|
||||||
|
int b0 = bytes[off] & 0xFF;
|
||||||
|
int b1 = bytes[off + 1] & 0xFF;
|
||||||
|
int b2 = bytes[off + 2] & 0xFF;
|
||||||
|
int b3 = bytes[off + 3] & 0xFF;
|
||||||
|
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* byte数组转换为int16整数
|
||||||
|
* @param bytes byte数组
|
||||||
|
* @param off 开始位置
|
||||||
|
* @return int整数
|
||||||
|
*/
|
||||||
|
public static int byte2ToInt(byte[] bytes, int off) {
|
||||||
|
int b0 = bytes[off] & 0xFF;
|
||||||
|
int b1 = bytes[off + 1] & 0xFF;
|
||||||
|
return (b1 << 8) | b0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* byte数组转换为int16整数
|
||||||
|
* @param bytes byte数组
|
||||||
|
* @param off 开始位置
|
||||||
|
* @return int整数
|
||||||
|
*/
|
||||||
|
public static long byte4ToLong(byte[] bytes, int off) {
|
||||||
|
long b0 = bytes[off] & 0xFF;
|
||||||
|
long b1 = bytes[off + 1] & 0xFF;
|
||||||
|
long b2 = bytes[off + 2] & 0xFF;
|
||||||
|
long b3 = bytes[off + 3] & 0xFF;
|
||||||
|
|
||||||
|
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -44,3 +44,4 @@ mybatis-plus:
|
|||||||
type-aliases-package: com.njcn.event.pojo
|
type-aliases-package: com.njcn.event.pojo
|
||||||
mqtt:
|
mqtt:
|
||||||
client-id: @artifactId@${random.value}
|
client-id: @artifactId@${random.value}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package com.njcn.event;
|
package com.njcn.event;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.OssPath;
|
||||||
|
import com.njcn.event.enums.EventResponseEnum;
|
||||||
import com.njcn.event.pojo.PqsEventDetail;
|
import com.njcn.event.pojo.PqsEventDetail;
|
||||||
import com.njcn.event.pojo.PqsOnlinerateAggregate;
|
import com.njcn.event.pojo.PqsOnlinerateAggregate;
|
||||||
import com.njcn.event.pojo.PqsEventDetailCount;
|
import com.njcn.event.pojo.PqsEventDetailCount;
|
||||||
|
import com.njcn.event.pojo.dto.wave.EigenvalueDTO;
|
||||||
|
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||||
|
import com.njcn.event.utils.WaveUtil;
|
||||||
|
import com.njcn.huawei.obs.util.OBSUtil;
|
||||||
import com.njcn.influxdb.config.InfluxDbConfig;
|
import com.njcn.influxdb.config.InfluxDbConfig;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||||
import org.influxdb.dto.QueryResult;
|
import org.influxdb.dto.QueryResult;
|
||||||
@@ -20,8 +26,14 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL;
|
import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL;
|
||||||
@@ -39,79 +51,85 @@ public class EventBootApplicationTest {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InfluxDbUtils influxDbUtils;
|
private InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WaveUtil waveUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OBSUtil obsUtil;
|
||||||
|
|
||||||
// TODO https://github.com/influxdata/influxdb-java/blob/master/QUERY_BUILDER.md
|
// TODO https://github.com/influxdata/influxdb-java/blob/master/QUERY_BUILDER.md
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryList() {
|
public void queryList() {
|
||||||
// or 条件数据
|
// or 条件数据
|
||||||
List<Clause> clauses = getClauses();
|
List<Clause> clauses = getClauses();
|
||||||
|
|
||||||
SelectQueryImpl selectQuery = select().column("line_id").column("eventass_index").from(influxDbConfig.getDatabase(), PQS_EVENT_DETAIL);
|
SelectQueryImpl selectQuery = select().column("line_id").column("eventass_index").from(influxDbConfig.getDatabase(), PQS_EVENT_DETAIL);
|
||||||
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
|
|
||||||
// WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后()
|
// WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后()
|
||||||
whereAndNested(clauses, where);
|
whereAndNested(clauses, where);
|
||||||
|
|
||||||
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
||||||
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
||||||
where.tz("Asia/Shanghai");
|
where.tz("Asia/Shanghai");
|
||||||
|
|
||||||
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||||
List<PqsEventDetail> re = influxDBResultMapper.toPOJO(result, PqsEventDetail.class);
|
List<PqsEventDetail> re = influxDBResultMapper.toPOJO(result, PqsEventDetail.class);
|
||||||
Assert.assertTrue(re.size() > 0);
|
Assert.assertTrue(re.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryCount() {
|
public void queryCount() {
|
||||||
// or 条件数据
|
// or 条件数据
|
||||||
List<Clause> clauses = getClauses();
|
List<Clause> clauses = getClauses();
|
||||||
|
|
||||||
SelectQueryImpl selectQuery = select().count("eventass_index").from(influxDbConfig.getDatabase(), PQS_EVENT_DETAIL);
|
SelectQueryImpl selectQuery = select().count("eventass_index").from(influxDbConfig.getDatabase(), PQS_EVENT_DETAIL);
|
||||||
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
|
|
||||||
// WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后()
|
// WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后()
|
||||||
whereAndNested(clauses, where);
|
whereAndNested(clauses, where);
|
||||||
|
|
||||||
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
||||||
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
||||||
where.tz("Asia/Shanghai");
|
where.tz("Asia/Shanghai");
|
||||||
|
|
||||||
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||||
List<PqsEventDetailCount> re = influxDBResultMapper.toPOJO(result, PqsEventDetailCount.class);
|
List<PqsEventDetailCount> re = influxDBResultMapper.toPOJO(result, PqsEventDetailCount.class);
|
||||||
Assert.assertTrue(re.size() > 0);
|
Assert.assertTrue(re.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryAggregate() {
|
public void queryAggregate() {
|
||||||
|
|
||||||
// SELECT (SUM(onlinemin) / (SUM(onlinemin) + SUM(offlinemin))) * 100 FROM pqs_onlinerate
|
// SELECT (SUM(onlinemin) / (SUM(onlinemin) + SUM(offlinemin))) * 100 FROM pqs_onlinerate
|
||||||
SelectionQueryImpl select = select();
|
SelectionQueryImpl select = select();
|
||||||
SelectionQueryImpl sum = select.op(op(sum("onlinemin"), "/", op(sum("onlinemin"), "+", sum("offlinemin"))), "*", 100)
|
SelectionQueryImpl sum = select.op(op(sum("onlinemin"), "/", op(sum("onlinemin"), "+", sum("offlinemin"))), "*", 100)
|
||||||
.as("value");
|
.as("value");
|
||||||
SelectQueryImpl selectQuery = sum.from(influxDbConfig.getDatabase(), "pqs_onlinerate");
|
SelectQueryImpl selectQuery = sum.from(influxDbConfig.getDatabase(), "pqs_onlinerate");
|
||||||
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
|
|
||||||
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
// AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai');
|
||||||
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z"));
|
||||||
where.tz("Asia/Shanghai");
|
where.tz("Asia/Shanghai");
|
||||||
|
|
||||||
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
QueryResult result = influxDbUtils.query(selectQuery.getCommand());
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||||
List<PqsOnlinerateAggregate> re = influxDBResultMapper.toPOJO(result, PqsOnlinerateAggregate.class);
|
List<PqsOnlinerateAggregate> re = influxDBResultMapper.toPOJO(result, PqsOnlinerateAggregate.class);
|
||||||
Assert.assertTrue(re.size() > 0);
|
Assert.assertTrue(re.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Clause> getClauses() {
|
private List<Clause> getClauses() {
|
||||||
Clause c1 = eq("line_id", "5e467a40023b299070682eb21f2ec9a1");
|
Clause c1 = eq("line_id", "5e467a40023b299070682eb21f2ec9a1");
|
||||||
Clause c2 = eq("line_id", "183245996f303ebfd80eeb3377cecdc2");
|
Clause c2 = eq("line_id", "183245996f303ebfd80eeb3377cecdc2");
|
||||||
Clause c3 = eq("line_id", "0d46f54420246e999d5c68b3133f668c");
|
Clause c3 = eq("line_id", "0d46f54420246e999d5c68b3133f668c");
|
||||||
|
|
||||||
return Arrays.asList(c1, c2, c3);
|
return Arrays.asList(c1, c2, c3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void whereAndNested(List<Clause> clauses, WhereQueryImpl<SelectQueryImpl> whereQuery) {
|
private void whereAndNested(List<Clause> clauses, WhereQueryImpl<SelectQueryImpl> whereQuery) {
|
||||||
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
|
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
|
||||||
for (Clause clause : clauses) {
|
for (Clause clause : clauses) {
|
||||||
@@ -119,5 +137,29 @@ public class EventBootApplicationTest {
|
|||||||
}
|
}
|
||||||
andNested.close();
|
andNested.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHuaweiOBS() throws FileNotFoundException {
|
||||||
|
|
||||||
|
String cfgPath = OssPath.WAVE_DIR+"192.168.1.190/PQMonitor_PQM1_002438_20210508_092859_938.CFG";
|
||||||
|
String datPath = OssPath.WAVE_DIR+"192.168.1.190/PQMonitor_PQM1_002438_20210508_092859_938.DAT";
|
||||||
|
|
||||||
|
InputStream cfgStream =obsUtil.fileDownload(cfgPath);
|
||||||
|
InputStream datStream =obsUtil.fileDownload(datPath);
|
||||||
|
|
||||||
|
if(Objects.isNull(cfgStream) || Objects.isNull(datStream)){
|
||||||
|
throw new FileNotFoundException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取瞬时波形 //获取原始波形值
|
||||||
|
WaveDataDTO waveDataDTO = waveUtil.getComtrade(cfgStream,datStream, 1);
|
||||||
|
|
||||||
|
// 获取RMS波形
|
||||||
|
WaveDataDTO waveDataDTO1 = waveUtil.getValidData(waveDataDTO);
|
||||||
|
|
||||||
|
// 获取特征值
|
||||||
|
List<EigenvalueDTO> lstEigenvalueDTO = waveUtil.getEigenvalue(waveDataDTO, true);
|
||||||
|
System.out.println(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,13 @@
|
|||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--华为obs工具包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>huawei-obs-springboot-starter</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class Test1 extends BaseJunitTest{
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethod(){
|
public void testMethod(){
|
||||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils(influxDbConfig.getUserName(), influxDbConfig.getPassword(), influxDbConfig.getInfluxDBUrl(), influxDbConfig.getDatabase(), "");
|
InfluxDbUtils influxDBUtil = new InfluxDbUtils(influxDbConfig.getUser(), influxDbConfig.getPassword(), influxDbConfig.getUrl(), influxDbConfig.getDatabase(), "");
|
||||||
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(),"data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
|
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(),"data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
|
||||||
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
QueryResult queryResult = influxDBUtil.query(selectQuery.getCommand());
|
QueryResult queryResult = influxDBUtil.query(selectQuery.getCommand());
|
||||||
|
|||||||
Reference in New Issue
Block a user