package com.iplatform.recvideo.api; import com.iplatform.recvideo.config.VideoSimilarProperties; import com.iplatform.recvideo.service.VideoExecutorServiceImpl; import com.iplatform.recvideo.support.DefaultSimilarExecutor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestController @RequestMapping("/debug/video") public class DemoDebug { private RestTemplate restTemplate; private VideoSimilarProperties videoSimilarProperties; private VideoExecutorServiceImpl videoExecutorService; private DefaultSimilarExecutor similarExecutor = null; @Autowired public DemoDebug(RestTemplate restTemplate , VideoSimilarProperties videoSimilarProperties , VideoExecutorServiceImpl videoExecutorService){ this.restTemplate = restTemplate; this.videoSimilarProperties = videoSimilarProperties; this.videoExecutorService = videoExecutorService; } /** * 该测试用于模拟调度任务,每次调用一次执行器方法,批量处理一张图片数据。
* 最终完成一批多个视频的相似度检索并写入数据库中。 * @return * @date 2022-09-24 */ @RequestMapping("/test1") public String testSimilarExecutor(){ // String if(similarExecutor == null){ this.similarExecutor = new DefaultSimilarExecutor(); this.similarExecutor.setVideoExecutorService(this.videoExecutorService); this.similarExecutor.setRestTemplate(this.restTemplate); this.similarExecutor.setRemoteUrl(this.videoSimilarProperties.getAiService()); this.similarExecutor.startup(this.videoSimilarProperties.getDataFolder() , "20220921", this.videoSimilarProperties.getTopN(), true); // 注意:这里测试模式 } try { this.similarExecutor.execute(); return "成功执行一次"; } catch (Exception e) { throw new RuntimeException(e); } } }