From e7284804aa8782a02c4c64188a19f29fe6212416 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 31 Jul 2023 16:38:37 +0800 Subject: [PATCH 1/5] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/impl/MaintenanceServiceImpl.java | 2 +- .../main/service/impl/HomeServiceImpl.java | 37 ++++++++++++++-------- .../main/service/impl/WindHomeServiceImpl.java | 4 +-- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java index 35b4ab5..47abb2b 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java @@ -108,7 +108,7 @@ public class MaintenanceServiceImpl extends BaseServiceImpl id.toString()).collect(Collectors.joining(","))); + regularWorkVO.setMainTaskIds(regularWorkList.stream().map(OperMaintenanceTaskEntity::getId).map(Object::toString).collect(Collectors.joining(","))); regularWorkVO.setRegularWorkSum(regularWorkList.size()); // 定期工作任务完成数量 List regularWorkFinishList = regularWorkList.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java index 519f722..1e78dea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java @@ -1,12 +1,14 @@ package com.hnac.hzims.operational.main.service.impl; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IPlanGenertionClient; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.fill.service.*; import com.hnac.hzims.operational.main.constant.HomePageConstant; @@ -55,6 +57,8 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class HomeServiceImpl implements HomeService { + private final WindService windService; + private final OverService overService; private final OtherService otherService; @@ -82,6 +86,8 @@ public class HomeServiceImpl implements HomeService { @Value("${hzims.operation.homePage.charge.url}") public String charge_url; + public final static String device_cache_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; + private final static String load_home_target_key = "load:operation:home:target:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; @@ -234,27 +240,32 @@ public class HomeServiceImpl implements HomeService { if(CollectionUtil.isEmpty(stations)){ return target; } - QueryWrapper queryWrapper = new QueryWrapper() {{ - in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); - eq("type", HomePageConstant.WIND_POWER_TYPE); - likeRight("mon", DateUtil.format(new Date(),"yyyy")); - }}; - List list = powerService.list(queryWrapper); - if(CollectionUtil.isEmpty(list)){ + List winds = windService.list(Wrappers.lambdaQuery() + .in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) + .likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy"))); + if(CollectionUtil.isEmpty(winds)){ return target; } - double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); - double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); + double plan = winds.stream().mapToDouble(WindEntity::getPlan).sum(); + double power = winds.stream().mapToDouble(WindEntity::getPower).sum(); + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference>() {}); // 装机容量 - target.setTaget_one(list.get(0).getInstalledCapacity()); + target.setTaget_one(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum()); // 发电量 - target.setTaget_two(list.stream().mapToDouble(PowerEntity::getPowerMon).sum()); + target.setTaget_two(power); if(Math.abs(plan) > 0){ // 发电完成率 - target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); } // 双票合格率 - target.setTaget_four(BigDecimal.valueOf(pass / list.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + R> result = sysClient.getDeptList(); + List areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); + DoublePassRateVO pass = ticketClient.getDoublePassRate(areas, firstDateTime, LocalDateTime.now()); + if (ObjectUtil.isNotEmpty(pass)) { + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } return target; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java index 7f22d06..a7143b1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java @@ -493,13 +493,13 @@ public class WindHomeServiceImpl implements WindHomeService { .like(WindEntity::getFillDate,DateUtil.format(new Date(),DateUtil.PATTERN_DATE)); }}); if(CollectionUtil.isNotEmpty(winds)){ - areaDuty.setSpeed(winds.stream().mapToDouble(WindEntity::getPower).average().orElse(0.0)); + areaDuty.setSpeed(winds.stream().mapToDouble(WindEntity::getSpeed).average().orElse(0.0)); areaDuty.setSurfPower(winds.stream().mapToDouble(WindEntity::getSurfPower).sum()); areaDuty.setBelowPower(winds.stream().mapToDouble(WindEntity::getBelowPower).sum()); areaDuty.setAvailable(winds.stream().mapToDouble(WindEntity::getAvailable).average().orElse(0.0)); areaDuty.setComprehensivePower(winds.stream().mapToDouble(WindEntity::getComprehensivePower).sum()); areaDuty.setPeakPower(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0)); - areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0)); + areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getFaultHours).average().orElse(0.0)); } List windMons = windService.list(new LambdaQueryWrapper() {{ in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) From 61640d9deb0218215fdf372bba0e2fc987914c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Mon, 31 Jul 2023 17:09:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BD=E5=AE=B6?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CountrySelectorController.java | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/CountrySelectorController.java diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/CountrySelectorController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/CountrySelectorController.java new file mode 100644 index 0000000..3254ccf --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/CountrySelectorController.java @@ -0,0 +1,62 @@ +package com.hnac.hzims.operational.station.controller; + + +import io.swagger.annotations.Api; +import org.springblade.core.tool.api.R; +import org.springblade.system.entity.Dict; +import org.springblade.system.feign.IDictClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/country/selector") +@Api(value = "国家管理", tags = "国家管理") +public class CountrySelectorController { + + + @Autowired + private IDictClient iDictClient; + + + /** + * 查询国家字典数据 + * + * @return + */ + @GetMapping("/countryOfIssue") + public R countryOfIssue() { + R> regionGlobal = iDictClient.getList("region_global"); + if (!regionGlobal.isSuccess()) { + return R.fail("查询数据不存在"); + } + List collect = regionGlobal.getData().stream() + .filter(item -> item.getParentId().longValue() == 1684523498650771L) + .collect(Collectors.toList()); + return R.data(collect); + } + + + /** + * 查询省份字典数据 + * + * @return + */ + @GetMapping("/loadProvince") + public R loadProvince() { + R> regionGlobal = iDictClient.getList("region_global"); + if (!regionGlobal.isSuccess()) { + return R.fail("查询数据不存在"); + } + List collect = regionGlobal.getData().stream() + .filter(item -> item.getParentId().longValue() == 1684523498650771459L) + .collect(Collectors.toList()); + return R.data(collect); + } + + +} \ No newline at end of file From d2a37de5073f0311c5e85834828fb6cdc8b199eb 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 10:17:55 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E7=9A=84=E6=9C=80=E5=90=8E=E4=B8=80=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=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 | 23 +++- .../config/service/CentralMonitorService.java | 13 +++ .../service/impl/CentralMonitorServiceImpl.java | 116 +++++++++++++++------ 3 files changed, 115 insertions(+), 37 deletions(-) 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 0989365..f9a3356 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 @@ -4,15 +4,14 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.station.service.IRealMonitorService; import com.hnac.hzims.operational.main.vo.RealStationVo; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.sdk.core.response.HzPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -45,4 +44,20 @@ public class CentralMonitorController extends BladeController { realMonitorService.realTimeData(""); return R.success("true"); } + + + /** + * 查询通讯告警的最后一小时的运行数据 + * @param page + * @param size + * @param roleId + * @return + */ + @GetMapping("/selectCommunication/{page}/{size}") + public R selectCommunication(@PathVariable Integer page, + @PathVariable Integer size, + String roleId){ + HzPage 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 040e7c9..cceb159 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 @@ -2,6 +2,8 @@ package com.hnac.hzims.operational.config.service; import com.hnac.hzims.operational.main.vo.RealStationVo; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.sdk.core.response.HzPage; import java.util.List; @@ -15,4 +17,15 @@ public interface CentralMonitorService{ * @return */ List getStationMonitor(); + + + /** + * 查询通讯告警的最后一小时的运行数据 + * @param page 当前页 + * @param size 每页记录数 + * @param roleId + * @return + */ + HzPage 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 2124c9c..8d0afa6 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 @@ -5,6 +5,12 @@ 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.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; +import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import lombok.Getter; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; @@ -15,7 +21,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -24,37 +36,75 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class CentralMonitorServiceImpl implements CentralMonitorService { - private final IStationService stationService; - private final ISysClient sysClient; - private final RedisTemplate redisTemplate; - - @Value("${hzims.operation.monitor.station}") - public String moniter_station_key; - - /** - * 获取站点监控数据 - * @return - */ - @Override - public List getStationMonitor() { - // 根据用户权限获取机构 - R> R = sysClient.getDeptByCurrentUser(); - if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { - return null; - } - List deptIdList = R.getData().stream().map(Dept::getId).collect(Collectors.toList()); - List list = stationService.getStationType(null, Collections.singletonList(HomePageConstant.HYDROPOWER),deptIdList); - if(CollectionUtil.isEmpty(list)){ - return null; - } - List codeList = list.stream().map(StationEntity::getCode).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(codeList)){ - return null; - } - List result = (List) redisTemplate.opsForValue().get(moniter_station_key); - if(StringUtil.isEmpty(result)){ - return null; - } - return result.stream().filter(o->codeList.contains(o.getStationCode())).collect(Collectors.toList()); - } + private final IStationService stationService; + private final ISysClient sysClient; + private final RedisTemplate redisTemplate; + private final IHistoryDataSearchClient historyDataSearchClient; + + @Value("${hzims.operation.monitor.station}") + public String moniter_station_key; + + /** + * 获取站点监控数据 + * + * @return + */ + @Override + public List getStationMonitor() { + // 根据用户权限获取机构 + R> R = sysClient.getDeptByCurrentUser(); + if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { + return null; + } + List deptIdList = R.getData().stream().map(Dept::getId).collect(Collectors.toList()); + List list = stationService.getStationType(null, Collections.singletonList(HomePageConstant.HYDROPOWER), deptIdList); + if (CollectionUtil.isEmpty(list)) { + return null; + } + List codeList = list.stream().map(StationEntity::getCode).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(codeList)) { + return null; + } + List result = (List) redisTemplate.opsForValue().get(moniter_station_key); + if (StringUtil.isEmpty(result)) { + return null; + } + return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList()); + } + + /** + * 查询通讯告警的最后一小时的运行数据 + * + * @param page 当前页 + * @param size 每页记录数 + * @param roleId + * @return + */ + @Override + public HzPage selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { + OriginalDataQuery originalDataQuery = new OriginalDataQuery(); + originalDataQuery.setRealId(roleId); + originalDataQuery.setLimit(size); + LocalDateTime startTime = LocalDateTime.now(); + LocalDateTime endTime = startTime.minusHours(1); + originalDataQuery.setBeginTime(this.getOriginalDate(startTime)); + originalDataQuery.setEndTime(this.getOriginalDate(endTime)); + Result> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); + if (!originalDataByRealIds.isSuccess()) { + throw new IllegalArgumentException("数据不存在"); + } + return originalDataByRealIds.getData(); + } + + + /** + * LocalDateTime 转 date + * @param localDateTime + * @return + */ + public static Date getOriginalDate(LocalDateTime localDateTime) { + Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant(); + return Date.from(instant); + } + } 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 4/5] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E7=9A=84=E6=9C=80=E5=90=8E=E4=B8=80=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=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; } } From 84e662f08969a970f9c1289036669be5cda06594 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 14:11:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E7=9A=84=E6=9C=80=E5=90=8E=E4=B8=80=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=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 --- .../operational/config/service/impl/CentralMonitorServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 34b2d03..7d9bc9b 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 @@ -16,6 +16,7 @@ import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import lombok.Getter; import lombok.RequiredArgsConstructor; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.StringUtil; @@ -91,13 +92,13 @@ public class CentralMonitorServiceImpl implements CentralMonitorService { OriginalDataQuery originalDataQuery = new OriginalDataQuery(); originalDataQuery.setRealId(roleId); originalDataQuery.setLimit(size); - LocalDateTime startTime = LocalDateTime.now(); - LocalDateTime endTime = startTime.minusHours(1); + LocalDateTime endTime = LocalDateTime.now(); + LocalDateTime startTime = endTime.minusHours(1); originalDataQuery.setBeginTime(this.getOriginalDate(startTime)); originalDataQuery.setEndTime(this.getOriginalDate(endTime)); Result> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); if (!originalDataByRealIds.isSuccess()) { - throw new IllegalArgumentException("数据不存在"); + throw new ServiceException("数据不存在"); } HzPage data = originalDataByRealIds.getData(); List collect = data.getRecords().stream().map(item -> {