Commit 4efbd22b authored by caotao's avatar caotao

监盘接口demo提交

parent 2cb99a81
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
...@@ -21,14 +18,18 @@ import io.swagger.annotations.ApiOperation; ...@@ -21,14 +18,18 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.*;
@RestController @RestController
@Api(tags = "Demo-test") @Api(tags = "Demo-test")
...@@ -55,6 +56,9 @@ public class DemoController extends BaseController { ...@@ -55,6 +56,9 @@ public class DemoController extends BaseController {
@Autowired @Autowired
InfluxDButils influxDButils; InfluxDButils influxDButils;
@Autowired @Autowired
EmqKeeper emqKeeper;
@Autowired
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper; private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
...@@ -117,6 +121,21 @@ public class DemoController extends BaseController { ...@@ -117,6 +121,21 @@ public class DemoController extends BaseController {
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试消息发送")
@GetMapping("/test5")
public void demoTest4() {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("test", String.valueOf(Math.random() *1000));
hashMap.put("test1", String.valueOf(Math.random() *100));
try {
emqKeeper.getMqttClient().publish("test_topic", JSON.toJSON(hashMap).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("test_topic1", JSON.toJSON(hashMap).toString().getBytes("UTF-8"), 1, true);
logger.info("++++++++++++++++++++++++++++++++++发送消息成功++++++++++++++++++++++++++++++++++++++");
} catch (Exception exception) {
logger.error("============================================================发送消息报错");
}
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
@Data
public class TestDto {
// "date": "2020-12-12 12:12:12",
// "address": "陕西省西安市雁塔区太白南路A座C区",
// "level": "紧急",
// "name": "咸阳机场项目",
// "id": "1",
// "status": "研发中"
private String createdTime;
private String equipmentIndex;
private String equipmentIndexName;
private String traceId;
private String value;
private String valueLabel;
private String unit;
}
...@@ -133,7 +133,4 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -133,7 +133,4 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public Object getIndicatoralueTotal(String gateway,String indicator){ public Object getIndicatoralueTotal(String gateway,String indicator){
return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway,indicator); return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway,indicator);
} }
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import org.influxdb.dto.QueryResult; ...@@ -5,6 +5,7 @@ import org.influxdb.dto.QueryResult;
import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -48,4 +49,46 @@ public class InfluxDButils { ...@@ -48,4 +49,46 @@ public class InfluxDButils {
} }
return list; return list;
} }
public <T> List<T> getListData1(String sql, Class<T> clazz) {
List<T> list = new ArrayList<>();
try {
QueryResult query = influxDbConnection.query(sql);
List<QueryResult.Result> queryResults = query.getResults();
for (QueryResult.Result result : queryResults) {
List<QueryResult.Series> series = result.getSeries();
if (series == null) {
continue;
}
for (QueryResult.Series serie : series) {
List<List<Object>> values = serie.getValues();
List<String> columns = serie.getColumns();
for (int i = 0; i < values.size(); ++i) {
T object = clazz.newInstance();
BeanWrapperImpl bean = new BeanWrapperImpl(object);
for (int j = 0; j < columns.size(); ++j) {
String k = columns.get(j).replace("last_","");
Object v = values.get(i).get(j);
System.out.println(k);
System.out.println(v);
if ("time".equals(k)) {
continue;
} else {
// if(ObjectUtils.isEmpty(v)){
// bean.setPropertyValue(k, "");
// }else{
bean.setPropertyValue(k, v);
// }
}
}
list.add(object);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
} }
...@@ -53,9 +53,13 @@ lettuce.timeout=10000 ...@@ -53,9 +53,13 @@ lettuce.timeout=10000
emqx.clean-session=true emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]} emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.18:2883 emqx.broker=tcp://172.16.10.220:1883
emqx.user-name=super emqx.user-name=admin
emqx.password=a123456 emqx.password=public
mqtt.scene.host=mqtt://172.16.10.220:8083/mqtt
mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000
emqx.max-inflight=1000 emqx.max-inflight=1000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment