Compare commits
7 Commits
0a94f51e0d
...
4319f97a5c
| Author | SHA1 | Date | |
|---|---|---|---|
| 4319f97a5c | |||
| c04c764ade | |||
| b0751a55cd | |||
| 046e4b2b43 | |||
| c12b165816 | |||
| 2a7c3d42c0 | |||
| 805cad8cb9 |
@ -310,9 +310,9 @@ public class StationServiceImpl implements StationService {
|
||||
* @param station
|
||||
*/
|
||||
private void updateStationInfo(Station station) {
|
||||
MyAddress address = AddressUntils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
|
||||
MyAddress address = AbroadAddressUtils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
|
||||
if (null != address) {
|
||||
String adCode = address.getAdcode();
|
||||
String adCode = address.getCityCode();
|
||||
station.setAdCode(adCode);
|
||||
station.setDistrict(address.getDistrict());
|
||||
station.setCity(address.getCity());
|
||||
@ -320,7 +320,7 @@ public class StationServiceImpl implements StationService {
|
||||
station.setNation(address.getNation());
|
||||
String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode;
|
||||
if (!redisService.hasKey(key)) {
|
||||
WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode());
|
||||
WeatherRespVo weatherRespVo = AbroadWeatherUtils.getWeatherRespVo(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
|
||||
if (weatherRespVo != null) {
|
||||
weatherRespVo.setUpdateTime(System.currentTimeMillis());
|
||||
redisService.set(key, weatherRespVo);
|
||||
|
||||
@ -25,16 +25,11 @@ import io.swagger.annotations.ApiOperation;
|
||||
import jodd.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -59,6 +54,12 @@ public class AutoDeviceCurveController {
|
||||
@Autowired
|
||||
DeviceTypeColService deviceTypeColService;
|
||||
|
||||
@GetMapping("/time")
|
||||
@TokenIgnore
|
||||
public String checkTime() {
|
||||
return "时区:" + TimeZone.getDefault().getID() +
|
||||
" | 时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
|
||||
}
|
||||
|
||||
@PostMapping("queryCurve")
|
||||
@ApiOperation(value = "查询两个曲线的差值/查询单条曲线")
|
||||
|
||||
@ -46,6 +46,11 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
</dependency>
|
||||
<!--jackson-->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
||||
@ -25,6 +25,9 @@ public class WeatherRespVo {
|
||||
@ApiModelProperty(value = "天气现象")
|
||||
String skyCon;
|
||||
|
||||
@ApiModelProperty(value = "天气现象编码")
|
||||
int code;
|
||||
|
||||
@ApiModelProperty(value = "风向风速")
|
||||
String speedAndDirection;
|
||||
|
||||
|
||||
@ -0,0 +1,128 @@
|
||||
package com.ho.common.tools.util;
|
||||
|
||||
import com.ho.common.tools.entity.MyAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.*;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*
|
||||
* 海外地址反向解析
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class AbroadAddressUtils {
|
||||
|
||||
static String apiKey = "AIzaSyAM4JOtE9yt48f60ATwByB7uWzTIrYSSUg";
|
||||
|
||||
public static MyAddress getAddress(String lat, String lng){
|
||||
// 构建API请求URL
|
||||
String urlString = "https://maps.googleapis.com/maps/api/geocode/json?" +
|
||||
"latlng=" + lat + "," + lng +
|
||||
"&key=" + apiKey;
|
||||
// 发送HTTP请求
|
||||
URL url = null;
|
||||
StringBuilder response = new StringBuilder();
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
// 创建代理(如果不需要代理,可以移除这部分)
|
||||
// Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("127.0.0.1", 4781));
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setConnectTimeout(10000); // 10秒连接超时
|
||||
conn.setReadTimeout(10000); // 10秒读取超时
|
||||
// 检查响应状态
|
||||
int responseCode = conn.getResponseCode();
|
||||
if (responseCode != 200) {
|
||||
throw new RuntimeException("HTTP请求失败: " + responseCode);
|
||||
}
|
||||
// 读取响应内容
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ProtocolException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
// 解析JSON响应
|
||||
return parseGeocodeResponse(response.toString());
|
||||
}
|
||||
|
||||
private static MyAddress parseGeocodeResponse(String jsonResponse) {
|
||||
JSONObject json = new JSONObject(jsonResponse);
|
||||
String status = json.getString("status");
|
||||
|
||||
if (!"OK".equals(status)) {
|
||||
throw new RuntimeException("地理编码API错误: " + status);
|
||||
}
|
||||
MyAddress address = new MyAddress();
|
||||
|
||||
// 获取第一个结果(最精确的匹配)
|
||||
JSONObject firstResult = json.getJSONArray("results").getJSONObject(0);
|
||||
// 解析地址组件
|
||||
JSONArray components = firstResult.getJSONArray("address_components");
|
||||
for (int i = 0; i < components.length(); i++) {
|
||||
JSONObject component = components.getJSONObject(i);
|
||||
JSONArray types = component.getJSONArray("types");
|
||||
String longName = component.getString("long_name");
|
||||
// 国家信息
|
||||
if (types.toString().contains("country")) {
|
||||
address.setNation(longName);
|
||||
}
|
||||
// 省份/州信息
|
||||
if (types.toString().contains("administrative_area_level_1")) {
|
||||
address.setProvince(longName);
|
||||
}
|
||||
// 城市信息
|
||||
if (types.toString().contains("locality")) {
|
||||
address.setCity(longName);
|
||||
}
|
||||
// 区县信息
|
||||
if (types.toString().contains("sublocality")) {
|
||||
address.setDistrict(longName);
|
||||
}
|
||||
// 邮政编码
|
||||
if (types.toString().contains("postal_code")) {
|
||||
address.setCityCode(longName);
|
||||
}
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 示例坐标 - 纽约
|
||||
String latitude = "48.877132";
|
||||
String longitude = "2.356407";
|
||||
|
||||
try {
|
||||
// 获取地址信息
|
||||
MyAddress address = getAddress(latitude, longitude);
|
||||
|
||||
// 打印结果
|
||||
System.out.println("============ 反向地理编码结果 ============");
|
||||
System.out.println("国家: " + address.getNation() );
|
||||
System.out.println("省份/州: " + address.getProvince());
|
||||
System.out.println("城市: " + address.getCity());
|
||||
System.out.println("地区/区县: " + address.getDistrict());
|
||||
System.out.println("邮政编码: " + address.getCityCode());
|
||||
} catch (Exception e) {
|
||||
System.err.println("发生错误: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.ho.common.tools.util;
|
||||
|
||||
import com.ho.common.tools.entity.WeatherRespVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*
|
||||
* 获取海外天气
|
||||
*/
|
||||
@Slf4j
|
||||
public class AbroadWeatherUtils {
|
||||
|
||||
static String apiKey = "6358b3081a5849f09ac90138252107";
|
||||
public static void main(String[] args) {
|
||||
String latitude = "40.714224";
|
||||
String longitude = "-73.961452";
|
||||
|
||||
try {
|
||||
System.out.println(getWeatherRespVo(latitude, longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static WeatherRespVo getWeatherRespVo(String lat, String lng) {
|
||||
String urlString = "http://api.weatherapi.com/v1/forecast.json?key="+apiKey+"&q=" + lat + "," + lng +"&days=1";
|
||||
URL url = null;
|
||||
StringBuilder response = new StringBuilder();
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return parseWeatherData(response.toString());
|
||||
}
|
||||
|
||||
private static WeatherRespVo parseWeatherData(String jsonResponse) {
|
||||
WeatherRespVo weatherRespVo =new WeatherRespVo();
|
||||
JSONObject root = new JSONObject(jsonResponse);
|
||||
|
||||
// 解析地区信息
|
||||
JSONObject location = root.getJSONObject("location");
|
||||
String area = location.getString("name");
|
||||
weatherRespVo.setCityzh(area);
|
||||
|
||||
// 获取天气预报数据
|
||||
JSONObject forecast = root.getJSONObject("forecast");
|
||||
JSONArray forecastday = forecast.getJSONArray("forecastday");
|
||||
JSONObject day = forecastday.getJSONObject(0).getJSONObject("day");
|
||||
|
||||
// 解析温度数据
|
||||
double maxTemp = day.getDouble("maxtemp_c");
|
||||
weatherRespVo.setMaxTemperature(new BigDecimal(String.valueOf(maxTemp)));
|
||||
double minTemp = day.getDouble("mintemp_c");
|
||||
weatherRespVo.setMinTemperature(new BigDecimal(String.valueOf(minTemp)));
|
||||
String condition = day.getJSONObject("condition").getString("text");
|
||||
weatherRespVo.setSkyCon(condition);
|
||||
int code = day.getJSONObject("condition").getInt("code");
|
||||
weatherRespVo.setCode(code);
|
||||
double maxWindKph = day.getDouble("maxwind_kph");
|
||||
// 获取风向(从最近的小时数据中获取)
|
||||
JSONArray hours = forecastday.getJSONObject(0).getJSONArray("hour");
|
||||
String windDirection = hours.getJSONObject(0).getString("wind_dir");
|
||||
// 组合风向风速信息
|
||||
String windInfo = windDirection + " " + maxWindKph + " km/h";
|
||||
weatherRespVo.setSpeedAndDirection(windInfo);
|
||||
weatherRespVo.setUpdateTime(System.currentTimeMillis());
|
||||
return weatherRespVo;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,75 +1,76 @@
|
||||
//package com.ho.datacollect.util;
|
||||
//
|
||||
//public class AnotherMqttConfigUtil {
|
||||
//
|
||||
// public static String[] commonTopic = new String[]{
|
||||
// "+/device/27d83a2844ff5866",
|
||||
// "+/device/77ba753718908d1a",
|
||||
// "1/device/+"
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * 获取登录验证的监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getLoginRequestTopic(){
|
||||
// String log = "/login/request";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 读取文件请求的监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getReadRequestTopic(){
|
||||
// String log = "/read/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 写文件响应的监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getWriteRequestTopic(){
|
||||
// String log = "/write/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取数据上送监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getReportPushTopic(){
|
||||
// String log = "/report/push";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取远程控制主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getControlResponseTopic(){
|
||||
// String log = "/control/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//}
|
||||
package com.ho.datacollect.util;
|
||||
|
||||
public class AnotherMqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/27d83a2844ff5866",
|
||||
"+/device/77ba753718908d1a",
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取登录验证的监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getLoginRequestTopic(){
|
||||
String log = "/login/request";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件请求的监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getReadRequestTopic(){
|
||||
String log = "/read/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写文件响应的监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getWriteRequestTopic(){
|
||||
String log = "/write/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据上送监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getReportPushTopic(){
|
||||
String log = "/report/push";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程控制主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getControlResponseTopic(){
|
||||
String log = "/control/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ package com.ho.datacollect.util;
|
||||
public class MqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"+/device/5b69426e2ff8e459",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
|
||||
@ -163,12 +163,7 @@ public class OrderSendController {
|
||||
return DataResult.success(heartbeatResp);
|
||||
}
|
||||
log.info("指令下发正常开始下发");
|
||||
List<String> snList = MqttConfigUtil.getSnList();
|
||||
if(snList.contains(sn)){
|
||||
orderSendService.orderIssued(vo);
|
||||
}else{
|
||||
anotherOrderSendService.orderIssued(vo);
|
||||
}
|
||||
if(vo.getPlanTemId() != null){
|
||||
String hourValue ="";
|
||||
String minuteValue ="";
|
||||
@ -332,14 +327,7 @@ public class OrderSendController {
|
||||
// @LogAnnotation(title = "命令下发曲线", action = "命令下发曲线")
|
||||
@TokenIgnore
|
||||
public DataResult<HeartbeatResp> sendPlanPowerOrder(@RequestBody OrderPlanPowerReq vo) {
|
||||
String sn = vo.getSn();
|
||||
List<String> snList = MqttConfigUtil.getSnList();
|
||||
HeartbeatResp heartbeatResp = null;
|
||||
if(snList.contains(sn)){
|
||||
heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
||||
}else{
|
||||
heartbeatResp = anotherOrderSendService.sendPlanPowerOrder(vo);
|
||||
}
|
||||
HeartbeatResp heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
||||
return DataResult.success(heartbeatResp);
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import com.ho.common.tools.entity.MyAddress;
|
||||
import com.ho.common.tools.entity.WeatherRespVo;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.AbroadWeatherUtils;
|
||||
import com.ho.common.tools.util.AddressUntils;
|
||||
import com.ho.common.tools.util.IPUtils;
|
||||
import com.ho.common.tools.util.WeatherUntils;
|
||||
@ -241,7 +242,7 @@ public class WeatherController {
|
||||
continue;
|
||||
}
|
||||
String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode;
|
||||
WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode());
|
||||
WeatherRespVo weatherRespVo = AbroadWeatherUtils.getWeatherRespVo(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
|
||||
weatherRespVo.setUpdateTime(updateTime);
|
||||
redisService.set(key, weatherRespVo);
|
||||
map.put(adCode, adCode);
|
||||
|
||||
@ -1,66 +1,67 @@
|
||||
//package com.ho.filecenter.util;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class AnotherMqttConfigUtil {
|
||||
//
|
||||
// public static String[] commonTopic = new String[]{
|
||||
// "+/device/27d83a2844ff5866",
|
||||
// "+/device/77ba753718908d1a",
|
||||
// "1/device/+"
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * 获取文件请求监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getFileRequestTopic(){
|
||||
// String log = "/file/request";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 读取文件响应监听主题
|
||||
// * @return
|
||||
// */
|
||||
// public static String[] getFileResponseTopic(){
|
||||
// String log = "/file/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// public static String[] getCurveResponseTopic(){
|
||||
// String log = "/curve/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// public static String[] getDispatchResponseTopic(){
|
||||
// String log = "/dispatch/response";
|
||||
// String[] str = new String[commonTopic.length];
|
||||
// for (int i = 0; i < commonTopic.length; i++) {
|
||||
// str[i] = commonTopic[i]+log;
|
||||
// }
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取SN配置合集
|
||||
// * @return
|
||||
// */
|
||||
// public static List<String> getSnList(){
|
||||
// List<String> strings = Arrays.asList(commonTopic);
|
||||
// return strings;
|
||||
// }
|
||||
//}
|
||||
package com.ho.filecenter.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AnotherMqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/27d83a2844ff5866",
|
||||
"+/device/77ba753718908d1a",
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取文件请求监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getFileRequestTopic(){
|
||||
String log = "/file/request";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件响应监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getFileResponseTopic(){
|
||||
String log = "/file/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String[] getCurveResponseTopic(){
|
||||
String log = "/curve/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String[] getDispatchResponseTopic(){
|
||||
String log = "/dispatch/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SN配置合集
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getSnList(){
|
||||
List<String> strings = Arrays.asList(commonTopic);
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import java.util.List;
|
||||
public class MqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"+/device/5b69426e2ff8e459",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user