天气api参数调整,虫情设备图片数据获取等
This commit is contained in:
@ -17,25 +17,11 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -7,6 +7,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.date.DateTimeCalculationUtils;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@ -28,10 +30,11 @@ public class RenkeDeviceDataService {
|
||||
* @param deviceAddrs 设备地址,支持多个用英文逗号分隔
|
||||
*/
|
||||
public DeviceRealtimedataWorms setData(String deviceAddrs) {
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms= new DeviceRealtimedataWorms();
|
||||
//处理鉴权
|
||||
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)
|
||||
.form("deviceAddrs", deviceAddrs)
|
||||
@ -46,7 +49,35 @@ public class RenkeDeviceDataService {
|
||||
JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
||||
//获取实时时间
|
||||
String realTime = jsonObject1.get("DTime").toString();
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||
//反序列化封装基础数据
|
||||
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||
//获取虫情设备关键数据
|
||||
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataList")
|
||||
.header("token", token)
|
||||
.form("deviceAddrs", deviceAddrs)
|
||||
//开始时间是5分钟前
|
||||
.form("beginTime", DateTimeCalculationUtils.format(DateTimeCalculationUtils.minus(5, ChronoUnit.MINUTES)))
|
||||
.form("endTime", DateUtils.getNowDate())
|
||||
.form("pages", 1)
|
||||
.form("limit", 10)
|
||||
.execute();
|
||||
String respBodyStr1 = response.body();
|
||||
if(StringUtils.isBlank(respBodyStr1)) {
|
||||
throw new RuntimeException("获取设备实时数据失败!");
|
||||
}
|
||||
JSONObject jsonObject2 = JSONUtil.parseObj(respBodyStr1);
|
||||
JSONObject jsonObject3 = JSONUtil.parseObj(jsonObject2.get("data"));
|
||||
JSONArray jsonArray = JSONUtil.parseArray(jsonObject3.get("rows"));
|
||||
JSONObject jsonObject4 = JSONUtil.parseObj(jsonArray.get(0));
|
||||
//获取拍照图片
|
||||
Object imagesUrl = jsonObject4.get("imagesUrl");
|
||||
//获取虫情分析后的图片地址
|
||||
Object analyseCoordUrl = jsonObject4.get("analyseCoordUrl");
|
||||
|
||||
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
|
||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||
|
||||
|
||||
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
|
@ -19,7 +19,7 @@ public class TianqiApi {
|
||||
|
||||
String url = UrlConstant.QitianApi + "?key=" +
|
||||
UrlConstant.PrivateKey +
|
||||
"&location=kenli&language=zh-Hans&unit=c";//指定URL
|
||||
"&location=YBMUBR41ZWVC&language=zh-Hans&unit=c";//指定URL
|
||||
HttpResponse execute = HttpUtil.createGet(url).execute();
|
||||
if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
||||
JSONObject jsonObject = new JSONObject(execute.body());
|
||||
@ -54,4 +54,22 @@ public class TianqiApi {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String url="https://api.seniverse.com/v3/location/search.json?key="+UrlConstant.PrivateKey+"&q=绥滨";
|
||||
// HttpResponse execute = HttpUtil.createGet(url).execute();
|
||||
// if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
||||
// JSONObject jsonObject = new JSONObject(execute.body());
|
||||
// System.out.println("jsonObject = " + jsonObject);
|
||||
// }
|
||||
String url = UrlConstant.QitianApi + "?key=" +
|
||||
UrlConstant.PrivateKey +
|
||||
"&location=YBMUBR41ZWVC&language=zh-Hans&unit=c";//指定URL
|
||||
HttpResponse execute = HttpUtil.createGet(url).execute();
|
||||
if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
||||
JSONObject jsonObject = new JSONObject(execute.body());
|
||||
System.out.println("jsonObject = " + jsonObject);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,4 +133,14 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("实时时间")
|
||||
private Date realTime;
|
||||
|
||||
/** 摄像头 */
|
||||
@Excel(name = "摄像头")
|
||||
@ApiModelProperty("摄像头")
|
||||
private String camera;
|
||||
|
||||
/** 虫害照片 */
|
||||
@Excel(name = "虫害照片")
|
||||
@ApiModelProperty("虫害照片")
|
||||
private String pestPhotos;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationMeteorology",description = "气象设备基础信息 iot_device_information_meteorology")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_meteorology")
|
||||
public class DeviceInformationMeteorology extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationMiaoqing",description = "苗情设备基础信息 iot_device_information_miaoQing")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_miaoQing")
|
||||
public class DeviceInformationMiaoqing extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationMoisture",description = "墒情设备基础信息 iot_device_information_moisture")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_moisture")
|
||||
public class DeviceInformationMoisture extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationMonitor",description = "监控站设备基础信息 iot_device_information_monitor")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_monitor")
|
||||
public class DeviceInformationMonitor extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -18,6 +19,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationTargetpests",description = "靶标害虫设备基础信息 iot_device_information_targetPests")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_targetPests")
|
||||
public class DeviceInformationTargetpests extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "DeviceInformationWorms",description = "虫情设备基础信息 iot_device_information_worms")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_information_worms")
|
||||
public class DeviceInformationWorms extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMeteorology;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationMeteorologyMapper
|
||||
public interface DeviceInformationMeteorologyMapper extends BaseMapper<DeviceInformationMeteorology>
|
||||
{
|
||||
/**
|
||||
* 查询气象设备基础信息
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMiaoqing;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationMiaoqingMapper
|
||||
public interface DeviceInformationMiaoqingMapper extends BaseMapper<DeviceInformationMiaoqing>
|
||||
{
|
||||
/**
|
||||
* 查询苗情设备基础信息
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMoisture;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationMoistureMapper
|
||||
public interface DeviceInformationMoistureMapper extends BaseMapper<DeviceInformationMoisture>
|
||||
{
|
||||
/**
|
||||
* 查询墒情设备基础信息
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMonitor;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationMonitorMapper
|
||||
public interface DeviceInformationMonitorMapper extends BaseMapper<DeviceInformationMonitor>
|
||||
{
|
||||
/**
|
||||
* 查询监控站设备基础信息
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationTargetpestsMapper
|
||||
public interface DeviceInformationTargetpestsMapper extends BaseMapper<DeviceInformationTargetpests>
|
||||
{
|
||||
/**
|
||||
* 查询靶标害虫设备基础信息
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationWorms;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceInformationWormsMapper
|
||||
public interface DeviceInformationWormsMapper extends BaseMapper<DeviceInformationWorms>
|
||||
{
|
||||
/**
|
||||
* 查询虫情设备基础信息
|
||||
|
@ -26,10 +26,12 @@
|
||||
<result property="status" column="status" />
|
||||
<result property="saveTime" column="save_time" />
|
||||
<result property="realTime" column="real_time" />
|
||||
<result property="camera" column="camera" />
|
||||
<result property="pestPhotos" column="pest_photos" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceRealtimedataWormsVo">
|
||||
select id, device_addr, rain, worm_flap, insecticide_tem, shake, lng, drying_flap, insecticide, move_worm, mode, drying, rain_flap, attract_worm, illum, drying_tem, lat, fill_light, status, save_time, real_time from iot_device_realtimedata_worms
|
||||
select id, device_addr, rain, worm_flap, insecticide_tem, shake, lng, drying_flap, insecticide, move_worm, mode, drying, rain_flap, attract_worm, illum, drying_tem, lat, fill_light, status, save_time, real_time, camera, pest_photos from iot_device_realtimedata_worms
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceRealtimedataWormsList" parameterType="DeviceRealtimedataWorms" resultMap="DeviceRealtimedataWormsResult">
|
||||
@ -55,6 +57,8 @@
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="saveTime != null "> and save_time = #{saveTime}</if>
|
||||
<if test="realTime != null "> and real_time = #{realTime}</if>
|
||||
<if test="camera != null and camera != ''"> and camera = #{camera}</if>
|
||||
<if test="pestPhotos != null and pestPhotos != ''"> and pest_photos = #{pestPhotos}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -86,6 +90,8 @@
|
||||
<if test="status != null">status,</if>
|
||||
<if test="saveTime != null">save_time,</if>
|
||||
<if test="realTime != null">real_time,</if>
|
||||
<if test="camera != null">camera,</if>
|
||||
<if test="pestPhotos != null">pest_photos,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceAddr != null">#{deviceAddr},</if>
|
||||
@ -108,6 +114,8 @@
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="saveTime != null">#{saveTime},</if>
|
||||
<if test="realTime != null">#{realTime},</if>
|
||||
<if test="camera != null">#{camera},</if>
|
||||
<if test="pestPhotos != null">#{pestPhotos},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -134,6 +142,8 @@
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="saveTime != null">save_time = #{saveTime},</if>
|
||||
<if test="realTime != null">real_time = #{realTime},</if>
|
||||
<if test="camera != null">camera = #{camera},</if>
|
||||
<if test="pestPhotos != null">pest_photos = #{pestPhotos},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
Reference in New Issue
Block a user