|
|
@ -160,10 +160,61 @@ public class OnenetEquipServiceImpl implements IOnenetEquipService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 缓存命令记录 |
|
|
|
* @param HistoryDto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String commandHistory(OnenetEquipDto.HistoryDto HistoryDto) { |
|
|
|
if (StrUtil.hasEmpty(HistoryDto.getImei())){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
OnenetConfig onenetConfigExample = new OnenetConfig(); |
|
|
|
onenetConfigExample.setConfigKey("onenet_api_key"); |
|
|
|
|
|
|
|
List<OnenetConfig> onenetConfigs = onenetConfigMapper.selectOnenetConfigList(onenetConfigExample); |
|
|
|
List<OnenetEquipVo.EquipList> list = new ArrayList<>(); |
|
|
|
if (onenetConfigs.size() > 0) { |
|
|
|
HashMap<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("imei", HistoryDto.getImei()); |
|
|
|
|
|
|
|
if (!StrUtil.hasEmpty(HistoryDto.getHistoryTime())){ |
|
|
|
|
|
|
|
paramMap.put("start", HistoryDto.getHistoryTime()[0]); |
|
|
|
paramMap.put("end", HistoryDto.getHistoryTime()[1]); |
|
|
|
} |
|
|
|
|
|
|
|
if (paramMap.get("start") == null){ |
|
|
|
DateTime yesterday = DateUtil.yesterday(); |
|
|
|
|
|
|
|
paramMap.put("start", DateUtil.format(yesterday, "yyyy-MM-dd'T'HH:mm:ss")); |
|
|
|
// paramMap.put("start", "2023-02-02T10:45:10");
|
|
|
|
} |
|
|
|
|
|
|
|
String url = "http://api.heclouds.com/nbiot/offline/history"; |
|
|
|
|
|
|
|
OnenetConfig onenetConfig = onenetConfigs.get(0); |
|
|
|
|
|
|
|
String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body(); |
|
|
|
|
|
|
|
JSONObject responseJson = JSON.parseObject(response); |
|
|
|
|
|
|
|
Integer errno = responseJson.getObject("errno", Integer.class); |
|
|
|
if (errno == 0) { |
|
|
|
String dataJson = responseJson.getString("data"); |
|
|
|
|
|
|
|
return dataJson; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询设备数据 |
|
|
|
* @param equipDataParam |
|
|
@ -191,13 +242,13 @@ public class OnenetEquipServiceImpl implements IOnenetEquipService { |
|
|
|
|
|
|
|
OnenetConfig onenetConfig = onenetConfigs.get(0); |
|
|
|
|
|
|
|
// String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body();
|
|
|
|
String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body(); |
|
|
|
|
|
|
|
String response = "{\"errno\":0,\"data\":{\"count\":1,\"datastreams\":[{\"datapoints\":[" + |
|
|
|
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " + |
|
|
|
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " + |
|
|
|
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}" + |
|
|
|
"],\"id\":\"3200_0_5750\"}]},\"error\":\"succ\"}"; |
|
|
|
// String response = "{\"errno\":0,\"data\":{\"count\":1,\"datastreams\":[{\"datapoints\":[" +
|
|
|
|
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
|
|
|
|
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
|
|
|
|
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}" +
|
|
|
|
// "],\"id\":\"3200_0_5750\"}]},\"error\":\"succ\"}";
|
|
|
|
|
|
|
|
JSONObject responseJson = JSON.parseObject(response); |
|
|
|
|
|
|
|