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