终端模块调整influx查询
This commit is contained in:
@@ -28,17 +28,5 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<!--排除okhttp3的依赖-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -40,12 +40,6 @@
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-influxDB</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
|
||||
@@ -29,10 +29,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pms.service.majornetwork.IPmsGeneralDeviceService;
|
||||
import com.njcn.device.pms.service.majornetwork.ITerminalService;
|
||||
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
||||
import com.njcn.device.pq.pojo.po.Communicate;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.influx.imapper.PqsCommunicateMapper;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
@@ -41,8 +42,6 @@ import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -71,10 +70,13 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
|
||||
private final IPmsGeneralDeviceService pmsGeneralDeviceService;
|
||||
|
||||
private final DistributionMonitorMapper distributionMonitorMapper;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final ITerminalService iTerminalService;
|
||||
|
||||
private final PqsCommunicateMapper pqsCommunicateMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, List<SubstationExpendVO>> getSubstationExpendInfo(StatisticsBizBaseParam param) {
|
||||
Map<String, List<SubstationExpendVO>> map = new HashMap<>();
|
||||
@@ -253,36 +255,23 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
|
||||
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getTerminalIdList().stream()).collect(Collectors.toList());
|
||||
|
||||
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))).append("' ");
|
||||
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
influxQueryWrapper.between(InfluxDBTableConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())),DateUtil.beginOfDay(DateUtil.parse(param.getEndTime())));
|
||||
if(CollUtil.isNotEmpty(terminalIds)){
|
||||
stringBuilder.append(" and ").append("(");
|
||||
for (int i = 0; i < terminalIds.size(); i++) {
|
||||
if (terminalIds.size() - i != 1) {
|
||||
stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("' or ");
|
||||
} else {
|
||||
stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("')");
|
||||
}
|
||||
}
|
||||
influxQueryWrapper.or(PqsCommunicate::getDevId,terminalIds);
|
||||
}
|
||||
stringBuilder.append(" limit "+param.getLimit());
|
||||
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder + InfluxDBPublicParam.TIME_ZONE;
|
||||
// 获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<Communicate> communicates = influxDBResultMapper.toPOJO(result, Communicate.class);
|
||||
if(CollUtil.isEmpty(communicates)){
|
||||
return info;
|
||||
}
|
||||
List<String> ids = communicates.stream().map(Communicate::getDevId).distinct().collect(Collectors.toList());
|
||||
influxQueryWrapper.limit(param.getLimit());
|
||||
List<PqsCommunicate> communicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
List<String> ids = communicates.stream().map(PqsCommunicate::getDevId).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(ids)){
|
||||
List<PmsTerminal> terminalSelectByIds = iTerminalService.getTerminalSelectByIds(ids);
|
||||
Map<String, String> terminalNameIp = terminalSelectByIds.stream().collect(Collectors.toMap(PmsTerminal::getId, x -> x.getName() + "_" + x.getIp()));
|
||||
CommunicateVO.PVCommunicateVO communicate;
|
||||
for (Communicate cate : communicates) {
|
||||
for (PqsCommunicate cate : communicates) {
|
||||
communicate=new CommunicateVO.PVCommunicateVO();
|
||||
BeanUtil.copyProperties(cate, communicate);
|
||||
communicate.setTime(cate.getUpdateTime());
|
||||
communicate.setTime(cate.getTime());
|
||||
if(terminalNameIp.containsKey(cate.getDevId())){
|
||||
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.device.pms.service.majornetwork;
|
||||
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
|
||||
/**
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @date 2022年12月14日 09:39
|
||||
*/
|
||||
public interface EventDetailPmsService {
|
||||
|
||||
/**
|
||||
* 根据监测点id和时区时间time获取暂降事件
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 暂降事件详情
|
||||
*/
|
||||
EventDetail getEventDetailByTime(String id, String time);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.njcn.device.pms.service.majornetwork.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.device.pms.service.majornetwork.EventDetailPmsService;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @date 2022年12月14日 09:39
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventDetailPmsServiceImpl implements EventDetailPmsService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public EventDetail getEventDetailByTime(String id, String time) {
|
||||
EventDetail eventDetail = new EventDetail();
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time = '").append(time).append("' and ").append("line_id ='").append(id).append("' limit 1 tz('Asia/Shanghai')");
|
||||
|
||||
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
if (!Objects.isNull(result)) {
|
||||
List<EventDetail> detailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
||||
if (!CollectionUtils.isEmpty(detailList)) {
|
||||
eventDetail = detailList.get(0);
|
||||
}
|
||||
}
|
||||
return eventDetail;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user