From 1cedb2b6d2f4622677f4c69a49531ca7d4e4511a Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 26 Jun 2023 09:43:18 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E7=AB=99=E7=82=B9=E9=9B=86=E4=B8=AD?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E5=B1=9E=E6=80=A7=E9=87=87=E9=9B=86=E7=82=B9?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StationAttributeController.java | 8 ++- .../station/service/IStationAttributeService.java | 2 +- .../service/impl/StationAttributeServiceImpl.java | 70 ++++++++++++---------- .../station/service/impl/StationServiceImpl.java | 11 +++- 4 files changed, 52 insertions(+), 39 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java index 0ba2954..eede11e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java @@ -91,10 +91,12 @@ public class StationAttributeController extends BladeController { return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids))); } - @PutMapping("/bandingMonitor/{emCode}") + @PutMapping("/bandingMonitor") @ApiOperation("根据设备编码更新集中监控监测点绑定") @ApiOperationSupport(order = 4) - public R> bandingMonitor(@PathVariable @ApiParam(value = "设备编码",required = true) String emCode) { - return R.data(stationAttributeService.bandingMonitor(emCode)); + public R> bandingMonitor(@ApiParam(value = "设备编码",required = true) String emCode, + @ApiParam(value = "站点类型",required = true) String stationType, + @ApiParam(value = "设备类型",required = true) String emType) { + return R.data(stationAttributeService.bandingMonitor(emCode,stationType,emType)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java index 9a0f891..d3ecdb8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java @@ -45,5 +45,5 @@ public interface IStationAttributeService extends BaseService bandingMonitor(String emCode); + List bandingMonitor(String emCode,String stationType,String emType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java index efaf4d1..e9dd316 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; +import com.hnac.hzims.operational.config.entity.FocusAttributeEntity; +import com.hnac.hzims.operational.config.service.IFocusAttributeService; import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -14,7 +16,10 @@ import com.hnac.hzims.operational.station.service.IStationAttrConfigService; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.vo.StationAttributeVo; +import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceChildrenDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceChildrenVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; @@ -25,19 +30,14 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -50,6 +50,7 @@ public class StationAttributeServiceImpl extends BaseServiceImpl bandingMonitor(String emCode) { - List result = new ArrayList<>(); - LambdaQueryWrapper wq = Wrappers.lambdaQuery().eq(StationAttributeEntity::getEmCode, emCode); - List attributeEntities = this.list(wq); - if(CollectionUtil.isEmpty(attributeEntities)) { - return Lists.newArrayList(); - } - // 获取设备实例物模型绑定数据 - R> onlineAttrR= deviceClient.getOnlineAttr(emCode); - Assert.isTrue(onlineAttrR.isSuccess(),() -> { - throw new ServiceException(onlineAttrR.getMsg()); - }); - if(CollectionUtil.isNotEmpty(onlineAttrR.getData())) { - Map> stringListMap = onlineAttrR.getData().stream().collect(Collectors.groupingBy(DeviceInstanceAttrVO::getSignage)); - result = attributeEntities.stream().map(attributeEntity -> { - StationAttributeVo attributeVo = BeanUtil.copy(attributeEntity, StationAttributeVo.class); - List deviceInstanceAttrVOS = stringListMap.get(attributeEntity.getSignage()); - if(CollectionUtil.isNotEmpty(deviceInstanceAttrVOS)) { - attributeVo.setMonitorId(deviceInstanceAttrVOS.get(0).getFacDeviceAttrId()); - attributeVo.setMonitorName(deviceInstanceAttrVOS.get(0).getFacDeviceAttrName()); - } - return attributeVo; - }).collect(Collectors.toList()); - } + public List bandingMonitor(String emCode,String stationType,String emType) { + List result; + // 获取集中监控属性配置 + List attributes = attributeService.list(Wrappers.lambdaQuery() + .eq(FocusAttributeEntity::getDomainId, stationType) + .eq(FocusAttributeEntity::getGroupId, emType) + .eq(FocusAttributeEntity::getStatus, 0) + ); + // 标识 + List signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList()); + // 根据设备实例查询采集点 + DeviceChildrenDTO deviceChildrenDTO = new DeviceChildrenDTO(); + deviceChildrenDTO.setSignages(signages); + deviceChildrenDTO.setDeviceCode(emCode); + deviceChildrenDTO.setType("attr"); + Result> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO); + boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData()); + // 根据集中监控属性配置获取站点集中监控属性配置 + Function convert = focusAttr -> { + StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class); + if(facAttrFlag) { + List data = deviceChildrenListResult.getData(); + Optional facAttrOptional = data.stream().filter(attr -> focusAttr.getSignage().equals(attr.getSignage())).findAny(); + vo.setMonitorId(facAttrOptional.map(DeviceChildrenVO::getRealId).orElse(null)); + vo.setMonitorName(facAttrOptional.map(DeviceChildrenVO::getName).orElse(null)); + } + return vo; + }; + result = attributes.stream().map(convert).collect(Collectors.toList()); return result; } } 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 1a06dad..17d0b92 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 @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.service.impl; + package com.hnac.hzims.operational.station.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -142,11 +142,16 @@ public class StationServiceImpl extends BaseServiceImpl { + // 删除站点下集中监控属性配置 stationAttributeService.removeByStationCode(stationEntity.getCode()); + // 删除智能诊断站点 + questionClient.deleteStationInfo(stationEntity.getCode()); + // 删除智能诊断实例图信息 + questionClient.deleteStationAnswer(stationEntity.getCode()); },"删除站点集中监控属性").start(); return saveFlag; }