|
|
|
@ -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<StationAttribut
|
|
|
|
|
|
|
|
|
|
private final UserAuthDataService userAuthDataService; |
|
|
|
|
private final IStationAttrConfigService stationAttrConfigService; |
|
|
|
|
private final IFocusAttributeService attributeService; |
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
private final DeviceClient deviceClient; |
|
|
|
|
|
|
|
|
@ -208,30 +209,35 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<StationAttributeVo> bandingMonitor(String emCode) { |
|
|
|
|
List<StationAttributeVo> result = new ArrayList<>(); |
|
|
|
|
LambdaQueryWrapper<StationAttributeEntity> wq = Wrappers.<StationAttributeEntity>lambdaQuery().eq(StationAttributeEntity::getEmCode, emCode); |
|
|
|
|
List<StationAttributeEntity> attributeEntities = this.list(wq); |
|
|
|
|
if(CollectionUtil.isEmpty(attributeEntities)) { |
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
} |
|
|
|
|
// 获取设备实例物模型绑定数据
|
|
|
|
|
R<List<DeviceInstanceAttrVO>> onlineAttrR= deviceClient.getOnlineAttr(emCode); |
|
|
|
|
Assert.isTrue(onlineAttrR.isSuccess(),() -> { |
|
|
|
|
throw new ServiceException(onlineAttrR.getMsg()); |
|
|
|
|
}); |
|
|
|
|
if(CollectionUtil.isNotEmpty(onlineAttrR.getData())) { |
|
|
|
|
Map<String, List<DeviceInstanceAttrVO>> stringListMap = onlineAttrR.getData().stream().collect(Collectors.groupingBy(DeviceInstanceAttrVO::getSignage)); |
|
|
|
|
result = attributeEntities.stream().map(attributeEntity -> { |
|
|
|
|
StationAttributeVo attributeVo = BeanUtil.copy(attributeEntity, StationAttributeVo.class); |
|
|
|
|
List<DeviceInstanceAttrVO> 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<StationAttributeVo> bandingMonitor(String emCode,String stationType,String emType) { |
|
|
|
|
List<StationAttributeVo> result; |
|
|
|
|
// 获取集中监控属性配置
|
|
|
|
|
List<FocusAttributeEntity> attributes = attributeService.list(Wrappers.<FocusAttributeEntity>lambdaQuery() |
|
|
|
|
.eq(FocusAttributeEntity::getDomainId, stationType) |
|
|
|
|
.eq(FocusAttributeEntity::getGroupId, emType) |
|
|
|
|
.eq(FocusAttributeEntity::getStatus, 0) |
|
|
|
|
); |
|
|
|
|
// 标识
|
|
|
|
|
List<String> 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<List<DeviceChildrenVO>> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO); |
|
|
|
|
boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData()); |
|
|
|
|
// 根据集中监控属性配置获取站点集中监控属性配置
|
|
|
|
|
Function<FocusAttributeEntity,StationAttributeVo> convert = focusAttr -> { |
|
|
|
|
StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class); |
|
|
|
|
if(facAttrFlag) { |
|
|
|
|
List<DeviceChildrenVO> data = deviceChildrenListResult.getData(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|