123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- package com.css.simulation.resource.util;
- import api.common.pojo.constants.DictConstants;
- import api.common.pojo.param.project.SimulationManualProjectParam;
- import api.common.pojo.po.project.SchedulerProjectPO;
- import api.common.pojo.po.project.SimulationManualProjectPo;
- import api.common.util.CollectionUtil;
- import api.common.util.StringUtil;
- import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
- import com.css.simulation.resource.model.mapper.ModelConfigMapper;
- import com.css.simulation.resource.model.mapper.ModelVehicleMapper;
- import com.css.simulation.resource.project.mapper.AutoSubProjectMapper;
- import com.css.simulation.resource.project.mapper.ManualProjectMapper;
- import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
- import com.css.simulation.resource.scene.mapper.ScenePackageMapper;
- import com.css.simulation.resource.scene.mapper.ScenePackageSublistMapper;
- import com.css.simulation.resource.scene.mapper.ScoringRulesMapper;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Component;
- import javax.annotation.Resource;
- import java.util.List;
- @Component
- @Slf4j
- public class ProjectUtil {
- @Resource
- private ManualProjectMapper manualProjectMapper;
- @Resource
- private AutoSubProjectMapper autoSubProjectMapper;
- @Resource
- private SimulationProjectMapper simulationProjectMapper;
- @Resource
- private ScenePackageMapper scenePackageMapper;
- @Resource
- private AlgorithmMapper algorithmMapper;
- @Resource
- private ScoringRulesMapper scoringRulesMapper;
- @Resource
- private ModelConfigMapper modelConfigMapper;
- @Resource
- private ModelVehicleMapper modelVehicleMapper;
- @Resource
- private ScenePackageSublistMapper scenePackageSublistMapper;
- public String getProjectTypeByProjectId(String projectId) {
- String projectType = null;
- SchedulerProjectPO manualProjectPO = manualProjectMapper.selectById(projectId);
- SchedulerProjectPO autoSubProjectPO = autoSubProjectMapper.selectById(projectId);
- if (manualProjectPO != null) {
- projectType = DictConstants.PROJECT_TYPE_MANUAL;
- } else if (autoSubProjectPO != null) {
- projectType = DictConstants.PROJECT_TYPE_AUTO_SUB;
- }
- return projectType;
- }
- public static String getEvaluationLevelReport(double algorithmScore) {
- if (algorithmScore >= 90) {
- return DictConstants.REPORT_LEVEL_G;
- } else if (algorithmScore >= 80) {
- return DictConstants.REPORT_LEVEL_A;
- } else if (algorithmScore >= 70) {
- return DictConstants.REPORT_LEVEL_M;
- } else {
- return DictConstants.REPORT_LEVEL_P;
- }
- }
- public SimulationManualProjectPo getProjectInfo(SimulationManualProjectParam param) {
- if (StringUtil.isEmpty(param.getId()) || StringUtil.isEmpty(param.getNowRunState())) {
- throw new RuntimeException("参数为空。");
- } else {
- SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
- if (po == null) {
- throw new RuntimeException("手动项目" + param.getId() + "不存在。");
- }
- return po;
- }
- }
- public void checkProject(String algorithmId, String vehicleConfigId, String scenePackageId) {
- //1 检查算法是否被删除
- if (DictConstants.IS_DELETED.equals(algorithmMapper.selectIsDeletedById(algorithmId))) {
- throw new RuntimeException("项目所使用算法已被删除。");
- }
- //2 查询车辆配置是否被删除。
- if (DictConstants.IS_DELETED.equals(modelConfigMapper.selectIsDeletedByConfigId(vehicleConfigId))) {
- throw new RuntimeException("项目所使用的车辆配置已被删除。");
- }
- //3 查询车辆配置中是否存在车辆模型。
- final List<String> vehicles = modelVehicleMapper.selectIsDeletedByConfigId(scenePackageId);
- if (CollectionUtil.isNotEmpty(vehicles)) {
- throw new RuntimeException("项目所使用的车辆配置不存在动力学配置。");
- }
- //4 查询场景测试包是否被禁用。
- String isUnavailable = scenePackageMapper.selectIsUnavailableByPackageId(scenePackageId);
- if (DictConstants.SCENE_PACKAGE_UNAVAILABLE.equals(isUnavailable)) {
- throw new RuntimeException("场景测试包已被禁用,编辑场景测试包后可重新运行。");
- }
- // //5 查询评分规则是否被删除
- // final List<String> rules = scoringRulesMapper.selectDeletedRulesByPackageId(scenePackageId);
- // if (CollectionUtil.isNotEmpty(rules)) {
- // throw new RuntimeException("评分规则已被删除:" + rules);
- // }
- //6 查询场景测试包是否有场景
- final int sceneNum = scenePackageSublistMapper.selectSceneNumByPackageId(scenePackageId);
- if (sceneNum == 0) {
- throw new RuntimeException("场景测试包内的场景已被全部删除,请添加场景。");
- }
- }
- }
|