终端模块调整influx查询
This commit is contained in:
@@ -55,6 +55,18 @@
|
|||||||
<artifactId>user-api</artifactId>
|
<artifactId>user-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>pqs-influx</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<!--排除okhttp3的依赖-->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -28,17 +28,5 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>pqs-influx</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<!--排除okhttp3的依赖-->
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>*</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -40,12 +40,6 @@
|
|||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>common-influxDB</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-oss</artifactId>
|
<artifactId>common-oss</artifactId>
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.njcn.device.pms.service.majornetwork.IPmsGeneralDeviceService;
|
import com.njcn.device.pms.service.majornetwork.IPmsGeneralDeviceService;
|
||||||
import com.njcn.device.pms.service.majornetwork.ITerminalService;
|
import com.njcn.device.pms.service.majornetwork.ITerminalService;
|
||||||
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
import com.njcn.device.pq.pojo.param.CommunicateParam;
|
||||||
import com.njcn.device.pq.pojo.po.Communicate;
|
|
||||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
import com.njcn.influx.imapper.PqsCommunicateMapper;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
|
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||||
|
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.enums.DicDataTypeEnum;
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
@@ -41,8 +42,6 @@ import com.njcn.user.pojo.dto.DeptDTO;
|
|||||||
import com.njcn.user.pojo.po.Dept;
|
import com.njcn.user.pojo.po.Dept;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -71,10 +70,13 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
|
|||||||
private final IPmsGeneralDeviceService pmsGeneralDeviceService;
|
private final IPmsGeneralDeviceService pmsGeneralDeviceService;
|
||||||
|
|
||||||
private final DistributionMonitorMapper distributionMonitorMapper;
|
private final DistributionMonitorMapper distributionMonitorMapper;
|
||||||
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
private final ITerminalService iTerminalService;
|
private final ITerminalService iTerminalService;
|
||||||
|
|
||||||
|
private final PqsCommunicateMapper pqsCommunicateMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<SubstationExpendVO>> getSubstationExpendInfo(StatisticsBizBaseParam param) {
|
public Map<String, List<SubstationExpendVO>> getSubstationExpendInfo(StatisticsBizBaseParam param) {
|
||||||
Map<String, List<SubstationExpendVO>> map = new HashMap<>();
|
Map<String, List<SubstationExpendVO>> map = new HashMap<>();
|
||||||
@@ -253,36 +255,23 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
|
|||||||
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getTerminalIdList().stream()).collect(Collectors.toList());
|
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getTerminalIdList().stream()).collect(Collectors.toList());
|
||||||
|
|
||||||
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
|
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))).append("' ");
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||||
|
influxQueryWrapper.between(InfluxDBTableConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())),DateUtil.beginOfDay(DateUtil.parse(param.getEndTime())));
|
||||||
if(CollUtil.isNotEmpty(terminalIds)){
|
if(CollUtil.isNotEmpty(terminalIds)){
|
||||||
stringBuilder.append(" and ").append("(");
|
influxQueryWrapper.or(PqsCommunicate::getDevId,terminalIds);
|
||||||
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("')");
|
|
||||||
}
|
}
|
||||||
}
|
influxQueryWrapper.limit(param.getLimit());
|
||||||
}
|
List<PqsCommunicate> communicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||||
stringBuilder.append(" limit "+param.getLimit());
|
List<String> ids = communicates.stream().map(PqsCommunicate::getDevId).distinct().collect(Collectors.toList());
|
||||||
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)){
|
if(CollUtil.isNotEmpty(ids)){
|
||||||
List<PmsTerminal> terminalSelectByIds = iTerminalService.getTerminalSelectByIds(ids);
|
List<PmsTerminal> terminalSelectByIds = iTerminalService.getTerminalSelectByIds(ids);
|
||||||
Map<String, String> terminalNameIp = terminalSelectByIds.stream().collect(Collectors.toMap(PmsTerminal::getId, x -> x.getName() + "_" + x.getIp()));
|
Map<String, String> terminalNameIp = terminalSelectByIds.stream().collect(Collectors.toMap(PmsTerminal::getId, x -> x.getName() + "_" + x.getIp()));
|
||||||
CommunicateVO.PVCommunicateVO communicate;
|
CommunicateVO.PVCommunicateVO communicate;
|
||||||
for (Communicate cate : communicates) {
|
for (PqsCommunicate cate : communicates) {
|
||||||
communicate=new CommunicateVO.PVCommunicateVO();
|
communicate=new CommunicateVO.PVCommunicateVO();
|
||||||
BeanUtil.copyProperties(cate, communicate);
|
BeanUtil.copyProperties(cate, communicate);
|
||||||
communicate.setTime(cate.getUpdateTime());
|
communicate.setTime(cate.getTime());
|
||||||
if(terminalNameIp.containsKey(cate.getDevId())){
|
if(terminalNameIp.containsKey(cate.getDevId())){
|
||||||
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.njcn.device.pms.service.majornetwork;
|
|
||||||
|
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author qijian
|
|
||||||
* @version 1.0.0
|
|
||||||
* @date 2022年12月14日 09:39
|
|
||||||
*/
|
|
||||||
public interface EventDetailPmsService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据监测点id和时区时间time获取暂降事件
|
|
||||||
*
|
|
||||||
* @param id 监测点id
|
|
||||||
* @return 暂降事件详情
|
|
||||||
*/
|
|
||||||
EventDetail getEventDetailByTime(String id, String time);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.njcn.device.pms.service.majornetwork.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.njcn.device.pms.service.majornetwork.EventDetailPmsService;
|
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author qijian
|
|
||||||
* @version 1.0.0
|
|
||||||
* @date 2022年12月14日 09:39
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class EventDetailPmsServiceImpl implements EventDetailPmsService {
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EventDetail getEventDetailByTime(String id, String time) {
|
|
||||||
EventDetail eventDetail = new EventDetail();
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time = '").append(time).append("' and ").append("line_id ='").append(id).append("' limit 1 tz('Asia/Shanghai')");
|
|
||||||
|
|
||||||
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
|
||||||
//获取暂降事件
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
if (!Objects.isNull(result)) {
|
|
||||||
List<EventDetail> detailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
|
||||||
if (!CollectionUtils.isEmpty(detailList)) {
|
|
||||||
eventDetail = detailList.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return eventDetail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.njcn.device.pq.pojo.po;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.influxdb.annotation.Column;
|
|
||||||
import org.influxdb.annotation.Measurement;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author cdf
|
|
||||||
* @since 2022-01-07
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Measurement(name = "pqs_communicate")
|
|
||||||
public class Communicate {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@Column(name = "time")
|
|
||||||
private Instant updateTime;
|
|
||||||
/**
|
|
||||||
* 监测点id
|
|
||||||
*/
|
|
||||||
@Column(name = "line_id")
|
|
||||||
private String id;
|
|
||||||
/**
|
|
||||||
* 终端Id
|
|
||||||
*/
|
|
||||||
@Column(name = "dev_id")
|
|
||||||
private String devId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 事件类型(0:中断;1:正常;2:退出)
|
|
||||||
*/
|
|
||||||
@Column(name = "type")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
@Column(name = "description")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.njcn.device.pq.pojo.po.influxdb;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.influxdb.annotation.Column;
|
|
||||||
import org.influxdb.annotation.Measurement;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Measurement(name = "cld_statis_flow")
|
|
||||||
public class DeviceDayFlow {
|
|
||||||
|
|
||||||
@Column(name="time")
|
|
||||||
private Instant time;
|
|
||||||
|
|
||||||
@Column(name="actual_value")
|
|
||||||
private Integer actualValue;
|
|
||||||
|
|
||||||
@Column(name="dev_id")
|
|
||||||
private String devId;
|
|
||||||
|
|
||||||
private float dailyActualValue;
|
|
||||||
|
|
||||||
private String date;
|
|
||||||
|
|
||||||
private String month;
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.njcn.device.pq.pojo.vo;
|
package com.njcn.device.pq.pojo.vo;
|
||||||
|
|
||||||
import com.njcn.device.pq.pojo.po.DevFuction;
|
import com.njcn.device.pq.pojo.po.DevFuction;
|
||||||
import com.njcn.device.pq.pojo.po.influxdb.DeviceDayFlow;
|
import com.njcn.influx.pojo.dto.DeviceDayFlowDTO;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -32,7 +31,7 @@ public class TerminalDaliyFlowVO {
|
|||||||
@ApiModelProperty(name = "flowMeal",value = "套餐流量(基础+拓展)")
|
@ApiModelProperty(name = "flowMeal",value = "套餐流量(基础+拓展)")
|
||||||
private Float flowMeal;
|
private Float flowMeal;
|
||||||
@ApiModelProperty(name = "deviceDayFlowsList",value = "装置日流量统计集合")
|
@ApiModelProperty(name = "deviceDayFlowsList",value = "装置日流量统计集合")
|
||||||
private List<DeviceDayFlow> deviceDayFlowsList;
|
private List<DeviceDayFlowDTO> deviceDayFlowsList;
|
||||||
@ApiModelProperty(name = "functions",value = "装置功能码集合")
|
@ApiModelProperty(name = "functions",value = "装置功能码集合")
|
||||||
private List<DevFuction> functions;
|
private List<DevFuction> functions;
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,6 @@
|
|||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>common-influxDB</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-oss</artifactId>
|
<artifactId>common-oss</artifactId>
|
||||||
|
|||||||
@@ -1,78 +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.common.utils.LogUtil;
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaDeviceOnlineVO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityVO;
|
|
||||||
import com.njcn.device.pq.service.AreaDeviceOnlineService;
|
|
||||||
import com.njcn.device.pq.service.AreaIntegrityService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
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 java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/11 14:05
|
|
||||||
*/
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/areaCensus")
|
|
||||||
@Api(tags = "区域统计")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AreaCensusController extends BaseController {
|
|
||||||
|
|
||||||
private final AreaDeviceOnlineService areaDeviceOnlineService;
|
|
||||||
|
|
||||||
private final AreaIntegrityService areaIntegrityService;
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getAreaDeviceOnline")
|
|
||||||
@ApiOperation("获取区域终端在线率")
|
|
||||||
@ApiImplicitParam(name = "areaCensusParam", value = "区域统计查询参数", required = true)
|
|
||||||
public HttpResult<List<AreaDeviceOnlineVO>> getAreaDeviceOnline(@RequestBody @Validated AreaCensusParam areaCensusParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getAreaDeviceOnline");
|
|
||||||
LogUtil.njcnDebug(log, "{}", methodDescribe, areaCensusParam);
|
|
||||||
List<AreaDeviceOnlineVO> result = areaDeviceOnlineService.getAreaDeviceOnline(areaCensusParam);
|
|
||||||
if (CollectionUtils.isEmpty(result)) {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
|
||||||
} else {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getAreaIntegrity")
|
|
||||||
@ApiOperation("获取区域数据完整性")
|
|
||||||
@ApiImplicitParam(name = "areaCensusParam", value = "查询参数实体", required = true)
|
|
||||||
public HttpResult<List<AreaIntegrityVO>> getAreaIntegrity(@RequestBody @Validated AreaCensusParam areaCensusParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getAreaIntegrity");
|
|
||||||
LogUtil.njcnDebug(log, "{}", methodDescribe, areaCensusParam);
|
|
||||||
List<AreaIntegrityVO> result = areaIntegrityService.getAreaIntegrity(areaCensusParam);
|
|
||||||
if (CollectionUtils.isEmpty(result)) {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
|
||||||
} else {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,59 +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.AreaIntegrityDataParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityDataVO;
|
|
||||||
import com.njcn.device.pq.service.AreaIntegrityDataService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
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 java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区域数据完整性
|
|
||||||
*
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/22
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Api(tags = "区域数据完整性")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/areaIntegrityData")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class AreaIntegrityDataController extends BaseController {
|
|
||||||
|
|
||||||
private AreaIntegrityDataService getIntegrityDataOfLine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区域数据完整性
|
|
||||||
*/
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getAreaIntegrityData")
|
|
||||||
@ApiOperation("区域数据完整性")
|
|
||||||
@ApiImplicitParam(name = "areaIntegrityDataParam", value = "参数实体", required = true)
|
|
||||||
public HttpResult<List<AreaIntegrityDataVO>> getAreaIntegrityData(@RequestBody AreaIntegrityDataParam areaIntegrityDataParam) {
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
String methodDescribe = getMethodDescribe("getAreaIntegrityData");
|
|
||||||
List<AreaIntegrityDataVO> areaIntegrityData = getIntegrityDataOfLine.getAreaIntegrityData(areaIntegrityDataParam);
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
System.out.println("当前程序运行多少毫秒:" + "=" + (end - start));
|
|
||||||
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, areaIntegrityData, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +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.DeviceRunExceptionParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceRunExceptionVO;
|
|
||||||
import com.njcn.device.pq.service.DeviceRunExceptionService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
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 java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/27
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Api(tags = "终端异常统计")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/deviceRunException")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DeviceRunExceptionController extends BaseController {
|
|
||||||
|
|
||||||
private final DeviceRunExceptionService deviceRunExceptionService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计
|
|
||||||
*/
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getDeviceRunException")
|
|
||||||
@ApiOperation("终端异常统计")
|
|
||||||
@ApiImplicitParam(name = "deviceRunExceptionParam", value = "参数实体", required = true)
|
|
||||||
public HttpResult<List<DeviceRunExceptionVO>> getDeviceRunException(@RequestBody DeviceRunExceptionParam deviceRunExceptionParam) {
|
|
||||||
// 开始时间
|
|
||||||
long start=System.currentTimeMillis();
|
|
||||||
|
|
||||||
String methodDescribe = getMethodDescribe("getDeviceRunException");
|
|
||||||
List<DeviceRunExceptionVO> deviceRunException = deviceRunExceptionService.getDeviceRunException(deviceRunExceptionParam);
|
|
||||||
|
|
||||||
// 结束时间
|
|
||||||
long end=System.currentTimeMillis();
|
|
||||||
// 计算运行时间
|
|
||||||
System.out.println("当前程序运行多少毫秒:" + "=" + (end-start));
|
|
||||||
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,deviceRunException,methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,16 +38,6 @@ public class LogManageController extends BaseController {
|
|||||||
|
|
||||||
private final LogManageService deviceLogService;
|
private final LogManageService deviceLogService;
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getDeviceLogData")
|
|
||||||
@ApiOperation("终端运维日志")
|
|
||||||
@ApiImplicitParam(name = "deviceLogParam", value = "查询终端日志信息", required = true)
|
|
||||||
public HttpResult<Page<DeviceLogVO>> getDeviceLogData(@RequestBody @Validated DeviceLogParam deviceLogParam){
|
|
||||||
String methodDescribe = getMethodDescribe("getDeviceLogData");
|
|
||||||
Page<DeviceLogVO> list = deviceLogService.getDeviceLogData(deviceLogParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getEventLogData")
|
@PostMapping("/getEventLogData")
|
||||||
@ApiOperation("暂降推送日志")
|
@ApiOperation("暂降推送日志")
|
||||||
|
|||||||
@@ -75,30 +75,6 @@ public class OperationContrController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getLineRunStatistics")
|
|
||||||
@ApiOperation("获取监测点运行统计")
|
|
||||||
@ApiImplicitParam(name = "deviceInfoParam", value = "实体", required = true)
|
|
||||||
public HttpResult<List<LineFlowMealDetailVO>> getLineRunStatistics(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getLineRunStatistics");
|
|
||||||
LogUtil.njcnDebug(log, "{},参数集合:{}", methodDescribe, deviceInfoParam);
|
|
||||||
List<LineFlowMealDetailVO> result = lineService.getLineRunStatistics(deviceInfoParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getDeviceRunStatistics")
|
|
||||||
@ApiOperation("获取终端运行统计")
|
|
||||||
@ApiImplicitParam(name = "deviceInfoParam", value = "实体", required = true)
|
|
||||||
public HttpResult<List<LineFlowMealDetailVO>> getDeviceRunStatistics(@RequestBody DeviceInfoParam.BusinessParam deviceInfoParam){
|
|
||||||
String methodDescribe = getMethodDescribe("getDeviceRunStatistics");
|
|
||||||
DeviceInfoParam param = new DeviceInfoParam(RequestUtil.getDeptIndex(),null);
|
|
||||||
deviceInfoParam.setDeptIndex(param.getDeptIndex());
|
|
||||||
LogUtil.njcnDebug(log, "{},参数集合:{}", methodDescribe, deviceInfoParam);
|
|
||||||
List<LineFlowMealDetailVO> result = lineService.getDeviceRunStatistics(deviceInfoParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getNewDeviceRunStatistics")
|
@PostMapping("/getNewDeviceRunStatistics")
|
||||||
@@ -116,30 +92,6 @@ public class OperationContrController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getLineStaticsView")
|
|
||||||
@ApiOperation("获取详细的监测点统计")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "startTime", value = "起始时间", required = true),
|
|
||||||
@ApiImplicitParam(name = "endTime", value = "结束时间", required = true),
|
|
||||||
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
|
|
||||||
})
|
|
||||||
public HttpResult<LineStaticsViewVO> getLineStaticsView(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("lineId") String lineId) {
|
|
||||||
String methodDescribe = getMethodDescribe("getLineStaticsView");
|
|
||||||
LineStaticsViewVO result = lineService.getLineStaticsView(startTime, endTime, lineId);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getComunicateStatics")
|
|
||||||
@ApiOperation("获取中断异常统计")
|
|
||||||
@ApiImplicitParam(name = "conditionBusinessParam", value = "实体", required = true)
|
|
||||||
public HttpResult<DeviceAbnormalVO> getComunicateStatics(@RequestBody @Validated DeviceInfoParam.BusinessParam conditionBusinessParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getComunicateStatics");
|
|
||||||
DeviceAbnormalVO result = lineService.getComunicateStatics(conditionBusinessParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getDailyDeviceAbnormalStatistics")
|
@PostMapping("/getDailyDeviceAbnormalStatistics")
|
||||||
@ApiOperation("获取终端异常统计")
|
@ApiOperation("获取终端异常统计")
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.njcn.device.pq.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
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.common.utils.LogUtil;
|
|
||||||
import com.njcn.device.pq.pojo.param.TabCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceOnlineTabVO;
|
|
||||||
import com.njcn.device.pq.service.DeviceOnlineDataService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
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 java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/16 14:34
|
|
||||||
*/
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tabCensus")
|
|
||||||
@Api(tags = "列表统计")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class TabCensusController extends BaseController {
|
|
||||||
|
|
||||||
private final DeviceOnlineDataService deviceOnlineDataService;
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/getDeviceOnlineData")
|
|
||||||
@ApiOperation("获取终端在线率列表")
|
|
||||||
@ApiImplicitParam(name = "tabCensusParam", value = "区域统计查询参数", required = true)
|
|
||||||
public HttpResult<List<DeviceOnlineTabVO>> getDeviceOnlineData(@RequestBody @Validated TabCensusParam tabCensusParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getDeviceOnlineData");
|
|
||||||
LogUtil.njcnDebug(log, "{}", methodDescribe, tabCensusParam);
|
|
||||||
List<DeviceOnlineTabVO> result = deviceOnlineDataService.getDeviceOnlineData(tabCensusParam);
|
|
||||||
if (CollectionUtil.isEmpty(result)) {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
|
||||||
} else {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.njcn.device.pq.mapper;
|
package com.njcn.device.pq.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.device.pq.pojo.param.AreaIntegrityDataParam;
|
|
||||||
import com.njcn.device.pq.pojo.po.Communicate;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityDataVO;
|
import com.njcn.device.pq.pojo.vo.AreaIntegrityDataVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.njcn.device.pq.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.njcn.device.pq.pojo.po.Communicate;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author denghuajun
|
|
||||||
* @date 2022/2/28
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface CommunicateMapper extends BaseMapper<Communicate> {
|
|
||||||
List<Communicate> getCommunicate(@Param("id") String id, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.njcn.device.pq.mapper.CommunicateMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.njcn.device.pq.service;
|
|
||||||
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaDeviceOnlineVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/11 20:52
|
|
||||||
*/
|
|
||||||
public interface AreaDeviceOnlineService {
|
|
||||||
|
|
||||||
List<AreaDeviceOnlineVO> getAreaDeviceOnline(AreaCensusParam areaCensusParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.njcn.device.pq.service;
|
|
||||||
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaIntegrityDataParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityDataVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区域数据完整性
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/22
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface AreaIntegrityDataService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取区域数据完整性
|
|
||||||
* @param areaIntegrityDataParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<AreaIntegrityDataVO> getAreaIntegrityData(AreaIntegrityDataParam areaIntegrityDataParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.njcn.device.pq.service;
|
|
||||||
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/15 15:43
|
|
||||||
*/
|
|
||||||
public interface AreaIntegrityService {
|
|
||||||
|
|
||||||
List<AreaIntegrityVO> getAreaIntegrity(AreaCensusParam areaCensusParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.njcn.device.pq.service;
|
|
||||||
|
|
||||||
import com.njcn.device.pq.pojo.param.TabCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceOnlineTabVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/16 14:53
|
|
||||||
*/
|
|
||||||
public interface DeviceOnlineDataService {
|
|
||||||
|
|
||||||
List<DeviceOnlineTabVO> getDeviceOnlineData(TabCensusParam tabCensusParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.njcn.device.pq.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.njcn.device.pq.pojo.param.DeviceRunExceptionParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceRunExceptionVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计业务层
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/27
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface DeviceRunExceptionService extends IService<DeviceRunExceptionVO> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计
|
|
||||||
* @param deviceRunExceptionParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<DeviceRunExceptionVO> getDeviceRunException(DeviceRunExceptionParam deviceRunExceptionParam);
|
|
||||||
}
|
|
||||||
@@ -107,31 +107,6 @@ public interface LineService {
|
|||||||
*/
|
*/
|
||||||
List<LineStatisticsTableVO> getLineStatisticsTable(DeviceInfoParam.BusinessParam deviceInfoParam);
|
List<LineStatisticsTableVO> getLineStatisticsTable(DeviceInfoParam.BusinessParam deviceInfoParam);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取监测点运行统计
|
|
||||||
* @param deviceInfoParam 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
List<LineFlowMealDetailVO> getLineRunStatistics(DeviceInfoParam.BusinessParam deviceInfoParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取终端运行统计
|
|
||||||
* @param deviceInfoParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
List<LineFlowMealDetailVO> getDeviceRunStatistics(DeviceInfoParam.BusinessParam deviceInfoParam);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取详细的统计数据
|
|
||||||
* @param startTime 起始时间
|
|
||||||
* @param endTime 结束时间
|
|
||||||
* @param lineId 监测点id
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
LineStaticsViewVO getLineStaticsView(String startTime,String endTime,String lineId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取监测点限值信息
|
* 获取监测点限值信息
|
||||||
@@ -154,12 +129,7 @@ public interface LineService {
|
|||||||
*/
|
*/
|
||||||
List<Line> getBaseLineList(List<String> lineIndex);
|
List<Line> getBaseLineList(List<String> lineIndex);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取终端异常数据
|
|
||||||
* @param deviceInfoParam 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam deviceInfoParam);
|
|
||||||
/**
|
/**
|
||||||
* @Description: 通过部门索引查询其下监测点数
|
* @Description: 通过部门索引查询其下监测点数
|
||||||
* @Param: [deviceInfoParam] 监测点查询条件
|
* @Param: [deviceInfoParam] 监测点查询条件
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ import com.njcn.device.pq.pojo.vo.EventLogVO;
|
|||||||
*/
|
*/
|
||||||
public interface LogManageService {
|
public interface LogManageService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取终端日志列表
|
|
||||||
* @param deviceLogParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam);
|
|
||||||
/**
|
/**
|
||||||
* 获取暂降推送日志列表
|
* 获取暂降推送日志列表
|
||||||
* @param eventLogParam
|
* @param eventLogParam
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.njcn.device.pq.controller.GeneralDeviceInfoController;
|
|
||||||
import com.njcn.device.pq.mapper.AreaDeviceOnlineMapper;
|
|
||||||
import com.njcn.device.pq.mapper.DeviceMapper;
|
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.po.Device;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaDeviceOnlineVO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.LineInfluxDbOnlineVO;
|
|
||||||
import com.njcn.device.pq.service.AreaDeviceOnlineService;
|
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/11 20:53
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AreaDeviceOnlineServiceImpl implements AreaDeviceOnlineService {
|
|
||||||
|
|
||||||
private final GeneralDeviceInfoController generalDeviceInfoController;
|
|
||||||
|
|
||||||
private final AreaDeviceOnlineMapper areaDeviceOnlineMapper;
|
|
||||||
|
|
||||||
private final DeviceMapper deviceMapper;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AreaDeviceOnlineVO> getAreaDeviceOnline(AreaCensusParam areaCensusParam) {
|
|
||||||
List<AreaDeviceOnlineVO> areaDeviceOnlineVOS = new ArrayList<>();
|
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOS = generalDeviceInfoController.getPracticalAllDeviceInfo(areaCensusParam).getData();
|
|
||||||
|
|
||||||
// //区域下的所有终端id集合
|
|
||||||
// List<String> deviceIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
|
|
||||||
if (!CollectionUtils.isEmpty(generalDeviceDTOS)) {
|
|
||||||
for (GeneralDeviceDTO generalDeviceDTO: generalDeviceDTOS) {
|
|
||||||
AreaDeviceOnlineVO areaDeviceOnlineVO = new AreaDeviceOnlineVO();
|
|
||||||
List<String> deviceIndexes = generalDeviceDTO.getDeviceIndexes();
|
|
||||||
if (CollectionUtils.isEmpty(deviceIndexes)) {
|
|
||||||
areaDeviceOnlineVO.setAreaName(generalDeviceDTO.getName());
|
|
||||||
areaDeviceOnlineVOS.add(areaDeviceOnlineVO);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
areaDeviceOnlineVO.setAreaName(generalDeviceDTO.getName());
|
|
||||||
switch (areaCensusParam.getLineLevel()) {
|
|
||||||
case 0:
|
|
||||||
// 查全部
|
|
||||||
areaDeviceOnlineVO.setNumber(deviceIndexes.size());
|
|
||||||
areaDeviceOnlineVO = deviceToAreaDeviceOnlineVO(deviceIndexes, areaDeviceOnlineVO, areaCensusParam);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// 查极重要
|
|
||||||
String firstLevel = "486927bc1c09c14f1e54a5b1757bf5c4";
|
|
||||||
int deviceNumberFirst = getDeviceNumber(firstLevel, deviceIndexes, generalDeviceDTO.getLineIndexes());
|
|
||||||
areaDeviceOnlineVO.setNumber(deviceNumberFirst);
|
|
||||||
areaDeviceOnlineVO = deviceToAreaDeviceOnlineVO(deviceIndexes, areaDeviceOnlineVO, areaCensusParam);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// 查重要
|
|
||||||
String secLevel = "eae449e73806a5c810fa2d3b01bc3e50";
|
|
||||||
int deviceNumberSec = getDeviceNumber(secLevel, deviceIndexes, generalDeviceDTO.getLineIndexes());
|
|
||||||
areaDeviceOnlineVO.setNumber(deviceNumberSec);
|
|
||||||
areaDeviceOnlineVO = deviceToAreaDeviceOnlineVO(deviceIndexes, areaDeviceOnlineVO, areaCensusParam);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// 查普通
|
|
||||||
String thiLevel = "64b4afe96e874c3c3dc634ea3ef79a21";
|
|
||||||
int deviceNumberThi = getDeviceNumber(thiLevel, deviceIndexes, generalDeviceDTO.getLineIndexes());
|
|
||||||
areaDeviceOnlineVO.setNumber(deviceNumberThi);
|
|
||||||
areaDeviceOnlineVO = deviceToAreaDeviceOnlineVO(deviceIndexes, areaDeviceOnlineVO, areaCensusParam);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// 查不重要
|
|
||||||
String fourLevel = "d3dac5ffa1daf6564e29e989e465135e";
|
|
||||||
int deviceNumberFour = getDeviceNumber(fourLevel, deviceIndexes, generalDeviceDTO.getLineIndexes());
|
|
||||||
areaDeviceOnlineVO.setNumber(deviceNumberFour);
|
|
||||||
areaDeviceOnlineVO = deviceToAreaDeviceOnlineVO(deviceIndexes, areaDeviceOnlineVO, areaCensusParam);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
areaDeviceOnlineVOS.add(areaDeviceOnlineVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return areaDeviceOnlineVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private AreaDeviceOnlineVO deviceToAreaDeviceOnlineVO(List<String> deviceIndexes, AreaDeviceOnlineVO areaDeviceOnlineVO, AreaCensusParam areaCensusParam) {
|
|
||||||
List<Device> devices = deviceMapper.selectBatchIds(deviceIndexes);
|
|
||||||
BiFunction<Integer, List<String>, Long> integerListLongBiFunction = countDeviceRunStatus(devices);
|
|
||||||
areaDeviceOnlineVO.setNormal(integerListLongBiFunction.apply(0, deviceIndexes).intValue());
|
|
||||||
areaDeviceOnlineVO.setBreaks(integerListLongBiFunction.apply(1, deviceIndexes).intValue());
|
|
||||||
areaDeviceOnlineVO.setShutdown(integerListLongBiFunction.apply(2, deviceIndexes).intValue());
|
|
||||||
double normalRate = areaDeviceOnlineVO.getNormal().doubleValue() / deviceIndexes.size() * 100;
|
|
||||||
areaDeviceOnlineVO.setNormalRate(new BigDecimal(normalRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
double breaksRate = areaDeviceOnlineVO.getBreaks().doubleValue() / deviceIndexes.size() * 100;
|
|
||||||
areaDeviceOnlineVO.setBreaksRate(new BigDecimal(breaksRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
double shutdownRate = areaDeviceOnlineVO.getShutdown().doubleValue() / deviceIndexes.size() * 100;
|
|
||||||
areaDeviceOnlineVO.setShutdownRate(new BigDecimal(shutdownRate).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
List<LineInfluxDbOnlineVO> onlineData = getOnlineData(deviceIndexes, areaCensusParam.getSearchBeginTime(), areaCensusParam.getSearchEndTime());
|
|
||||||
if (!CollectionUtils.isEmpty(onlineData)) {
|
|
||||||
double avgOnline = onlineData.stream().mapToDouble(LineInfluxDbOnlineVO::getOnlineRate).sum() / onlineData.size();
|
|
||||||
areaDeviceOnlineVO.setOnlineRate(new BigDecimal(avgOnline).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
}
|
|
||||||
return areaDeviceOnlineVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private int getDeviceNumber(String lineLevel, List<String> deviceIndexes, List<String> lineIndexes) {
|
|
||||||
List<String> lineIdList = areaDeviceOnlineMapper.selectLineIdBylineLevel(lineLevel);
|
|
||||||
List<String> result = lineIdList.stream().filter(item -> lineIndexes.contains(item)).collect(Collectors.toList());
|
|
||||||
int i = 0;
|
|
||||||
for (String id: deviceIndexes) {
|
|
||||||
List<String> strings = areaDeviceOnlineMapper.selectLineIds(id);
|
|
||||||
List<String> lineIds = result.stream().filter(item -> strings.contains(item)).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isEmpty(lineIds)) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取终端运行状态*/
|
|
||||||
private BiFunction<Integer, List<String>, Long> countDeviceRunStatus(List<Device> pqDeviceList) {
|
|
||||||
return (runFlag, deviceIndexes) -> pqDeviceList.stream()
|
|
||||||
.filter(t -> Objects.equals(t.getRunFlag(), runFlag))
|
|
||||||
.filter(t -> deviceIndexes.contains(t.getId()))
|
|
||||||
.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取按终端分组的终端在线率*/
|
|
||||||
public List<LineInfluxDbOnlineVO> getOnlineData(List<String> deviceIndexes, String searchBeginTime, String searchEndTime) {
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(searchBeginTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(searchEndTime))).append("' and ");
|
|
||||||
|
|
||||||
for (int i = 0; i < deviceIndexes.size(); i++) {
|
|
||||||
if (deviceIndexes.size() - i != 1) {
|
|
||||||
stringBuilder.append("dev_id ='").append(deviceIndexes.get(i)).append("' or ");
|
|
||||||
} else {
|
|
||||||
stringBuilder.append("dev_id ='").append(deviceIndexes.get(i)).append("' ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String sql = "select sum(onlinemin)/(sum(onlinemin) +sum(offlinemin))*100 as onlinerate from pqs_onlinerate where " + stringBuilder + "group by dev_id " + InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
System.out.println("sql>>>>>>>>>>>>>>>>>>>>>"+sql);
|
|
||||||
//获取暂降事件
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVOS = influxDBResultMapper.toPOJO(result, LineInfluxDbOnlineVO.class);
|
|
||||||
return lineInfluxDbOnlineVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.njcn.device.pq.api.AlarmClient;
|
|
||||||
import com.njcn.device.pq.mapper.AreaIntegrityDataMapper;
|
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaIntegrityDataParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityDataVO;
|
|
||||||
import com.njcn.device.pq.service.AreaIntegrityDataService;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/22
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class AreaIntegrityDataServiceImpl extends ServiceImpl<AreaIntegrityDataMapper, AreaIntegrityDataVO> implements AreaIntegrityDataService {
|
|
||||||
|
|
||||||
private final AreaIntegrityDataMapper areaIntegrityDataMapper;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final AlarmClient alarmClient;
|
|
||||||
|
|
||||||
private final GeneralDeviceService generalDeviceService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取区域数据完整性
|
|
||||||
*
|
|
||||||
* @param areaIntegrityDataParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<AreaIntegrityDataVO> getAreaIntegrityData(AreaIntegrityDataParam areaIntegrityDataParam) {
|
|
||||||
|
|
||||||
// TODO 获取部门id
|
|
||||||
// areaIntegrityDataParam.setDeptIndex(RequestUtil.getDeptIndex());
|
|
||||||
|
|
||||||
// 获取所有数据
|
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(areaIntegrityDataParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.njcn.device.pq.controller.GeneralDeviceInfoController;
|
|
||||||
import com.njcn.device.pq.mapper.AreaDeviceOnlineMapper;
|
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
||||||
import com.njcn.device.pq.pojo.param.AreaCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
|
||||||
import com.njcn.device.pq.pojo.vo.AreaIntegrityVO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.LineInfluxDbInegrityVO;
|
|
||||||
import com.njcn.device.pq.service.AreaIntegrityService;
|
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/15 15:53
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AreaIntegrityServiceImpl implements AreaIntegrityService {
|
|
||||||
|
|
||||||
private final GeneralDeviceInfoController generalDeviceInfoController;
|
|
||||||
|
|
||||||
private final AreaDeviceOnlineMapper areaDeviceOnlineMapper;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AreaIntegrityVO> getAreaIntegrity(AreaCensusParam areaCensusParam) {
|
|
||||||
List<AreaIntegrityVO> areaIntegrityVOS = new ArrayList<>();
|
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOS = generalDeviceInfoController.getPracticalAllDeviceInfo(areaCensusParam).getData();
|
|
||||||
if (!CollectionUtils.isEmpty(generalDeviceDTOS)) {
|
|
||||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOS) {
|
|
||||||
AreaIntegrityVO areaIntegrityVO = new AreaIntegrityVO();
|
|
||||||
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
|
|
||||||
if (CollectionUtils.isEmpty(lineIndexes)) {
|
|
||||||
areaIntegrityVO.setAreaName(generalDeviceDTO.getName());
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
areaIntegrityVO.setAreaName(generalDeviceDTO.getName());
|
|
||||||
switch (areaCensusParam.getLineLevel()) {
|
|
||||||
case 0:
|
|
||||||
// 查全部
|
|
||||||
areaIntegrityVO.setNumber(lineIndexes.size());
|
|
||||||
areaIntegrityVO = lineIdsToAreaOnlineVO(lineIndexes, areaIntegrityVO, areaCensusParam);
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// 查极重要
|
|
||||||
String firstLevel = "486927bc1c09c14f1e54a5b1757bf5c4";
|
|
||||||
List<String> firstLineIdList = areaDeviceOnlineMapper.selectLineIdBylineLevel(firstLevel);
|
|
||||||
List<String> firstResult = firstLineIdList.stream().filter(item -> lineIndexes.contains(item)).collect(Collectors.toList());
|
|
||||||
areaIntegrityVO.setNumber(firstResult.size());
|
|
||||||
areaIntegrityVO = lineIdsToAreaOnlineVO(lineIndexes, areaIntegrityVO, areaCensusParam);
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// 查重要
|
|
||||||
String secLevel = "eae449e73806a5c810fa2d3b01bc3e50";
|
|
||||||
List<String> secLineIdList = areaDeviceOnlineMapper.selectLineIdBylineLevel(secLevel);
|
|
||||||
List<String> secResult = secLineIdList.stream().filter(item -> lineIndexes.contains(item)).collect(Collectors.toList());
|
|
||||||
areaIntegrityVO.setNumber(secResult.size());
|
|
||||||
areaIntegrityVO = lineIdsToAreaOnlineVO(lineIndexes, areaIntegrityVO, areaCensusParam);
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// 查普通
|
|
||||||
String thiLevel = "64b4afe96e874c3c3dc634ea3ef79a21";
|
|
||||||
List<String> thiLineIdList = areaDeviceOnlineMapper.selectLineIdBylineLevel(thiLevel);
|
|
||||||
List<String> thiResult = thiLineIdList.stream().filter(item -> lineIndexes.contains(item)).collect(Collectors.toList());
|
|
||||||
areaIntegrityVO.setNumber(thiResult.size());
|
|
||||||
areaIntegrityVO = lineIdsToAreaOnlineVO(lineIndexes, areaIntegrityVO, areaCensusParam);
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// 查不重要
|
|
||||||
String fourLevel = "d3dac5ffa1daf6564e29e989e465135e";
|
|
||||||
List<String> fourLineIdList = areaDeviceOnlineMapper.selectLineIdBylineLevel(fourLevel);
|
|
||||||
List<String> fourResult = fourLineIdList.stream().filter(item -> lineIndexes.contains(item)).collect(Collectors.toList());
|
|
||||||
areaIntegrityVO.setNumber(fourResult.size());
|
|
||||||
areaIntegrityVO = lineIdsToAreaOnlineVO(lineIndexes, areaIntegrityVO, areaCensusParam);
|
|
||||||
areaIntegrityVOS.add(areaIntegrityVO);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
areaIntegrityVO.setAreaName(generalDeviceDTO.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return areaIntegrityVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AreaIntegrityVO lineIdsToAreaOnlineVO(List<String> lineIndexes, AreaIntegrityVO areaIntegrityVO, AreaCensusParam areaCensusParam) {
|
|
||||||
List<LineInfluxDbInegrityVO> integrityData = getIntegrityData(lineIndexes, areaCensusParam);
|
|
||||||
if (!CollectionUtils.isEmpty(integrityData)) {
|
|
||||||
double avgIntegrity = integrityData.stream().mapToDouble(LineInfluxDbInegrityVO::getIntegrity).sum() / integrityData.size();
|
|
||||||
areaIntegrityVO.setIntegrity(new BigDecimal(avgIntegrity).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
}
|
|
||||||
return areaIntegrityVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取按监测点分组的数据完整性*/
|
|
||||||
public List<LineInfluxDbInegrityVO> getIntegrityData(List<String> lineIndexes, DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and ");
|
|
||||||
for (int i = 0; i < lineIndexes.size(); i++) {
|
|
||||||
if (lineIndexes.size() - i != 1) {
|
|
||||||
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' or ");
|
|
||||||
} else {
|
|
||||||
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String sql = "select sum(real)/(sum(due))*100 as integrity from pqs_integrity where " + stringBuilder + "group by line_id " + InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
//获取暂降事件
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<LineInfluxDbInegrityVO> eventDetailList = influxDBResultMapper.toPOJO(result, LineInfluxDbInegrityVO.class);
|
|
||||||
return eventDetailList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import com.njcn.device.pq.pojo.vo.*;
|
|||||||
import com.njcn.device.pq.service.CommunicateService;
|
import com.njcn.device.pq.service.CommunicateService;
|
||||||
import com.njcn.device.pq.service.LineService;
|
import com.njcn.device.pq.service.LineService;
|
||||||
import com.njcn.device.pq.utils.PublicDateUtil;
|
import com.njcn.device.pq.utils.PublicDateUtil;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -33,9 +32,8 @@ public class CommunicateServiceImpl implements CommunicateService {
|
|||||||
|
|
||||||
private final LineService lineService;
|
private final LineService lineService;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final RStatOnlinerateDMapper onlinerateDMapper;
|
private final RStatOnlinerateDMapper onlinerateDMapper;
|
||||||
|
|
||||||
private final RStatIntegrityDMapper integrityDMapper;
|
private final RStatIntegrityDMapper integrityDMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,37 +164,6 @@ public class CommunicateServiceImpl implements CommunicateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultList[0];
|
return resultList[0];
|
||||||
|
|
||||||
//
|
|
||||||
// //组装sql语句
|
|
||||||
// StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
// stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
|
|
||||||
// //sql语句
|
|
||||||
// String sql = "";
|
|
||||||
// if (state == 0) {
|
|
||||||
// stringBuilder.append(LINE_ID + "='").append(lineList).append("')");
|
|
||||||
// sql = "SELECT SUM(" + REAL + ")/SUM(" + DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + LINE_ID + " tz('Asia/Shanghai')";
|
|
||||||
// } else {
|
|
||||||
// stringBuilder.append(DEV_INDEX + "='").append(lineList).append("')");
|
|
||||||
// sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + DEV_INDEX + " tz('Asia/Shanghai')";
|
|
||||||
// }
|
|
||||||
// //结果集
|
|
||||||
// QueryResult result = influxDbUtils.query(sql);
|
|
||||||
// //处理结果集
|
|
||||||
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
|
||||||
// if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
// list.forEach(po -> {
|
|
||||||
// List<List<Object>> valueList = po.getValues();
|
|
||||||
// if (!CollectionUtils.isEmpty(valueList)) {
|
|
||||||
// for (List<Object> value : valueList) {
|
|
||||||
// //数据完整性 保留四位小数
|
|
||||||
// resultList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return resultList[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,152 +0,0 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
|
||||||
|
|
||||||
import com.njcn.device.pq.mapper.DeviceOnlineDataMapper;
|
|
||||||
import com.njcn.device.pq.pojo.dto.DeviceOnlineDataDTO;
|
|
||||||
import com.njcn.device.pq.pojo.param.TabCensusParam;
|
|
||||||
import com.njcn.device.pq.pojo.po.TopMsg;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceOnlineTabVO;
|
|
||||||
import com.njcn.device.pq.pojo.vo.LineInfluxDbOnlineVO;
|
|
||||||
import com.njcn.device.pq.service.DeviceOnlineDataService;
|
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 1.0.0
|
|
||||||
* @author: chenchao
|
|
||||||
* @date: 2022/08/16 14:55
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DeviceOnlineDataServiceImpl implements DeviceOnlineDataService {
|
|
||||||
|
|
||||||
private final DeviceOnlineDataMapper deviceOnlineDataMapper;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final AreaDeviceOnlineServiceImpl areaDeviceOnlineService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DeviceOnlineTabVO> getDeviceOnlineData(TabCensusParam tabCensusParam) {
|
|
||||||
List<DeviceOnlineTabVO> deviceOnlineTabVOS = new ArrayList<>();
|
|
||||||
|
|
||||||
List<TopMsg> topMsg = getTopMsg(tabCensusParam.getSearchBeginTime(), tabCensusParam.getSearchEndTime());
|
|
||||||
if (!CollectionUtils.isEmpty(topMsg)) {
|
|
||||||
List<String> deviceIds = topMsg.stream().map(TopMsg::getDeviceId).collect(Collectors.toList());
|
|
||||||
List<LineInfluxDbOnlineVO> onlineData = areaDeviceOnlineService.getOnlineData(deviceIds, tabCensusParam.getSearchBeginTime(), tabCensusParam.getSearchEndTime());
|
|
||||||
if (!CollectionUtils.isEmpty(onlineData)) {
|
|
||||||
for (LineInfluxDbOnlineVO onlineVO: onlineData) {
|
|
||||||
onlineVO.setOnlineRate(new BigDecimal(onlineVO.getOnlineRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
}
|
|
||||||
Integer qualify = tabCensusParam.getQualify();
|
|
||||||
if (qualify==1) {
|
|
||||||
onlineData = onlineData.stream().filter(item -> item.getOnlineRate() < 95).collect(Collectors.toList());
|
|
||||||
} if (qualify==2) {
|
|
||||||
onlineData = onlineData.stream().filter(item -> item.getOnlineRate() >= 95).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
List<String> devIndexes = onlineData.stream().map(LineInfluxDbOnlineVO::getDevIndex).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<String> devIndexesByLevel = getDevIndexesByLevel(devIndexes, tabCensusParam.getLevel());
|
|
||||||
topMsg = topMsg.stream().filter(item -> devIndexesByLevel.contains(item.getDeviceId())).collect(Collectors.toList());
|
|
||||||
if (!CollectionUtils.isEmpty(topMsg)) {
|
|
||||||
List<DeviceOnlineTabVO> deviceFatherData = deviceOnlineDataMapper.getDeviceFatherData(devIndexesByLevel);
|
|
||||||
for (TopMsg msg: topMsg) {
|
|
||||||
DeviceOnlineTabVO deviceOnlineTabVO = new DeviceOnlineTabVO();
|
|
||||||
DeviceOnlineTabVO tabVO = deviceFatherData.stream().filter(item -> item.getDeviceId().equals(msg.getDeviceId())).collect(Collectors.toList()).get(0);
|
|
||||||
BeanUtils.copyProperties(tabVO, deviceOnlineTabVO);
|
|
||||||
deviceOnlineTabVO.setDeviceId(msg.getDeviceId());
|
|
||||||
deviceOnlineTabVO.setComOutNumber(msg.getComOutNum());
|
|
||||||
Double onlineRate = onlineData.stream().filter(item -> item.getDevIndex().equals(msg.getDeviceId())).collect(Collectors.toList()).get(0).getOnlineRate();
|
|
||||||
deviceOnlineTabVO.setOnlineRate(onlineRate);
|
|
||||||
switch (tabCensusParam.getLevel()) {
|
|
||||||
case 0:
|
|
||||||
DeviceOnlineDataDTO minDeviceLevelById = deviceOnlineDataMapper.getMinDeviceLevelById(msg.getDeviceId());
|
|
||||||
deviceOnlineTabVO.setLevel(minDeviceLevelById.getLevelName());
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
deviceOnlineTabVO.setLevel("极重要");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
deviceOnlineTabVO.setLevel("重要");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
deviceOnlineTabVO.setLevel("普通");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
deviceOnlineTabVO.setLevel("不重要");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
deviceOnlineTabVOS.add(deviceOnlineTabVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceOnlineTabVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**通过监测点等级获取终端集合 */
|
|
||||||
public List<String> getDevIndexesByLevel(List<String> deviceIds, Integer level) {
|
|
||||||
switch (level) {
|
|
||||||
case 0:
|
|
||||||
return deviceIds;
|
|
||||||
case 1:
|
|
||||||
List<DeviceOnlineDataDTO> minDeviceLevelOne = deviceOnlineDataMapper.getMinDeviceLevel(deviceIds);
|
|
||||||
List<DeviceOnlineDataDTO> collectListOne = minDeviceLevelOne.stream().filter(item -> item.getLineGrade().equals("486927bc1c09c14f1e54a5b1757bf5c4")).collect(Collectors.toList());
|
|
||||||
deviceIds = collectListOne.stream().map(DeviceOnlineDataDTO::getDeviceId).distinct().collect(Collectors.toList());
|
|
||||||
return deviceIds;
|
|
||||||
case 2:
|
|
||||||
List<DeviceOnlineDataDTO> minDeviceLevelTwo = deviceOnlineDataMapper.getMinDeviceLevel(deviceIds);
|
|
||||||
List<DeviceOnlineDataDTO> collectListTwo = minDeviceLevelTwo.stream().filter(item -> item.getLineGrade().equals("eae449e73806a5c810fa2d3b01bc3e50")).collect(Collectors.toList());
|
|
||||||
deviceIds = collectListTwo.stream().map(DeviceOnlineDataDTO::getDeviceId).collect(Collectors.toList());
|
|
||||||
return deviceIds;
|
|
||||||
case 3:
|
|
||||||
List<DeviceOnlineDataDTO> minDeviceLevelThr = deviceOnlineDataMapper.getMinDeviceLevel(deviceIds);
|
|
||||||
List<DeviceOnlineDataDTO> collectListThr = minDeviceLevelThr.stream().filter(item -> item.getLineGrade().equals("64b4afe96e874c3c3dc634ea3ef79a21")).collect(Collectors.toList());
|
|
||||||
deviceIds = collectListThr.stream().map(DeviceOnlineDataDTO::getDeviceId).collect(Collectors.toList());
|
|
||||||
return deviceIds;
|
|
||||||
case 4:
|
|
||||||
List<DeviceOnlineDataDTO> minDeviceLevelFour = deviceOnlineDataMapper.getMinDeviceLevel(deviceIds);
|
|
||||||
List<DeviceOnlineDataDTO> collectListFour = minDeviceLevelFour.stream().filter(item -> item.getLineGrade().equals("d3dac5ffa1daf6564e29e989e465135e")).collect(Collectors.toList());
|
|
||||||
deviceIds = collectListFour.stream().map(DeviceOnlineDataDTO::getDeviceId).collect(Collectors.toList());
|
|
||||||
return deviceIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**查询按终端分组的中断次数 */
|
|
||||||
private List<TopMsg> getTopMsg(String startTime, String endTime) {
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder string = new StringBuilder();
|
|
||||||
string.append(InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "'");
|
|
||||||
//sql语句
|
|
||||||
String sql = "SELECT sum(com_out_num) as com_out_num FROM pqs_top_msg WHERE " + string + " group by dev_id " + InfluxDBPublicParam.TIME_ZONE ;
|
|
||||||
//结果集
|
|
||||||
QueryResult results = influxDbUtils.query(sql);
|
|
||||||
//结果集映射到对象中
|
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
|
||||||
List<TopMsg> topMsgList = resultMapper.toPOJO(results, TopMsg.class);
|
|
||||||
|
|
||||||
return topMsgList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,331 +0,0 @@
|
|||||||
package com.njcn.device.pq.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.njcn.device.pq.mapper.DeviceRunExceptionMapper;
|
|
||||||
import com.njcn.device.pq.pojo.param.DeviceRunExceptionParam;
|
|
||||||
import com.njcn.device.pq.pojo.po.DeviceRunException;
|
|
||||||
import com.njcn.device.pq.pojo.vo.DeviceRunExceptionVO;
|
|
||||||
import com.njcn.device.pq.service.DeviceRunExceptionService;
|
|
||||||
import com.njcn.device.pq.utils.SpiltDateUtil;
|
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
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.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计业务层实现类
|
|
||||||
*
|
|
||||||
* @author yzh
|
|
||||||
* @date 2022/9/27
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DeviceRunExceptionServiceImpl extends ServiceImpl<DeviceRunExceptionMapper, DeviceRunExceptionVO> implements DeviceRunExceptionService {
|
|
||||||
|
|
||||||
private final DeviceRunExceptionMapper deviceRunExceptionMapper;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 终端异常统计
|
|
||||||
*
|
|
||||||
* @param deviceRunExceptionParam 全段参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<DeviceRunExceptionVO> getDeviceRunException(DeviceRunExceptionParam deviceRunExceptionParam) {
|
|
||||||
// 创建集合,用于返回数据
|
|
||||||
List<DeviceRunExceptionVO> deviceRunExceptionList = new ArrayList<>();
|
|
||||||
// 获取终端等级信息
|
|
||||||
List<DeviceRunExceptionVO> deviceLevelData = deviceRunExceptionMapper.getDeviceLevelData(deviceRunExceptionParam.getSearchBeginTime(), deviceRunExceptionParam.getSearchEndTime());
|
|
||||||
// 判断终端等级
|
|
||||||
judgeDeviceLevel(deviceLevelData, deviceRunExceptionParam.getAlgoDescribe());
|
|
||||||
// 查询influxdb数据库
|
|
||||||
List<DeviceRunException> pqsTopMsg = getPqsTopMsg(deviceRunExceptionParam, deviceLevelData);
|
|
||||||
|
|
||||||
// 根据前端传入的时间区间选择不同的返回结果
|
|
||||||
switch (deviceRunExceptionParam.getTimeFlag()) {
|
|
||||||
// 年或季
|
|
||||||
case 0:
|
|
||||||
try {
|
|
||||||
// 将时间段按照月分割
|
|
||||||
List<SpiltDateUtil.Range> ranges = SpiltDateUtil.splitToMonths(deviceRunExceptionParam.getSearchBeginTime(), deviceRunExceptionParam.getSearchEndTime());
|
|
||||||
// 数据处理(年或季)
|
|
||||||
deviceRunExceptionList = getData(pqsTopMsg, ranges, deviceRunExceptionParam);
|
|
||||||
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 月或周或自定义
|
|
||||||
case 1:
|
|
||||||
try {
|
|
||||||
// 时间段中的每个日期
|
|
||||||
List<String> dates = findDates(deviceRunExceptionParam.getSearchBeginTime(), deviceRunExceptionParam.getSearchEndTime());
|
|
||||||
// 数据处理(月或周)
|
|
||||||
deviceRunExceptionList = getData(pqsTopMsg, dates);
|
|
||||||
deviceRunExceptionList = deviceRunExceptionList.stream().peek(deviceRunExceptionVO -> deviceRunExceptionVO.setAlgoDescribe(deviceRunExceptionParam.getAlgoDescribe())).collect(Collectors.toList());
|
|
||||||
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return deviceRunExceptionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据处理(月或周)
|
|
||||||
*
|
|
||||||
* @param pqsTopMsg influxdb中数据
|
|
||||||
* @param dates 时间段中的每个日期
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DeviceRunExceptionVO> getData(List<DeviceRunException> pqsTopMsg, List<String> dates) {
|
|
||||||
List<DeviceRunExceptionVO> deviceRunExceptionList = new ArrayList<>();
|
|
||||||
// 将influxdb中的数据根据时间进行分类
|
|
||||||
Map<String, List<DeviceRunException>> groupByTime = pqsTopMsg.stream().collect(Collectors.groupingBy(DeviceRunException::getTime));
|
|
||||||
// 将map集合中的key取出
|
|
||||||
Set<String> times = groupByTime.keySet();
|
|
||||||
|
|
||||||
for (String date : dates) {
|
|
||||||
// 创建对象用于封装数据
|
|
||||||
DeviceRunExceptionVO deviceRunExceptionVO = new DeviceRunExceptionVO();
|
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(groupByTime)) {
|
|
||||||
// 遍历时间key
|
|
||||||
for (String time : times) {
|
|
||||||
|
|
||||||
// 创建变量,用于统计当前时间的异常次数
|
|
||||||
int sumDeviceRunException = 0;
|
|
||||||
|
|
||||||
// 将key对应的值取出
|
|
||||||
List<DeviceRunException> deviceRunExceptions = groupByTime.get(time);
|
|
||||||
// 变量值的集合
|
|
||||||
for (DeviceRunException deviceRunException : deviceRunExceptions) {
|
|
||||||
// 计算当前时间的异常次数
|
|
||||||
sumDeviceRunException += deviceRunException.getAlarmNum() + deviceRunException.getComOutNum();
|
|
||||||
}
|
|
||||||
if (date.equals(time)) {
|
|
||||||
if (sumDeviceRunException == 0) {
|
|
||||||
deviceRunExceptionVO.setDeviceRunExceptionFrequency(3.14159);
|
|
||||||
} else {
|
|
||||||
deviceRunExceptionVO.setDeviceRunExceptionFrequency((double) sumDeviceRunException);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deviceRunExceptionVO.setDay(date);
|
|
||||||
deviceRunExceptionList.add(deviceRunExceptionVO);
|
|
||||||
}else {
|
|
||||||
deviceRunExceptionVO.setDay(date);
|
|
||||||
deviceRunExceptionVO.setDeviceRunExceptionFrequency(3.14159);
|
|
||||||
deviceRunExceptionList.add(deviceRunExceptionVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deviceRunExceptionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据处理(年或季)
|
|
||||||
*
|
|
||||||
* @param pqsTopMsg influxdb中数据
|
|
||||||
* @param ranges 分割后的月份
|
|
||||||
* @param deviceRunExceptionParam 前端参数
|
|
||||||
* @return
|
|
||||||
* @throws ParseException
|
|
||||||
*/
|
|
||||||
private List<DeviceRunExceptionVO> getData
|
|
||||||
(List<DeviceRunException> pqsTopMsg, List<SpiltDateUtil.Range> ranges, DeviceRunExceptionParam
|
|
||||||
deviceRunExceptionParam) throws ParseException {
|
|
||||||
// 获取年份
|
|
||||||
String years = SpiltDateUtil.getYears(deviceRunExceptionParam.getSearchBeginTime(), deviceRunExceptionParam.getSearchEndTime());
|
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
List<DeviceRunExceptionVO> deviceRunExceptionList = new ArrayList<>();
|
|
||||||
// 将influxdb中的数据根据时间进行分类
|
|
||||||
Map<String, List<DeviceRunException>> groupByTime = pqsTopMsg.stream().collect(Collectors.groupingBy(DeviceRunException::getTime));
|
|
||||||
// 将map集合中的key取出
|
|
||||||
Set<String> times = groupByTime.keySet();
|
|
||||||
|
|
||||||
// 遍历时间key
|
|
||||||
for (SpiltDateUtil.Range range : ranges) {
|
|
||||||
int sumDeviceRunException = 0;
|
|
||||||
// 创建变量,用于统计当前时间的异常次数
|
|
||||||
DeviceRunExceptionVO deviceRunExceptionVO = new DeviceRunExceptionVO();
|
|
||||||
for (String time : times) {
|
|
||||||
long compareTime = sdf.parse(time).getTime();
|
|
||||||
long startTime = range.getStart().getTime();
|
|
||||||
long endTime = range.getEnd().getTime();
|
|
||||||
if (compareTime >= startTime && compareTime <= endTime) {
|
|
||||||
// 将key对应的值取出
|
|
||||||
List<DeviceRunException> deviceRunExceptions = groupByTime.get(time);
|
|
||||||
// 变量值的集合
|
|
||||||
for (DeviceRunException deviceRunException : deviceRunExceptions) {
|
|
||||||
// 计算当前时间的异常次数
|
|
||||||
sumDeviceRunException += deviceRunException.getAlarmNum() + deviceRunException.getComOutNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (sumDeviceRunException == 0) {
|
|
||||||
deviceRunExceptionVO.setDeviceRunExceptionFrequency(3.14159);
|
|
||||||
} else {
|
|
||||||
deviceRunExceptionVO.setDeviceRunExceptionFrequency((double) sumDeviceRunException);
|
|
||||||
}
|
|
||||||
deviceRunExceptionVO.setAlgoDescribe(deviceRunExceptionParam.getAlgoDescribe());
|
|
||||||
deviceRunExceptionVO.setMonth(range.getMonth());
|
|
||||||
deviceRunExceptionVO.setYear(years);
|
|
||||||
deviceRunExceptionList.add(deviceRunExceptionVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceRunExceptionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断终端等级
|
|
||||||
*
|
|
||||||
* @param deviceLevelData 终端等级信息集合
|
|
||||||
* @param algoDescribe 前端传入终端等级
|
|
||||||
*/
|
|
||||||
private void judgeDeviceLevel(List<DeviceRunExceptionVO> deviceLevelData, Integer algoDescribe) {
|
|
||||||
if (algoDescribe != null) {
|
|
||||||
switch (algoDescribe) {
|
|
||||||
// 极重要
|
|
||||||
case 0:
|
|
||||||
deviceLevelData = deviceLevelData.stream().filter(dev -> dev.getAlgoDescribe() != null && dev.getAlgoDescribe() == 0).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
// 重要
|
|
||||||
case 1:
|
|
||||||
deviceLevelData = deviceLevelData.stream().filter(dev -> dev.getAlgoDescribe() != null && dev.getAlgoDescribe() == 1).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
// 普通
|
|
||||||
case 2:
|
|
||||||
deviceLevelData = deviceLevelData.stream().filter(dev -> dev.getAlgoDescribe() != null && dev.getAlgoDescribe() == 2).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
//不重要
|
|
||||||
case 3:
|
|
||||||
deviceLevelData = deviceLevelData.stream().filter(dev -> dev.getAlgoDescribe() != null && dev.getAlgoDescribe() == 3).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析时间
|
|
||||||
*
|
|
||||||
* @param time
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String dateFormat(String time) {
|
|
||||||
String dateString = null;
|
|
||||||
try {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
// String -> Date
|
|
||||||
Date date = dateFormat.parse(time);
|
|
||||||
// Date -> String
|
|
||||||
dateString = dateFormat.format(date);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return dateString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询influxdb数据
|
|
||||||
*
|
|
||||||
* @param deviceRunExceptionParam
|
|
||||||
* @param deviceLevelData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DeviceRunException> getPqsTopMsg(DeviceRunExceptionParam
|
|
||||||
deviceRunExceptionParam, List<DeviceRunExceptionVO> deviceLevelData) {
|
|
||||||
// 获取终端id
|
|
||||||
List<String> devId = deviceLevelData.stream().map(DeviceRunExceptionVO::getDevId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<DeviceRunException> deviceRunExceptions = new ArrayList<>();
|
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(devId)) {
|
|
||||||
// 将终端id
|
|
||||||
StringBuilder lineIdsForInfluxdb = InfluxDBCommUtils.assToInfluxParam(devId);
|
|
||||||
// 组装sql语句
|
|
||||||
StringBuilder queryCriteria = new StringBuilder();
|
|
||||||
// 构造sql查询条件
|
|
||||||
queryCriteria.append(lineIdsForInfluxdb)
|
|
||||||
.append(" and ")
|
|
||||||
.append(InfluxDBPublicParam.TIME)
|
|
||||||
.append(" >= '")
|
|
||||||
.append(deviceRunExceptionParam.getSearchBeginTime())
|
|
||||||
.append(InfluxDBPublicParam.START_TIME)
|
|
||||||
.append("' and ")
|
|
||||||
.append(InfluxDBPublicParam.TIME)
|
|
||||||
.append(" <= '")
|
|
||||||
.append(deviceRunExceptionParam.getSearchEndTime())
|
|
||||||
.append(InfluxDBPublicParam.END_TIME)
|
|
||||||
.append("' ")
|
|
||||||
.append(InfluxDBPublicParam.TIME_ZONE);
|
|
||||||
//sql语句
|
|
||||||
|
|
||||||
String sql = "SELECT * FROM \"pqs_top_msg\" WHERE " + queryCriteria;
|
|
||||||
// 结果集
|
|
||||||
QueryResult results = influxDbUtils.query(sql);
|
|
||||||
// 结果集映射到对象中
|
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
|
||||||
deviceRunExceptions = resultMapper.toPOJO(results, DeviceRunException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回结果
|
|
||||||
return deviceRunExceptions;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 传入两个时间范围,返回这两个时间范围内的所有时间,并保存在一个集合中
|
|
||||||
*
|
|
||||||
* @param beginTime
|
|
||||||
* @param endTime
|
|
||||||
* @return
|
|
||||||
* @throws ParseException
|
|
||||||
*/
|
|
||||||
public static List<String> findDates(String beginTime, String endTime) throws ParseException {
|
|
||||||
List<String> allDate = new ArrayList();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
|
|
||||||
Date dBegin = sdf.parse(beginTime);
|
|
||||||
Date dEnd = sdf.parse(endTime);
|
|
||||||
allDate.add(sdf.format(dBegin));
|
|
||||||
Calendar calBegin = Calendar.getInstance();
|
|
||||||
// 使用给定的 Date 设置此 Calendar 的时间
|
|
||||||
calBegin.setTime(dBegin);
|
|
||||||
Calendar calEnd = Calendar.getInstance();
|
|
||||||
// 使用给定的 Date 设置此 Calendar 的时间
|
|
||||||
calEnd.setTime(dEnd);
|
|
||||||
// 测试此日期是否在指定日期之后
|
|
||||||
while (dEnd.after(calBegin.getTime())) {
|
|
||||||
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
|
||||||
calBegin.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
allDate.add(sdf.format(calBegin.getTime()));
|
|
||||||
}
|
|
||||||
System.out.println("时间==" + allDate);
|
|
||||||
return allDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -25,8 +25,6 @@ import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
|
|||||||
import com.njcn.device.pq.service.LineIntegrityDataService;
|
import com.njcn.device.pq.service.LineIntegrityDataService;
|
||||||
import com.njcn.device.pq.utils.DataStatisticsUtil;
|
import com.njcn.device.pq.utils.DataStatisticsUtil;
|
||||||
import com.njcn.harmonic.pojo.vo.IntegrityIconVO;
|
import com.njcn.harmonic.pojo.vo.IntegrityIconVO;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -56,8 +54,6 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
|
|
||||||
private final LineIntegrityDataMapper lineIntegrityDataMapper;
|
private final LineIntegrityDataMapper lineIntegrityDataMapper;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final AlarmClient alarmClient;
|
private final AlarmClient alarmClient;
|
||||||
|
|
||||||
private final GeneralDeviceService generalDeviceService;
|
private final GeneralDeviceService generalDeviceService;
|
||||||
@@ -324,38 +320,4 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 从influxdb中获取完整数据百分比
|
|
||||||
*
|
|
||||||
* @param startTime 查询开始时间
|
|
||||||
* @param endTime 查询结束时间
|
|
||||||
* @param lineIdsForInfluxdb 监测点索引集合
|
|
||||||
*/
|
|
||||||
private List<LineDataIntegrity> getPercentageOfCompleteData(String startTime, String endTime, StringBuilder lineIdsForInfluxdb) {
|
|
||||||
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder queryCriteria = new StringBuilder();
|
|
||||||
// 构造sql查询条件
|
|
||||||
queryCriteria.append(lineIdsForInfluxdb)
|
|
||||||
.append(" and ")
|
|
||||||
.append(InfluxDBPublicParam.TIME)
|
|
||||||
.append(" >= '")
|
|
||||||
.append(startTime)
|
|
||||||
.append(InfluxDBPublicParam.START_TIME)
|
|
||||||
.append("' and ")
|
|
||||||
.append(InfluxDBPublicParam.TIME)
|
|
||||||
.append(" <= '")
|
|
||||||
.append(endTime)
|
|
||||||
.append(InfluxDBPublicParam.END_TIME)
|
|
||||||
.append("'");
|
|
||||||
//sql语句
|
|
||||||
String sql = "SELECT sum(real)/sum(due) as integrityData FROM pqs_integrity WHERE " + queryCriteria + " group by line_id " + InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
// 结果集
|
|
||||||
QueryResult results = influxDbUtils.query(sql);
|
|
||||||
// 结果集映射到对象中
|
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
|
||||||
// 返回结果
|
|
||||||
return resultMapper.toPOJO(results, LineDataIntegrity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ import com.njcn.device.pq.pojo.po.*;
|
|||||||
import com.njcn.device.pq.pojo.vo.*;
|
import com.njcn.device.pq.pojo.vo.*;
|
||||||
import com.njcn.device.pq.mapper.*;
|
import com.njcn.device.pq.mapper.*;
|
||||||
import com.njcn.device.pq.service.LineService;
|
import com.njcn.device.pq.service.LineService;
|
||||||
import com.njcn.device.pq.utils.PublicDateUtil;
|
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
import com.njcn.influx.imapper.PqsCommunicateMapper;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||||
|
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||||
import com.njcn.system.api.AreaFeignClient;
|
import com.njcn.system.api.AreaFeignClient;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.web.pojo.vo.LineDataVO;
|
import com.njcn.web.pojo.vo.LineDataVO;
|
||||||
@@ -39,17 +40,12 @@ import com.njcn.web.utils.RequestUtil;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -82,11 +78,9 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
|
|
||||||
private final LineMapper lineMapper;
|
private final LineMapper lineMapper;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final TopMsgMapper topMsgMapper;
|
private final TopMsgMapper topMsgMapper;
|
||||||
|
|
||||||
// private final PqsCommunicateService pqsCommunicateService;
|
private final PqsCommunicateMapper pqsCommunicateMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LineDetailDataVO getLineDetailData(String id) {
|
public LineDetailDataVO getLineDetailData(String id) {
|
||||||
@@ -172,15 +166,14 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
public CommunicateVO getComFlagInfoData(String id, String searchBeginTime, String searchEndTime) {
|
public CommunicateVO getComFlagInfoData(String id, String searchBeginTime, String searchEndTime) {
|
||||||
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<PqsCommunicate> 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<>();
|
||||||
//开始时间
|
//开始时间
|
||||||
Boolean beginFly =false;
|
Boolean beginFly =false;
|
||||||
if(CollUtil.isNotEmpty(communicateList)){
|
if(CollUtil.isNotEmpty(communicateList)){
|
||||||
if(!communicateList.get(0).getUpdateTime().equals(DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toInstant())){
|
if(!communicateList.get(0).getTime().equals(DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toInstant())){
|
||||||
beginFly =true;
|
beginFly =true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -203,9 +196,9 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (Communicate communicate : communicateList) {
|
for (PqsCommunicate communicate : communicateList) {
|
||||||
//转化时间
|
//转化时间
|
||||||
Instant now = communicate.getUpdateTime();
|
Instant now = communicate.getTime();
|
||||||
Long time = now.toEpochMilli();
|
Long time = now.toEpochMilli();
|
||||||
String timeText = df.format(time);
|
String timeText = df.format(time);
|
||||||
updateTime.add(timeText);
|
updateTime.add(timeText);
|
||||||
@@ -219,7 +212,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
|
|
||||||
Boolean endFly =false;
|
Boolean endFly =false;
|
||||||
if(CollUtil.isNotEmpty(communicateList)){
|
if(CollUtil.isNotEmpty(communicateList)){
|
||||||
if(!communicateList.get(communicateList.size()-1).getUpdateTime().equals(endTime)){
|
if(!communicateList.get(communicateList.size()-1).getTime().equals(endTime)){
|
||||||
endFly =true;
|
endFly =true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -467,185 +460,11 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
return topMsgDetails;
|
return topMsgDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LineFlowMealDetailVO> getDeviceRunStatistics(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
ArrayList<LineFlowMealDetailVO> lineFlowMealDetailList = new ArrayList<>();
|
|
||||||
List<GeneralDeviceDTO> deviceInfoList = generalDeviceService.getDeviceInfo(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
|
||||||
for (GeneralDeviceDTO generalDeviceDTO : deviceInfoList) {
|
|
||||||
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
|
|
||||||
List<String> deviceIndexes = generalDeviceDTO.getDeviceIndexes();
|
|
||||||
if (CollectionUtils.isEmpty(deviceIndexes)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LineFlowMealDetailVO lineFlowMealDetailVO = new LineFlowMealDetailVO();
|
|
||||||
lineFlowMealDetailVO.setId(generalDeviceDTO.getIndex());
|
|
||||||
lineFlowMealDetailVO.setName(generalDeviceDTO.getName());
|
|
||||||
lineFlowMealDetailVO.setLevel(1);
|
|
||||||
//组装父级数据树
|
|
||||||
List<LineFlowMealDetailVO> treeList = getFlowTreeData(lineIndexes, deviceIndexes, deviceInfoParam);
|
|
||||||
lineFlowMealDetailVO.setChildren(treeList);
|
|
||||||
lineFlowMealDetailList.add(lineFlowMealDetailVO);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return lineFlowMealDetailList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LineFlowMealDetailVO> getLineRunStatistics(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
List<LineFlowMealDetailVO> lineFlowMealDetailList = new ArrayList<>();
|
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
|
||||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
|
||||||
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
|
|
||||||
List<String> devIndexs = generalDeviceDTO.getDeviceIndexes();
|
|
||||||
if (CollectionUtils.isEmpty(lineIndexes)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LineFlowMealDetailVO lineFlowMealDetailVO = new LineFlowMealDetailVO();
|
|
||||||
lineFlowMealDetailVO.setId(generalDeviceDTO.getIndex());
|
|
||||||
lineFlowMealDetailVO.setName(generalDeviceDTO.getName());
|
|
||||||
lineFlowMealDetailVO.setLevel(1);
|
|
||||||
//组装父级数据树
|
|
||||||
List<LineFlowMealDetailVO> treeList = getFlowTreeData(lineIndexes, devIndexs, deviceInfoParam);
|
|
||||||
lineFlowMealDetailVO.setChildren(treeList);
|
|
||||||
lineFlowMealDetailList.add(lineFlowMealDetailVO);
|
|
||||||
}
|
|
||||||
return lineFlowMealDetailList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LineStaticsViewVO getLineStaticsView(String startTime, String endTime, String lineId) {
|
|
||||||
//根据监测点id获取终端id
|
|
||||||
String devIndex = lineMapper.getDevIndex(lineId);
|
|
||||||
//获取在线率
|
|
||||||
List<LineStaticsValueVO> onlineRateValue = getDevOnline(devIndex, startTime, endTime);
|
|
||||||
//获取数据完整性
|
|
||||||
List<LineStaticsValueVO> integrityValue = getInegrity(lineId, startTime, endTime);
|
|
||||||
//获取流量占比
|
|
||||||
List<LineStaticsValueVO> flowMealValue = new ArrayList<>();
|
|
||||||
//组装
|
|
||||||
LineStaticsViewVO lineStaticsViewVO = new LineStaticsViewVO();
|
|
||||||
lineStaticsViewVO.setOnlineRateValue(onlineRateValue);
|
|
||||||
lineStaticsViewVO.setIntegrityValue(integrityValue);
|
|
||||||
lineStaticsViewVO.setFlowMealValue(flowMealValue);
|
|
||||||
|
|
||||||
return lineStaticsViewVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Overlimit> getOverLimitByList(PollutionParamDTO pollutionParamDTO) {
|
public List<Overlimit> getOverLimitByList(PollutionParamDTO pollutionParamDTO) {
|
||||||
return overlimitMapper.selectBatchIds(pollutionParamDTO.getLineList());
|
return overlimitMapper.selectBatchIds(pollutionParamDTO.getLineList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取父级每层数据
|
|
||||||
*/
|
|
||||||
private List<LineFlowMealDetailVO> getFlowTreeData(List<String> lineIndexes, List<String> devIndexs, DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
// 在线率(设备)
|
|
||||||
List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVO = getOnlineData(devIndexs, deviceInfoParam);
|
|
||||||
// 数据完整性(监测点)
|
|
||||||
List<LineInfluxDbInegrityVO> lineInfluxDbInegrityVO = getInegrityData(lineIndexes, deviceInfoParam);
|
|
||||||
// 监测点运行统计
|
|
||||||
List<LineFlowMealDetailVO> monitorList = lineMapper.getLineRunStatistics(lineIndexes, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())), DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())));
|
|
||||||
// List<LineFlowMealDetailVO> monitorList = lineMapper.getDeviceRunStatistics(devIndexs, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())), DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())));
|
|
||||||
for (LineFlowMealDetailVO lineFlowMealDetailVO : monitorList) {
|
|
||||||
for (LineInfluxDbInegrityVO lineInfluxDbInegrity : lineInfluxDbInegrityVO) {
|
|
||||||
if (lineFlowMealDetailVO.getId().equals(lineInfluxDbInegrity.getLineId())) {
|
|
||||||
lineFlowMealDetailVO.setDue(lineInfluxDbInegrity.getDue());
|
|
||||||
lineFlowMealDetailVO.setReal(lineInfluxDbInegrity.getReal());
|
|
||||||
} else {
|
|
||||||
lineFlowMealDetailVO.setDue(1440);
|
|
||||||
lineFlowMealDetailVO.setReal(1440);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 母线集合
|
|
||||||
List<LineFlowMealDetailVO> busBarList = lineMapper.getFlowLineInfoByTableList(monitorList.stream().map(LineFlowMealDetailVO::getPid).distinct().collect(Collectors.toList()));
|
|
||||||
// 终端集合
|
|
||||||
List<LineFlowMealDetailVO> deviceList = lineMapper.getFlowLineRunStatistics(busBarList.stream().map(LineFlowMealDetailVO::getPid).distinct().collect(Collectors.toList()), DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())), DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())));
|
|
||||||
for (LineFlowMealDetailVO lineFlowMealDetailVO : deviceList) {
|
|
||||||
int deviceDue=0,deviceReal=0;
|
|
||||||
Float staticsValue = getStatisValueFlow(lineFlowMealDetailVO.getId(), deviceInfoParam);
|
|
||||||
BigDecimal b = new BigDecimal(staticsValue);
|
|
||||||
float f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
||||||
lineFlowMealDetailVO.setStatisValue(f1);
|
|
||||||
BigDecimal flow = new BigDecimal(f1 / lineFlowMealDetailVO.getFlowMeal() * 100);
|
|
||||||
// 获取流量占比
|
|
||||||
lineFlowMealDetailVO.setFlowProportion(flow.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
|
|
||||||
|
|
||||||
// 在线率
|
|
||||||
for (LineInfluxDbOnlineVO lineInfluxDbOnline : lineInfluxDbOnlineVO) {
|
|
||||||
if (lineFlowMealDetailVO.getId().equals(lineInfluxDbOnline.getDevIndex())) {
|
|
||||||
BigDecimal flowValue = new BigDecimal(lineInfluxDbOnline.getOnlineRate().floatValue());
|
|
||||||
lineFlowMealDetailVO.setOnlineRate(flowValue.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据完整性
|
|
||||||
for (LineFlowMealDetailVO monitor : monitorList) {
|
|
||||||
if (monitor.getDeviceId().equals(lineFlowMealDetailVO.getId())){
|
|
||||||
deviceDue+=monitor.getDue();
|
|
||||||
deviceReal+=monitor.getReal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float integrity = BigDecimal.valueOf((double) deviceReal / deviceDue).setScale(2, RoundingMode.HALF_UP).floatValue();
|
|
||||||
lineFlowMealDetailVO.setIntegrity(integrity);
|
|
||||||
|
|
||||||
}
|
|
||||||
// 变电站集合
|
|
||||||
List<LineFlowMealDetailVO> substationList = lineMapper.getFlowLineInfoByTableList(deviceList.stream().map(LineFlowMealDetailVO::getPid).distinct().collect(Collectors.toList()));
|
|
||||||
// 供电公司集合
|
|
||||||
List<LineFlowMealDetailVO> powerCompanyList = lineMapper.getFlowLineInfoByTableList(substationList.stream().map(LineFlowMealDetailVO::getPid).distinct().collect(Collectors.toList()));
|
|
||||||
|
|
||||||
setFlowChildesList(substationList, deviceList);
|
|
||||||
|
|
||||||
// setFlowDeChildesList(deviceList, monitorList);
|
|
||||||
|
|
||||||
powerCompanyList.stream()
|
|
||||||
.peek(item -> item.setChildren(getFlowChildCategoryList(item, substationList)))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return powerCompanyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFlowDeChildesList(List<LineFlowMealDetailVO> item, List<LineFlowMealDetailVO> childes) {
|
|
||||||
Map<String, List<LineFlowMealDetailVO>> groupLine;
|
|
||||||
groupLine = childes.stream().collect(Collectors.groupingBy(steadyQualifyVO -> {
|
|
||||||
String[] pid = steadyQualifyVO.getPids().split(",");
|
|
||||||
List<String> value = new ArrayList<>();
|
|
||||||
value.add(pid[LineBaseEnum.DEVICE_LEVEL.getCode()]);
|
|
||||||
System.out.printf(steadyQualifyVO.getName());
|
|
||||||
return pid[LineBaseEnum.DEVICE_LEVEL.getCode()];
|
|
||||||
}));
|
|
||||||
item.stream().peek(steadyQualifyVO -> {
|
|
||||||
if (!CollectionUtils.isEmpty(groupLine.get(steadyQualifyVO.getId()))) {
|
|
||||||
steadyQualifyVO.setChildren(groupLine.get(steadyQualifyVO.getId()));
|
|
||||||
}
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFlowChildesList(List<LineFlowMealDetailVO> item, List<LineFlowMealDetailVO> childrenList) {
|
|
||||||
Map<String, List<LineFlowMealDetailVO>> groupLine;
|
|
||||||
groupLine = childrenList.stream().collect(Collectors.groupingBy(steadyQualifyVO -> {
|
|
||||||
String[] pid = steadyQualifyVO.getPids().split(",");
|
|
||||||
return pid[LineBaseEnum.SUB_LEVEL.getCode()];
|
|
||||||
}));
|
|
||||||
item.stream().peek(steadyQualifyVO -> {
|
|
||||||
if (!CollectionUtils.isEmpty(groupLine.get(steadyQualifyVO.getId()))) {
|
|
||||||
steadyQualifyVO.setChildren(groupLine.get(steadyQualifyVO.getId()));
|
|
||||||
}
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组装树层级
|
|
||||||
*/
|
|
||||||
private List<LineFlowMealDetailVO> getFlowChildCategoryList(LineFlowMealDetailVO item, List<LineFlowMealDetailVO> child) {
|
|
||||||
return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取父级每层数据
|
* 获取父级每层数据
|
||||||
*/
|
*/
|
||||||
@@ -688,134 +507,11 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LineInfluxDbOnlineVO> getOnlineData(List<String> devIndexs, DeviceInfoParam.BusinessParam deviceInfoParam) {
|
public List<PqsCommunicate> getCommunicate(String devId, String startTime, String endTime) {
|
||||||
// 组装sql语句
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(startTime)),DateUtil.beginOfDay(DateUtil.parse(endTime)))
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and ");
|
.eq(PqsCommunicate::getDevId,devId);
|
||||||
|
return pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||||
for (int i = 0; i < devIndexs.size(); i++) {
|
|
||||||
if (devIndexs.size() - i != 1) {
|
|
||||||
stringBuilder.append("dev_id ='").append(devIndexs.get(i)).append("' or ");
|
|
||||||
} else {
|
|
||||||
stringBuilder.append("dev_id ='").append(devIndexs.get(i)).append("' ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// stringBuilder.append(InfluxDBPublicParam.TIME_ZONE);
|
|
||||||
String sql = "select sum(online_min)/(sum(online_min) +sum(offline_min))*100 as online_rate from pqs_onlinerate where " + stringBuilder.toString() + " group by dev_id "+InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
// 获取暂降事件
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<LineInfluxDbOnlineVO> eventDetailList = influxDBResultMapper.toPOJO(result, LineInfluxDbOnlineVO.class);
|
|
||||||
return eventDetailList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LineInfluxDbInegrityVO> getInegrityData(List<String> lineIndexes, DeviceInfoParam.BusinessParam deviceInfoParam) {
|
|
||||||
// 组装sql语句
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and ");
|
|
||||||
for (int i = 0; i < lineIndexes.size(); i++) {
|
|
||||||
if (lineIndexes.size() - i != 1) {
|
|
||||||
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' or ");
|
|
||||||
} else {
|
|
||||||
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//String sql = "select sum(real)/(sum(due))*100 as integrity from pqs_integrity where " + stringBuilder.toString() + "group by line_id";
|
|
||||||
String sql = "select due as due, real as real from pqs_integrity where " + stringBuilder.toString() + "group by line_id";
|
|
||||||
// 获取暂降事件
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<LineInfluxDbInegrityVO> eventDetailList = influxDBResultMapper.toPOJO(result, LineInfluxDbInegrityVO.class);
|
|
||||||
return eventDetailList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public List<LineStaticsValueVO> getDevOnline(String devIndex, 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("dev_index ='").append(devIndex).append("' ");
|
|
||||||
|
|
||||||
String sql = "select time,onlinemin/(onlinemin+offlinemin)*100 as value from pqs_onlinerate where " + stringBuilder.toString() + "group by dev_index tz('Asia/Shanghai')";
|
|
||||||
//获取在线率
|
|
||||||
List<LineStaticsValueVO> lineInfluxDbOnline = new ArrayList<>();
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
List<List<Object>> listData = list.get(0).getValues();
|
|
||||||
for (int i = 0; i < listData.size(); i++) {
|
|
||||||
LineStaticsValueVO lineStaticsValueVO = new LineStaticsValueVO();
|
|
||||||
List<Object> objectList = listData.get(i);
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
lineStaticsValueVO.setTime(formatter.parse(objectList.get(0).toString()).toString());
|
|
||||||
lineStaticsValueVO.setValue((Double) objectList.get(1));
|
|
||||||
lineInfluxDbOnline.add(lineStaticsValueVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lineInfluxDbOnline;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public List<LineStaticsValueVO> getInegrity(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("' ");
|
|
||||||
String sql = "select time,(real/due)*100 as value from pqs_integrity where " + stringBuilder.toString() + " group by line_id tz('Asia/Shanghai')";
|
|
||||||
//获取数据完整性
|
|
||||||
List<LineStaticsValueVO> lineInfluxDbInegrity = new ArrayList<>();
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
List<List<Object>> listData = list.get(0).getValues();
|
|
||||||
for (int i = 0; i < listData.size(); i++) {
|
|
||||||
LineStaticsValueVO lineStaticsValueVO = new LineStaticsValueVO();
|
|
||||||
List<Object> objectList = listData.get(i);
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
lineStaticsValueVO.setTime(formatter.parse(objectList.get(0).toString()).toString());
|
|
||||||
lineStaticsValueVO.setValue((Double) objectList.get(1));
|
|
||||||
lineInfluxDbInegrity.add(lineStaticsValueVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lineInfluxDbInegrity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public Float getStatisValueFlow(String lineIndex, DeviceInfoParam.BusinessParam steadyParam) {
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(steadyParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(steadyParam.getSearchEndTime()))).append("' and ");
|
|
||||||
stringBuilder.append("device_id ='").append(lineIndex).append("' ");
|
|
||||||
String sql = "select sum(actual_value)/1024/1024 as statisValue from pqs_month_flow where " + stringBuilder.toString() + " group by device_id tz('Asia/Shanghai')";
|
|
||||||
//获取统计流量
|
|
||||||
Float staticsValue = 0f;
|
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
List<List<Object>> listData = list.get(0).getValues();
|
|
||||||
List<Object> objectList = listData.get(0);
|
|
||||||
staticsValue = ((Double) objectList.get(1)).floatValue();
|
|
||||||
} else {
|
|
||||||
staticsValue = 0f;
|
|
||||||
}
|
|
||||||
return staticsValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(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);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<Communicate> communicateList = influxDBResultMapper.toPOJO(result, Communicate.class);
|
|
||||||
return communicateList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -830,68 +526,6 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
return this.list(lambdaQueryWrapper);
|
return this.list(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@Override
|
|
||||||
public DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam conditionBusinessParam) {
|
|
||||||
DeviceAbnormalVO deviceAbnormalVO = new DeviceAbnormalVO();
|
|
||||||
//获取所有监测点
|
|
||||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(conditionBusinessParam, null, Stream.of(1).collect(Collectors.toList()));
|
|
||||||
List<String> lineIndexs = generalDeviceDTOList.stream()
|
|
||||||
.flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
|
|
||||||
if (conditionBusinessParam.getTimeFlag() == 0) {
|
|
||||||
List<String> intervalTime = this.getIntervalTime(conditionBusinessParam.getSearchBeginTime(), conditionBusinessParam.getSearchEndTime());
|
|
||||||
List<AbnomalCommuncateVO> abnomalCommuncateVOS = new ArrayList<>();
|
|
||||||
deviceAbnormalVO.setIsPid(true);
|
|
||||||
for (String interTime : intervalTime) {
|
|
||||||
System.out.println(lineIndexs);
|
|
||||||
AbnomalCommuncateVO inter = new AbnomalCommuncateVO();
|
|
||||||
String startTime, endTime;
|
|
||||||
inter.setMonth(interTime.substring(5));
|
|
||||||
inter.setYear(interTime.substring(0, 4));
|
|
||||||
startTime = PublicDateUtil.getFisrtDayOfMonth(Integer.parseInt(interTime.substring(0, 4)), Integer.parseInt(interTime.substring(5)));
|
|
||||||
endTime = PublicDateUtil.getLastDayOfMonth(Integer.parseInt(interTime.substring(0, 4)), Integer.parseInt(interTime.substring(5)));
|
|
||||||
List<Communicate> communicateList = getCommunicateAbnorm(lineIndexs, startTime, endTime);
|
|
||||||
inter.setDay("/");
|
|
||||||
if (communicateList.size() == 0) {
|
|
||||||
inter.setAbnormalTimes("3.14159");
|
|
||||||
} else {
|
|
||||||
inter.setAbnormalTimes(String.valueOf(communicateList.size()));
|
|
||||||
}
|
|
||||||
abnomalCommuncateVOS.add(inter);
|
|
||||||
}
|
|
||||||
deviceAbnormalVO.setData(abnomalCommuncateVOS);
|
|
||||||
} else {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
Date dt = simpleDateFormat.parse(conditionBusinessParam.getSearchBeginTime());
|
|
||||||
Date dtDate = simpleDateFormat.parse(conditionBusinessParam.getSearchEndTime());
|
|
||||||
Integer year = Integer.valueOf(String.format("%tY", dt));
|
|
||||||
Integer mon = Integer.valueOf(String.format("%tm", dt));
|
|
||||||
Integer day = Integer.valueOf(String.format("%td", dtDate));
|
|
||||||
List<String> intervalTime = this.getIntervalDateTime(year, mon, day);
|
|
||||||
List<AbnomalCommuncateVO> abnomalCommuncateVOS = new ArrayList<>();
|
|
||||||
deviceAbnormalVO.setIsPid(false);
|
|
||||||
for (String interTime : intervalTime) {
|
|
||||||
AbnomalCommuncateVO inter = new AbnomalCommuncateVO();
|
|
||||||
String startTime, endTime;
|
|
||||||
inter.setMonth(interTime.substring(5, 7));
|
|
||||||
inter.setYear(interTime.substring(0, 4));
|
|
||||||
inter.setDay(interTime.substring(8));
|
|
||||||
startTime = sdf.format(DateUtil.beginOfDay(DateUtil.parse(interTime)));
|
|
||||||
endTime = sdf.format(DateUtil.endOfDay(DateUtil.parse(interTime)));
|
|
||||||
List<Communicate> communicateList = getCommunicateAbnorm(lineIndexs, startTime, endTime);
|
|
||||||
if (communicateList.size() == 0) {
|
|
||||||
inter.setAbnormalTimes("3.14159");
|
|
||||||
} else {
|
|
||||||
inter.setAbnormalTimes(String.valueOf(communicateList.size()));
|
|
||||||
}
|
|
||||||
abnomalCommuncateVOS.add(inter);
|
|
||||||
}
|
|
||||||
deviceAbnormalVO.setData(abnomalCommuncateVOS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceAbnormalVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 通过部门索引查询其下监测点数
|
* @Description: 通过部门索引查询其下监测点数
|
||||||
@@ -1086,52 +720,4 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
}
|
}
|
||||||
return times;
|
return times;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
private List<String> getIntervalDateTime(Integer startTime, Integer endTime, Integer dd) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
Calendar calendar = Calendar.getInstance(Locale.CHINA);
|
|
||||||
calendar.set(startTime, endTime - 1, 1);
|
|
||||||
int year = calendar.get(Calendar.YEAR);//年份
|
|
||||||
int month = calendar.get(Calendar.MONTH) + 1;//月份
|
|
||||||
for (int i = 1; i <= dd; i++) {
|
|
||||||
String date = null;
|
|
||||||
if (month < 10 && i < 10) {
|
|
||||||
date = year + "-0" + month + "-0" + i;
|
|
||||||
}
|
|
||||||
if (month < 10 && i >= 10) {
|
|
||||||
date = year + "-0" + month + "-" + i;
|
|
||||||
}
|
|
||||||
if (month >= 10 && i < 10) {
|
|
||||||
date = year + "-" + month + "-0" + i;
|
|
||||||
}
|
|
||||||
if (month >= 10 && i >= 10) {
|
|
||||||
date = year + "-" + month + "-" + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.add(date);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Communicate> getCommunicateAbnorm(List<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("(");
|
|
||||||
for (int i = 0; i < lineIndex.size(); i++) {
|
|
||||||
if (lineIndex.size() - i != 1) {
|
|
||||||
stringBuilder.append("line_id = '").append(lineIndex.get(i)).append("' or ");
|
|
||||||
} else {
|
|
||||||
stringBuilder.append("line_id = '").append(lineIndex.get(i)).append("')");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stringBuilder.append("and type = 0").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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import com.njcn.device.pq.pojo.vo.EventLogVO;
|
|||||||
import com.njcn.device.pq.service.LogManageService;
|
import com.njcn.device.pq.service.LogManageService;
|
||||||
import com.njcn.event.api.EventDetailFeignClient;
|
import com.njcn.event.api.EventDetailFeignClient;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.influxdb.dto.QueryResult;
|
import org.influxdb.dto.QueryResult;
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
import org.influxdb.impl.InfluxDBResultMapper;
|
||||||
@@ -50,58 +48,15 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class LogManageServiceImpl implements LogManageService {
|
public class LogManageServiceImpl implements LogManageService {
|
||||||
|
|
||||||
private final LogManageMapper logManageMapper;
|
|
||||||
|
|
||||||
private final EventDetailFeignClient eventDetailFeignClient;
|
private final EventDetailFeignClient eventDetailFeignClient;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final EventPushLogsMapper eventPushLogsMapper;
|
private final EventPushLogsMapper eventPushLogsMapper;
|
||||||
|
|
||||||
private final LineMapper lineMapper;
|
private final LineMapper lineMapper;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam) {
|
|
||||||
Page<DeviceLogVO> page = new Page<>();
|
|
||||||
page.setSize(deviceLogParam.getPageSize());
|
|
||||||
page.setCurrent(deviceLogParam.getPageNum());
|
|
||||||
|
|
||||||
List<DeviceLogVO> logData = new ArrayList<>();
|
|
||||||
List<TerminalLogs> terminalLogs = getTerminalLogs(deviceLogParam.getSearchBeginTime(), deviceLogParam.getSearchEndTime(), deviceLogParam.getType());
|
|
||||||
//待分页数据总量
|
|
||||||
page.setTotal(terminalLogs.size());
|
|
||||||
//分页总页数
|
|
||||||
int pages = (int) Math.ceil(terminalLogs.size() * 1.0 / deviceLogParam.getPageSize());
|
|
||||||
page.setPages(pages);
|
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(terminalLogs)) {
|
|
||||||
List<List<TerminalLogs>> partition = Lists.partition(terminalLogs, deviceLogParam.getPageSize());
|
|
||||||
List<TerminalLogs> pageLogs = partition.get(deviceLogParam.getPageNum() - 1);
|
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(pageLogs)) {
|
|
||||||
for (TerminalLogs logs : pageLogs) {
|
|
||||||
DeviceLogVO deviceLogVO = logManageMapper.getDeviceLogData(logs.getLineId(), logs.getTerminalType(), logs.getUpdateBy());
|
|
||||||
if (Objects.isNull(deviceLogVO)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(logs.getTimeId(), ZoneId.systemDefault());
|
|
||||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
|
||||||
String time = dateTimeFormatter.format(localDateTime);
|
|
||||||
deviceLogVO.setUpdateTime(time);
|
|
||||||
deviceLogVO.setRemark(logs.getTerminalDescribe());
|
|
||||||
logData.add(deviceLogVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//当前页数据
|
|
||||||
page.setRecords(logData);
|
|
||||||
}
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EventLogVO> getEventLogData(EventLogParam eventLogParam) {
|
public Page<EventLogVO> getEventLogData(EventLogParam eventLogParam) {
|
||||||
|
|
||||||
//查询全部时间
|
//查询全部时间
|
||||||
List<String> lineByIDs = lineMapper.getLineByIDs(eventLogParam.getSearchValue());
|
List<String> lineByIDs = lineMapper.getLineByIDs(eventLogParam.getSearchValue());
|
||||||
if (CollUtil.isEmpty(lineByIDs)) {
|
if (CollUtil.isEmpty(lineByIDs)) {
|
||||||
@@ -188,59 +143,5 @@ public class LogManageServiceImpl implements LogManageService {
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* influxDB查询终端运维日志相关信息
|
|
||||||
*
|
|
||||||
* @param startTime
|
|
||||||
* @param endTime
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
private List<TerminalLogs> getTerminalLogs(String startTime, String endTime, String type) {
|
|
||||||
List<TerminalLogs> terminalLogs;
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder string = new StringBuilder();
|
|
||||||
string.append(InfluxDBPublicParam.TIME + " >= '" + startTime + InfluxDBPublicParam.START_TIME + "' and " + InfluxDBPublicParam.TIME + " <= '" + endTime + InfluxDBPublicParam.END_TIME + "'");
|
|
||||||
if (!type.isEmpty()) {
|
|
||||||
string.append(" and terminal_type = '" + type + "'");
|
|
||||||
}
|
|
||||||
//sql语句
|
|
||||||
String sql = "SELECT * FROM " + InfluxDBPublicParam.PQS_TERMINAL_LOGS + " WHERE " + string + InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
System.out.println("sql===========" + sql);
|
|
||||||
//结果集
|
|
||||||
QueryResult results = influxDbUtils.query(sql);
|
|
||||||
//结果集映射到对象中
|
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
|
||||||
terminalLogs = resultMapper.toPOJO(results, TerminalLogs.class);
|
|
||||||
|
|
||||||
return terminalLogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* influxDB查询暂降事件相关信息
|
|
||||||
*
|
|
||||||
* @param startTime
|
|
||||||
* @param endTime
|
|
||||||
* @param result
|
|
||||||
*/
|
|
||||||
private List<EventPushLogs> getEventPushLogs(String startTime, String endTime, Integer result) {
|
|
||||||
List<EventPushLogs> logsList;
|
|
||||||
//组装sql语句
|
|
||||||
StringBuilder string = new StringBuilder();
|
|
||||||
string.append(DeviceValidMessage.TIME + " >= '" + startTime + DeviceValidMessage.START_TIME + "' and " + DeviceValidMessage.TIME + " <= '" + endTime + DeviceValidMessage.END_TIME + "'");
|
|
||||||
if (result == 1 || result == 2) {
|
|
||||||
string.append(" and result=" + result);
|
|
||||||
}
|
|
||||||
//sql语句
|
|
||||||
String sql = "SELECT * FROM pqs_event_push_logs WHERE " + string + InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
System.out.println("sql===========" + sql);
|
|
||||||
//结果集
|
|
||||||
QueryResult results = influxDbUtils.query(sql);
|
|
||||||
//结果集映射到对象中
|
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
|
||||||
logsList = resultMapper.toPOJO(results, EventPushLogs.class);
|
|
||||||
|
|
||||||
return logsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,30 +22,23 @@ import com.njcn.device.pq.pojo.vo.TerminalLedgerVO;
|
|||||||
import com.njcn.device.pq.service.LineService;
|
import com.njcn.device.pq.service.LineService;
|
||||||
import com.njcn.device.pq.service.RunManageService;
|
import com.njcn.device.pq.service.RunManageService;
|
||||||
import com.njcn.device.pq.service.TerminalBaseService;
|
import com.njcn.device.pq.service.TerminalBaseService;
|
||||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.enums.DicDataTypeEnum;
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_ONLINERATE;
|
|
||||||
import static com.njcn.influxdb.param.InfluxDBPublicParam.TIME_ZONE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author denghuajun
|
* @author denghuajun
|
||||||
|
|||||||
@@ -7,17 +7,16 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.njcn.device.pq.pojo.bo.DeviceType;
|
import com.njcn.device.pq.pojo.bo.DeviceType;
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
import com.njcn.device.pq.pojo.po.Communicate;
|
|
||||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||||
import com.njcn.device.pq.pojo.vo.TerminalBaseVO;
|
import com.njcn.device.pq.pojo.vo.TerminalBaseVO;
|
||||||
import com.njcn.device.pq.service.ISubstationExpendService;
|
import com.njcn.device.pq.service.ISubstationExpendService;
|
||||||
import com.njcn.device.pq.service.TerminalBaseService;
|
import com.njcn.device.pq.service.TerminalBaseService;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
import com.njcn.influx.imapper.PqsCommunicateMapper;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
|
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||||
|
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -37,8 +36,10 @@ import java.util.stream.Stream;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SubstationExpendServiceImpl implements ISubstationExpendService {
|
public class SubstationExpendServiceImpl implements ISubstationExpendService {
|
||||||
|
|
||||||
|
private final PqsCommunicateMapper pqsCommunicateMapper;
|
||||||
|
|
||||||
private final GeneralDeviceService generalDeviceService;
|
private final GeneralDeviceService generalDeviceService;
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
private final TerminalBaseService terminalBaseService;
|
private final TerminalBaseService terminalBaseService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,36 +48,25 @@ public class SubstationExpendServiceImpl implements ISubstationExpendService {
|
|||||||
//获取所有终端id
|
//获取所有终端id
|
||||||
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
|
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||||
List<CommunicateVO.PVCommunicateVO> info = new ArrayList<>();
|
List<CommunicateVO.PVCommunicateVO> info = new ArrayList<>();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))).append("' ");
|
influxQueryWrapper.between(InfluxDBTableConstant.TIME, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())), DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())));
|
||||||
if (CollUtil.isNotEmpty(terminalIds)) {
|
if (CollUtil.isNotEmpty(terminalIds)) {
|
||||||
stringBuilder.append(" and ").append("(");
|
influxQueryWrapper.or(PqsCommunicate::getDevId, terminalIds);
|
||||||
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("')");
|
|
||||||
}
|
}
|
||||||
}
|
influxQueryWrapper.limit(param.getLimit());
|
||||||
}
|
List<PqsCommunicate> communicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||||
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)) {
|
if (CollUtil.isEmpty(communicates)) {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
List<String> ids = communicates.stream().map(Communicate::getDevId).distinct().collect(Collectors.toList());
|
List<String> ids = communicates.stream().map(PqsCommunicate::getDevId).distinct().collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(ids)) {
|
if (CollUtil.isNotEmpty(ids)) {
|
||||||
List<TerminalBaseVO> deviceByIds = terminalBaseService.getDeviceByIdOnOrOff(ids, new DeviceType(), 0);
|
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()));
|
Map<String, String> terminalNameIp = deviceByIds.stream().collect(Collectors.toMap(TerminalBaseVO::getDevId, x -> x.getDevName() + "_" + x.getIp()));
|
||||||
CommunicateVO.PVCommunicateVO communicate;
|
CommunicateVO.PVCommunicateVO communicate;
|
||||||
for (Communicate cate : communicates) {
|
for (PqsCommunicate cate : communicates) {
|
||||||
communicate = new CommunicateVO.PVCommunicateVO();
|
communicate = new CommunicateVO.PVCommunicateVO();
|
||||||
BeanUtil.copyProperties(cate, communicate);
|
BeanUtil.copyProperties(cate, communicate);
|
||||||
communicate.setTime(cate.getUpdateTime());
|
communicate.setTime(cate.getTime());
|
||||||
if (terminalNameIp.containsKey(cate.getDevId())) {
|
if (terminalNameIp.containsKey(cate.getDevId())) {
|
||||||
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,15 @@ import com.njcn.device.pq.mapper.SuperDataMapper;
|
|||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
import com.njcn.device.pq.pojo.param.*;
|
import com.njcn.device.pq.pojo.param.*;
|
||||||
import com.njcn.device.pq.pojo.po.*;
|
import com.njcn.device.pq.pojo.po.*;
|
||||||
import com.njcn.device.pq.pojo.po.influxdb.DeviceDayFlow;
|
|
||||||
import com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO;
|
import com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO;
|
||||||
import com.njcn.device.pq.pojo.vo.TerminalDaliyFlowVO;
|
import com.njcn.device.pq.pojo.vo.TerminalDaliyFlowVO;
|
||||||
import com.njcn.device.pq.pojo.vo.TerminalMaintainVO;
|
import com.njcn.device.pq.pojo.vo.TerminalMaintainVO;
|
||||||
import com.njcn.device.pq.service.*;
|
import com.njcn.device.pq.service.*;
|
||||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influx.imapper.CldStatisticsFlowMapper;
|
||||||
|
import com.njcn.influx.pojo.dto.DeviceDayFlowDTO;
|
||||||
|
import com.njcn.influx.pojo.po.CldStatisFlow;
|
||||||
|
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||||
@@ -29,8 +31,6 @@ import com.njcn.user.api.DeptFeignClient;
|
|||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.dto.QueryResult;
|
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@@ -65,8 +65,6 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
|
|
||||||
private final DeptFeignClient deptFeignClient;
|
private final DeptFeignClient deptFeignClient;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
|
||||||
|
|
||||||
private final SuperDataMapper superDataMapper;
|
private final SuperDataMapper superDataMapper;
|
||||||
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
@@ -75,6 +73,8 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
|
|
||||||
private final DevFuctionMapper devFuctionMapper;
|
private final DevFuctionMapper devFuctionMapper;
|
||||||
|
|
||||||
|
private final CldStatisticsFlowMapper cldStatisticsFlowMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TerminalMaintainVO> getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) {
|
public List<TerminalMaintainVO> getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) {
|
||||||
List<TerminalMaintainVO> resList = new ArrayList<>();
|
List<TerminalMaintainVO> resList = new ArrayList<>();
|
||||||
@@ -287,8 +287,8 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
funQueryWrapper.lambda().eq(DevFuction::getLineId,param.getDevId());
|
funQueryWrapper.lambda().eq(DevFuction::getLineId,param.getDevId());
|
||||||
List<DevFuction> functions = devFuctionMapper.selectList(funQueryWrapper);
|
List<DevFuction> functions = devFuctionMapper.selectList(funQueryWrapper);
|
||||||
flowManageDetail.setFunctions(functions);
|
flowManageDetail.setFunctions(functions);
|
||||||
List<DeviceDayFlow> deviceDayFlowList = getFlowManageDetailFromInfluxDB(param);
|
List<DeviceDayFlowDTO> deviceDayFlowList = getFlowManageDetailFromInfluxDB(param);
|
||||||
float sum = (float) deviceDayFlowList.stream().mapToDouble(DeviceDayFlow::getDailyActualValue).sum();
|
float sum = (float) deviceDayFlowList.stream().mapToDouble(DeviceDayFlowDTO::getDailyActualValue).sum();
|
||||||
flowManageDetail.setDeviceDayFlowsList(deviceDayFlowList);
|
flowManageDetail.setDeviceDayFlowsList(deviceDayFlowList);
|
||||||
flowManageDetail.setActualValue(sum);
|
flowManageDetail.setActualValue(sum);
|
||||||
list.add(flowManageDetail);
|
list.add(flowManageDetail);
|
||||||
@@ -305,28 +305,24 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DeviceDayFlow> getFlowManageDetailFromInfluxDB(TerminalMainQueryParam param) {
|
private List<DeviceDayFlowDTO> getFlowManageDetailFromInfluxDB(TerminalMainQueryParam param) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(CldStatisFlow.class,DeviceDayFlowDTO.class);
|
||||||
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))).append("' and ");
|
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())))
|
||||||
stringBuilder.append("dev_id ='").append(param.getDevId()).append("'");
|
.eq(CldStatisFlow::getDevId,param.getDevId());
|
||||||
String sql = "select * from " + InfluxDBPublicParam.CLD_STATIS_FLOW + " where " + stringBuilder.toString() + InfluxDBPublicParam.TIME_ZONE;
|
List<DeviceDayFlowDTO> deviceDayFlow = cldStatisticsFlowMapper.selectDeviceDayFlowByQueryWrapper(influxQueryWrapper);
|
||||||
QueryResult result = influxDbUtils.query(sql);
|
|
||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
|
||||||
List<DeviceDayFlow> deviceDayFlow = influxDBResultMapper.toPOJO(result, DeviceDayFlow.class);
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
deviceDayFlow.forEach(t -> t.setDate(formatter.format(Date.from(t.getTime()))));
|
deviceDayFlow.forEach(t -> t.setDate(formatter.format(Date.from(t.getTime()))));
|
||||||
Map<String, List<DeviceDayFlow>> dayFlowMap = deviceDayFlow.stream().collect(Collectors.groupingBy(DeviceDayFlow::getDate));
|
Map<String, List<DeviceDayFlowDTO>> dayFlowMap = deviceDayFlow.stream().collect(Collectors.groupingBy(DeviceDayFlowDTO::getDate));
|
||||||
List<DeviceDayFlow> list = new ArrayList<>();
|
List<DeviceDayFlowDTO> list = new ArrayList<>();
|
||||||
for (Map.Entry<String, List<DeviceDayFlow>> entry : dayFlowMap.entrySet()) {
|
for (Map.Entry<String, List<DeviceDayFlowDTO>> entry : dayFlowMap.entrySet()) {
|
||||||
DeviceDayFlow dayFlow = new DeviceDayFlow();
|
DeviceDayFlowDTO dayFlow = new DeviceDayFlowDTO();
|
||||||
dayFlow.setDevId(entry.getValue().get(0).getDevId());
|
dayFlow.setDevId(entry.getValue().get(0).getDevId());
|
||||||
BigDecimal bigDecimal = new BigDecimal((float) entry.getValue().stream().mapToInt(DeviceDayFlow::getActualValue).sum() / (float) 1024 / (float) 1024);
|
BigDecimal bigDecimal = new BigDecimal((float) entry.getValue().stream().mapToInt(DeviceDayFlowDTO::getActualValue).sum() / (float) 1024 / (float) 1024);
|
||||||
dayFlow.setDailyActualValue(bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
|
dayFlow.setDailyActualValue(bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
|
||||||
dayFlow.setDate(entry.getKey());
|
dayFlow.setDate(entry.getKey());
|
||||||
list.add(dayFlow);
|
list.add(dayFlow);
|
||||||
}
|
}
|
||||||
list = list.stream().sorted(Comparator.comparing(DeviceDayFlow::getDate)).collect(Collectors.toList());
|
list = list.stream().sorted(Comparator.comparing(DeviceDayFlowDTO::getDate)).collect(Collectors.toList());
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.njcn.influx.imapper;
|
package com.njcn.influx.imapper;
|
||||||
|
|
||||||
import com.njcn.influx.base.InfluxDbBaseMapper;
|
import com.njcn.influx.base.InfluxDbBaseMapper;
|
||||||
|
import com.njcn.influx.pojo.dto.DeviceDayFlowDTO;
|
||||||
import com.njcn.influx.pojo.po.CldStatisFlow;
|
import com.njcn.influx.pojo.po.CldStatisFlow;
|
||||||
|
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -11,4 +15,5 @@ import com.njcn.influx.pojo.po.CldStatisFlow;
|
|||||||
public interface CldStatisticsFlowMapper extends InfluxDbBaseMapper<CldStatisFlow>{
|
public interface CldStatisticsFlowMapper extends InfluxDbBaseMapper<CldStatisFlow>{
|
||||||
|
|
||||||
|
|
||||||
|
List<DeviceDayFlowDTO> selectDeviceDayFlowByQueryWrapper(InfluxQueryWrapper influxQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.njcn.influx.imapper;
|
||||||
|
|
||||||
|
import com.njcn.influx.base.InfluxDbBaseMapper;
|
||||||
|
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年08月09日 09:29
|
||||||
|
*/
|
||||||
|
public interface PqsCommunicateMapper extends InfluxDbBaseMapper<PqsCommunicate> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.influx.pojo.dto;
|
||||||
|
|
||||||
|
import com.njcn.influx.pojo.po.CldStatisFlow;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.influxdb.annotation.Column;
|
||||||
|
import org.influxdb.annotation.Measurement;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Measurement(name = "cld_statis_flow")
|
||||||
|
public class DeviceDayFlowDTO extends CldStatisFlow {
|
||||||
|
|
||||||
|
private float dailyActualValue;
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
private String month;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.njcn.influx.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年08月09日 09:28
|
||||||
|
*/
|
||||||
|
public interface PqsCommunicateService {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.njcn.influx.service.impl;
|
||||||
|
|
||||||
|
import com.njcn.influx.service.PqsCommunicateService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年08月09日 09:28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PqsCommunicateServiceImpl implements PqsCommunicateService {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user