Browse Source

上传设备状态定时

develop
zhaoxianglong 10 months ago
parent
commit
0cece6f32e
  1. 34
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  2. 5
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

34
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -1,5 +1,6 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
@ -20,10 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.ruoyi.common.constant.Constants.HTTP;
@ -130,6 +128,21 @@ public class VideoController extends BaseController {
}
iDcDeviceService.batchUpdate(list);
logger.debug("执行:同步数据平台视频设备的设备状态成功!!");
}
AjaxResult ajaxResult = synchronizingDeviceStatus();
if (ajaxResult.get("code").equals(200)) {
JSONArray data = (JSONArray) ajaxResult.get("data");
ArrayList<DcDevice> dcDevices = new ArrayList<>();
for (Object datum : data) {
DcDevice dcDevice = new DcDevice();
JSONObject datum1 = (JSONObject) datum;
dcDevice.setIotDeviceId(datum1.getString("id"));
dcDevice.setDeviceState(Objects.equals(datum1.getString("deviceState"), "online") ?"1":"0");
dcDevices.add(dcDevice);
}
iDcDeviceService.batchUpdate(dcDevices);
logger.debug("执行:同步数据平台设备的设备状态成功!!");
}
@ -138,6 +151,19 @@ public class VideoController extends BaseController {
}
private AjaxResult synchronizingDeviceStatus() throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
Response response // 请求响应
= okHttp
.url(HTTP+"10.0.81.202:8081" + "/api/iot/device/query") // 请求地址
.get(); // 请求方法
AjaxResult ajaxResult = JSON.parseObject(response.body().string(), AjaxResult.class);
return ajaxResult;
}
/**
* 查询同步相机数据
*/

5
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="durableYears" column="durable_years"/>
<result property="installationSite" column="installation_site"/>
<result property="useState" column="use_state"/>
<result property="deviceState" column="device_state"/>
<result property="otherConfig" column="other_config"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
@ -49,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
durable_years,
installation_site,
use_state,
device_state,
other_config,
remark,
create_time,
@ -59,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark_id, t1.direction, t1.device_name, t1.device_code, t1.device_type,
t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,
t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,
t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark_id = t2.id and t1.direction = t2.direction
@ -78,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="durableYears != null and durableYears != ''">and t1.durable_years = #{durableYears}</if>
<if test="installationSite != null and installationSite != ''">and t1.installation_site = #{installationSite}</if>
<if test="useState != null and useState != ''">and t1.use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''">and t1.device_state = #{deviceState}</if>
<if test="otherConfig != null and otherConfig != ''">and t1.other_config = #{otherConfig}</if>
<if test="remark != null and remark != ''">and t1.remark = #{remark}</if>
<if test="createTime != null and createTime != ''">and t1.create_time = #{createTime}</if>

Loading…
Cancel
Save