因修改influxDB数据库的部分表结构,谐波模块修改了部分代码
This commit is contained in:
@@ -3,9 +3,14 @@ package com.njcn.device.pojo.po;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.influxdb.annotation.Column;
|
||||
import org.influxdb.annotation.Measurement;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -15,9 +20,8 @@ import lombok.Setter;
|
||||
* @author cdf
|
||||
* @since 2022-01-07
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_communicate")
|
||||
@Data
|
||||
@Measurement(name = "pqs_communicate")
|
||||
public class Communicate {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -25,21 +29,26 @@ public class Communicate {
|
||||
/**
|
||||
* 终端Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
@Column(name = "time")
|
||||
private Instant updateTime;
|
||||
|
||||
@Column(name = "line_id")
|
||||
private String id;
|
||||
|
||||
|
||||
/**
|
||||
* 事件类型(0:中断;1:正常;2:退出)
|
||||
*/
|
||||
@Column(name = "type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Column(name = "description")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
@@ -22,4 +22,6 @@ public class SubstationDetailVO implements Serializable {
|
||||
private Double coordX;
|
||||
|
||||
private String color;
|
||||
|
||||
private String scale;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
line.NAME srbName,
|
||||
sub.Lng coordY,
|
||||
sub.Lat coordX,
|
||||
"blue" color
|
||||
"blue" color,
|
||||
dic.name scale
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_substation sub
|
||||
pq_substation sub,
|
||||
sys_dict_data dic
|
||||
WHERE
|
||||
line.Id = sub.Id
|
||||
and
|
||||
sub.scale = dic.id
|
||||
AND
|
||||
sub.Id IN
|
||||
<foreach collection="id" item="item" open="(" close=")" separator=",">
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pojo.po.*;
|
||||
import com.njcn.device.pojo.vo.*;
|
||||
import com.njcn.device.service.LineService;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -38,8 +39,10 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -152,18 +155,17 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
|
||||
@Override
|
||||
public CommunicateVO getComFlagInfoData(String id, String searchBeginTime, String searchEndTime) {
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String devId = getLineIdByDevId(id);
|
||||
QueryWrapper<Communicate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(Communicate::getId, devId)
|
||||
.between(Communicate::getUpdateTime, PubUtils.beginTimeToLocalDateTime(searchBeginTime), PubUtils.endTimeToLocalDateTime(searchEndTime));
|
||||
queryWrapper.orderBy(true, true, "pq_communicate.update_time");
|
||||
List<Communicate> communicateList = communicateMapper.selectList(queryWrapper);
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<Communicate> communicateList = getCommunicate(id,searchBeginTime,searchEndTime);
|
||||
CommunicateVO communicateVOList = new CommunicateVO();
|
||||
List<String> updateTime = new ArrayList<>();
|
||||
List<Integer> comType = new ArrayList<>();
|
||||
for (Communicate communicate : communicateList) {
|
||||
updateTime.add(df.format(communicate.getUpdateTime()));
|
||||
//转化时间
|
||||
Instant now = communicate.getUpdateTime().plusMillis(TimeUnit.HOURS.toMillis(8));
|
||||
Long time = now.toEpochMilli();
|
||||
String timeText = df.format(time);
|
||||
updateTime.add(timeText);
|
||||
comType.add(communicate.getType());
|
||||
}
|
||||
communicateVOList.setUpdateTime(updateTime);
|
||||
@@ -541,6 +543,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
stringBuilder.append("dev_index ='").append(devIndexs.get(i)).append("' ");
|
||||
}
|
||||
}
|
||||
stringBuilder.append(InfluxDBPublicParam.TIME_ZONE);
|
||||
String sql = "select sum(onlinemin)/(sum(onlinemin) +sum(offlinemin))*100 as onlinerate from pqs_onlinerate where " + stringBuilder.toString() + "group by dev_index";
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
@@ -641,4 +644,17 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
return staticsValue;
|
||||
}
|
||||
|
||||
public List<Communicate> getCommunicate(String lineIndex, 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 ");
|
||||
stringBuilder.append("line_id = '").append(lineIndex).append("' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE);
|
||||
String sql = "select * from "+InfluxDBPublicParam.PQS_COMMUNICATE+" where " + stringBuilder.toString();
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<Communicate> communicateList = influxDBResultMapper.toPOJO(result, Communicate.class);
|
||||
return communicateList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user