From c18220a7f3908eb4890e8d842eb84d06dda415f7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 11 Jul 2024 13:36:42 +0800 Subject: [PATCH] =?UTF-8?q?#app=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE,?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E5=91=8A=E8=AD=A6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/history/vo/HistoricalCurveVo.java | 52 +++++++++++ .../history/vo/HistoryProjectAlarmVo.java | 32 +++++++ .../controller/CentralMonitorController.java | 2 +- .../history/controller/HistoryController.java | 61 ++++++++++--- .../operational/history/service/AlarmService.java | 8 +- .../operational/history/service/PointService.java | 17 +++- .../history/service/impl/AlarmServiceImpl.java | 50 +++++----- .../history/service/impl/PointServiceImpl.java | 101 ++++++++++++++++++++- 8 files changed, 280 insertions(+), 43 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java new file mode 100644 index 0000000..1ba4a0a --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.operational.history.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "历史告警数据查询") +public class HistoricalCurveVo { + + @ApiModelProperty(value = "第一个点位") + private String firstAttrId; + + @ApiModelProperty(value = "第二个点位") + private String secondAttrId; + + @ApiModelProperty(value = "第三个点位") + private String thirdlyAttrId; + + @ApiModelProperty(value = "第四个点位") + private String fourthAttrId; + + @ApiModelProperty(value = "第五个点位") + private String fifthAttrId; + + @ApiModelProperty(value = "第五个点位") + private LocalDateTime startTime; + + @ApiModelProperty(value = "第五个点位") + private LocalDateTime endTime; + + @ApiModelProperty(value = "厂组点/设备") + private Integer dimension; + + @ApiModelProperty(value = "维度 :0-10秒 、 1-1分钟 、2-5分钟 .....") + private Integer intervalType; + + @ApiModelProperty(value = "是否分页") + private Boolean isPage; + + @ApiModelProperty(value = "页码") + private Integer current; + + @ApiModelProperty(value = "页码条数") + private Integer pageSize; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java new file mode 100644 index 0000000..6ab8c38 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.operational.history.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "历史告警数据查询") +public class HistoryProjectAlarmVo { + + @ApiModelProperty(value = "站点编号") + private String projectId; + + @ApiModelProperty(value = "维度") + private Integer dimension; + + @ApiModelProperty(value = "主键Id") + private String id; + + @ApiModelProperty(value = "告警类型") + private Integer soeType; + + @ApiModelProperty(value = "开始时间") + private String startTime; + + @ApiModelProperty(value = "结束时间") + private String endTime; +} 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 00de1d9..824c597 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 @@ -62,7 +62,7 @@ public class CentralMonitorController extends BladeController { @GetMapping("/communications") @ApiOperation("查询通讯告警图表数据") @ApiOperationSupport(order = 4) - public R> communications(String roleId,Date start,@RequestParam Date end){ + public R> communications(String roleId,Date start,Date end){ return R.data(monitorService.communications(roleId,start,end)); } } 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 index 537c53f..f5d1b9a 100644 --- 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 @@ -4,11 +4,15 @@ 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.hzims.operational.history.vo.HistoricalCurveVo; +import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; 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 com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -16,7 +20,9 @@ import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; +import javax.management.Query; import java.util.List; +import java.util.Map; /** * @author ysj @@ -32,24 +38,57 @@ public class HistoryController extends BladeController { 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("/projectAlarm") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "站点告警数据", notes = "查询站点告警数据") + public R> projectAlarm(HistoryProjectAlarmVo alarm, Query query) { + return R.data(alarmService.projectAlarm(alarm,query)); } + @GetMapping("/projectFacDevice") @ApiOperationSupport(order = 2) - @ApiOperation(value = "站点厂租点", notes = "根据站点id查询厂组点信息") - public R> projectFacDevice(@RequestParam(value = "projectId") String projectId) { - return R.data(pointService.projectFacDevice(projectId)); + @ApiOperation(value = "站点厂组", notes = "根据站点id查询厂组信息") + public R> projectFacDevice(@RequestParam(value = "projectId") String projectId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectFacDevice(projectId,attrName)); } + @GetMapping("/projectFacDeviceAttr") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "站点厂租点", notes = "根据厂组Id查询厂组点信息") + public R> projectFacDeviceAttr(@RequestParam(value = "facDeviceId") String facDeviceId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectFacDeviceAttr(facDeviceId,attrName)); + } @GetMapping("/projectDeviceInstance") @ApiOperationSupport(order = 3) @ApiOperation(value = "站点虚拟设备息", notes = "根据站点id查询虚拟设备") - public R> projectDeviceInstance(@RequestParam(value = "projectId") String projectId) { - return R.data(pointService.projectDeviceInstance(projectId)); + public R> projectDeviceInstance(@RequestParam(value = "projectId") String projectId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectDeviceInstance(projectId,attrName)); + } + + @GetMapping("/projectDeviceInstanceAttr") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "设备点位信息", notes = "根据设备编号查询点位") + public R> projectDeviceInstanceAttr(@RequestParam(value = "deviceCode") String deviceCode, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectDeviceInstanceAttr(deviceCode,attrName)); + } + + @PostMapping("/historicalCurve") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "查询历史数据曲线图", notes = "获取历史数据折线图数据") + public R> historicalCurve(HistoricalCurveVo curve) { + return R.data(pointService.historicalCurve(curve)); + } + + @PostMapping("/attrStatistics") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "历史数据统计", notes = "获取历史数据统计数据") + public R> attrStatistics(HistoricalCurveVo curve) { + return R.data(pointService.attrStatistics(curve)); } -} +} \ No newline at end of file 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 index 5617635..712fefd 100644 --- 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 @@ -1,8 +1,14 @@ package com.hnac.hzims.operational.history.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; 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 javax.management.Query; +import java.util.List; +import java.util.Map; /** * @author ysj @@ -10,5 +16,5 @@ import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; public interface AlarmService { - IPage alarm(SoeQueryCondition soeQueryCondition); + Map projectAlarm(HistoryProjectAlarmVo alarm, Query query); } 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 index 43da1e1..3588143 100644 --- 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 @@ -1,13 +1,17 @@ package com.hnac.hzims.operational.history.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; 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 com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; import java.util.List; +import java.util.Map; /** * @author ysj @@ -15,8 +19,15 @@ import java.util.List; public interface PointService { - List projectFacDevice(String projectId); + List projectFacDevice(String projectId, String attrName); + List projectFacDeviceAttr(String facDeviceId, String attrName); - List projectDeviceInstance(String projectId); -} + List projectDeviceInstance(String projectId,String attrName); + + List projectDeviceInstanceAttr(String deviceCode, String attrName); + + Map historicalCurve(HistoricalCurveVo curve); + + Map attrStatistics(HistoricalCurveVo curve); +} \ No newline at end of file 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 index 8d2b9bc..daeca61 100644 --- 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 @@ -1,21 +1,17 @@ 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.hzims.operational.history.vo.HistoryProjectAlarmVo; import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; -import java.util.List; +import javax.management.Query; +import java.util.HashMap; +import java.util.Map; /** * @author ysj @@ -25,21 +21,31 @@ import java.util.List; @AllArgsConstructor public class AlarmServiceImpl implements AlarmService { - private final ISoeClient soeClient; + private final SoeDataClient soeClient; - private final DeviceClient deviceClient; + /** + * 查询站点告警数据 + * @param alarm + * @param query + * @return + */ @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; + public Map projectAlarm(HistoryProjectAlarmVo alarm, Query query) { + Result> result = soeClient.getDeviceSoeData( + alarm.getProjectId(), + alarm.getDimension(), + alarm.getId(), + alarm.getSoeType(), + alarm.getStartTime(), + alarm.getEndTime(), + query + ); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new HashMap<>(); } - page.setPages(result.getData().getCurrent()); - page.setSize(result.getData().getSize()); - page.setTotal(result.getData().getTotal()); - page.setRecords(result.getData().getRecords()); - return page; + return result.getData(); } + + } \ 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 index 0bfe398..a123379 100644 --- 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 @@ -1,11 +1,16 @@ package com.hnac.hzims.operational.history.service.impl; import com.hnac.hzims.operational.history.service.PointService; +import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; import com.hnac.hzinfo.dataconfig.entity.Device; import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import com.hnac.hzinfo.sdk.v5.hzfac.HzFacClient; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -14,8 +19,11 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author ysj @@ -25,10 +33,14 @@ import java.util.List; @AllArgsConstructor public class PointServiceImpl implements PointService { + private final DeviceDataClient deviceDataClient; + private final ProjectClient projectClient; private final DeviceClient deviceClient; + private final HzFacClient hzFacClient; + /** * 根据站点查询厂组点信息 @@ -36,8 +48,23 @@ public class PointServiceImpl implements PointService { * @return */ @Override - public List projectFacDevice(String projectId) { - Result> result = deviceClient.facDeviceByProjectId(projectId); + public List projectFacDevice(String projectId,String attrName) { + Result> result = hzFacClient.facDeviceByProjectId(projectId,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** + * 根据厂组Id查询厂组点信息 + * @param facDeviceId + * @param attrName + * @return + */ + @Override + public List projectFacDeviceAttr(String facDeviceId, String attrName) { + Result> result = hzFacClient.facDeviceAttrList(facDeviceId,attrName); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ return new ArrayList<>(); } @@ -50,13 +77,77 @@ public class PointServiceImpl implements PointService { * @return */ @Override - public List projectDeviceInstance(String projectId) { - R> result = deviceClient.getOnlineDeviceInstance(projectId); + public List projectDeviceInstance(String projectId,String attrName) { + R> result = deviceClient.getOnlineDeviceInstanceSearchName(projectId,attrName); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ return new ArrayList<>(); } return result.getData(); } + /** + * 查询站点厂组/设备点位信息 + * @param deviceCode + * @param attrName + * @return + */ + @Override + public List projectDeviceInstanceAttr(String deviceCode, String attrName) { + Result> result = deviceClient.getDeviceAttrByName(deviceCode,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** + * 查询历史数据曲线图 + * @return + */ + @Override + public Map historicalCurve(HistoricalCurveVo curve) { + Result> result = deviceDataClient.getLineDataByRealId( + curve.getFirstAttrId(), + curve.getSecondAttrId(), + curve.getThirdlyAttrId(), + curve.getFourthAttrId(), + curve.getFifthAttrId(), + curve.getStartTime(), + curve.getEndTime(), + curve.getDimension(), + curve.getIntervalType(), + curve.getIsPage(), + curve.getCurrent(), + curve.getPageSize() + ); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new HashMap<>(); + } + return result.getData(); + } + + /** + * 历史数据统计 + * @param curve + * @return + */ + @Override + public Map attrStatistics(HistoricalCurveVo curve) { + Result> result = deviceDataClient.getAttrStatistics(curve.getFirstAttrId(), + curve.getSecondAttrId(), + curve.getThirdlyAttrId(), + curve.getFourthAttrId(), + curve.getFifthAttrId(), + curve.getStartTime(), + curve.getEndTime(), + curve.getDimension(), + curve.getIntervalType()); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new HashMap<>(); + } + return result.getData(); + } + + +} -} \ No newline at end of file