光伏设备实时数据封装
This commit is contained in:
parent
3d84b71d00
commit
707d027f30
@ -1,19 +1,11 @@
|
||||
package com.fastbee.deviceData.api.devlink.service;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
|
||||
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* devLink气象设备数据服务
|
||||
|
@ -20,7 +20,7 @@ public class DevLinkPhotovoltaicDataService extends DevLinkRealTimeDataService{
|
||||
DeviceRealtimedataPhotovoltaic photovoltaic = DeviceRealtimedataPhotovoltaic.builder()
|
||||
.airTemp(toBigDecimalValue(propertiesMap.get("airTemp")))
|
||||
.mppTemp(toBigDecimalValue(propertiesMap.get("mppTemp")))
|
||||
.batteryCap(Long.parseLong(propertiesMap.get("batteryCap")))
|
||||
.batteryCap(toBigDecimalValue(propertiesMap.get("batteryCap")))
|
||||
.batteryVolt(toBigDecimalValue(propertiesMap.get("batteryVolt")))
|
||||
.batteryCur(toBigDecimalValue(propertiesMap.get("batteryCur")))
|
||||
.batteryPower(toBigDecimalValue(propertiesMap.get("batteryPower")))
|
||||
@ -42,7 +42,7 @@ public class DevLinkPhotovoltaicDataService extends DevLinkRealTimeDataService{
|
||||
.control(toBigDecimalValue(propertiesMap.get("control")))
|
||||
.airTemp2(toBigDecimalValue(propertiesMap.get("airTemp_2")))
|
||||
.mppTemp2(toBigDecimalValue(propertiesMap.get("mppTemp_2")))
|
||||
.batteryCap2(Long.parseLong(propertiesMap.get("batteryCap_2")))
|
||||
.batteryCap2(toBigDecimalValue(propertiesMap.get("batteryCap_2")))
|
||||
.batteryVolt2(toBigDecimalValue(propertiesMap.get("batteryVolt_2")))
|
||||
.batteryCur2(toBigDecimalValue(propertiesMap.get("batteryCur_2")))
|
||||
.batteryPower2(toBigDecimalValue(propertiesMap.get("batteryPower_2")))
|
||||
|
@ -27,11 +27,11 @@ public class RenKeAuthorizationService {
|
||||
|
||||
public String getToken(){
|
||||
//判断token是否过期
|
||||
String cacheToken = stringRedisTemplate.opsForValue().get("renke:user:token");
|
||||
if (!Objects.isNull(cacheToken)){
|
||||
System.err.println("缓存中获取token:"+cacheToken);
|
||||
return cacheToken;
|
||||
}
|
||||
// String cacheToken = stringRedisTemplate.opsForValue().get("renke:user:token");
|
||||
// if (!Objects.isNull(cacheToken)){
|
||||
// System.err.println("缓存中获取token:"+cacheToken);
|
||||
// return cacheToken;
|
||||
// }
|
||||
//获取token
|
||||
//构建请求体
|
||||
Map<String,Object> reqBody =new HashMap<>();
|
||||
@ -50,8 +50,9 @@ public class RenKeAuthorizationService {
|
||||
int expDate = Integer.parseInt(tokenObject.get("expDate").toString());
|
||||
Integer periodValidity= expDate - currDate;
|
||||
//将token存入redis
|
||||
stringRedisTemplate.opsForValue().set("renke:user:token", tokenObject.get("token").toString(),2, TimeUnit.HOURS);
|
||||
System.err.println("请求获取到token:"+tokenObject.get("token").toString());
|
||||
return stringRedisTemplate.opsForValue().get("renke:user:token");
|
||||
return tokenObject.get("token").toString();
|
||||
// stringRedisTemplate.opsForValue().set("renke:user:token", tokenObject.get("token").toString(),2, TimeUnit.HOURS);
|
||||
// System.err.println("请求获取到token:"+tokenObject.get("token").toString());
|
||||
// return stringRedisTemplate.opsForValue().get("renke:user:token");
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ public class RenkeDeviceDataService {
|
||||
*/
|
||||
public void getDeviceRealtimeData(String deviceAddrs) {
|
||||
//处理鉴权
|
||||
String token = authenticationService.getToken();
|
||||
// String token = authenticationService.getToken();
|
||||
String token = new RenKeAuthorizationService().getToken();
|
||||
//获取设备实时数据
|
||||
HttpResponse response = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/entrance/device/getRealTimeData")
|
||||
.header("token", token)
|
||||
@ -36,6 +37,9 @@ public class RenkeDeviceDataService {
|
||||
System.err.println("设备实时数据:"+realtimeDataList);
|
||||
}
|
||||
|
||||
//获取token
|
||||
public static void main(String[] args) {
|
||||
RenkeDeviceDataService renkeDeviceDataService = new RenkeDeviceDataService();
|
||||
renkeDeviceDataService.getDeviceRealtimeData("1017240042");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,17 +15,17 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
* 光伏设备实时数据对象 iot_device_realtimedata_photovoltaic
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-14
|
||||
* @date 2024-11-15
|
||||
*/
|
||||
@ApiModel(value = "DeviceRealtimedataPhotovoltaic",description = "光伏设备实时数据 iot_device_realtimedata_photovoltaic")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeviceRealtimedataPhotovoltaic extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
@ -36,223 +36,223 @@ private static final long serialVersionUID = 1L;
|
||||
private String deviceId;
|
||||
|
||||
/** 1#环境温度 */
|
||||
@Excel(name = "1#环境温度")
|
||||
@ApiModelProperty("1#环境温度")
|
||||
@Excel(name = "1#环境温度")
|
||||
@ApiModelProperty("1#环境温度")
|
||||
private BigDecimal airTemp;
|
||||
|
||||
/** 1#设备温度 */
|
||||
@Excel(name = "1#设备温度")
|
||||
@ApiModelProperty("1#设备温度")
|
||||
@Excel(name = "1#设备温度")
|
||||
@ApiModelProperty("1#设备温度")
|
||||
private BigDecimal mppTemp;
|
||||
|
||||
/** 1#电池电量 */
|
||||
@Excel(name = "1#电池电量")
|
||||
@ApiModelProperty("1#电池电量")
|
||||
private Long batteryCap;
|
||||
@Excel(name = "1#电池电量")
|
||||
@ApiModelProperty("1#电池电量")
|
||||
private BigDecimal batteryCap;
|
||||
|
||||
/** 1#电池电压 */
|
||||
@Excel(name = "1#电池电压")
|
||||
@ApiModelProperty("1#电池电压")
|
||||
@Excel(name = "1#电池电压")
|
||||
@ApiModelProperty("1#电池电压")
|
||||
private BigDecimal batteryVolt;
|
||||
|
||||
/** 1#电池电流 */
|
||||
@Excel(name = "1#电池电流")
|
||||
@ApiModelProperty("1#电池电流")
|
||||
@Excel(name = "1#电池电流")
|
||||
@ApiModelProperty("1#电池电流")
|
||||
private BigDecimal batteryCur;
|
||||
|
||||
/** 1#电池功率 */
|
||||
@Excel(name = "1#电池功率")
|
||||
@ApiModelProperty("1#电池功率")
|
||||
@Excel(name = "1#电池功率")
|
||||
@ApiModelProperty("1#电池功率")
|
||||
private BigDecimal batteryPower;
|
||||
|
||||
/** 1#负载电压 */
|
||||
@Excel(name = "1#负载电压")
|
||||
@ApiModelProperty("1#负载电压")
|
||||
@Excel(name = "1#负载电压")
|
||||
@ApiModelProperty("1#负载电压")
|
||||
private BigDecimal loadVolt;
|
||||
|
||||
/** 1#负载电流 */
|
||||
@Excel(name = "1#负载电流")
|
||||
@ApiModelProperty("1#负载电流")
|
||||
@Excel(name = "1#负载电流")
|
||||
@ApiModelProperty("1#负载电流")
|
||||
private BigDecimal loadCur;
|
||||
|
||||
/** 1#负载功率 */
|
||||
@Excel(name = "1#负载功率")
|
||||
@ApiModelProperty("1#负载功率")
|
||||
@Excel(name = "1#负载功率")
|
||||
@ApiModelProperty("1#负载功率")
|
||||
private BigDecimal loadPower;
|
||||
|
||||
/** 1#光伏电压 */
|
||||
@Excel(name = "1#光伏电压")
|
||||
@ApiModelProperty("1#光伏电压")
|
||||
@Excel(name = "1#光伏电压")
|
||||
@ApiModelProperty("1#光伏电压")
|
||||
private BigDecimal photVolt;
|
||||
|
||||
/** 1#光伏电流 */
|
||||
@Excel(name = "1#光伏电流")
|
||||
@ApiModelProperty("1#光伏电流")
|
||||
@Excel(name = "1#光伏电流")
|
||||
@ApiModelProperty("1#光伏电流")
|
||||
private BigDecimal photCur;
|
||||
|
||||
/** 1#光伏功率 */
|
||||
@Excel(name = "1#光伏功率")
|
||||
@ApiModelProperty("1#光伏功率")
|
||||
@Excel(name = "1#光伏功率")
|
||||
@ApiModelProperty("1#光伏功率")
|
||||
private BigDecimal photPower;
|
||||
|
||||
/** 1#当日累计充电量 */
|
||||
@Excel(name = "1#当日累计充电量")
|
||||
@ApiModelProperty("1#当日累计充电量")
|
||||
@Excel(name = "1#当日累计充电量")
|
||||
@ApiModelProperty("1#当日累计充电量")
|
||||
private BigDecimal cumChargeDay;
|
||||
|
||||
/** 1#当月累计充电量 */
|
||||
@Excel(name = "1#当月累计充电量")
|
||||
@ApiModelProperty("1#当月累计充电量")
|
||||
@Excel(name = "1#当月累计充电量")
|
||||
@ApiModelProperty("1#当月累计充电量")
|
||||
private BigDecimal cumChargeMon;
|
||||
|
||||
/** 1#当年累积充电量 */
|
||||
@Excel(name = "1#当年累积充电量")
|
||||
@ApiModelProperty("1#当年累积充电量")
|
||||
@Excel(name = "1#当年累积充电量")
|
||||
@ApiModelProperty("1#当年累积充电量")
|
||||
private BigDecimal cumChargeYear;
|
||||
|
||||
/** 1#总累计充电量 */
|
||||
@Excel(name = "1#总累计充电量")
|
||||
@ApiModelProperty("1#总累计充电量")
|
||||
@Excel(name = "1#总累计充电量")
|
||||
@ApiModelProperty("1#总累计充电量")
|
||||
private BigDecimal cumChargeAll;
|
||||
|
||||
/** 1#当日累计用电量 */
|
||||
@Excel(name = "1#当日累计用电量")
|
||||
@ApiModelProperty("1#当日累计用电量")
|
||||
@Excel(name = "1#当日累计用电量")
|
||||
@ApiModelProperty("1#当日累计用电量")
|
||||
private BigDecimal cumEleDay;
|
||||
|
||||
/** 1#当月累积用电量 */
|
||||
@Excel(name = "1#当月累积用电量")
|
||||
@ApiModelProperty("1#当月累积用电量")
|
||||
@Excel(name = "1#当月累积用电量")
|
||||
@ApiModelProperty("1#当月累积用电量")
|
||||
private BigDecimal cumEleMon;
|
||||
|
||||
/** 1#当年累计用电量 */
|
||||
@Excel(name = "1#当年累计用电量")
|
||||
@ApiModelProperty("1#当年累计用电量")
|
||||
@Excel(name = "1#当年累计用电量")
|
||||
@ApiModelProperty("1#当年累计用电量")
|
||||
private BigDecimal cumEleYear;
|
||||
|
||||
/** 1#总累积用电量 */
|
||||
@Excel(name = "1#总累积用电量")
|
||||
@ApiModelProperty("1#总累积用电量")
|
||||
@Excel(name = "1#总累积用电量")
|
||||
@ApiModelProperty("1#总累积用电量")
|
||||
private BigDecimal cumEleAll;
|
||||
|
||||
/** 1#手动控制模式 */
|
||||
@Excel(name = "1#手动控制模式")
|
||||
@ApiModelProperty("1#手动控制模式")
|
||||
@Excel(name = "1#手动控制模式")
|
||||
@ApiModelProperty("1#手动控制模式")
|
||||
private BigDecimal shoudong;
|
||||
|
||||
/** 1#远程通断电 */
|
||||
@Excel(name = "1#远程通断电")
|
||||
@ApiModelProperty("1#远程通断电")
|
||||
@Excel(name = "1#远程通断电")
|
||||
@ApiModelProperty("1#远程通断电")
|
||||
private BigDecimal control;
|
||||
|
||||
/** 2#环境温度 */
|
||||
@Excel(name = "2#环境温度")
|
||||
@ApiModelProperty("2#环境温度")
|
||||
@Excel(name = "2#环境温度")
|
||||
@ApiModelProperty("2#环境温度")
|
||||
private BigDecimal airTemp2;
|
||||
|
||||
/** 2#设备温度 */
|
||||
@Excel(name = "2#设备温度")
|
||||
@ApiModelProperty("2#设备温度")
|
||||
@Excel(name = "2#设备温度")
|
||||
@ApiModelProperty("2#设备温度")
|
||||
private BigDecimal mppTemp2;
|
||||
|
||||
/** 2#电池电量 */
|
||||
@Excel(name = "2#电池电量")
|
||||
@ApiModelProperty("2#电池电量")
|
||||
private Long batteryCap2;
|
||||
@Excel(name = "2#电池电量")
|
||||
@ApiModelProperty("2#电池电量")
|
||||
private BigDecimal batteryCap2;
|
||||
|
||||
/** 2#电池电压 */
|
||||
@Excel(name = "2#电池电压")
|
||||
@ApiModelProperty("2#电池电压")
|
||||
@Excel(name = "2#电池电压")
|
||||
@ApiModelProperty("2#电池电压")
|
||||
private BigDecimal batteryVolt2;
|
||||
|
||||
/** 2#电池电流 */
|
||||
@Excel(name = "2#电池电流")
|
||||
@ApiModelProperty("2#电池电流")
|
||||
@Excel(name = "2#电池电流")
|
||||
@ApiModelProperty("2#电池电流")
|
||||
private BigDecimal batteryCur2;
|
||||
|
||||
/** 2#电池功率 */
|
||||
@Excel(name = "2#电池功率")
|
||||
@ApiModelProperty("2#电池功率")
|
||||
@Excel(name = "2#电池功率")
|
||||
@ApiModelProperty("2#电池功率")
|
||||
private BigDecimal batteryPower2;
|
||||
|
||||
/** 2#负载电压 */
|
||||
@Excel(name = "2#负载电压")
|
||||
@ApiModelProperty("2#负载电压")
|
||||
@Excel(name = "2#负载电压")
|
||||
@ApiModelProperty("2#负载电压")
|
||||
private BigDecimal loadVolt2;
|
||||
|
||||
/** 2#负载电流 */
|
||||
@Excel(name = "2#负载电流")
|
||||
@ApiModelProperty("2#负载电流")
|
||||
@Excel(name = "2#负载电流")
|
||||
@ApiModelProperty("2#负载电流")
|
||||
private BigDecimal loadCur2;
|
||||
|
||||
/** 2#负载功率 */
|
||||
@Excel(name = "2#负载功率")
|
||||
@ApiModelProperty("2#负载功率")
|
||||
@Excel(name = "2#负载功率")
|
||||
@ApiModelProperty("2#负载功率")
|
||||
private BigDecimal loadPower2;
|
||||
|
||||
/** 2#光伏电压 */
|
||||
@Excel(name = "2#光伏电压")
|
||||
@ApiModelProperty("2#光伏电压")
|
||||
@Excel(name = "2#光伏电压")
|
||||
@ApiModelProperty("2#光伏电压")
|
||||
private BigDecimal photVolt2;
|
||||
|
||||
/** 2#光伏电流 */
|
||||
@Excel(name = "2#光伏电流")
|
||||
@ApiModelProperty("2#光伏电流")
|
||||
@Excel(name = "2#光伏电流")
|
||||
@ApiModelProperty("2#光伏电流")
|
||||
private BigDecimal photCur2;
|
||||
|
||||
/** 2#光伏功率 */
|
||||
@Excel(name = "2#光伏功率")
|
||||
@ApiModelProperty("2#光伏功率")
|
||||
@Excel(name = "2#光伏功率")
|
||||
@ApiModelProperty("2#光伏功率")
|
||||
private BigDecimal photPower2;
|
||||
|
||||
/** 2#当日累计充电量 */
|
||||
@Excel(name = "2#当日累计充电量")
|
||||
@ApiModelProperty("2#当日累计充电量")
|
||||
@Excel(name = "2#当日累计充电量")
|
||||
@ApiModelProperty("2#当日累计充电量")
|
||||
private BigDecimal cumChargeDay2;
|
||||
|
||||
/** 2#当月累计充电量 */
|
||||
@Excel(name = "2#当月累计充电量")
|
||||
@ApiModelProperty("2#当月累计充电量")
|
||||
@Excel(name = "2#当月累计充电量")
|
||||
@ApiModelProperty("2#当月累计充电量")
|
||||
private BigDecimal cumChargeMon2;
|
||||
|
||||
/** 2#当年累积充电量 */
|
||||
@Excel(name = "2#当年累积充电量")
|
||||
@ApiModelProperty("2#当年累积充电量")
|
||||
@Excel(name = "2#当年累积充电量")
|
||||
@ApiModelProperty("2#当年累积充电量")
|
||||
private BigDecimal cumChargeYear2;
|
||||
|
||||
/** 2#总累计充电量 */
|
||||
@Excel(name = "2#总累计充电量")
|
||||
@ApiModelProperty("2#总累计充电量")
|
||||
@Excel(name = "2#总累计充电量")
|
||||
@ApiModelProperty("2#总累计充电量")
|
||||
private BigDecimal cumChargeAll2;
|
||||
|
||||
/** 2#当日累计用电量 */
|
||||
@Excel(name = "2#当日累计用电量")
|
||||
@ApiModelProperty("2#当日累计用电量")
|
||||
@Excel(name = "2#当日累计用电量")
|
||||
@ApiModelProperty("2#当日累计用电量")
|
||||
private BigDecimal cumEleDay2;
|
||||
|
||||
/** 2#当年累计用电量 */
|
||||
@Excel(name = "2#当年累计用电量")
|
||||
@ApiModelProperty("2#当年累计用电量")
|
||||
@Excel(name = "2#当年累计用电量")
|
||||
@ApiModelProperty("2#当年累计用电量")
|
||||
private BigDecimal cumEleYear2;
|
||||
|
||||
/** 2#总累积用电量 */
|
||||
@Excel(name = "2#总累积用电量")
|
||||
@ApiModelProperty("2#总累积用电量")
|
||||
@Excel(name = "2#总累积用电量")
|
||||
@ApiModelProperty("2#总累积用电量")
|
||||
private BigDecimal cumEleAll2;
|
||||
|
||||
/** 2#手动控制模式 */
|
||||
@Excel(name = "2#手动控制模式")
|
||||
@ApiModelProperty("2#手动控制模式")
|
||||
@Excel(name = "2#手动控制模式")
|
||||
@ApiModelProperty("2#手动控制模式")
|
||||
private BigDecimal shoudong2;
|
||||
|
||||
/** 2#远程通断电 */
|
||||
@Excel(name = "2#远程通断电")
|
||||
@ApiModelProperty("2#远程通断电")
|
||||
@Excel(name = "2#远程通断电")
|
||||
@ApiModelProperty("2#远程通断电")
|
||||
private BigDecimal control2;
|
||||
|
||||
/** 2#当月累计用电量 */
|
||||
@Excel(name = "2#当月累计用电量")
|
||||
@ApiModelProperty("2#当月累计用电量")
|
||||
@Excel(name = "2#当月累计用电量")
|
||||
@ApiModelProperty("2#当月累计用电量")
|
||||
private BigDecimal cumEleMon2;
|
||||
|
||||
/** 保存时间 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user