package com.css.simulation.resource.server.infra.db.mysql.mapper;

import api.common.pojo.param.project.SimulationManualProjectParam;
import api.common.pojo.po.algorithm.AlgorithmPO;
import api.common.pojo.po.model.ConfigPO;
import api.common.pojo.po.model.ConfigSensorPO;
import api.common.pojo.po.model.VehiclePO;
import api.common.pojo.po.project.SimulationManualProjectPO;
import api.common.pojo.po.project.SimulationMptFirstTargetScorePO;
import api.common.pojo.po.project.SimulationMptLastTargetScorePO;
import api.common.pojo.po.scene.ScenePackagePO;
import api.common.pojo.vo.project.*;
import com.css.simulation.resource.server.infra.db.entity.SimulationManualProjectEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SimulationManualProjectMapper {

    int add(SimulationManualProjectPO po);

    int update(SimulationManualProjectPO po);

//    SimulationManualProjectPO selectLastProjectId(@Param("nowRq") Integer nowRq,@Param("createUserId") String createUserId);
    SimulationManualProjectPO selectLastProjectId(@Param("nowRq") Integer nowRq);

    List<SimulationManualProjectPO> selectProject(SimulationManualProjectParam param);

    List<SimulationManualProjectVO> selectProjectList(SimulationManualProjectParam param);

    SimulationManualProjectPO selectProjectById(SimulationManualProjectParam param);

    List<SimulationManualProjectPO> selectProjectByName(SimulationManualProjectParam param);

    SimulationManualProjectPO selectProjectBaseById(SimulationManualProjectParam param);


    int deleteProject(String[] ids);

    int updateProjectNowRunState(SimulationManualProjectParam param);

    List<AlgorithmPO> selectAlgorithmBaseInfoById(AlgorithmPO algorithmPO);

    List<AlgorithmPO> selectAlgorithmBaseInfoByIdGy(AlgorithmPO algorithmPO);

    List<AlgorithmPO> selectAlgorithmBaseInfoByIdSy(AlgorithmPO algorithmPO);

    @Select("select id, algorithm_name, description\n" +
            "        from algorithm\n" +
            "        where id = #{algorithmId}")
    AlgorithmPO selectAlgorithmInfoById(@Param("algorithmId") String algorithmId);

    @Select("select id, algorithm_name, description\n" +
        "        from algorithm\n" +
        "        where id = #{algorithmId} and is_deleted = 0")
    AlgorithmPO selectAvailableAlgorithmById(@Param("algorithmId") String algorithmId);

    List<VehiclePO> selectVehicleBaseInfoById(String id);

    List<ScenePackagePO> selectScenePackageBaseById(ScenePackagePO scenePackagePO);

    List<ScenePackagePO> selectScenePackageBaseByIdGy(ScenePackagePO scenePackagePO);

    List<ScenePackagePO> selectScenePackageBaseByIdSy(ScenePackagePO scenePackagePO);

    ScenePackagePO selectScenePackageInfoById(String id);

    List<ConfigSensorPO> selectVehicleSensor(String id);

    SensorBaseInfoVo selectSensorCamera(String id);

    SensorBaseInfoVo selectSensorOgt(String id);

    SensorBaseInfoVo selectSensorLidar(String id);

    SensorBaseInfoVo selectSensorRadar(String id);

    SensorBaseInfoVo selectSensorGps(String id);

    SceneBaseInfoVo selectSceneAccidentById(String id);

    SceneBaseInfoVo selectSceneNatural(String id);

    SceneBaseInfoVo selectSceneGeneralDataById(String id);

    SceneBaseInfoVo selectSceneReferenceLibDataById(String id);

    SceneBaseInfoVo selectSceneStandardsRegulations(String id);

    List<ScenePackageSubListVO> selectSubSceneByPid(String id);

    ScenePackageSubListVO selectsublistBySublistId(String id);

    List<ScenePackageSubListVO> selectSubListByPid(String id);

    List<SublistScoreVo> selectSublistByRootId(SimulationManualProjectParam param);

    int insertSimulationMptLastTargetScorePo(SimulationMptLastTargetScorePO po);

    int insertSimulationMptFirstTargetScorePo(SimulationMptFirstTargetScorePO po);


    SystemUserVo selectUserById(String id);

    List<ConfigPO> selectConfigVehicle(ConfigPO configPO);

    List<ConfigPO> selectConfigVehicle2(ConfigPO configPO);

    List<ConfigPO> selectConfigVehicleGy(ConfigPO configPO);

    List<ConfigPO> selectConfigVehicleSy(ConfigPO configPO);

    @Select("select id,config_name from model_config where id = #{id} and is_deleted = 0 and is_unavailable = 0")
    ConfigPO selectConfigVehicleById(@Param("id") String id);

    List<ConfigSensorPO> selectConfigSensor(String id);

    List<SimulationManualProjectPO> selectProjectNowRunState(String[] ids);

    List<SublistScoreVo> selectSubScore(SimulationManualProjectParam param);

    List<SublistScoreVo> selectSubScore2(SimulationManualProjectParam param);

    List<Map<String, Object>> selectRunProjectByState(@Param("createUserId") String createUserId);

    List<Map<String, Object>> selectEvaluationLevel(Map map);

    int insertOtherAlgorithm(AlgorithmPO po);

    int updateOtherAlgorithm(AlgorithmPO po);

    AlgorithmPO selectAlgorithmByQuery(AlgorithmPO po);

    String selectLastProjectIdByAlgorithmId(String algorithmId);

    @Update("update simulation_manual_project\n" +
            "set details = #{details},now_run_state = #{nowRunState}\n" +
            "where id = #{id}")
    void updateDetailsAndNowRunStateById(@Param("id") String id, @Param("details") String details, @Param("nowRunState") String nowRunState);

    @Update("update simulation_manual_project\n" +
            "set id = #{newId}, details = #{details},now_run_state = #{nowRunState}\n" +
            "where id = #{oldId}")
    void updateIdAndDetailsAndNowRunStateById(@Param("oldId") String oldId, @Param("newId") String newId, @Param("details") String details, @Param("nowRunState") String nowRunState);


    @Select("select report from simulation_manual_project where id = #{id}")
    String selectReportById(@Param("id") String id);

    String selectAlgorithmTypeById(SimulationManualProjectEntity build);

    String selectAlgorithmById(SimulationManualProjectEntity build);
}
