package com.css.simulation.resource.server.app.service.job_manage;

import api.common.pojo.param.project.SimulationManualProjectParam;
import api.common.pojo.vo.project.ProjectReportVO;
import api.common.util.StringUtil;
import com.css.simulation.resource.server.domain.service.ProjectDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class JobManageApplicationService {

    @Resource
    private ProjectDomainService projectDomainService;

    public ProjectReportVO getLastProjectReportByAlgorithmId(String algorithmId) {
        //1 获取最新的项目ID
        String projectId = projectDomainService.getLastProjectIdByAlgorithmId(algorithmId);
        if (StringUtil.isEmpty(projectId)) {
//            log.warn("算法 "+ algorithmId+"还未执行过项目。");
            return null;
        }
        String projectType = projectDomainService.getProjectTypeByProjectId(projectId);

        //2 获取报告详情
        return projectDomainService.getProjectReport(SimulationManualProjectParam.builder()
                .id(projectId)
                .projectType(projectType)
                .build());
    }

    public List<String> getLastVideoListByAlgorithmId(String algorithmId) {
        String projectId = projectDomainService.getLastProjectIdByAlgorithmId(algorithmId);
        if (StringUtil.isEmpty(projectId)) {
            return null;
        }
        String projectType = projectDomainService.getProjectTypeByProjectId(projectId);

//        return projectDomainService.getVideoList(SimulationManualProjectParam.builder()
//                .id(projectId)
//                .projectType(projectType)
//                .build());
        return projectDomainService.getVideoListV20240301(SimulationManualProjectParam.builder()
                .id(projectId)
                .projectType(projectType)
                .build());

    }

}
