From 108e6ab7e9bd84042bdbefe4db3916e551b6960d Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 10 Jul 2024 08:46:33 +0800 Subject: [PATCH] =?UTF-8?q?#=E4=BC=98=E5=8C=96app=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/controller/HistoryController.java | 61 ++++++++++++++++++ .../operational/history/service/AlarmService.java | 14 +++++ .../operational/history/service/PointService.java | 22 +++++++ .../history/service/impl/AlarmServiceImpl.java | 45 +++++++++++++ .../history/service/impl/PointServiceImpl.java | 73 ++++++++++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java new file mode 100644 index 0000000..8af9018 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java @@ -0,0 +1,61 @@ +package com.hnac.hzims.operational.history.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.history.service.AlarmService; +import com.hnac.hzims.operational.history.service.PointService; +import com.hnac.hzinfo.dataconfig.entity.Device; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +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.*; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/history") +@Api(value = "历史数据查询", tags = "历史数据查询") +@AllArgsConstructor +public class HistoryController extends BladeController { + + + private final PointService pointService; + + private final AlarmService alarmService; + + @PostMapping("/alarm") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "告警数据查询", notes = "根据站点查询数据") + public R> alarm(@RequestBody SoeQueryCondition soeQueryCondition) { + return R.data(alarmService.alarm(soeQueryCondition)); + } + + @GetMapping("/projectSid") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "查询站点sid", notes = "根据站点id查询sid") + public R projectSid(@RequestParam(value = "stationId") String projectId) { + return R.data(pointService.projectSid(projectId)); + } + + @GetMapping("/projectGroup") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "站点分组信息", notes = "根据站点sid查询厂信息分组") + public R> projectGroup(@RequestParam(value = "sid") String sid) { + return R.data(pointService.projectGroup(sid)); + } + + @GetMapping("/onlineAttr") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "分组点位信息", notes = "根据分组Id查询分组点位") + public R> onlineAttr(@RequestParam(value = "groupId") String groupId) { + return R.data(pointService.onlineAttr(groupId)); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java new file mode 100644 index 0000000..5617635 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.history.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; + +/** + * @author ysj + */ +public interface AlarmService { + + + IPage alarm(SoeQueryCondition soeQueryCondition); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java new file mode 100644 index 0000000..3ae1460 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.history.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzinfo.dataconfig.entity.Device; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; + +import java.util.List; + +/** + * @author ysj + */ +public interface PointService { + + + String projectSid(String projectId); + + List projectGroup(String projectId); + + List onlineAttr(String groupId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java new file mode 100644 index 0000000..8d2b9bc --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.operational.history.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.operational.history.service.AlarmService; +import com.hnac.hzinfo.dataconfig.entity.Device; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class AlarmServiceImpl implements AlarmService { + + private final ISoeClient soeClient; + + private final DeviceClient deviceClient; + + @Override + public IPage alarm(SoeQueryCondition soeQueryCondition) { + IPage page = new Page<>(soeQueryCondition.getPage(), soeQueryCondition.getLimit()); + Result> result = soeClient.getByTypeAndTimeRangeOfPage(soeQueryCondition); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ + return page; + } + page.setPages(result.getData().getCurrent()); + page.setSize(result.getData().getSize()); + page.setTotal(result.getData().getTotal()); + page.setRecords(result.getData().getRecords()); + return page; + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java new file mode 100644 index 0000000..172a302 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java @@ -0,0 +1,73 @@ +package com.hnac.hzims.operational.history.service.impl; + +import com.hnac.hzims.operational.history.service.PointService; +import com.hnac.hzinfo.dataconfig.entity.Device; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class PointServiceImpl implements PointService { + + private final ProjectClient projectClient; + + private final DeviceClient deviceClient; + + /** + * 查询站点厂信息分组 + * @param projectId + * @return + */ + @Override + public String projectSid(String projectId) { + Result result = projectClient.getProjectBySid(projectId); + if(!result.isSuccess() || StringUtil.isBlank(result.getData())){ + return ""; + } + return result.getData(); + } + + /** + * 厂信息分组 + * @param sid + * @return + */ + @Override + public List projectGroup(String sid) { + Result> result = deviceClient.facDeviceByProjectId(sid); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** + * 查询分组点位信息 + * @param groupId + * @return + */ + @Override + public List onlineAttr(String groupId) { + R> result = deviceClient.getOnlineAttr(groupId); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + +} \ No newline at end of file