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.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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 TopMsgMapper topMsgMapper;
|
||||||
|
|
||||||
|
// private final PqsCommunicateService pqsCommunicateService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LineDetailDataVO getLineDetailData(String id) {
|
public LineDetailDataVO getLineDetailData(String id) {
|
||||||
@@ -165,17 +167,42 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
String devId = lineMapper.getDevIndex(id);
|
String devId = lineMapper.getDevIndex(id);
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
List<Communicate> communicateList = getCommunicate(devId, searchBeginTime, searchEndTime);
|
List<Communicate> communicateList = getCommunicate(devId, searchBeginTime, searchEndTime);
|
||||||
|
|
||||||
CommunicateVO communicateVOList = new CommunicateVO();
|
CommunicateVO communicateVOList = new CommunicateVO();
|
||||||
List<String> updateTime = new ArrayList<>();
|
List<String> updateTime = new ArrayList<>();
|
||||||
List<Integer> comType = 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) {
|
for (Communicate communicate : communicateList) {
|
||||||
//转化时间
|
//转化时间
|
||||||
Instant now = communicate.getUpdateTime().plusMillis(TimeUnit.HOURS.toMillis(8));
|
Instant now = communicate.getUpdateTime();
|
||||||
Long time = now.toEpochMilli();
|
Long time = now.toEpochMilli();
|
||||||
String timeText = df.format(time);
|
String timeText = df.format(time);
|
||||||
updateTime.add(timeText);
|
updateTime.add(timeText);
|
||||||
comType.add(communicate.getType());
|
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.setUpdateTime(updateTime);
|
||||||
communicateVOList.setType(comType);
|
communicateVOList.setType(comType);
|
||||||
return communicateVOList;
|
return communicateVOList;
|
||||||
@@ -743,11 +770,14 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
return staticsValue;
|
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语句
|
//组装sql语句
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
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("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();
|
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder.toString();
|
||||||
//获取暂降事件
|
//获取暂降事件
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
QueryResult result = influxDbUtils.query(sql);
|
||||||
|
|||||||
@@ -61,5 +61,8 @@ public class TransientParam extends DeviceInfoParam.BusinessParam {
|
|||||||
|
|
||||||
@ApiModelProperty("搜索值")
|
@ApiModelProperty("搜索值")
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
|
@ApiModelProperty("在线离线 0:在线 1:离线")
|
||||||
|
private Integer isType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -288,8 +288,12 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
page.setSize(transientParam.getPageSize());
|
page.setSize(transientParam.getPageSize());
|
||||||
page.setCurrent(transientParam.getPageNum());
|
page.setCurrent(transientParam.getPageNum());
|
||||||
// 按部门分类的实际运行终端综合信息
|
// 按部门分类的实际运行终端综合信息
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
List<GeneralDeviceDTO> generalDeviceDTOList =new ArrayList<>();
|
||||||
|
if(transientParam.getIsType()==0){
|
||||||
|
generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
||||||
|
}else{
|
||||||
|
generalDeviceDTOList = generalDeviceInfoClient.getOfflineRunDeviceInfo(transientParam).getData();
|
||||||
|
}
|
||||||
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
||||||
if (Objects.nonNull(transientParam.getEventValueMin())) {
|
if (Objects.nonNull(transientParam.getEventValueMin())) {
|
||||||
transientParam.setEventValueMin(transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
|
transientParam.setEventValueMin(transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
|
||||||
|
|||||||
Reference in New Issue
Block a user