|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|