Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-dc into develop

develop
lau572 8 months ago
parent
commit
a1ed063d2a
  1. 16
      zc-business/src/main/java/com/zc/business/controller/VideoController.java

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

@ -22,6 +22,7 @@ import io.swagger.annotations.ApiParam;
import okhttp3.Response; import okhttp3.Response;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -71,17 +72,15 @@ public class VideoController extends BaseController {
// 组织机构id // 组织机构id
private final static String CAM_DEPT_ID = "1301730"; private final static String CAM_DEPT_ID = "1301730";
@PostConstruct
public void init() {
synchronizeIotIds();
}
/** /**
* 同步物联网ID * 同步物联网ID
* 该方法用于查询未同步物联网ID的摄像头设备信息并从外部API获取这些设备的详细信息然后更新它们的物联网ID * 该方法用于查询未同步物联网ID的摄像头设备信息并从外部API获取这些设备的详细信息然后更新它们的物联网ID
* 该过程主要涉及查询未初始化物联网ID的摄像头构建设备IP与设备映射从API获取设备详细信息以及批量更新设备的物联网ID * 该过程主要涉及查询未初始化物联网ID的摄像头构建设备IP与设备映射从API获取设备详细信息以及批量更新设备的物联网ID
*/ */
public void synchronizeIotIds() { @ApiOperation("同步监控摄像设备ID")
@PatchMapping(value = "/sync/id")
public AjaxResult synchronizeIotIds() {
// 查询未同步物联ID的摄像头设备信息 // 查询未同步物联ID的摄像头设备信息
LambdaQueryWrapper<DcDevice> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DcDevice> query = new LambdaQueryWrapper<>();
query.eq(DcDevice::getDeviceType, DeviceTypeConstants.CAMERA) query.eq(DcDevice::getDeviceType, DeviceTypeConstants.CAMERA)
@ -90,7 +89,7 @@ public class VideoController extends BaseController {
List<DcDevice> uninitializedCameras = iDcDeviceService.list(query); List<DcDevice> uninitializedCameras = iDcDeviceService.list(query);
if (uninitializedCameras.isEmpty()) { if (uninitializedCameras.isEmpty()) {
return; // 若无待同步设备,则直接返回 return AjaxResult.success("没有需要同步的设备"); // 若无待同步设备,则直接返回
} }
// 将未初始化的摄像头列表转换为Map,以设备的桩号、方向和子类型拼接作为键,设备本身作为值 // 将未初始化的摄像头列表转换为Map,以设备的桩号、方向和子类型拼接作为键,设备本身作为值
@ -109,7 +108,7 @@ public class VideoController extends BaseController {
JSONObject camApiResponse = getCamByDept(CAM_DEPT_ID); JSONObject camApiResponse = getCamByDept(CAM_DEPT_ID);
if (camApiResponse == null || !camApiResponse.containsKey("data")) { if (camApiResponse == null || !camApiResponse.containsKey("data")) {
return; // 如果获取信息失败或不含有效数据,直接返回 return AjaxResult.error("根据组织机构获取摄像机信息失败"); // 如果获取信息失败或不含有效数据,直接返回
} }
JSONArray camDataArray = camApiResponse.getJSONArray("data"); JSONArray camDataArray = camApiResponse.getJSONArray("data");
@ -138,9 +137,12 @@ public class VideoController extends BaseController {
// 批量更新摄像头设备的物联ID // 批量更新摄像头设备的物联ID
iDcDeviceService.updateBatchById(devicesToUpdate); iDcDeviceService.updateBatchById(devicesToUpdate);
return AjaxResult.success("同步物联ID成功", devicesToUpdate);
} catch (Exception e) { } catch (Exception e) {
logger.error("获取摄像头信息失败!", e); logger.error("获取摄像头信息失败!", e);
} }
return AjaxResult.error("同步物联ID失败");
} }
/** /**

Loading…
Cancel
Save