高级算法 部分
This commit is contained in:
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.event.pojo.po.BalanceInfo;
|
||||
import com.njcn.event.pojo.vo.AreaLineVO;
|
||||
import com.njcn.event.pojo.vo.EventHeatMapVO;
|
||||
import com.njcn.event.pojo.vo.EventSeverityVO;
|
||||
@@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
@@ -106,5 +109,22 @@ public class AreaController extends BaseController {
|
||||
TerminalRunningStatisticsVO result = areaLineService.getTerminalRunningStatistics(deviceInfoParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取暂降严重度
|
||||
*
|
||||
* @param deviceInfoParam 参数
|
||||
* @return 结果
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getBalanceInfo")
|
||||
@ApiOperation("获取区域暂降综合评估")
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "参数", required = true)
|
||||
public HttpResult<List<BalanceInfo>> getBalanceInfo(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getBalanceInfo");
|
||||
LogUtil.njcnDebug(log, "{},参数为:{}", methodDescribe, deviceInfoParam);
|
||||
List<BalanceInfo> result = areaLineService.getBalanceInfo(deviceInfoParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.event.service;
|
||||
|
||||
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.event.pojo.po.BalanceInfo;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,4 +43,11 @@ public interface AreaLineService {
|
||||
*/
|
||||
TerminalRunningStatisticsVO getTerminalRunningStatistics(DeviceInfoParam.BusinessParam deviceInfoParam);
|
||||
|
||||
/**
|
||||
* 获取区域暂降综合评估
|
||||
* @param deviceInfoParam 参数
|
||||
* @return 结果
|
||||
*/
|
||||
List<BalanceInfo> getBalanceInfo(DeviceInfoParam.BusinessParam deviceInfoParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,19 +8,22 @@ import com.njcn.device.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.api.LineFeignClient;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.device.pojo.vo.LineDetailVO;
|
||||
import com.njcn.device.pojo.vo.LineDeviceStateVO;
|
||||
import com.njcn.device.pojo.vo.SubstationDetailVO;
|
||||
import com.njcn.event.influxdb.PqsOnlinerateQuery;
|
||||
import com.njcn.event.mapper.PqDeviceMapper;
|
||||
import com.njcn.event.pojo.po.PqDevice;
|
||||
import com.njcn.event.pojo.po.PqsOnlinerate;
|
||||
import com.njcn.event.pojo.po.*;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO;
|
||||
import com.njcn.event.service.AreaLineService;
|
||||
import com.njcn.event.service.EventDetailService;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||
import com.sun.org.apache.regexp.internal.RE;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
@@ -37,6 +40,8 @@ import java.util.stream.Collectors;
|
||||
import static com.njcn.event.influxdb.PqsOnlinerateQuery.devIdOr;
|
||||
import static com.njcn.event.influxdb.QueryBuilder.*;
|
||||
|
||||
import com.njcn.event.pojo.po.BalanceInfo.PointInfo;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
@@ -46,17 +51,19 @@ import static com.njcn.event.influxdb.QueryBuilder.*;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AreaLineServiceImpl implements AreaLineService {
|
||||
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
|
||||
private final PqsOnlinerateQuery pqsOnlinerateQuery;
|
||||
|
||||
|
||||
private final PqDeviceMapper pqDeviceMapper;
|
||||
|
||||
|
||||
private final EventDetailService eventDetailService;
|
||||
|
||||
@Override
|
||||
public AreaLineVO getAreaLineVO(DeviceInfoParam deviceInfoParam) {
|
||||
AreaLineVO areaLineVO = new AreaLineVO();
|
||||
@@ -78,7 +85,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
int stateZd = 0;
|
||||
// 总次数
|
||||
int tail = 0;
|
||||
|
||||
|
||||
String color = "";
|
||||
List<SubstationDetailVO> substationDetailVOS = new ArrayList<>();
|
||||
if (subIndexs.size() > 0) {
|
||||
@@ -104,7 +111,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
int stateFalse = 0;
|
||||
// 次数
|
||||
double r = 0.0035;
|
||||
|
||||
|
||||
int j = 0;
|
||||
// 总的监测点个数
|
||||
int lineTail = lineDataVOList.size();
|
||||
@@ -144,7 +151,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
areaLineVO.setAreaValue(listObject);
|
||||
return areaLineVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
EventHeatMapVO eventHeatMapVO = new EventHeatMapVO();
|
||||
@@ -183,7 +190,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
eventHeatMapVO.setEventHeatMapValue(eventHeatMapDetailList);
|
||||
return eventHeatMapVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EventSeverityVO getEventSeverity(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
EventSeverityVO eventSeverityVO = new EventSeverityVO();
|
||||
@@ -222,7 +229,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
eventSeverityVO.setEventSeverityValue(eventSeverityValueList);
|
||||
return eventSeverityVO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取终端运行统计
|
||||
*
|
||||
@@ -233,60 +240,99 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
public TerminalRunningStatisticsVO getTerminalRunningStatistics(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
// 区域计算
|
||||
TerminalRunningVO area = analyzeTerminalRun(deviceInfoParam);
|
||||
|
||||
|
||||
// 厂家计算
|
||||
deviceInfoParam.getStatisticalType().setCode(StatisticsEnum.MANUFACTURER.getCode());
|
||||
TerminalRunningVO factory = analyzeTerminalRun(deviceInfoParam);
|
||||
|
||||
|
||||
return TerminalRunningStatisticsVO.buildVO(area, factory);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<BalanceInfo> getBalanceInfo(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
List<BalanceInfo> balanceInfos = new ArrayList<>();
|
||||
//获取符合条件的监测点
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
|
||||
if (CollUtil.isEmpty(generalDeviceDTOList)) {
|
||||
return balanceInfos;
|
||||
}
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
BalanceInfo balanceInfo = new BalanceInfo();
|
||||
balanceInfo.setAreaName(generalDeviceDTO.getName());
|
||||
balanceInfo.setAreaIndex(generalDeviceDTO.getIndex());
|
||||
//监测点
|
||||
List<String> lineList = generalDeviceDTO.getLineIndexes();
|
||||
List<PointInfo> list = new ArrayList<>();
|
||||
for (String lineIndex : lineList) {
|
||||
PointInfo pointInfo = balanceInfo.new PointInfo();
|
||||
Float value = getSarfiValue(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.9f, lineIndex);
|
||||
pointInfo.getQtIdx().r_esm = (value == null ? 0f : value);
|
||||
pointInfo.getQtIdx().sarfi_90 = getSarfiCount(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.9f, lineIndex); // 统计小于0.9的总数
|
||||
pointInfo.getQtIdx().sarifi_50 = getSarfiCount(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.5f, lineIndex); // 统计小于0.9的总数 // 统计小于0.5的总数
|
||||
//获取当前监测点的暂降信息
|
||||
List<EventDetail> eventDetailList = getEventDetailInfo(lineIndex, 0.9f, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime());
|
||||
if(eventDetailList.size()>0) {
|
||||
//获取监测点信息
|
||||
LineDetailDataVO lineDetailVO = lineFeignClient.getLineDetailData(lineIndex).getData();
|
||||
List<Sarifi> sarifis = new ArrayList<>();
|
||||
for (EventDetail eventDetail:eventDetailList){
|
||||
Sarifi sarifi = new Sarifi();
|
||||
sarifi.setTime(eventDetail.getPersistTime().floatValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return balanceInfos;
|
||||
}
|
||||
|
||||
private TerminalRunningVO analyzeTerminalRun(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
|
||||
|
||||
|
||||
if (CollUtil.isEmpty(generalDeviceDTOList)) {
|
||||
return TerminalRunningVO.empty();
|
||||
}
|
||||
List<String> deviceIndexList =
|
||||
generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||
|
||||
|
||||
if (CollUtil.isEmpty(deviceIndexList)) {
|
||||
return TerminalRunningVO.empty();
|
||||
}
|
||||
|
||||
|
||||
List<PqsOnlinerate> pqsOnlinerateList =
|
||||
pqsOnlinerateQuery.selectList(Arrays.asList("dev_id", "offlinemin", "onlinemin"),
|
||||
devIdOr(deviceIndexList),
|
||||
timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime())));
|
||||
|
||||
|
||||
List<PqDevice> pqDeviceList = pqDeviceMapper.queryRunFlagByDeviceIndexs(deviceIndexList);
|
||||
|
||||
|
||||
List<TerminalRunningInfoVO> terminalRun = generalDeviceDTOList.parallelStream().map(dto -> {
|
||||
List<String> deviceIndexes = dto.getDeviceIndexes();
|
||||
|
||||
TerminalRunningInfoVO terminalRunningInfoVO = new TerminalRunningInfoVO();
|
||||
terminalRunningInfoVO.setAreaName(dto.getName());
|
||||
terminalRunningInfoVO.setNumberOfTerminals(deviceIndexes.size());
|
||||
terminalRunningInfoVO.setNormal(countDeviceRunStatus(pqDeviceList).apply(0, deviceIndexes));
|
||||
terminalRunningInfoVO.setBreaks(countDeviceRunStatus(pqDeviceList).apply(1, deviceIndexes));
|
||||
terminalRunningInfoVO.setShutdown(countDeviceRunStatus(pqDeviceList).apply(2, deviceIndexes));
|
||||
if (deviceIndexes.size()==0) {
|
||||
terminalRunningInfoVO.setNormalRate(0.0);
|
||||
terminalRunningInfoVO.setBreaksRate(0.0);
|
||||
terminalRunningInfoVO.setShutdownRate(0.0);
|
||||
} else {
|
||||
double normalRate = terminalRunningInfoVO.getNormal().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setNormalRate(new BigDecimal(normalRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
double breaksRate = terminalRunningInfoVO.getBreaks().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setBreaksRate(new BigDecimal(breaksRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
double shutdownRate = terminalRunningInfoVO.getShutdown().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setShutdownRate(new BigDecimal(shutdownRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
terminalRunningInfoVO.setOnlineRate(computingDeviceOnlineRate(pqsOnlinerateList).apply(deviceIndexes));
|
||||
return terminalRunningInfoVO;
|
||||
}).sorted(TerminalRunningInfoVO.sortAscAreaName())
|
||||
List<String> deviceIndexes = dto.getDeviceIndexes();
|
||||
|
||||
TerminalRunningInfoVO terminalRunningInfoVO = new TerminalRunningInfoVO();
|
||||
terminalRunningInfoVO.setAreaName(dto.getName());
|
||||
terminalRunningInfoVO.setNumberOfTerminals(deviceIndexes.size());
|
||||
terminalRunningInfoVO.setNormal(countDeviceRunStatus(pqDeviceList).apply(0, deviceIndexes));
|
||||
terminalRunningInfoVO.setBreaks(countDeviceRunStatus(pqDeviceList).apply(1, deviceIndexes));
|
||||
terminalRunningInfoVO.setShutdown(countDeviceRunStatus(pqDeviceList).apply(2, deviceIndexes));
|
||||
if (deviceIndexes.size() == 0) {
|
||||
terminalRunningInfoVO.setNormalRate(0.0);
|
||||
terminalRunningInfoVO.setBreaksRate(0.0);
|
||||
terminalRunningInfoVO.setShutdownRate(0.0);
|
||||
} else {
|
||||
double normalRate = terminalRunningInfoVO.getNormal().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setNormalRate(new BigDecimal(normalRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
double breaksRate = terminalRunningInfoVO.getBreaks().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setBreaksRate(new BigDecimal(breaksRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
double shutdownRate = terminalRunningInfoVO.getShutdown().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100;
|
||||
terminalRunningInfoVO.setShutdownRate(new BigDecimal(shutdownRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
terminalRunningInfoVO.setOnlineRate(computingDeviceOnlineRate(pqsOnlinerateList).apply(deviceIndexes));
|
||||
return terminalRunningInfoVO;
|
||||
}).sorted(TerminalRunningInfoVO.sortAscAreaName())
|
||||
.collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>())));
|
||||
|
||||
|
||||
Integer terminalSum = terminalRun.stream().mapToInt(TerminalRunningInfoVO::getNumberOfTerminals)
|
||||
.sum();
|
||||
Long normalSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getNormal)
|
||||
@@ -295,17 +341,17 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
.sum();
|
||||
Long shutdownSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getShutdown)
|
||||
.sum();
|
||||
Double normalRateSum = 0.0,breaksRateSum = 0.0,shutdownRateSum = 0.0;
|
||||
if (terminalSum!=0) {
|
||||
normalRateSum = new BigDecimal(normalSum.doubleValue() / terminalSum *100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
breaksRateSum = new BigDecimal(breaksSum.doubleValue() / terminalSum *100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
shutdownRateSum = new BigDecimal(shutdownSum.doubleValue() / terminalSum *100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
Double normalRateSum = 0.0, breaksRateSum = 0.0, shutdownRateSum = 0.0;
|
||||
if (terminalSum != 0) {
|
||||
normalRateSum = new BigDecimal(normalSum.doubleValue() / terminalSum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
breaksRateSum = new BigDecimal(breaksSum.doubleValue() / terminalSum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
shutdownRateSum = new BigDecimal(shutdownSum.doubleValue() / terminalSum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
Double onlineRateAvg = computingDeviceOnlineRate(pqsOnlinerateList).apply(deviceIndexList);
|
||||
return TerminalRunningVO.buildVO(terminalSum, normalSum, normalRateSum, breaksSum, breaksRateSum, shutdownSum,
|
||||
shutdownRateSum, onlineRateAvg, terminalRun);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算装置在线率,在线率计算公式
|
||||
* OnlineRate = OnLineMin/( OnLineMin+ OffLineMin) * 100%;
|
||||
@@ -318,7 +364,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
List<PqsOnlinerate> value = pqsOnlinerateList.stream()
|
||||
.filter(t -> deviceIndexes.contains(t.getDevId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
int onlineSum = value.stream().mapToInt(PqsOnlinerate::getOnlinemin).sum();
|
||||
int offlineSum = value.stream().mapToInt(PqsOnlinerate::getOfflinemin).sum();
|
||||
BigDecimal b1 = new BigDecimal(onlineSum);
|
||||
@@ -330,7 +376,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
return b1.divide(b1.add(b2), 4, RoundingMode.HALF_UP).multiply(c).doubleValue();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据终端运行状态(0:投运;1:热备用;2:停运)查询数据数量
|
||||
*
|
||||
@@ -343,7 +389,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
.filter(t -> deviceIndexes.contains(t.getId()))
|
||||
.count();
|
||||
}
|
||||
|
||||
|
||||
public List<EventHeatDeatilVO> getContion(DeviceInfoParam.BusinessParam deviceInfoParam, List<String> lineIndexs) {
|
||||
// 组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
@@ -366,4 +412,69 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
List<EventHeatDeatilVO> eventdetailList = influxDBResultMapper.toPOJO(result, EventHeatDeatilVO.class);
|
||||
return eventdetailList;
|
||||
}
|
||||
|
||||
public Float getSarfiValue(String startTime, String endTime, Float fvalue, String id) {
|
||||
Float retList = 0f;
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and ");
|
||||
stringBuilder.append("line_id = '").append(id).append("'").append(" and event_value <=").append(fvalue).append(InfluxDBPublicParam.TIME_ZONE);
|
||||
String sql = "select mean(event_value) from " + InfluxDBPublicParam.PQS_EVENT_DETAIL + " where " + stringBuilder.toString();
|
||||
QueryResult queryResult = influxDbUtils.query(sql);
|
||||
List<QueryResult.Result> results = queryResult.getResults();
|
||||
if (results == null || results.isEmpty()) {
|
||||
return retList;
|
||||
}
|
||||
QueryResult.Result result = results.get(0);
|
||||
List<QueryResult.Series> seriess = result.getSeries();
|
||||
if (seriess == null || seriess.isEmpty()) {
|
||||
return retList;
|
||||
}
|
||||
QueryResult.Series series = seriess.get(0);
|
||||
List<List<Object>> values = series.getValues();
|
||||
for (List<Object> columnValue : values) {
|
||||
retList = BigDecimal.valueOf(Float.parseFloat(columnValue.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public Integer getSarfiCount(String startTime, String endTime, Float fvalue, String id) {
|
||||
Integer retList = 0;
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and ");
|
||||
stringBuilder.append("line_id = '").append(id).append("'").append(" and event_value <=").append(fvalue).append(" and persist_time<6000").append(InfluxDBPublicParam.TIME_ZONE);
|
||||
String sql = "select count(*) from " + InfluxDBPublicParam.PQS_EVENT_DETAIL + " where " + stringBuilder.toString();
|
||||
QueryResult queryResult = influxDbUtils.query(sql);
|
||||
List<QueryResult.Result> results = queryResult.getResults();
|
||||
if (results == null || results.isEmpty()) {
|
||||
return retList;
|
||||
}
|
||||
QueryResult.Result result = results.get(0);
|
||||
List<QueryResult.Series> seriess = result.getSeries();
|
||||
if (seriess == null || seriess.isEmpty()) {
|
||||
return retList;
|
||||
}
|
||||
QueryResult.Series series = seriess.get(0);
|
||||
List<List<Object>> values = series.getValues();
|
||||
for (List<Object> columnValue : values) {
|
||||
retList = (Integer) columnValue.get(1);
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public List<EventDetail> getEventDetailInfo(String id, Float fvalue, String startTime, String endTime) {
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and ");
|
||||
//sql语句
|
||||
stringBuilder.append("line_id ='").append(id).append("'").append(" and event_value <=").append(fvalue).append(" and persist_time < 60000").append(" tz('Asia/Shanghai')");
|
||||
|
||||
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
||||
return eventDetailList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user