|
@@ -26,6 +26,7 @@ import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.feign.AlgoPlatformService;
|
|
import com.css.simulation.resource.feign.AlgoPlatformService;
|
|
import com.css.simulation.resource.feign.FileDownService;
|
|
import com.css.simulation.resource.feign.FileDownService;
|
|
import com.css.simulation.resource.feign.MonitorService;
|
|
import com.css.simulation.resource.feign.MonitorService;
|
|
|
|
+import com.css.simulation.resource.model.mapper.VehicleMapper;
|
|
import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
@@ -73,95 +74,81 @@ import java.util.zip.ZipOutputStream;
|
|
public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
@Resource(name = "myKafkaAdmin")
|
|
@Resource(name = "myKafkaAdmin")
|
|
- Admin kafkaAdminClient;
|
|
|
|
|
|
+ private Admin kafkaAdminClient;
|
|
@Resource
|
|
@Resource
|
|
- SimulationProjectMapper simulationProjectMapper;
|
|
|
|
|
|
+ private SimulationProjectMapper simulationProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
- ManualProjectMapper manualProjectMapper;
|
|
|
|
|
|
+ private ManualProjectMapper manualProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
- AutoSubProjectMapper autoSubProjectMapper;
|
|
|
|
|
|
+ private AutoSubProjectMapper autoSubProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
- SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
|
|
|
|
|
|
+ private SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
- SimulationProjectTaskMapper simulationProjectTaskMapper;
|
|
|
|
|
|
+ private SimulationProjectTaskMapper simulationProjectTaskMapper;
|
|
@Resource
|
|
@Resource
|
|
- SimulationAutomaticSubProjectMapper simulationAutomaticSubProjectMapper;
|
|
|
|
|
|
+ private SimulationAutomaticSubProjectMapper simulationAutomaticSubProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
- SimulationMptFirstTargetScoreMapper simulationMptFirstTargetScoreMapper;
|
|
|
|
|
|
+ private SimulationMptFirstTargetScoreMapper simulationMptFirstTargetScoreMapper;
|
|
@Resource
|
|
@Resource
|
|
- SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
|
|
|
|
|
|
+ private SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
|
|
@Resource
|
|
@Resource
|
|
- AlgorithmMapper algorithmMapper;
|
|
|
|
-
|
|
|
|
|
|
+ private AlgorithmMapper algorithmMapper;
|
|
@Resource
|
|
@Resource
|
|
- KafkaTemplate<String, String> kafkaTemplate;
|
|
|
|
|
|
+ private KafkaTemplate<String, String> kafkaTemplate;
|
|
@Resource
|
|
@Resource
|
|
- DictService dictService;
|
|
|
|
-
|
|
|
|
|
|
+ private DictService dictService;
|
|
@Resource
|
|
@Resource
|
|
- AlgoPlatformService algoPlatformService;
|
|
|
|
-
|
|
|
|
|
|
+ private AlgoPlatformService algoPlatformService;
|
|
@Resource
|
|
@Resource
|
|
- FileDownService fileDownService;
|
|
|
|
-
|
|
|
|
|
|
+ private FileDownService fileDownService;
|
|
@Resource
|
|
@Resource
|
|
- AlgorithmService algorithmService;
|
|
|
|
|
|
+ private AlgorithmService algorithmService;
|
|
@Resource
|
|
@Resource
|
|
- MonitorService monitorService;
|
|
|
|
|
|
+ private MonitorService monitorService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ProjectUtil projectUtil;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- ProjectUtil projectUtil;
|
|
|
|
|
|
+ private VehicleMapper vehicleMapper;
|
|
|
|
|
|
//* -------------------------------- Comment --------------------------------
|
|
//* -------------------------------- Comment --------------------------------
|
|
|
|
|
|
- private String[] dateFmtArr = new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"};
|
|
|
|
|
|
+ private final String[] dateFmtArr = new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"};
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseBodyVO<String> addOrUpdateProject(SimulationManualProjectParam param) {
|
|
public ResponseBodyVO<String> addOrUpdateProject(SimulationManualProjectParam param) {
|
|
|
|
|
|
if (isEmpty(param.getProjectName())) {
|
|
if (isEmpty(param.getProjectName())) {
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "工作名称不能为空");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "工作名称不能为空。");
|
|
}
|
|
}
|
|
SimulationManualProjectPo po = convertParamToPo(param);
|
|
SimulationManualProjectPo po = convertParamToPo(param);
|
|
|
|
|
|
if (isEmpty(param.getId())) {
|
|
if (isEmpty(param.getId())) {
|
|
-
|
|
|
|
- //工作名称一样的的不能创建
|
|
|
|
|
|
+ // 工作名称一样的的不能创建
|
|
List<SimulationManualProjectPo> simulationManualProjectPos = simulationProjectMapper.selectProjectByName(param);
|
|
List<SimulationManualProjectPo> simulationManualProjectPos = simulationProjectMapper.selectProjectByName(param);
|
|
if (!isEmpty(simulationManualProjectPos)) {
|
|
if (!isEmpty(simulationManualProjectPos)) {
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "工作名称已经存在,请修改后再保存");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "工作名称已经存在,请修改后再保存。");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
po.createPo(AuthUtil.getCurrentUserId());
|
|
po.createPo(AuthUtil.getCurrentUserId());
|
|
- //生成id
|
|
|
|
|
|
+ // 生成id
|
|
createProjectId(po);
|
|
createProjectId(po);
|
|
-
|
|
|
|
int add = simulationProjectMapper.add(po);
|
|
int add = simulationProjectMapper.add(po);
|
|
if (add > 0) {
|
|
if (add > 0) {
|
|
- //第三方算法存到算发表(索为)
|
|
|
|
-// insertOtherAlgorithm(param);
|
|
|
|
-
|
|
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, ResponseBodyVO.Response.SUCCESS.getMessage(), po.getId());
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, ResponseBodyVO.Response.SUCCESS.getMessage(), po.getId());
|
|
}
|
|
}
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "添加失败");
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "添加失败");
|
|
} else {
|
|
} else {
|
|
- //TODO 删除逻辑有待商议
|
|
|
|
- //获取工作状态,仅未开始的才可以修改信息
|
|
|
|
|
|
+ // 取工作状态,仅未开始的才可以修改信息
|
|
SimulationManualProjectPo simulationManualProjectPo = simulationProjectMapper.selectProjectById(param);
|
|
SimulationManualProjectPo simulationManualProjectPo = simulationProjectMapper.selectProjectById(param);
|
|
if (!ProjectRunStateEnum.NOT_START.getCode().equals(simulationManualProjectPo.getNowRunState())) {
|
|
if (!ProjectRunStateEnum.NOT_START.getCode().equals(simulationManualProjectPo.getNowRunState())) {
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "当前状态不支持修改。");
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "当前状态不支持修改。");
|
|
}
|
|
}
|
|
-
|
|
|
|
po.updatePo(AuthUtil.getCurrentUserId());
|
|
po.updatePo(AuthUtil.getCurrentUserId());
|
|
int update = simulationProjectMapper.update(po);
|
|
int update = simulationProjectMapper.update(po);
|
|
if (update > 0) {
|
|
if (update > 0) {
|
|
- //第三方算法存到算发表(索为)
|
|
|
|
-// insertOtherAlgorithm(param);
|
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, ResponseBodyVO.Response.SUCCESS.getMessage(), po.getId());
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, ResponseBodyVO.Response.SUCCESS.getMessage(), po.getId());
|
|
}
|
|
}
|
|
-
|
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "修改失败");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "修改失败。");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -209,7 +196,6 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
//查询有效数据
|
|
//查询有效数据
|
|
param.setIsDeleted("0");
|
|
param.setIsDeleted("0");
|
|
-
|
|
|
|
setPage(param.getCurrentPage() == null ? 1 : param.getCurrentPage(), param.getPageSize() == null ? 10 : param.getPageSize());
|
|
setPage(param.getCurrentPage() == null ? 1 : param.getCurrentPage(), param.getPageSize() == null ? 10 : param.getPageSize());
|
|
List<SimulationManualProjectVo> vos = simulationProjectMapper.selectProjectList(param); // 查出来的 algorithm 字段内容是算法 id
|
|
List<SimulationManualProjectVo> vos = simulationProjectMapper.selectProjectList(param); // 查出来的 algorithm 字段内容是算法 id
|
|
PageInfo<SimulationManualProjectVo> pageInfo = new PageInfo<>(vos);
|
|
PageInfo<SimulationManualProjectVo> pageInfo = new PageInfo<>(vos);
|
|
@@ -240,11 +226,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseBodyVO deleteProjectByids(SimulationManualProjectParam param) {
|
|
|
|
|
|
+ public ResponseBodyVO<String> deleteProjectByids(SimulationManualProjectParam param) {
|
|
|
|
|
|
String ids = param.getIds();
|
|
String ids = param.getIds();
|
|
if (isEmpty(ids)) {
|
|
if (isEmpty(ids)) {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
}
|
|
}
|
|
|
|
|
|
String[] idArr = ids.split(",");
|
|
String[] idArr = ids.split(",");
|
|
@@ -253,16 +239,16 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
List<SimulationManualProjectPo> pos = simulationProjectMapper.selectProjectNowRunState(idArr);
|
|
List<SimulationManualProjectPo> pos = simulationProjectMapper.selectProjectNowRunState(idArr);
|
|
for (SimulationManualProjectPo p : pos) {
|
|
for (SimulationManualProjectPo p : pos) {
|
|
if (ProjectRunStateEnum.EXECUTION.getCode().equals(p.getNowRunState())) {
|
|
if (ProjectRunStateEnum.EXECUTION.getCode().equals(p.getNowRunState())) {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "数据不支持删除。");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "数据不支持删除。");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int i = simulationProjectMapper.deleteProject(idArr);
|
|
int i = simulationProjectMapper.deleteProject(idArr);
|
|
if (i > 0) {
|
|
if (i > 0) {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "删除失败。");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "删除失败。");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -335,36 +321,40 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
- private void projectRunToKafka(SimulationManualProjectPo po) throws JsonProcessingException {
|
|
|
|
- SimulationManualProjectKafkaParam kafkaParam = new SimulationManualProjectKafkaParam();
|
|
|
|
- kafkaParam.setProjectId(po.getId());
|
|
|
|
- kafkaParam.setAlgorithmId(po.getAlgorithm());
|
|
|
|
- kafkaParam.setVehicleConfigId(po.getVehicle());
|
|
|
|
- kafkaParam.setScenePackageId(po.getScene());
|
|
|
|
- kafkaParam.setMaxSimulationTime(po.getMaxSimulationTime());
|
|
|
|
- kafkaParam.setParallelism(Integer.valueOf(po.getParallelism()));
|
|
|
|
- kafkaParam.setType(DictConstants.PROJECT_TYPE_MANUAL);
|
|
|
|
- KafkaParameter kafkaParameter = new KafkaParameter();
|
|
|
|
- kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
|
|
|
|
- String data = JsonUtil.beanToJson(kafkaParam);
|
|
|
|
- kafkaParameter.setData(data);
|
|
|
|
- log.info("推送项目运行消息到kafka:" + data);
|
|
|
|
-// kafkaService.send(kafkaParameter);
|
|
|
|
- kafkaTemplate.send(kafkaParameter.getTopic(), kafkaParameter.getData()).addCallback(success -> {
|
|
|
|
- // 消息发送到的topic
|
|
|
|
- String topic = success.getRecordMetadata().topic();
|
|
|
|
- // 消息发送到的分区
|
|
|
|
- int partition = success.getRecordMetadata().partition();
|
|
|
|
- // 消息在分区内的offset
|
|
|
|
- long offset = success.getRecordMetadata().offset();
|
|
|
|
- log.info("------- 发送消息成功:\n"
|
|
|
|
- + "主题 topic 为:" + topic + "\n"
|
|
|
|
- + "分区 partition 为:" + partition + "\n"
|
|
|
|
- + "偏移量为:" + offset + "\n"
|
|
|
|
- + "消息体为:" + kafkaParameter.getData());
|
|
|
|
- }, failure -> {
|
|
|
|
- log.error("发送消息失败:" + failure.getMessage());
|
|
|
|
- });
|
|
|
|
|
|
+ private void projectRunToKafka(SimulationManualProjectPo po) {
|
|
|
|
+ try {
|
|
|
|
+ SimulationManualProjectKafkaParam kafkaParam = new SimulationManualProjectKafkaParam();
|
|
|
|
+ kafkaParam.setProjectId(po.getId());
|
|
|
|
+ kafkaParam.setAlgorithmId(po.getAlgorithm());
|
|
|
|
+ kafkaParam.setVehicleConfigId(po.getVehicle());
|
|
|
|
+ kafkaParam.setScenePackageId(po.getScene());
|
|
|
|
+ kafkaParam.setMaxSimulationTime(po.getMaxSimulationTime());
|
|
|
|
+ kafkaParam.setParallelism(Integer.valueOf(po.getParallelism()));
|
|
|
|
+ kafkaParam.setType(DictConstants.PROJECT_TYPE_MANUAL);
|
|
|
|
+ kafkaParam.setModelType(vehicleMapper.selectParameterTypeById(po.getVehicle()));
|
|
|
|
+ KafkaParameter kafkaParameter = new KafkaParameter();
|
|
|
|
+ kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
|
|
|
|
+ String data = JsonUtil.beanToJson(kafkaParam);
|
|
|
|
+ kafkaParameter.setData(data);
|
|
|
|
+ log.info("推送项目运行消息到kafka:" + data);
|
|
|
|
+ kafkaTemplate.send(kafkaParameter.getTopic(), kafkaParameter.getData()).addCallback(success -> {
|
|
|
|
+ // 消息发送到的topic
|
|
|
|
+ String topic = success.getRecordMetadata().topic();
|
|
|
|
+ // 消息发送到的分区
|
|
|
|
+ int partition = success.getRecordMetadata().partition();
|
|
|
|
+ // 消息在分区内的offset
|
|
|
|
+ long offset = success.getRecordMetadata().offset();
|
|
|
|
+ log.info("------- 发送消息成功:\n"
|
|
|
|
+ + "主题 topic 为:" + topic + "\n"
|
|
|
|
+ + "分区 partition 为:" + partition + "\n"
|
|
|
|
+ + "偏移量为:" + offset + "\n"
|
|
|
|
+ + "消息体为:" + kafkaParameter.getData());
|
|
|
|
+ }, failure -> {
|
|
|
|
+ log.error("发送消息失败:" + failure.getMessage());
|
|
|
|
+ });
|
|
|
|
+ } catch (NumberFormatException | JsonProcessingException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void projectStopToKafka(SimulationManualProjectPo po) throws JsonProcessingException {
|
|
private void projectStopToKafka(SimulationManualProjectPo po) throws JsonProcessingException {
|