From e3fab15fddcc451dd397ca397540b194c8a5ba07 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Tue, 15 Oct 2024 10:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/VideoController.java | 56 ++++++++++++------- .../zc/business/mapper/DcDeviceMapper.java | 3 + .../zc/business/service/IDcDeviceService.java | 3 +- .../service/impl/DcDeviceServiceImpl.java | 5 ++ .../mapper/business/DcDeviceMapper.xml | 11 ++++ 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java index 8b0d1489..94cd2a9a 100644 --- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java +++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java @@ -99,8 +99,8 @@ public class VideoController extends BaseController { public AjaxResult synchronizeIotIds() { // 查询未同步物联ID的摄像头设备信息 LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(DcDevice::getDeviceType, DeviceTypeConstants.CAMERA) - .isNull(DcDevice::getIotDeviceId); + query.eq(DcDevice::getDeviceType, DeviceTypeConstants.CAMERA); +// .isNull(DcDevice::getIotDeviceId); List uninitializedCameras = iDcDeviceService.list(query); @@ -164,23 +164,23 @@ public class VideoController extends BaseController { // 遍历并更新具备匹配IP的摄像头设备物联ID List devicesToUpdate = new ArrayList<>(); camType1Array.forEach(item -> { - JSONObject cameraInfo = (JSONObject) item; - // 桩号 - String pileNum = cameraInfo.getString("pileNum"); - // 方向 - Integer camOrientation = cameraInfo.getInteger("camOrientation"); - LaneDirectionEnum laneDirectionEnum = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection(); - - // 是否有云台控制 0 有(球机) 1 ⽆(枪机) - String ptzCtrl = cameraInfo.getString("ptzCtrl"); - - String key = pileNum + UniversalEnum.VERTICAL_LINE.getValue() + laneDirectionEnum.getValue() + UniversalEnum.VERTICAL_LINE.getValue() + ptzCtrl; - - if (cameraMap.containsKey(key)) { - DcDevice dcDevice = cameraMap.get(key); - dcDevice.setIotDeviceId(cameraInfo.getString("camId")); - devicesToUpdate.add(dcDevice); - } + JSONObject cameraInfo = (JSONObject) item; + // 桩号 + String pileNum = cameraInfo.getString("pileNum"); + // 方向 + int camOrientation = Integer.valueOf(cameraInfo.getString("camOrientation")); + LaneDirectionEnum laneDirectionEnum = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection(); + + // 是否有云台控制 0 有(球机) 1 ⽆(枪机) + String ptzCtrl = cameraInfo.getString("ptzCtrl"); + + String key = pileNum + UniversalEnum.VERTICAL_LINE.getValue() + laneDirectionEnum.getValue() + UniversalEnum.VERTICAL_LINE.getValue() + ptzCtrl; + + if (cameraMap.containsKey(key)) { + DcDevice dcDevice = cameraMap.get(key); + dcDevice.setIotDeviceId(cameraInfo.getString("camId")); + devicesToUpdate.add(dcDevice); + } }); // 批量更新摄像头设备的物联ID @@ -235,7 +235,7 @@ public class VideoController extends BaseController { /*** * 根据相机中的设备状态,修改数据平台设备的设备状态 */ - @Scheduled(cron = "0 0/5 * * * ?") + //@Scheduled(cron = "0 0/5 * * * ?") @PostMapping("/updateDeviceState") public void updateDeviceState() throws HttpException, IOException { logger.debug("开始执行:同步数据平台视频设备设备的设备状态!!"); @@ -246,6 +246,7 @@ public class VideoController extends BaseController { // 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"); @@ -292,6 +293,7 @@ public class VideoController extends BaseController { // device.setIotDeviceId(item.get("camId").toString()); // list.add(device); // } + iDcDeviceService.batchUpdate(list); //更新中间库的设备状态 @@ -526,7 +528,21 @@ public class VideoController extends BaseController { return AjaxResult.success(result); } + /** + * 根据桩号查询附近收费站摄像机 + */ + @ApiOperation("根据桩号查询附近收费站摄像机") + @GetMapping(value = "/tollStationList") + public Object selectTollStationCamPile(@ApiParam(value = "桩号", name = "pileNum", required = true) String pileNum) throws HttpException, IOException { + Map result = new HashMap<>(); + Integer pileNumDistance = pileNumTransformMetre(pileNum); + String startMileage = String.valueOf(pileNumDistance - UniversalEnum.TWO_THOUSAND.getNumber()); + String endMileage = String.valueOf(pileNumDistance + UniversalEnum.TWO_THOUSAND.getNumber()); + List tollStationList = iDcDeviceService.selectTollStationCamPile(UniversalEnum.THREE.getValue(),startMileage,endMileage); + result.put("tollStationList",tollStationList); + return AjaxResult.success(result); + } /** * 获取视频流信息 */ diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java index 9c28ea5f..f1e845dc 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java @@ -39,4 +39,7 @@ public interface DcDeviceMapper extends BaseMapper { List selectDeviceTollStationCamera(); //同步收费站摄像头状态 Integer updateTollStationCameraStatus(DcDevice dcDevice); + + //获取收费站摄像头 + List selectTollStationCamPile(@Param("direction") String direction,@Param("startMileage") String startMileage,@Param("endMileage") String endMileage); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java index c23145d1..fe5f8fb4 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java @@ -127,5 +127,6 @@ public interface IDcDeviceService extends IService { List selectDeviceTollStationCamera(); //同步收费站摄像头状态 Integer updateTollStationCameraStatus(DcDevice dcDevice); - + //获取附近收费站摄像头 + List selectTollStationCamPile(String direction, String startMileage, String endMileage); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index a9fc7693..3d6cd0f0 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -654,5 +654,10 @@ public class DcDeviceServiceImpl extends ServiceImpl i public Integer updateTollStationCameraStatus(DcDevice dcDevice) { return dcDeviceMapper.updateTollStationCameraStatus(dcDevice); } + //获取附近收费站摄像头 + @Override + public List selectTollStationCamPile(String direction, String startMileage, String endMileage) { + return dcDeviceMapper.selectTollStationCamPile(direction, startMileage, endMileage); + } } diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml index 3b8ed357..45d28fa9 100644 --- a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml @@ -185,7 +185,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + update dc_device set device_state=#{deviceState} where id=#{id} +