From 66906d15d9081c4e9ac363df402c3c57f4379a10 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Wed, 17 May 2023 11:02:53 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3=E7=BB=9F=E8=AE=A1=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=EF=BC=9A=E5=9C=A8=E7=BA=BF=E7=A6=BB=E7=BA=BF=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=202.=E8=A7=A3=E5=86=B3=E8=AE=BE=E5=A4=87=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E5=88=9D=E5=A7=8B=E6=97=B6=E9=97=B4=E5=92=8C?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pq/service/impl/LineServiceImpl.java | 36 +++++++++++++++++-- .../njcn/event/pojo/param/TransientParam.java | 3 ++ .../Impl/TransientServiceImpl.java | 8 +++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java index 30439a4cc..4cf45e2b3 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java @@ -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 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 implements Li String devId = lineMapper.getDevIndex(id); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List communicateList = getCommunicate(devId, searchBeginTime, searchEndTime); + CommunicateVO communicateVOList = new CommunicateVO(); List updateTime = new ArrayList<>(); List 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 implements Li return staticsValue; } - public List getCommunicate(String lineIndex, String startTime, String endTime) { + public List getCommunicate(String devId, String startTime, String endTime) { +// List 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); diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java index ca3c642cd..a5efc6e90 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java @@ -61,5 +61,8 @@ public class TransientParam extends DeviceInfoParam.BusinessParam { @ApiModelProperty("搜索值") private String searchValue; + + @ApiModelProperty("在线离线 0:在线 1:离线") + private Integer isType; } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java index 808347c74..d7b4b38a2 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/TransientServiceImpl.java @@ -288,8 +288,12 @@ public class TransientServiceImpl implements TransientService { page.setSize(transientParam.getPageSize()); page.setCurrent(transientParam.getPageNum()); // 按部门分类的实际运行终端综合信息 - List generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData(); - + List generalDeviceDTOList =new ArrayList<>(); + if(transientParam.getIsType()==0){ + generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData(); + }else{ + generalDeviceDTOList = generalDeviceInfoClient.getOfflineRunDeviceInfo(transientParam).getData(); + } if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { if (Objects.nonNull(transientParam.getEventValueMin())) { transientParam.setEventValueMin(transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));