1.解决统计类型:在线离线类型
2.解决设备运行,初始时间和结束时间bug
This commit is contained in:
@@ -2,6 +2,7 @@ package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -84,6 +85,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
|
||||
private final TopMsgMapper topMsgMapper;
|
||||
|
||||
// private final PqsCommunicateService pqsCommunicateService;
|
||||
|
||||
@Override
|
||||
public LineDetailDataVO getLineDetailData(String id) {
|
||||
@@ -165,17 +167,42 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
String devId = lineMapper.getDevIndex(id);
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<Communicate> communicateList = getCommunicate(devId, searchBeginTime, searchEndTime);
|
||||
|
||||
CommunicateVO communicateVOList = new CommunicateVO();
|
||||
List<String> updateTime = new ArrayList<>();
|
||||
List<Integer> comType = new ArrayList<>();
|
||||
//开始时间
|
||||
if(!communicateList.get(0).getUpdateTime().equals(DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toInstant())){
|
||||
Instant instant = DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toInstant();
|
||||
Long time = instant.toEpochMilli();
|
||||
String timeText = df.format(time);
|
||||
updateTime.add(timeText);
|
||||
if(communicateList.get(0).getType()==0){
|
||||
comType.add(1);
|
||||
}else{
|
||||
comType.add(0);
|
||||
}
|
||||
}
|
||||
for (Communicate communicate : communicateList) {
|
||||
//转化时间
|
||||
Instant now = communicate.getUpdateTime().plusMillis(TimeUnit.HOURS.toMillis(8));
|
||||
Instant now = communicate.getUpdateTime();
|
||||
Long time = now.toEpochMilli();
|
||||
String timeText = df.format(time);
|
||||
updateTime.add(timeText);
|
||||
comType.add(communicate.getType());
|
||||
}
|
||||
//拼接最后时间
|
||||
SimpleDateFormat times = new SimpleDateFormat("HH:mm:ss");
|
||||
DateTime date = DateTime.now();
|
||||
String format = times.format(date);
|
||||
Instant endTime = DateUtil.parse(searchEndTime + " " + format).toInstant();
|
||||
|
||||
if(!communicateList.get(communicateList.size()-1).getUpdateTime().equals(endTime)){
|
||||
Long time = endTime.toEpochMilli();
|
||||
String timeText = df.format(time);
|
||||
updateTime.add(timeText);
|
||||
comType.add(communicateList.get(communicateList.size()-1).getType());
|
||||
}
|
||||
communicateVOList.setUpdateTime(updateTime);
|
||||
communicateVOList.setType(comType);
|
||||
return communicateVOList;
|
||||
@@ -743,11 +770,14 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
return staticsValue;
|
||||
}
|
||||
|
||||
public List<Communicate> getCommunicate(String lineIndex, String startTime, String endTime) {
|
||||
public List<Communicate> getCommunicate(String devId, String startTime, String endTime) {
|
||||
// List<PqsCommunicate> communicateList = pqsCommunicateService.getPqsCommunicate(devId, DateUtil.beginOfDay(DateUtil.parse(startTime)).toString(), DateUtil.beginOfDay(DateUtil.parse(endTime)).toString());
|
||||
|
||||
|
||||
//组装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("dev_id = '").append(lineIndex).append("' group by dev_id ").append(InfluxDBPublicParam.TIME_ZONE);
|
||||
stringBuilder.append("dev_id = '").append(devId).append("' group by dev_id ").append(InfluxDBPublicParam.TIME_ZONE);
|
||||
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder.toString();
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
|
||||
Reference in New Issue
Block a user