@@ -42,16 +42,16 @@
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.slf4j</groupId>-->
|
||||
<!-- <artifactId>slf4j-log4j12</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>ch.qos.logback</groupId>-->
|
||||
<!-- <artifactId>logback-classic</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.njcn.device.pq.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||
import com.njcn.device.pq.service.ISubstationExpendService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "冀北变电站地图信息")
|
||||
@RestController
|
||||
@RequestMapping("/substationExpend")
|
||||
@RequiredArgsConstructor
|
||||
public class SubstationExpendController extends BaseController {
|
||||
|
||||
private final ISubstationExpendService substationExpendService;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getPVCommunicationStatus")
|
||||
@ApiOperation("冀北主网监测点通讯状态统计")
|
||||
@ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
|
||||
public HttpResult<List<CommunicateVO.PVCommunicateVO>> getPVCommunicationStatus(@RequestBody DeviceInfoParam.CompareLimitParam param) {
|
||||
String methodDescribe = getMethodDescribe("getPVCommunicationStatus");
|
||||
List<CommunicateVO.PVCommunicateVO> communicationStatus = substationExpendService.getCommunicationStatus(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, communicationStatus, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,6 @@
|
||||
|
||||
<select id="getDeviceByIdOnOrOff" resultType="com.njcn.device.pq.pojo.vo.TerminalBaseVO">
|
||||
SELECT
|
||||
t1.id devId,
|
||||
t1.name devName,t2.ip,t2.dev_type,t2.update_time,sub.name subName,gd.name gdName
|
||||
FROM
|
||||
pq_line t1,
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
|
||||
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhuxinyu
|
||||
* @since 2023-05-08
|
||||
*/
|
||||
public interface ISubstationExpendService {
|
||||
|
||||
List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(DeviceInfoParam.CompareLimitParam param);
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.device.pq.pojo.bo.DeviceType;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.po.Communicate;
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||
import com.njcn.device.pq.pojo.vo.TerminalBaseVO;
|
||||
import com.njcn.device.pq.service.IDeviceService;
|
||||
import com.njcn.device.pq.service.ISubstationExpendService;
|
||||
import com.njcn.device.pq.service.TerminalBaseService;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
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.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhuxinyu
|
||||
* @since 2023-05-08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SubstationExpendServiceImpl implements ISubstationExpendService {
|
||||
|
||||
private final GeneralDeviceService generalDeviceService;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final IDeviceService deviceService;
|
||||
private final TerminalBaseService terminalBaseService;
|
||||
|
||||
@Override
|
||||
public List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(DeviceInfoParam.CompareLimitParam param) {
|
||||
List<GeneralDeviceDTO> generalDeviceDTOS = generalDeviceService.getDeviceInfo(param, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
//获取所有终端id
|
||||
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))).append("' ");
|
||||
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("')");
|
||||
}
|
||||
}
|
||||
}
|
||||
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());
|
||||
if(CollUtil.isNotEmpty(ids)){
|
||||
List<TerminalBaseVO> deviceByIds = terminalBaseService.getDeviceByIdOnOrOff(ids, new DeviceType(), 0);
|
||||
Map<String, String> terminalNameIp = deviceByIds.stream().collect(Collectors.toMap(TerminalBaseVO::getDevId, x -> x.getDevName() + "_" + x.getIp()));
|
||||
CommunicateVO.PVCommunicateVO communicate;
|
||||
for (Communicate cate : communicates) {
|
||||
communicate=new CommunicateVO.PVCommunicateVO();
|
||||
BeanUtil.copyProperties(cate, communicate);
|
||||
communicate.setTime(cate.getUpdateTime());
|
||||
if(terminalNameIp.containsKey(cate.getDevId())){
|
||||
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
||||
}
|
||||
info.add(communicate);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user