shikeying
2022-10-11 2b1f542577dd8dfc54d3433dff3615796ceab0af
recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java
@@ -18,6 +18,36 @@
    private static final transient Logger logger = LoggerFactory.getLogger(PythonInvokeUtils.class);
    public static boolean postLoadVideoGather(String batchId, String url, RestTemplate restTemplate) throws Exception{
        LoadRequest request = new LoadRequest();
        request.setDate(batchId);
        request.setFrame_rate("30");
        ResponseEntity<String> entity = restTemplate.postForEntity(url, request, String.class);
        if(entity == null){
            return false;
        }
        String jsonData = entity.getBody();
        try {
            Map<String, Object> map = JsonUtils.jsonStringToObject(jsonData, Map.class);
            if(map == null || !map.containsKey("code")){
                logger.error("python返回结果为空,或者没有code标志,无法判断调用加载视频成功!");
                return false;
            }
            String code = map.get("code").toString();
            if(code.equals("0")){
                logger.info("python notify_gather_once() 加载视频处理成功! batchId = " + batchId);
                return true;
            }
            logger.warn("python notify_gather_once() 加载视频处理失败, batchId = " + batchId);
            return false;
        } catch (Exception e) {
            logger.error("解析json结果错误:" + jsonData, e);
            throw e;
        }
    }
    public static List<Rc_video_t1> acquireImageSearchResult(String videoId, String imgPath
            , String topN, String url, RestTemplate restTemplate) throws Exception{
        SearchRequest request = new SearchRequest();
@@ -55,6 +85,8 @@
     * @return
     */
    public static final String getFileNameWithoutSuffix(String videoPath, String suffix){
        // 如果存在windows反斜杠,先转换成正斜杠。2022-10-11
        videoPath = videoPath.replaceAll("\\\\", StringUtils.FOLDER_SEPARATOR);
        String[] array = videoPath.split("/");
        if(array == null || array.length == 0){
            logger.error("视频名称截取id错误:" + videoPath);