Browse Source

#app历史数据统计、告警数据查询

zhongwei
yang_shj 5 months ago
parent
commit
c0df81a615
  1. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java
  2. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java

11
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java

@ -6,7 +6,6 @@ import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe;
import com.hnac.hzinfo.subscribe.SoeSubscribe; import com.hnac.hzinfo.subscribe.SoeSubscribe;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttAsyncClient;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -56,16 +55,16 @@ public class MqttConfigHzims {
mqttConfig.setPassword(mqtt_fdp_password); mqttConfig.setPassword(mqtt_fdp_password);
mqttConfig.setUsername(mqtt_fdp_username); mqttConfig.setUsername(mqtt_fdp_username);
//fdp //fdp
/*AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe();
MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer); MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer);
log.info(fdpClient.toString()+fdpClient.getClientId()); log.info(fdpClient.toString()+fdpClient.getClientId());
//drools //drools
DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe();
MqttAsyncClient droolsClient = droolsSoeSubscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), droolsMqttConsumer);
log.info(droolsClient.toString()+droolsClient.getClientId()); log.info(droolsClient.toString()+droolsClient.getClientId());
//Soe //Soe
SoeSubscribe soeSubscribe = new SoeSubscribe(); SoeSubscribe soeSubscribe = new SoeSubscribe();
MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), soeMqttConsumer);
log.info(soeClient.toString()+soeClient.getClientId()); log.info(soeClient.toString()+soeClient.getClientId());
//hz3000 //hz3000
HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe();
@ -73,8 +72,8 @@ public class MqttConfigHzims {
log.info(hz3000Client.toString()+hz3000Client.getClientId()); log.info(hz3000Client.toString()+hz3000Client.getClientId());
//视频 //视频
SoeSubscribe subscribe = new SoeSubscribe(); SoeSubscribe subscribe = new SoeSubscribe();
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), videoMqttConsumer);
log.info(videoClient.toString()+videoClient.getClientId());*/ log.info(videoClient.toString()+videoClient.getClientId());
}catch (Exception e){ }catch (Exception e){
log.error(e.toString()) ; log.error(e.toString()) ;
} }

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java

@ -2,7 +2,7 @@ package com.hnac.hzims.operational.history.service.impl;
import com.hnac.hzims.operational.history.service.PointService; import com.hnac.hzims.operational.history.service.PointService;
import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; import com.hnac.hzims.operational.history.vo.HistoricalCurveVo;
import com.hnac.hzinfo.dataconfig.entity.Device; import com.hnac.hzinfo.sdk.core.response.DataResultCode;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
@ -14,14 +14,11 @@ import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,7 +48,7 @@ public class PointServiceImpl implements PointService {
public List<FacDeviceVO> projectFacDevice(String projectId,String attrName) { public List<FacDeviceVO> projectFacDevice(String projectId,String attrName) {
Result<List<FacDeviceVO>> result = hzFacClient.facDeviceByProjectId(projectId,attrName); Result<List<FacDeviceVO>> result = hzFacClient.facDeviceByProjectId(projectId,attrName);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }
@ -66,7 +63,7 @@ public class PointServiceImpl implements PointService {
public List<FacDeviceAttrVO> projectFacDeviceAttr(String facDeviceId, String attrName) { public List<FacDeviceAttrVO> projectFacDeviceAttr(String facDeviceId, String attrName) {
Result<List<FacDeviceAttrVO>> result = hzFacClient.facDeviceAttrList(facDeviceId,attrName); Result<List<FacDeviceAttrVO>> result = hzFacClient.facDeviceAttrList(facDeviceId,attrName);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }
@ -80,7 +77,7 @@ public class PointServiceImpl implements PointService {
public List<DeviceInstanceVO> projectDeviceInstance(String projectId,String attrName) { public List<DeviceInstanceVO> projectDeviceInstance(String projectId,String attrName) {
R<List<DeviceInstanceVO>> result = deviceClient.getOnlineDeviceInstanceSearchName(projectId,attrName); R<List<DeviceInstanceVO>> result = deviceClient.getOnlineDeviceInstanceSearchName(projectId,attrName);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }
@ -95,7 +92,7 @@ public class PointServiceImpl implements PointService {
public List<DeviceInstanceAttrVO> projectDeviceInstanceAttr(String deviceCode, String attrName) { public List<DeviceInstanceAttrVO> projectDeviceInstanceAttr(String deviceCode, String attrName) {
Result<List<DeviceInstanceAttrVO>> result = deviceClient.getDeviceAttrByName(deviceCode,attrName); Result<List<DeviceInstanceAttrVO>> result = deviceClient.getDeviceAttrByName(deviceCode,attrName);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }
@ -121,7 +118,7 @@ public class PointServiceImpl implements PointService {
curve.getPageSize() curve.getPageSize()
); );
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new HashMap<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }
@ -144,7 +141,7 @@ public class PointServiceImpl implements PointService {
curve.getDimension(), curve.getDimension(),
curve.getIntervalType()); curve.getIntervalType());
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new HashMap<>(); throw new ServiceException(DataResultCode.FAIL,result.getMsg());
} }
return result.getData(); return result.getData();
} }

Loading…
Cancel
Save