展连设备数据解析策略
This commit is contained in:
@ -1,53 +0,0 @@
|
||||
package com.fastbee.deviceData.api.devlink.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
@Component
|
||||
public class DevLinkAuthorizationService {
|
||||
|
||||
private final static String ak = "suibin";
|
||||
|
||||
private final static String sk = "MZALH5WB";
|
||||
|
||||
private final static String authId = "23";
|
||||
|
||||
private final static String BASE_URL = "https://plat.developlink.cloud/prod-api/iot/data/forward";
|
||||
|
||||
|
||||
public String getBaseUrl(){
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
public String getAuth(){
|
||||
String sign;
|
||||
// long time = 1731480451430L;
|
||||
long time = System.currentTimeMillis();
|
||||
String message = "ak=" + ak + "&authId=" + authId + "&time=" + time;
|
||||
try {
|
||||
SecretKeySpec keySpec = new SecretKeySpec(
|
||||
sk.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(keySpec);
|
||||
byte[] rawHmac = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
||||
sign = DatatypeConverter.printHexBinary(rawHmac).toLowerCase();
|
||||
// System.out.println("d6dbca6837dcfec70954b7261eb6dfadc06fcdfdb771d86ee901ab4823bbb33c");
|
||||
System.err.println("result:"+sign);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unable to generate HMAC : " + e.getMessage(), e);
|
||||
}
|
||||
return "?ak="+ak+"&time="+time+"&sign="+sign+"&authId="+authId;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DevLinkAuthorizationService de = new DevLinkAuthorizationService();
|
||||
de.getAuth();
|
||||
System.out.println(de.getBaseUrl()+de.getAuth());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.fastbee.deviceData.api.devlink.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ZhanLianAuthorizationService {
|
||||
|
||||
private String ak = "suibin";
|
||||
|
||||
private String sk = "MZALH5WB";
|
||||
|
||||
private String authId = "23";
|
||||
|
||||
private String endpoint = "https://plat.developlink.cloud/prod-api/iot/data/forward";
|
||||
|
||||
public String getAuthEndpoint(){
|
||||
return endpoint + getDefaultAuth();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 鉴权参数生成
|
||||
*/
|
||||
public String getDefaultAuth(){
|
||||
String sign;
|
||||
long time = System.currentTimeMillis();
|
||||
String message = "ak=" + ak + "&authId=" + authId + "&time=" + time;
|
||||
try {
|
||||
SecretKeySpec keySpec = new SecretKeySpec(
|
||||
sk.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(keySpec);
|
||||
byte[] rawHmac = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
||||
sign = DatatypeConverter.printHexBinary(rawHmac).toLowerCase();
|
||||
// System.err.println("result:"+sign);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("签名生成失败! : " + e.getMessage(), e);
|
||||
}
|
||||
return "?ak="+ak+"&time="+time+"&sign="+sign+"&authId="+authId;
|
||||
}
|
||||
|
||||
public String getAuth(ZhanLianConfig zhanLianConfig){
|
||||
String ak = zhanLianConfig.getAk();
|
||||
String sk = zhanLianConfig.getSk();
|
||||
String authId = zhanLianConfig.getAuthId();
|
||||
String sign;
|
||||
long time = System.currentTimeMillis();
|
||||
String message = "ak=" + ak + "&authId=" + authId + "&time=" + time;
|
||||
try {
|
||||
SecretKeySpec keySpec = new SecretKeySpec(
|
||||
sk.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(keySpec);
|
||||
byte[] rawHmac = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
||||
sign = DatatypeConverter.printHexBinary(rawHmac).toLowerCase();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("签名生成失败! : " + e.getMessage(), e);
|
||||
}
|
||||
return "?ak="+ak+"&time="+time+"&sign="+sign+"&authId="+authId;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
ZhanLianAuthorizationService de = new ZhanLianAuthorizationService();
|
||||
System.out.println("完整请求路径:"+de.getAuthEndpoint());
|
||||
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -14,38 +13,70 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class DevLinkBaseService {
|
||||
public class ZhanLianBaseService {
|
||||
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备实时数据
|
||||
* 基本请求
|
||||
* @param body 请求负载
|
||||
* @return 请求结果 data
|
||||
*/
|
||||
public JSONObject baseRequest(Map<String,Object> body){
|
||||
String jsonStr = JSONUtil.toJsonStr(body);
|
||||
String respStr = HttpUtil.post(authorizationService.getAuthEndpoint(), jsonStr);
|
||||
JSONObject resp = JSONUtil.parseObj(respStr);
|
||||
if(!resp.get("code").toString().equals("200")){
|
||||
throw new ServiceException(resp.get("message").toString());
|
||||
}
|
||||
return resp.getJSONObject("data");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 请求设备实时数据
|
||||
* @param deviceId 设备id
|
||||
* @return 实时数据
|
||||
*/
|
||||
public Map<String,String> getMetDeviceRealData(String deviceId){
|
||||
String result = requestDeviceData(deviceId);
|
||||
private JSONObject requestDeviceData(String deviceId) {
|
||||
//构建请求体
|
||||
HashMap<String, Object> body = new HashMap<>();
|
||||
body.put("method","get");
|
||||
body.put("path","api/v1/product/device/run_status");
|
||||
Map<String,Object> params=new HashMap<>();
|
||||
params.put("id", deviceId);
|
||||
body.put("params",params);
|
||||
return baseRequest(body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备id请求数据并解析设备实时数据为易于存储的map键值对
|
||||
* @param deviceId 设备id
|
||||
* @return 实时数据
|
||||
*/
|
||||
public Map<String,String> getDeviceRealTimeData(String deviceId){
|
||||
//解析返回数据
|
||||
JSONObject jsonObject = JSONUtil.parseObj(result);
|
||||
Object data = jsonObject.get("data");
|
||||
JSONObject data = requestDeviceData(deviceId);
|
||||
//获取设备状态
|
||||
JSONObject jsonObjectData = JSONUtil.parseObj(data);
|
||||
Object status = jsonObjectData.get("status");
|
||||
// System.err.println("status:"+status);
|
||||
//获取设备属性以及实时数据值
|
||||
Object properties = jsonObjectData.get("properties");
|
||||
//获取数据上报时间
|
||||
String time = jsonObjectData.get("lastOnlineTime").toString();
|
||||
JSONArray propertiesArray = JSONUtil.parseArray(properties);
|
||||
DeviceRealtimedataMeteorology realData = new DeviceRealtimedataMeteorology();
|
||||
//获取设备各项属性实时数据
|
||||
//设备属性与值建立map
|
||||
Map<String, String> propertiesMap = new HashMap<>();
|
||||
propertiesArray.forEach(p -> {
|
||||
Object property = JSONUtil.parseObj(p).get("property");
|
||||
JSONObject propertyMap = JSONUtil.parseObj(property);
|
||||
// System.err.println("propertyMap:"+propertyMap);
|
||||
//属性名称
|
||||
String name = propertyMap.get("name").toString();
|
||||
//属性key
|
||||
@ -59,71 +90,32 @@ public class DevLinkBaseService {
|
||||
|
||||
//TODO 属性值历史数据,是否需要
|
||||
Object list = JSONUtil.parseObj(p).get("list");
|
||||
// System.err.print("name:"+name);
|
||||
// System.err.print("key:"+key);
|
||||
// System.err.println("------------value:"+value);
|
||||
//建立属性-值映射关系
|
||||
propertiesMap.put(key,value);
|
||||
// saveRealData(key,value,realData);
|
||||
|
||||
});
|
||||
propertiesMap.put("status",status.toString());
|
||||
propertiesMap.put("deviceId",deviceId);
|
||||
propertiesMap.put("realTime",time);
|
||||
|
||||
return propertiesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求设备实时数据
|
||||
* @param deviceId 设备id
|
||||
* @return 实时数据
|
||||
*/
|
||||
private String requestDeviceData(String deviceId) {
|
||||
DevLinkAuthorizationService authorization = new DevLinkAuthorizationService();
|
||||
//构建请求体
|
||||
HashMap<String, Object> body = new HashMap<>();
|
||||
body.put("method","get");
|
||||
body.put("path","api/v1/product/device/run_status");
|
||||
Map<String,Object> params=new HashMap<>();
|
||||
params.put("id", deviceId);
|
||||
body.put("params",params);
|
||||
String jsonStr = JSONUtil.toJsonStr(body);
|
||||
System.err.println(authorization.getBaseUrl() + authorization.getAuth());
|
||||
return HttpUtil.post(authorization.getBaseUrl() + authorization.getAuth(), jsonStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 基本请求
|
||||
* @return 请求结果data
|
||||
*/
|
||||
public JSONObject baseRequest(Map<String,Object> body){
|
||||
DevLinkAuthorizationService authorization = new DevLinkAuthorizationService();
|
||||
String jsonStr = JSONUtil.toJsonStr(body);
|
||||
System.err.println(authorization.getBaseUrl() + authorization.getAuth());
|
||||
String respStr = HttpUtil.post(authorization.getBaseUrl() + authorization.getAuth(), jsonStr);
|
||||
JSONObject resp = JSONUtil.parseObj(respStr);
|
||||
if(!resp.get("code").toString().equals("200")){
|
||||
throw new ServiceException(resp.get("message").toString());
|
||||
}
|
||||
return resp.getJSONObject("data");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public BigDecimal toBigDecimalValue(String str) {
|
||||
if (str == null||"".equals(str)) {
|
||||
if (str == null|| str.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new BigDecimal(str);
|
||||
}
|
||||
public Long toLongValue(String str) {
|
||||
if (str == null||"".equals(str)) {
|
||||
if (str == null|| str.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DevLinkBaseService devLinkBaseService = new DevLinkBaseService();
|
||||
Map<String, String> metDeviceRealData = devLinkBaseService.getMetDeviceRealData("3270");
|
||||
// System.err.println(metDeviceRealData);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.fastbee.deviceData.api.devlink.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ZhanLianConfig {
|
||||
|
||||
private String ak;
|
||||
|
||||
private String sk;
|
||||
|
||||
private String authId;
|
||||
|
||||
private String endpoint;
|
||||
}
|
@ -4,9 +4,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DevLinkCountService {
|
||||
public class ZhanLianCountService {
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
|
||||
|
||||
/**
|
@ -17,10 +17,10 @@ import java.util.Map;
|
||||
* devLink气象设备数据服务
|
||||
*/
|
||||
@Service
|
||||
public class DevLinkMetDataService extends DevLinkBaseService {
|
||||
public class ZhanLianMetDataService extends ZhanLianBaseService {
|
||||
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
||||
@ -59,8 +59,8 @@ public class DevLinkMetDataService extends DevLinkBaseService {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DevLinkMetDataService devLinkMetDataService = new DevLinkMetDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMetDataService.getMetDeviceRealData("3269");
|
||||
ZhanLianMetDataService devLinkMetDataService = new ZhanLianMetDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMetDataService.getDeviceRealTimeData("3269");
|
||||
devLinkMetDataService.setData(metDeviceRealData);
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@ import java.util.Map;
|
||||
* devLink苗情设备数据服务
|
||||
*/
|
||||
@Service
|
||||
public class DevLinkMiaoQingDataService extends DevLinkBaseService {
|
||||
public class ZhanLianMiaoQingDataService extends ZhanLianBaseService {
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
@Autowired
|
||||
private DeviceRealtimedataMiaoqingMapper deviceRealtimedataMiaoqingMapper;
|
||||
public DeviceRealtimedataMiaoqing setData(Map<String, String> propertiesMap){
|
||||
@ -61,8 +61,8 @@ public class DevLinkMiaoQingDataService extends DevLinkBaseService {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DevLinkMiaoQingDataService devLinkMiaoQingDataService = new DevLinkMiaoQingDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMiaoQingDataService.getMetDeviceRealData("3275");
|
||||
ZhanLianMiaoQingDataService devLinkMiaoQingDataService = new ZhanLianMiaoQingDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMiaoQingDataService.getDeviceRealTimeData("3275");
|
||||
devLinkMiaoQingDataService.setData(metDeviceRealData);
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@ import java.util.Map;
|
||||
* devLink墒情设备数据服务
|
||||
*/
|
||||
@Service
|
||||
public class DevLinkMoistureDataService extends DevLinkBaseService {
|
||||
public class ZhanLianMoistureDataService extends ZhanLianBaseService {
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
@Autowired
|
||||
private DeviceRealtimedataMoistureMapper moistureMapper;
|
||||
//封装数据
|
||||
@ -74,8 +74,8 @@ public class DevLinkMoistureDataService extends DevLinkBaseService {
|
||||
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
DevLinkMoistureDataService devLinkMoistureDataService = new DevLinkMoistureDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMoistureDataService.getMetDeviceRealData("3270");
|
||||
ZhanLianMoistureDataService devLinkMoistureDataService = new ZhanLianMoistureDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkMoistureDataService.getDeviceRealTimeData("3270");
|
||||
devLinkMoistureDataService.setData(metDeviceRealData);
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@ import java.util.Map;
|
||||
* devLink光伏设备数据服务
|
||||
*/
|
||||
@Service
|
||||
public class DevLinkPhotovoltaicDataService extends DevLinkBaseService {
|
||||
public class ZhanLianPhotovoltaicDataService extends ZhanLianBaseService {
|
||||
@Autowired
|
||||
private DevLinkAuthorizationService authorizationService;
|
||||
private ZhanLianAuthorizationService authorizationService;
|
||||
@Autowired
|
||||
private DeviceRealtimedataPhotovoltaicMapper photovoltaicMapper;
|
||||
//封装数据
|
||||
@ -84,8 +84,8 @@ public class DevLinkPhotovoltaicDataService extends DevLinkBaseService {
|
||||
return photovoltaic;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
DevLinkPhotovoltaicDataService devLinkPhotovoltaicDataService = new DevLinkPhotovoltaicDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkPhotovoltaicDataService.getMetDeviceRealData("3276");
|
||||
ZhanLianPhotovoltaicDataService devLinkPhotovoltaicDataService = new ZhanLianPhotovoltaicDataService();
|
||||
Map<String, String> metDeviceRealData = devLinkPhotovoltaicDataService.getDeviceRealTimeData("3276");
|
||||
devLinkPhotovoltaicDataService.setData(metDeviceRealData);
|
||||
|
||||
}
|
@ -86,14 +86,18 @@ public class RenkeDeviceDataService {
|
||||
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
||||
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
||||
|
||||
//获取拍照图片
|
||||
Object imagesUrl = entries .get("imagesUrl");
|
||||
//获取虫情分析后的图片地址
|
||||
Object analyseCoordUrl = entries .get("analyseCoordUrl");
|
||||
|
||||
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
|
||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||
//获取害虫种类以及数量
|
||||
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
|
||||
//有害虫时保存
|
||||
if(!analyseData.isEmpty()){
|
||||
//获取拍照图片
|
||||
Object imagesUrl = entries .get("imagesUrl");
|
||||
//获取虫情分析后的图片地址
|
||||
Object analyseCoordUrl = entries .get("analyseCoordUrl");
|
||||
|
||||
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
|
||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||
}
|
||||
|
||||
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
@ -21,8 +21,6 @@ public class RenkeMetDeviceService {
|
||||
private RenKeAuthorizationService authorizationService;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取气象设备全部信息
|
||||
* @param deviceStr 设备地址,支持多个用英文逗号分隔
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.fastbee.deviceData.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -111,9 +108,11 @@ public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtime
|
||||
queryWrapper.orderByDesc("real_time");
|
||||
queryWrapper.last("limit 1");
|
||||
DeviceRealtimedataMeteorology meteorology = deviceRealtimedataMeteorologyMapper.selectOne(queryWrapper);
|
||||
List<Map<String, String>> mapList = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
List<DeviceProperties> devicePropertiesList = new ArrayList<>();
|
||||
if(Objects.isNull(meteorology)){
|
||||
return devicePropertiesList;
|
||||
}
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("空气温度").value(meteorology.getAirTemp().toString()).unit("°C").build());
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("空气湿度").value(meteorology.getAirHumi().toString()).unit("°C").build());
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("风速").value(meteorology.getWindSpeed().toString()).unit("m/s").build());
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.fastbee.deviceData.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
@ -101,14 +98,17 @@ public class DeviceRealtimedataMoistureServiceImpl implements IDeviceRealtimedat
|
||||
* @return
|
||||
*/
|
||||
public List<DeviceProperties> getLatestWeatherRealtimedata(String deviceId){
|
||||
System.err.println(deviceId);
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.orderByDesc("real_time");
|
||||
queryWrapper.last("limit 1");
|
||||
queryWrapper.eq("device_id",deviceId);
|
||||
DeviceRealtimedataMoisture moisture = deviceRealtimedataMoistureMapper.selectOne(queryWrapper);
|
||||
List<Map<String, String>> mapList = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
List<DeviceProperties> devicePropertiesList = new ArrayList<>();
|
||||
if(Objects.isNull(moisture)){
|
||||
return devicePropertiesList;
|
||||
}
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("土壤温度").value(moisture.getSoilTemp().toString()).unit("°C").build());
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("土壤湿度").value(moisture.getSoilHumi().toString()).unit("%").build());
|
||||
devicePropertiesList.add(DeviceProperties.builder().name("土壤EC").value(moisture.getSoilEc().toString()).unit("MS/cm").build());
|
||||
|
Reference in New Issue
Block a user