Browse Source

新换摄像头账号,更改摄像头规则

develop
wangsixiang 3 months ago
parent
commit
61a6cac51d
  1. 88
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  2. 4
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  3. 8
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  4. 12
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  5. 8
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

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

@ -28,12 +28,17 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@ -118,11 +123,43 @@ public class VideoController extends BaseController {
return AjaxResult.error(UniversalEnum.FAILED_TO_OBTAIN_CAMERA_INFORMATION_BASED_ON_THE_ORGANIZATION.getValue()); // 如果获取信息失败或不含有效数据,直接返回
}
JSONArray camDataArray = camApiResponse.getJSONArray("data");
JSONArray camDataArray = camApiResponse.getJSONArray("data");//总的道路+收费站
JSONArray camType1Array = new JSONArray();//道路
JSONArray camTypeNot1Array = new JSONArray();//收费站
for (int i = 0; i < camDataArray.size(); i++) {
JSONObject camObject = camDataArray.getJSONObject(i);
int camType = camObject.getInteger("camType");
if (camType == 4||camType == 5) {
camTypeNot1Array.add(camObject); //收费站+收费广场
} else {
camType1Array.add(camObject); //道路摄像头
}
}
//循环处理收费站的摄像头
List<DcDevice> dcDevices = iDcDeviceService.selectDeviceTollStationCamera();//收费站全部摄像头
camTypeNot1Array.forEach(item->{
JSONObject cameraInfo = (JSONObject) item;
String camId = cameraInfo.getString("camId");//摄像头物联id
String status = cameraInfo.getString("status");//
DcDevice dcDevice = new DcDevice();
for (DcDevice device:dcDevices){
if (device.getIotDeviceId().equals(camId)){
dcDevice.setId(device.getId());
if ("0".equals(status)){
dcDevice.setDeviceState("1");
}else {
dcDevice.setDeviceState("0");
}
iDcDeviceService.updateTollStationCameraStatus(dcDevice);//同步状态
}else {
continue;
}
}
});
// 遍历并更新具备匹配IP的摄像头设备物联ID
List<DcDevice> devicesToUpdate = new ArrayList<>();
camDataArray.forEach(item -> {
camType1Array.forEach(item -> {
JSONObject cameraInfo = (JSONObject) item;
// 桩号
String pileNum = cameraInfo.getString("pileNum");
@ -195,15 +232,36 @@ public class VideoController extends BaseController {
* 根据相机中的设备状态修改数据平台设备的设备状态
*/
@Scheduled(cron = "0 0/5 * * * ?")
@PostMapping("/updateDeviceState")
public void updateDeviceState() throws HttpException, IOException {
logger.debug("开始执行:同步数据平台视频设备设备的设备状态!!");
JSONObject cameraData = synchronizeCameraData();
if (cameraData.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
JSONObject data = JSONObject.parseObject(JSONArray.parseArray(cameraData.get("data").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
JSONObject dataChildren = JSONObject.parseObject(JSONArray.parseArray(data.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
JSONObject qiLuGaoSu = JSONObject.parseObject(JSONArray.parseArray(dataChildren.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
JSONObject jiHeYunGuan = JSONObject.parseObject(JSONArray.parseArray(qiLuGaoSu.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
JSONArray jiHeYunGuanG35 = JSONArray.parseArray(jiHeYunGuan.get("children").toString());
// JSONObject data = JSONObject.parseObject(JSONArray.parseArray(cameraData.get("data").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
// JSONObject dataChildren = JSONObject.parseObject(JSONArray.parseArray(data.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
// JSONObject qiLuGaoSu = JSONObject.parseObject(JSONArray.parseArray(dataChildren.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
// JSONObject jiHeYunGuan = JSONObject.parseObject(JSONArray.parseArray(qiLuGaoSu.get("children").toString()).get(UniversalEnum.ZERO.getNumber()).toString());
// JSONArray jiHeYunGuanG35 = JSONArray.parseArray(jiHeYunGuan.get("children").toString());
JSONArray data = cameraData.getJSONArray("data");
JSONObject children = data.getJSONObject(0);
JSONArray jsonObject = children.getJSONArray("children");
JSONObject jsonObjectValue = jsonObject.getJSONObject(0);//济菏+德幸
JSONArray array = jsonObjectValue.getJSONArray("children");
JSONObject object = array.getJSONObject(0);//收费站
JSONArray jsonArray = object.getJSONArray("children");
JSONArray objects = new JSONArray();
jsonArray.forEach(item->{
JSONObject cameraInfo = (JSONObject) item;
if (cameraInfo.containsKey("children")) {
JSONArray cameraInfoJSONArray = cameraInfo.getJSONArray("children");
for (int i = 0; i < cameraInfoJSONArray.size(); i++){
JSONObject camObject = cameraInfoJSONArray.getJSONObject(i);
objects.add(camObject);
}
}
});
JSONObject arrayJSONObject = array.getJSONObject(1);//扩建
JSONArray jiHeYunGuanG35 = arrayJSONObject.getJSONArray("children");
List<DcDevice> list = new ArrayList<>();
for (Object json : jiHeYunGuanG35) {
JSONObject item = JSONObject.parseObject(json.toString());
@ -216,7 +274,17 @@ public class VideoController extends BaseController {
device.setIotDeviceId(item.get("camId").toString());
list.add(device);
}
for (Object json : objects) {
JSONObject item = JSONObject.parseObject(json.toString());
DcDevice device = new DcDevice();
if (item.get("status").equals(UniversalEnum.ZERO.getValue())) {
device.setDeviceState(UniversalEnum.ONE.getValue());
} else {
device.setDeviceState(UniversalEnum.ZERO.getValue());
}
device.setIotDeviceId(item.get("camId").toString());
list.add(device);
}
iDcDeviceService.batchUpdate(list);
//更新中间库的设备状态
@ -822,7 +890,6 @@ public class VideoController extends BaseController {
return getJsonResult(response,okHttp);
}
/**
* 判断是否是附近桩号
*
@ -852,5 +919,4 @@ public class VideoController extends BaseController {
int meter = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
return kilometer * UniversalEnum.THOUSAND.getNumber() + meter;
}
}

4
zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java

@ -35,4 +35,8 @@ public interface DcDeviceMapper extends BaseMapper<DcDevice> {
int selectDeviceNumber();
public List<Map<String,Object>> selectDeviceOfRoad();
//收费站摄像头
List<DcDevice> selectDeviceTollStationCamera();
//同步收费站摄像头状态
Integer updateTollStationCameraStatus(DcDevice dcDevice);
}

8
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -7,6 +7,8 @@ import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcStakeMark;
import com.zc.common.core.httpclient.exception.HttpException;
import io.swagger.v3.oas.models.security.SecurityScheme;
import sun.reflect.generics.tree.VoidDescriptor;
import java.io.IOException;
import java.util.HashMap;
@ -120,4 +122,10 @@ public interface IDcDeviceService extends IService<DcDevice> {
public List<HashMap<String,Object>> selectDeviceParameterProperties(DcDevice dcDevice);
AjaxResult getDeviceByIotDeviceId(String iotDeviceId) throws HttpException, IOException;
//查询收费站摄像头
List<DcDevice> selectDeviceTollStationCamera();
//同步收费站摄像头状态
Integer updateTollStationCameraStatus(DcDevice dcDevice);
}

12
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -638,9 +638,21 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
public List<Map<String, Object>> selectDeviceOfRoad() {
return dcDeviceMapper.selectDeviceOfRoad();
}
//查询收费站摄像头
@Override
public List<DcDevice> selectDeviceTollStationCamera() {
return dcDeviceMapper.selectDeviceTollStationCamera();
}
@Override
public Integer updateTollStationCameraStatus(DcDevice dcDevice) {
return dcDeviceMapper.updateTollStationCameraStatus(dcDevice);
}
}

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

@ -72,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, 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.device_state,t1.other_config,t1.remark,
@ -181,5 +182,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
JOIN dc_stake_mark s ON s.stake_mark = d.stake_mark AND s.direction = d.direction
JOIN dc_road_section r ON r.id = s.section_id
</select>
<select id="selectDeviceTollStationCamera" resultType="com.zc.business.domain.DcDevice">
select id,iot_device_id from dc_device where facilities_type=5
</select>
<update id="updateTollStationCameraStatus">
update dc_device set device_state=#{deviceState} where id=#{id}
</update>
</mapper>

Loading…
Cancel
Save