Browse Source

# 站点集中监控属性采集点绑定

zhongwei
haungxing 1 year ago
parent
commit
1cedb2b6d2
  1. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java
  2. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java
  3. 70
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java
  4. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

8
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))); return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids)));
} }
@PutMapping("/bandingMonitor/{emCode}") @PutMapping("/bandingMonitor")
@ApiOperation("根据设备编码更新集中监控监测点绑定") @ApiOperation("根据设备编码更新集中监控监测点绑定")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R<List<StationAttributeVo>> bandingMonitor(@PathVariable @ApiParam(value = "设备编码",required = true) String emCode) { public R<List<StationAttributeVo>> bandingMonitor(@ApiParam(value = "设备编码",required = true) String emCode,
return R.data(stationAttributeService.bandingMonitor(emCode)); @ApiParam(value = "站点类型",required = true) String stationType,
@ApiParam(value = "设备类型",required = true) String emType) {
return R.data(stationAttributeService.bandingMonitor(emCode,stationType,emType));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java

@ -45,5 +45,5 @@ public interface IStationAttributeService extends BaseService<StationAttributeEn
*/ */
void removeByStationCode(String stationCode); void removeByStationCode(String stationCode);
List<StationAttributeVo> bandingMonitor(String emCode); List<StationAttributeVo> bandingMonitor(String emCode,String stationType,String emType);
} }

70
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.google.common.collect.Lists;
import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.common.service.UserAuthDataService;
import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; 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.StationAttrConfigEntity;
import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; 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.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationAttributeVo; 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.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 com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; 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.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.function.Function;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -50,6 +50,7 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
private final UserAuthDataService userAuthDataService; private final UserAuthDataService userAuthDataService;
private final IStationAttrConfigService stationAttrConfigService; private final IStationAttrConfigService stationAttrConfigService;
private final IFocusAttributeService attributeService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final DeviceClient deviceClient; private final DeviceClient deviceClient;
@ -208,30 +209,35 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
* @return * @return
*/ */
@Override @Override
public List<StationAttributeVo> bandingMonitor(String emCode) { public List<StationAttributeVo> bandingMonitor(String emCode,String stationType,String emType) {
List<StationAttributeVo> result = new ArrayList<>(); List<StationAttributeVo> result;
LambdaQueryWrapper<StationAttributeEntity> wq = Wrappers.<StationAttributeEntity>lambdaQuery().eq(StationAttributeEntity::getEmCode, emCode); // 获取集中监控属性配置
List<StationAttributeEntity> attributeEntities = this.list(wq); List<FocusAttributeEntity> attributes = attributeService.list(Wrappers.<FocusAttributeEntity>lambdaQuery()
if(CollectionUtil.isEmpty(attributeEntities)) { .eq(FocusAttributeEntity::getDomainId, stationType)
return Lists.newArrayList(); .eq(FocusAttributeEntity::getGroupId, emType)
} .eq(FocusAttributeEntity::getStatus, 0)
// 获取设备实例物模型绑定数据 );
R<List<DeviceInstanceAttrVO>> onlineAttrR= deviceClient.getOnlineAttr(emCode); // 标识
Assert.isTrue(onlineAttrR.isSuccess(),() -> { List<String> signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList());
throw new ServiceException(onlineAttrR.getMsg()); // 根据设备实例查询采集点
}); DeviceChildrenDTO deviceChildrenDTO = new DeviceChildrenDTO();
if(CollectionUtil.isNotEmpty(onlineAttrR.getData())) { deviceChildrenDTO.setSignages(signages);
Map<String, List<DeviceInstanceAttrVO>> stringListMap = onlineAttrR.getData().stream().collect(Collectors.groupingBy(DeviceInstanceAttrVO::getSignage)); deviceChildrenDTO.setDeviceCode(emCode);
result = attributeEntities.stream().map(attributeEntity -> { deviceChildrenDTO.setType("attr");
StationAttributeVo attributeVo = BeanUtil.copy(attributeEntity, StationAttributeVo.class); Result<List<DeviceChildrenVO>> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO);
List<DeviceInstanceAttrVO> deviceInstanceAttrVOS = stringListMap.get(attributeEntity.getSignage()); boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData());
if(CollectionUtil.isNotEmpty(deviceInstanceAttrVOS)) { // 根据集中监控属性配置获取站点集中监控属性配置
attributeVo.setMonitorId(deviceInstanceAttrVOS.get(0).getFacDeviceAttrId()); Function<FocusAttributeEntity,StationAttributeVo> convert = focusAttr -> {
attributeVo.setMonitorName(deviceInstanceAttrVOS.get(0).getFacDeviceAttrName()); StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class);
} if(facAttrFlag) {
return attributeVo; List<DeviceChildrenVO> data = deviceChildrenListResult.getData();
}).collect(Collectors.toList()); Optional<DeviceChildrenVO> 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; return result;
} }
} }

11
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.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -142,11 +142,16 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
logger.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg()); logger.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg());
} }
} }
// 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode()); // 清空
} }
new Thread(()-> { new Thread(()-> {
// 删除站点下集中监控属性配置
stationAttributeService.removeByStationCode(stationEntity.getCode()); stationAttributeService.removeByStationCode(stationEntity.getCode());
// 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode());
// 删除智能诊断实例图信息
questionClient.deleteStationAnswer(stationEntity.getCode());
},"删除站点集中监控属性").start(); },"删除站点集中监控属性").start();
return saveFlag; return saveFlag;
} }

Loading…
Cancel
Save