获取气象设备实时数据相关逻辑
This commit is contained in:
parent
60f48d503c
commit
91d2929cb1
@ -0,0 +1,53 @@
|
|||||||
|
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,76 @@
|
|||||||
|
package com.fastbee.deviceData.api.devlink.service;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import cn.hutool.json.JSON;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.fastbee.deviceData.api.renke.service.RenkeMetDeviceService;
|
||||||
|
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DevLinkMoistureService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DevLinkAuthorizationService authorizationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备列表
|
||||||
|
*/
|
||||||
|
public List<?> getMoistureDevice(){
|
||||||
|
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","3269");
|
||||||
|
body.put("params",params);
|
||||||
|
String jsonStr = JSONUtil.toJsonStr(body);
|
||||||
|
System.err.println(authorization.getBaseUrl() + authorization.getAuth());
|
||||||
|
String result = HttpUtil.post(authorization.getBaseUrl() + authorization.getAuth(), jsonStr);
|
||||||
|
System.err.println(result);
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(result);
|
||||||
|
Object data = jsonObject.get("data");
|
||||||
|
//获取设备状态
|
||||||
|
JSONObject jsonObjectData = JSONUtil.parseObj(data);
|
||||||
|
Object status = jsonObjectData.get("status");
|
||||||
|
//获取设备属性以及实时数据值
|
||||||
|
Object properties = jsonObject.get("properties");
|
||||||
|
JSONArray propertiesArray = JSONUtil.parseArray(properties);
|
||||||
|
//获取设备各项属性实时数据
|
||||||
|
propertiesArray.forEach(p -> {
|
||||||
|
|
||||||
|
Object property = JSONUtil.parseObj(p).get("property");
|
||||||
|
JSONObject propertyMap = JSONUtil.parseObj(property);
|
||||||
|
//属性名称
|
||||||
|
propertyMap.get("name");
|
||||||
|
//属性key
|
||||||
|
propertyMap.get("key");
|
||||||
|
//属性值
|
||||||
|
Object value = JSONUtil.parseObj(p).get("value");
|
||||||
|
//TODO 属性值历史数据,是否需要
|
||||||
|
Object list = JSONUtil.parseObj(p).get("list");
|
||||||
|
//TODO 封装所需数据
|
||||||
|
deviceRealtimedataMeteorologyMapper.insertDeviceRealtimedataMeteorology(null);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DevLinkMoistureService service = new DevLinkMoistureService();
|
||||||
|
service.getMoistureDevice();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.fastbee.deviceData.domain;
|
package com.fastbee.deviceData.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -14,89 +14,77 @@ import com.fastbee.common.core.domain.BaseEntity;
|
|||||||
* 气象设备实时数据对象 iot_device_realtimedata_meteorology
|
* 气象设备实时数据对象 iot_device_realtimedata_meteorology
|
||||||
*
|
*
|
||||||
* @author kerwincui
|
* @author kerwincui
|
||||||
* @date 2024-11-13
|
* @date 2024-11-08
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "DeviceRealtimedataMeteorology",description = "气象设备实时数据 iot_device_realtimedata_meteorology")
|
@ApiModel(value = "DeviceRealtimedataMeteorology",description = "气象设备实时数据 iot_device_realtimedata_meteorology")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("iot_device_realtimedata_meteorology")
|
||||||
public class DeviceRealtimedataMeteorology extends BaseEntity
|
public class DeviceRealtimedataMeteorology extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/** 节点编号 */
|
||||||
private Long id;
|
private Long nodeId;
|
||||||
|
|
||||||
/** 设备id */
|
/** 节点名称 */
|
||||||
@Excel(name = "设备id")
|
@Excel(name = "节点名称")
|
||||||
@ApiModelProperty("设备id")
|
@ApiModelProperty("节点名称")
|
||||||
private Long deviceId;
|
private String nodeName;
|
||||||
|
|
||||||
/** 空气温度 */
|
/** 节点类型 -- 节点类型 --1:模拟量1使能模拟量2使能 --2:模拟量1使能模拟量2禁用 --3:模拟量1禁用模拟量2使能 --4:浮点型设备--5:开关量型设备 --6:32位有符号整形 --7:32位无符号整形--8:遥调设备 */
|
||||||
@Excel(name = "空气温度")
|
@Excel(name = "节点类型 -- 节点类型 --1:模拟量1使能模拟量2使能 --2:模拟量1使能模拟量2禁用 --3:模拟量1禁用模拟量2使能 --4:浮点型设备--5:开关量型设备 --6:32位有符号整形 --7:32位无符号整形--8:遥调设备")
|
||||||
@ApiModelProperty("空气温度")
|
@ApiModelProperty("节点类型 -- 节点类型 --1:模拟量1使能模拟量2使能 --2:模拟量1使能模拟量2禁用 --3:模拟量1禁用模拟量2使能 --4:浮点型设备--5:开关量型设备 --6:32位有符号整形 --7:32位无符号整形--8:遥调设备")
|
||||||
private BigDecimal airTemp;
|
private Long nodeType;
|
||||||
|
|
||||||
/** 空气湿度 */
|
/** 模拟量1名称 */
|
||||||
@Excel(name = "空气湿度")
|
@Excel(name = "模拟量1名称")
|
||||||
@ApiModelProperty("空气湿度")
|
@ApiModelProperty("模拟量1名称")
|
||||||
private BigDecimal airHumi;
|
private String temName;
|
||||||
|
|
||||||
/** 风速 */
|
/** 模拟量1单位 */
|
||||||
@Excel(name = "风速")
|
@Excel(name = "模拟量1单位")
|
||||||
@ApiModelProperty("风速")
|
@ApiModelProperty("模拟量1单位")
|
||||||
private BigDecimal windSpeed;
|
private String temUnit;
|
||||||
|
|
||||||
/** 风向 */
|
/** 模拟量1原值 */
|
||||||
@Excel(name = "风向")
|
@Excel(name = "模拟量1原值")
|
||||||
@ApiModelProperty("风向")
|
@ApiModelProperty("模拟量1原值")
|
||||||
private Long windDir;
|
private Long temValue;
|
||||||
|
|
||||||
/** 大气压力 */
|
/** 模拟量1显示值 */
|
||||||
@Excel(name = "大气压力")
|
@Excel(name = "模拟量1显示值")
|
||||||
@ApiModelProperty("大气压力")
|
@ApiModelProperty("模拟量1显示值")
|
||||||
private BigDecimal airPre;
|
private String temValueStr;
|
||||||
|
|
||||||
/** 光照度 */
|
/** 报警等级, -- 报警等级 --0:正常--1:超上限报警 --2:超下限报警 --3:开关闭合报警 --4:开关断开报警 --5:遥调报警 */
|
||||||
@Excel(name = "光照度")
|
@Excel(name = "报警等级, -- 报警等级 --0:正常--1:超上限报警 --2:超下限报警 --3:开关闭合报警 --4:开关断开报警 --5:遥调报警")
|
||||||
@ApiModelProperty("光照度")
|
@ApiModelProperty("报警等级, -- 报警等级 --0:正常--1:超上限报警 --2:超下限报警 --3:开关闭合报警 --4:开关断开报警 --5:遥调报警")
|
||||||
private Long guangzhao;
|
private Long temAlarmStatus;
|
||||||
|
|
||||||
/** 光合有效辐射 */
|
/** 模拟量2名称 */
|
||||||
@Excel(name = "光合有效辐射")
|
@Excel(name = "模拟量2名称")
|
||||||
@ApiModelProperty("光合有效辐射")
|
@ApiModelProperty("模拟量2名称")
|
||||||
private BigDecimal fushe;
|
private String humName;
|
||||||
|
|
||||||
/** 累积雨量 */
|
/** 模拟量2单位 */
|
||||||
@Excel(name = "累积雨量")
|
@Excel(name = "模拟量2单位")
|
||||||
@ApiModelProperty("累积雨量")
|
@ApiModelProperty("模拟量2单位")
|
||||||
private BigDecimal sumRain;
|
private String humUnit;
|
||||||
|
|
||||||
/** 瞬时雨量 */
|
/** 模拟量2原值 */
|
||||||
@Excel(name = "瞬时雨量")
|
@Excel(name = "模拟量2原值")
|
||||||
@ApiModelProperty("瞬时雨量")
|
@ApiModelProperty("模拟量2原值")
|
||||||
private BigDecimal insRain;
|
private Long humValue;
|
||||||
|
|
||||||
/** 日雨量 */
|
/** 模拟量2显示值 */
|
||||||
@Excel(name = "日雨量")
|
@Excel(name = "模拟量2显示值")
|
||||||
@ApiModelProperty("日雨量")
|
@ApiModelProperty("模拟量2显示值")
|
||||||
private BigDecimal dayRain;
|
private String humValueStr;
|
||||||
|
|
||||||
/** 蒸发量 */
|
/** 报警等级 , --0:正常 --1:超上限报警 --2:超下限报警 */
|
||||||
@Excel(name = "蒸发量")
|
@Excel(name = "报警等级 , --0:正常 --1:超上限报警 --2:超下限报警")
|
||||||
@ApiModelProperty("蒸发量")
|
@ApiModelProperty("报警等级 , --0:正常 --1:超上限报警 --2:超下限报警")
|
||||||
private BigDecimal zhengfa;
|
private Long humAlarmStatus;
|
||||||
|
|
||||||
/** 土壤温度 */
|
|
||||||
@Excel(name = "土壤温度")
|
|
||||||
@ApiModelProperty("土壤温度")
|
|
||||||
private BigDecimal soilTemp;
|
|
||||||
|
|
||||||
/** 土壤湿度 */
|
|
||||||
@Excel(name = "土壤湿度")
|
|
||||||
@ApiModelProperty("土壤湿度")
|
|
||||||
private BigDecimal soilHumi;
|
|
||||||
|
|
||||||
/** 删除标志(0代表存在,2代表删除) */
|
|
||||||
private Integer delFlag;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,137 +5,113 @@
|
|||||||
<mapper namespace="com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper">
|
<mapper namespace="com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper">
|
||||||
|
|
||||||
<resultMap type="DeviceRealtimedataMeteorology" id="DeviceRealtimedataMeteorologyResult">
|
<resultMap type="DeviceRealtimedataMeteorology" id="DeviceRealtimedataMeteorologyResult">
|
||||||
<result property="id" column="id" />
|
<result property="nodeId" column="node_id" />
|
||||||
<result property="deviceId" column="device_id" />
|
<result property="nodeName" column="node_name" />
|
||||||
<result property="airTemp" column="air_temp" />
|
<result property="nodeType" column="node_type" />
|
||||||
<result property="airHumi" column="air_humi" />
|
<result property="temName" column="tem_name" />
|
||||||
<result property="windSpeed" column="wind_speed" />
|
<result property="temUnit" column="tem_unit" />
|
||||||
<result property="windDir" column="wind_dir" />
|
<result property="temValue" column="tem_value" />
|
||||||
<result property="airPre" column="air_pre" />
|
<result property="temValueStr" column="tem_value_str" />
|
||||||
<result property="guangzhao" column="guangzhao" />
|
<result property="temAlarmStatus" column="tem_alarm_status" />
|
||||||
<result property="fushe" column="fushe" />
|
<result property="humName" column="hum_name" />
|
||||||
<result property="sumRain" column="sum_rain" />
|
<result property="humUnit" column="hum_unit" />
|
||||||
<result property="insRain" column="ins_rain" />
|
<result property="humValue" column="hum_value" />
|
||||||
<result property="dayRain" column="day_rain" />
|
<result property="humValueStr" column="hum_value_str" />
|
||||||
<result property="zhengfa" column="zhengfa" />
|
<result property="humAlarmStatus" column="hum_alarm_status" />
|
||||||
<result property="soilTemp" column="soil_temp" />
|
|
||||||
<result property="soilHumi" column="soil_humi" />
|
|
||||||
<result property="delFlag" column="del_flag" />
|
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeviceRealtimedataMeteorologyVo">
|
<sql id="selectDeviceRealtimedataMeteorologyVo">
|
||||||
select id, device_id, air_temp, air_humi, wind_speed, wind_dir, air_pre, guangzhao, fushe, sum_rain, ins_rain, day_rain, zhengfa, soil_temp, soil_humi, del_flag, create_time, create_by, update_time, update_by from iot_device_realtimedata_meteorology
|
select node_id, node_name, node_type, tem_name, tem_unit, tem_value, tem_value_str, tem_alarm_status, hum_name, hum_unit, hum_value, hum_value_str, hum_alarm_status, create_time from iot_device_realtimedata_meteorology
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDeviceRealtimedataMeteorologyList" parameterType="DeviceRealtimedataMeteorology" resultMap="DeviceRealtimedataMeteorologyResult">
|
<select id="selectDeviceRealtimedataMeteorologyList" parameterType="DeviceRealtimedataMeteorology" resultMap="DeviceRealtimedataMeteorologyResult">
|
||||||
<include refid="selectDeviceRealtimedataMeteorologyVo"/>
|
<include refid="selectDeviceRealtimedataMeteorologyVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
|
||||||
<if test="airTemp != null "> and air_temp = #{airTemp}</if>
|
<if test="nodeType != null "> and node_type = #{nodeType}</if>
|
||||||
<if test="airHumi != null "> and air_humi = #{airHumi}</if>
|
<if test="temName != null and temName != ''"> and tem_name like concat('%', #{temName}, '%')</if>
|
||||||
<if test="windSpeed != null "> and wind_speed = #{windSpeed}</if>
|
<if test="temUnit != null and temUnit != ''"> and tem_unit = #{temUnit}</if>
|
||||||
<if test="windDir != null "> and wind_dir = #{windDir}</if>
|
<if test="temValue != null "> and tem_value = #{temValue}</if>
|
||||||
<if test="airPre != null "> and air_pre = #{airPre}</if>
|
<if test="temValueStr != null and temValueStr != ''"> and tem_value_str = #{temValueStr}</if>
|
||||||
<if test="guangzhao != null "> and guangzhao = #{guangzhao}</if>
|
<if test="temAlarmStatus != null "> and tem_alarm_status = #{temAlarmStatus}</if>
|
||||||
<if test="fushe != null "> and fushe = #{fushe}</if>
|
<if test="humName != null and humName != ''"> and hum_name like concat('%', #{humName}, '%')</if>
|
||||||
<if test="sumRain != null "> and sum_rain = #{sumRain}</if>
|
<if test="humUnit != null and humUnit != ''"> and hum_unit = #{humUnit}</if>
|
||||||
<if test="insRain != null "> and ins_rain = #{insRain}</if>
|
<if test="humValue != null "> and hum_value = #{humValue}</if>
|
||||||
<if test="dayRain != null "> and day_rain = #{dayRain}</if>
|
<if test="humValueStr != null and humValueStr != ''"> and hum_value_str = #{humValueStr}</if>
|
||||||
<if test="zhengfa != null "> and zhengfa = #{zhengfa}</if>
|
<if test="humAlarmStatus != null "> and hum_alarm_status = #{humAlarmStatus}</if>
|
||||||
<if test="soilTemp != null "> and soil_temp = #{soilTemp}</if>
|
|
||||||
<if test="soilHumi != null "> and soil_humi = #{soilHumi}</if>
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeviceRealtimedataMeteorologyById" parameterType="Long" resultMap="DeviceRealtimedataMeteorologyResult">
|
<select id="selectDeviceRealtimedataMeteorologyByNodeId" parameterType="Long" resultMap="DeviceRealtimedataMeteorologyResult">
|
||||||
<include refid="selectDeviceRealtimedataMeteorologyVo"/>
|
<include refid="selectDeviceRealtimedataMeteorologyVo"/>
|
||||||
where id = #{id}
|
where node_id = #{nodeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology">
|
||||||
insert into iot_device_realtimedata_meteorology
|
insert into iot_device_realtimedata_meteorology
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="deviceId != null">device_id,</if>
|
<if test="nodeId != null">node_id,</if>
|
||||||
<if test="airTemp != null">air_temp,</if>
|
<if test="nodeName != null">node_name,</if>
|
||||||
<if test="airHumi != null">air_humi,</if>
|
<if test="nodeType != null">node_type,</if>
|
||||||
<if test="windSpeed != null">wind_speed,</if>
|
<if test="temName != null">tem_name,</if>
|
||||||
<if test="windDir != null">wind_dir,</if>
|
<if test="temUnit != null">tem_unit,</if>
|
||||||
<if test="airPre != null">air_pre,</if>
|
<if test="temValue != null">tem_value,</if>
|
||||||
<if test="guangzhao != null">guangzhao,</if>
|
<if test="temValueStr != null">tem_value_str,</if>
|
||||||
<if test="fushe != null">fushe,</if>
|
<if test="temAlarmStatus != null">tem_alarm_status,</if>
|
||||||
<if test="sumRain != null">sum_rain,</if>
|
<if test="humName != null">hum_name,</if>
|
||||||
<if test="insRain != null">ins_rain,</if>
|
<if test="humUnit != null">hum_unit,</if>
|
||||||
<if test="dayRain != null">day_rain,</if>
|
<if test="humValue != null">hum_value,</if>
|
||||||
<if test="zhengfa != null">zhengfa,</if>
|
<if test="humValueStr != null">hum_value_str,</if>
|
||||||
<if test="soilTemp != null">soil_temp,</if>
|
<if test="humAlarmStatus != null">hum_alarm_status,</if>
|
||||||
<if test="soilHumi != null">soil_humi,</if>
|
|
||||||
<if test="delFlag != null">del_flag,</if>
|
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="updateTime != null">update_time,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="deviceId != null">#{deviceId},</if>
|
<if test="nodeId != null">#{nodeId},</if>
|
||||||
<if test="airTemp != null">#{airTemp},</if>
|
<if test="nodeName != null">#{nodeName},</if>
|
||||||
<if test="airHumi != null">#{airHumi},</if>
|
<if test="nodeType != null">#{nodeType},</if>
|
||||||
<if test="windSpeed != null">#{windSpeed},</if>
|
<if test="temName != null">#{temName},</if>
|
||||||
<if test="windDir != null">#{windDir},</if>
|
<if test="temUnit != null">#{temUnit},</if>
|
||||||
<if test="airPre != null">#{airPre},</if>
|
<if test="temValue != null">#{temValue},</if>
|
||||||
<if test="guangzhao != null">#{guangzhao},</if>
|
<if test="temValueStr != null">#{temValueStr},</if>
|
||||||
<if test="fushe != null">#{fushe},</if>
|
<if test="temAlarmStatus != null">#{temAlarmStatus},</if>
|
||||||
<if test="sumRain != null">#{sumRain},</if>
|
<if test="humName != null">#{humName},</if>
|
||||||
<if test="insRain != null">#{insRain},</if>
|
<if test="humUnit != null">#{humUnit},</if>
|
||||||
<if test="dayRain != null">#{dayRain},</if>
|
<if test="humValue != null">#{humValue},</if>
|
||||||
<if test="zhengfa != null">#{zhengfa},</if>
|
<if test="humValueStr != null">#{humValueStr},</if>
|
||||||
<if test="soilTemp != null">#{soilTemp},</if>
|
<if test="humAlarmStatus != null">#{humAlarmStatus},</if>
|
||||||
<if test="soilHumi != null">#{soilHumi},</if>
|
|
||||||
<if test="delFlag != null">#{delFlag},</if>
|
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology">
|
<update id="updateDeviceRealtimedataMeteorology" parameterType="DeviceRealtimedataMeteorology">
|
||||||
update iot_device_realtimedata_meteorology
|
update iot_device_realtimedata_meteorology
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
<if test="nodeName != null">node_name = #{nodeName},</if>
|
||||||
<if test="airTemp != null">air_temp = #{airTemp},</if>
|
<if test="nodeType != null">node_type = #{nodeType},</if>
|
||||||
<if test="airHumi != null">air_humi = #{airHumi},</if>
|
<if test="temName != null">tem_name = #{temName},</if>
|
||||||
<if test="windSpeed != null">wind_speed = #{windSpeed},</if>
|
<if test="temUnit != null">tem_unit = #{temUnit},</if>
|
||||||
<if test="windDir != null">wind_dir = #{windDir},</if>
|
<if test="temValue != null">tem_value = #{temValue},</if>
|
||||||
<if test="airPre != null">air_pre = #{airPre},</if>
|
<if test="temValueStr != null">tem_value_str = #{temValueStr},</if>
|
||||||
<if test="guangzhao != null">guangzhao = #{guangzhao},</if>
|
<if test="temAlarmStatus != null">tem_alarm_status = #{temAlarmStatus},</if>
|
||||||
<if test="fushe != null">fushe = #{fushe},</if>
|
<if test="humName != null">hum_name = #{humName},</if>
|
||||||
<if test="sumRain != null">sum_rain = #{sumRain},</if>
|
<if test="humUnit != null">hum_unit = #{humUnit},</if>
|
||||||
<if test="insRain != null">ins_rain = #{insRain},</if>
|
<if test="humValue != null">hum_value = #{humValue},</if>
|
||||||
<if test="dayRain != null">day_rain = #{dayRain},</if>
|
<if test="humValueStr != null">hum_value_str = #{humValueStr},</if>
|
||||||
<if test="zhengfa != null">zhengfa = #{zhengfa},</if>
|
<if test="humAlarmStatus != null">hum_alarm_status = #{humAlarmStatus},</if>
|
||||||
<if test="soilTemp != null">soil_temp = #{soilTemp},</if>
|
|
||||||
<if test="soilHumi != null">soil_humi = #{soilHumi},</if>
|
|
||||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where node_id = #{nodeId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteDeviceRealtimedataMeteorologyById" parameterType="Long">
|
<delete id="deleteDeviceRealtimedataMeteorologyByNodeId" parameterType="Long">
|
||||||
delete from iot_device_realtimedata_meteorology where id = #{id}
|
delete from iot_device_realtimedata_meteorology where node_id = #{nodeId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteDeviceRealtimedataMeteorologyByIds" parameterType="String">
|
<delete id="deleteDeviceRealtimedataMeteorologyByNodeIds" parameterType="String">
|
||||||
delete from iot_device_realtimedata_meteorology where id in
|
delete from iot_device_realtimedata_meteorology where node_id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="nodeId" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{nodeId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
@ -1,12 +1,15 @@
|
|||||||
package com.fastbee.iot.timer;
|
package com.fastbee.iot.timer;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
|
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.fastbee.deviceData.api.renke.constant.RenKeDeviceTypeConstant;
|
||||||
import com.fastbee.deviceData.api.renke.service.RenKeAuthorizationService;
|
import com.fastbee.deviceData.api.renke.service.RenKeAuthorizationService;
|
||||||
|
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimeDataWormsServiceImpl;
|
import com.fastbee.deviceData.service.impl.DeviceRealtimeDataWormsServiceImpl;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -25,8 +28,6 @@ public class DeviceDateTask {
|
|||||||
private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimeDataWormsServiceImpl deviceRealtimedataWormsServiceImpl;
|
private DeviceRealtimeDataWormsServiceImpl deviceRealtimedataWormsServiceImpl;
|
||||||
@Autowired
|
|
||||||
private DeviceRealtimeDataMeteorologyServiceImpl deviceRealtimedataMeteorologyServiceImpl;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RenKeAuthorizationService renKeAuthorizationService;
|
private RenKeAuthorizationService renKeAuthorizationService;
|
||||||
@ -51,30 +52,38 @@ public class DeviceDateTask {
|
|||||||
}
|
}
|
||||||
JSONObject respBody = JSONUtil.parseObj(respBodyStr);
|
JSONObject respBody = JSONUtil.parseObj(respBodyStr);
|
||||||
JSONArray realtimeList = JSONUtil.parseArray(respBody.get("data"));
|
JSONArray realtimeList = JSONUtil.parseArray(respBody.get("data"));
|
||||||
threadPoolTaskExecutor.execute( () -> {System.err.println("设备实时数据:"+realtimeList);});
|
// threadPoolTaskExecutor.execute( () -> {System.err.println("设备实时数据:"+realtimeList);});
|
||||||
|
|
||||||
//TODO 解析实时数据保存到数据库
|
//TODO 解析实时数据保存到数据库
|
||||||
// for (Object jsonObject : realtimeList){
|
for (Object realtimeData : realtimeList){
|
||||||
// JSONObject josnConversion = (JSONObject) jsonObject;
|
JSONObject jsonConversion = JSONUtil.parseObj(realtimeData);
|
||||||
// if (RenKeDeviceTypeConstant.WORM.equals(josnConversion.get("deviceType"))){
|
if (RenKeDeviceTypeConstant.WORM.equals(jsonConversion.get("deviceType"))){
|
||||||
// JSONObject josnArray = JSONUtil.parseObj(josnConversion.get("data"));
|
JSONObject jsonObject1 = JSONUtil.parseObj(jsonConversion.get("data"));
|
||||||
// DeviceRealtimedataWorms deviceRealtimedataWorms = JSONUtil.toBean(josnArray, DeviceRealtimedataWorms.class);
|
DeviceRealtimedataWorms deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||||
// deviceRealtimedataWorms.setCreateTime(DateTime.now());
|
deviceRealtimedataWorms.setCreateTime(DateTime.now());
|
||||||
// if(deviceRealtimedataWormsServiceImpl.insertDeviceRealtimedataWorms(deviceRealtimedataWorms)==1){
|
// System.err.println("序列化为蠕虫设备数据类:"+deviceRealtimedataWorms);
|
||||||
// System.out.println("插入成功");
|
if(deviceRealtimedataWormsServiceImpl.insertDeviceRealtimedataWorms(deviceRealtimedataWorms)!=1){
|
||||||
// };
|
System.out.println("插入失败!");
|
||||||
// }else if (RenKeDeviceTypeConstant.MET.equals(josnConversion.get("deviceType"))){
|
};
|
||||||
// JSONArray josnArray = JSONUtil.parseArray(josnConversion.get("data"));
|
}
|
||||||
// for (Object json : josnArray){
|
// else if (RenKeDeviceTypeConstant.MET.equals(jsonConversion.get("deviceType"))){
|
||||||
// DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = JSONUtil.toBean((JSONObject) json, DeviceRealtimedataMeteorology.class);
|
// //获取设备地址
|
||||||
|
// Object deviceAddr = jsonConversion.get("deviceAddr");
|
||||||
|
// JSONArray jsonArray = JSONUtil.parseArray(jsonConversion.get("data"));
|
||||||
|
//// System.err.println("气象设备数据列表:"+jsonArray);
|
||||||
|
// for (Object json : jsonArray){
|
||||||
|
// JSONObject jsonConversion1 = JSONUtil.parseObj(json);
|
||||||
|
// DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = JSONUtil.toBean(jsonConversion1, DeviceRealtimedataMeteorology.class);
|
||||||
// deviceRealtimedataMeteorology.setCreateTime(DateTime.now());
|
// deviceRealtimedataMeteorology.setCreateTime(DateTime.now());
|
||||||
// if(deviceRealtimedataMeteorologyServiceImpl.insertDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology)==1){
|
// deviceRealtimedataMeteorology.setDeviceaddr(deviceAddr.toString());
|
||||||
// System.out.println("插入成功");
|
//// System.err.println("序列化为气象设备数据类:"+deviceRealtimedataMeteorology);
|
||||||
|
// if(deviceRealtimedataMeteorologyServiceImpl.insertDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology)!=1){
|
||||||
|
// System.out.println("插入失败!");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user