From d54c0c284bf79383edf140e67cda39258f626eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Tue, 1 Aug 2023 11:05:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=9A=E8=AE=AF=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E7=9A=84=E6=9C=80=E5=90=8E=E4=B8=80=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CentralMonitorController.java | 4 +- .../config/service/CentralMonitorService.java | 4 +- .../service/impl/CentralMonitorServiceImpl.java | 24 +++++++++++- .../hzims/operational/config/vo/PointDataVo.java | 45 ++++++++++++++++++++++ .../station/service/IStationService.java | 6 +++ .../station/service/impl/StationServiceImpl.java | 35 ++++++++++++++--- 6 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java index f9a3356..a86b507 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java +++ b/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; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.main.vo.RealStationVo; import com.hnac.hzinfo.datasearch.PointData; @@ -57,7 +59,7 @@ public class CentralMonitorController extends BladeController { public R selectCommunication(@PathVariable Integer page, @PathVariable Integer size, String roleId){ - HzPage result = monitorService.selectOriginalDataByRealIds(page, size, roleId); + IPage result = monitorService.selectOriginalDataByRealIds(page, size, roleId); return R.data(result); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java index cceb159..887026e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java +++ b/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; +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.hzinfo.datasearch.PointData; import com.hnac.hzinfo.sdk.core.response.HzPage; @@ -26,6 +28,6 @@ public interface CentralMonitorService{ * @param roleId * @return */ - HzPage selectOriginalDataByRealIds(Integer page, Integer size, String roleId); + IPage selectOriginalDataByRealIds(Integer page, Integer size, String roleId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java index 8d0afa6..34b2d03 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java +++ b/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; +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.vo.PointDataVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; 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.history.IHistoryDataSearchClient; 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.system.entity.Dept; import org.springblade.system.feign.ISysClient; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -81,7 +87,7 @@ public class CentralMonitorServiceImpl implements CentralMonitorService { * @return */ @Override - public HzPage selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { + public IPage selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { OriginalDataQuery originalDataQuery = new OriginalDataQuery(); originalDataQuery.setRealId(roleId); originalDataQuery.setLimit(size); @@ -93,12 +99,26 @@ public class CentralMonitorServiceImpl implements CentralMonitorService { if (!originalDataByRealIds.isSuccess()) { throw new IllegalArgumentException("数据不存在"); } - return originalDataByRealIds.getData(); + HzPage data = originalDataByRealIds.getData(); + List 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 iPage = new Page(data.getCurrent(), data.getSize()); + iPage.setRecords(collect); + return iPage; } /** * LocalDateTime 转 date + * * @param localDateTime * @return */ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java new file mode 100644 index 0000000..444da82 --- /dev/null +++ b/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; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 1d8e8d1..95e2bc6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -131,4 +131,10 @@ public interface IStationService extends BaseService { */ void uniqueStationByStation(String signage); + /** + * 通过站点id获取站点名称 + * @param station + * @return + */ + String selectStationById(String station); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index e2b5123..bc86153 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/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.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.toolkit.Wrappers; import com.hnac.hzims.common.service.UserAuthDataService; @@ -37,6 +38,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springblade.core.log.exception.ServiceException; 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.support.Condition; import org.springblade.core.mp.support.Query; @@ -106,19 +108,20 @@ public class StationServiceImpl extends BaseServiceImpl questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送"), "智能诊断站点推送").start(); } // 如果设备数据来源未选定其他 则进行站点初始化操作 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(); } } @@ -697,8 +700,30 @@ public class StationServiceImpl extends BaseServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(StationEntity::getSignage, signage); Integer count = baseMapper.selectCount(queryWrapper); - if (count > 0){ - throw new ServiceException("两票编号抬头已存在"); + if (count > 0) { + throw new ServiceException("两票编号抬头已存在"); + } + } + + + /** + * 通过站点id获取站点名称 + * + * @param station + * @return + */ + @Override + public String selectStationById(String station) { + if (StringUtils.isEmpty(station)) { + return null; + } + QueryWrapper 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; } }