zhanghua
2023-12-12 bc2da7908a227c09e5cc7b6d8dab3e9c94b784a1
ycl-platform/src/main/java/com/ycl/task/SynchronizeHKVideo.java
@@ -25,27 +25,30 @@
    @Autowired
    private VideoUtil videoUtil;
    @Scheduled(cron = "0/1 * * * * ?")   // 每秒执行
//    @Scheduled(cron = "0 0/1 * ?")
//    @Scheduled(cron = "0 */5 * * * ?")   // 每5分钟执行
    @Scheduled(cron = "0 0 1 * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void scheduledTask() {
        try {
            findVideoList(1, 20);
        } catch (Exception ex) {
//        System.out.println("海康:开始执行");
        }
        findVideoList(1, 5);
    }
    private void findVideoList(Integer pageNo, Integer pageSize) throws Exception {
        PageResult<Camera> pageResult = videoUtil.callPostCameras(pageNo, pageSize, "0");
        if (pageResult.getTotal() > 0) {
            if (pageResult.getList().size() > 0) {
                saveVideoFromCamera(pageResult.getList());
    private void findVideoList(Integer pageNo, Integer pageSize) {
        try {
            PageResult<Camera> pageResult = videoUtil.callPostCameras(pageNo, pageSize, "0");
            if (pageResult.getTotal() > 0) {
                if (pageResult.getList().size() > 0) {
                    saveVideoFromCamera(pageResult.getList());
                if (pageResult.getList().size() >= pageSize) {
                    findVideoList(pageNo + 1, pageSize);
                    if (pageResult.getList().size() >= pageSize) {
                        findVideoList(pageNo + 1, pageSize);
                    }
                }
            }
        } catch (Exception ex) {
            System.out.println("海康:" + ex.getMessage());
        }
    }