Browse Source

查询通讯告警的最后一小时的运行数据

zhongwei
段飞宇 2 years ago
parent
commit
d54c0c284b
  1. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java
  2. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java
  3. 24
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java
  4. 45
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java
  5. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  6. 35
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java

@ -1,7 +1,9 @@
package com.hnac.hzims.operational.config.controller; package com.hnac.hzims.operational.config.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.config.service.CentralMonitorService;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.station.service.IRealMonitorService; import com.hnac.hzims.operational.station.service.IRealMonitorService;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
@ -57,7 +59,7 @@ public class CentralMonitorController extends BladeController {
public R selectCommunication(@PathVariable Integer page, public R selectCommunication(@PathVariable Integer page,
@PathVariable Integer size, @PathVariable Integer size,
String roleId){ String roleId){
HzPage<PointData> result = monitorService.selectOriginalDataByRealIds(page, size, roleId); IPage<PointDataVo> result = monitorService.selectOriginalDataByRealIds(page, size, roleId);
return R.data(result); return R.data(result);
} }
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java

@ -1,6 +1,8 @@
package com.hnac.hzims.operational.config.service; package com.hnac.hzims.operational.config.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.HzPage;
@ -26,6 +28,6 @@ public interface CentralMonitorService{
* @param roleId * @param roleId
* @return * @return
*/ */
HzPage<PointData> selectOriginalDataByRealIds(Integer page, Integer size, String roleId); IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId);
} }

24
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java

@ -1,10 +1,14 @@
package com.hnac.hzims.operational.config.service.impl; package com.hnac.hzims.operational.config.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.config.service.CentralMonitorService;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzims.operational.ticket.fegin.StationFeginService;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
@ -17,7 +21,9 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -81,7 +87,7 @@ public class CentralMonitorServiceImpl implements CentralMonitorService {
* @return * @return
*/ */
@Override @Override
public HzPage<PointData> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { public IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(roleId); originalDataQuery.setRealId(roleId);
originalDataQuery.setLimit(size); originalDataQuery.setLimit(size);
@ -93,12 +99,26 @@ public class CentralMonitorServiceImpl implements CentralMonitorService {
if (!originalDataByRealIds.isSuccess()) { if (!originalDataByRealIds.isSuccess()) {
throw new IllegalArgumentException("数据不存在"); throw new IllegalArgumentException("数据不存在");
} }
return originalDataByRealIds.getData(); HzPage<PointData> data = originalDataByRealIds.getData();
List<PointDataVo> collect = data.getRecords().stream().map(item -> {
PointDataVo pointDataVo = new PointDataVo();
BeanUtils.copyProperties(item, pointDataVo);
//通过站点id获取站点名称
String station = pointDataVo.getStation();
String stationName = stationService.selectStationById(station);
pointDataVo.setStationName(stationName);
return pointDataVo;
}).collect(Collectors.toList());
IPage<PointDataVo> iPage = new Page(data.getCurrent(), data.getSize());
iPage.setRecords(collect);
return iPage;
} }
/** /**
* LocalDateTime date * LocalDateTime date
*
* @param localDateTime * @param localDateTime
* @return * @return
*/ */

45
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java

@ -0,0 +1,45 @@
package com.hnac.hzims.operational.config.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/8/1 10:37
*/
@Data
public class PointDataVo {
/**
* 站点id
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String station;
/**
* 站点名称
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String stationName;
/**
* 数据采集时间
*/
private String time;
/**
* 数据
*/
private String value;
/**
* 质量值
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer q;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String signage;
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -131,4 +131,10 @@ public interface IStationService extends BaseService<StationEntity> {
*/ */
void uniqueStationByStation(String signage); void uniqueStationByStation(String signage);
/**
* 通过站点id获取站点名称
* @param station
* @return
*/
String selectStationById(String station);
} }

35
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.station.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.common.service.UserAuthDataService;
@ -37,6 +38,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
@ -106,19 +108,20 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/** /**
* 推送站点 * 推送站点
*
* @param req 推送站点内容 * @param req 推送站点内容
*/ */
private void pushStation(StationEntity req) { private void pushStation(StationEntity req) {
// 读取站点类型配置确定是否推送FDP // 读取站点类型配置确定是否推送FDP
StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build(); StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build();
StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class)); StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class));
if(ObjectUtil.isNotEmpty(configVO) && configVO.getIsPush()) { if (ObjectUtil.isNotEmpty(configVO) && configVO.getIsPush()) {
log.info("{}站点开始智能诊断站点推送",req.getCode()); log.info("{}站点开始智能诊断站点推送", req.getCode());
new Thread(() -> questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送"), "智能诊断站点推送").start(); new Thread(() -> questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送"), "智能诊断站点推送").start();
} }
// 如果设备数据来源未选定其他 则进行站点初始化操作 // 如果设备数据来源未选定其他 则进行站点初始化操作
if (StationConstants.GATHER.equals(req.getDataOrigin()) && !StationConstants.HZ3000_OTHER.equals(req.getDataSource())) { if (StationConstants.GATHER.equals(req.getDataOrigin()) && !StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
log.info("{}站点开始数据平台新建项目",req.getCode()); log.info("{}站点开始数据平台新建项目", req.getCode());
new Thread(() -> this.instanceProject(req), "数据平台新建项目").start(); new Thread(() -> this.instanceProject(req), "数据平台新建项目").start();
} }
} }
@ -697,8 +700,30 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
LambdaQueryWrapper<StationEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StationEntity::getSignage, signage); queryWrapper.eq(StationEntity::getSignage, signage);
Integer count = baseMapper.selectCount(queryWrapper); Integer count = baseMapper.selectCount(queryWrapper);
if (count > 0){ if (count > 0) {
throw new ServiceException("两票编号抬头已存在"); throw new ServiceException("两票编号抬头已存在");
}
}
/**
* 通过站点id获取站点名称
*
* @param station
* @return
*/
@Override
public String selectStationById(String station) {
if (StringUtils.isEmpty(station)) {
return null;
}
QueryWrapper<StationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseEntity::getId, station);
queryWrapper.lambda().or().eq(StationEntity::getCode, station);
StationEntity stationEntity = baseMapper.selectOne(queryWrapper);
if (stationEntity != null) {
return stationEntity.getName();
} }
return null;
} }
} }

Loading…
Cancel
Save