diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationAttributeEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationAttributeEntity.java index 6e1135e..f35b024 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationAttributeEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationAttributeEntity.java @@ -94,4 +94,10 @@ public class StationAttributeEntity extends TenantEntity implements Serializable @ApiModelProperty("单位") private String unit; + + @ApiModelProperty("监测点映射标识") + private String signage; + + @ApiModelProperty("物模型属性名称") + private String signageName; } 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 aac33ad..0ba2954 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 @@ -90,4 +90,11 @@ public class StationAttributeController extends BladeController { public R removeByIds(@RequestParam String ids) { return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids))); } + + @PutMapping("/bandingMonitor/{emCode}") + @ApiOperation("根据设备编码更新集中监控监测点绑定") + @ApiOperationSupport(order = 4) + public R> bandingMonitor(@PathVariable @ApiParam(value = "设备编码",required = true) String emCode) { + return R.data(stationAttributeService.bandingMonitor(emCode)); + } } 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 14121d5..9a0f891 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 @@ -3,9 +3,12 @@ package com.hnac.hzims.operational.station.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.station.dto.StationAttributeDto; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; +import com.hnac.hzims.operational.station.vo.StationAttributeVo; +import io.swagger.annotations.ApiParam; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PathVariable; import java.util.List; import java.util.Map; @@ -41,4 +44,6 @@ public interface IStationAttributeService extends BaseService bandingMonitor(String emCode); } 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 27a0ded..9131c87 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 @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.station.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; 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.station.entity.StationAttrConfigEntity; @@ -13,20 +14,25 @@ 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.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; 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.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; @@ -45,6 +51,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()); + } + 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 fe18a39..42f3447 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 @@ -98,11 +98,8 @@ public class StationServiceImpl extends BaseServiceImpl questionClient.submitStationInfo(req.getCode(), "")); - // 新建项目 - executor.submit(() -> this.instanceProject(req)); + new Thread(()->questionClient.submitStationInfo(req.getCode(), ""),"智能诊断站点推送").start(); + new Thread(()->this.instanceProject(req),"新建项目").start(); } } diff --git a/hzims-service/operational/src/main/resources/db/1.0.2.sql b/hzims-service/operational/src/main/resources/db/1.0.2.sql new file mode 100644 index 0000000..1acd90e --- /dev/null +++ b/hzims-service/operational/src/main/resources/db/1.0.2.sql @@ -0,0 +1,3 @@ +-- 站点集中监控属性表添加物模型属性标识、名称 +alter table hzims_station_attribute add column `SIGNAGE` VARCHAR(50) default null comment '加物模型属性标识'; +alter table hzims_station_attribute add column `SIGNAGE_NAME` VARCHAR(100) default null comment '加物模型属性标识名称'; \ No newline at end of file