root 2 anos atrás
pai
commit
18dc3eba9c

+ 1 - 1
api-common/src/main/java/api/common/pojo/dto/ProjectMessageDTO.java

@@ -23,12 +23,12 @@ import lombok.NoArgsConstructor;
 public class ProjectMessageDTO {
 
     private String projectId;// 项目 id
-    private String modelType;// vtd carsim
     private String algorithmId;// 算法 id
     private String vehicleConfigId;// 车辆配置 id
     private String scenePackageId;// 场景包 id
     private Integer maxSimulationTime;// 最大仿真时间(秒)
     private Integer parallelism;// 期望并行度,页面上创建项目时指定的并行度
+    private String modelType;// vtd carsim
     private String type;// 项目类型
     // -------------------------------- Comment --------------------------------
     private Integer currentParallelism;// 当前正在使用的并行度

+ 1 - 0
api-common/src/main/java/api/common/pojo/po/model/VehiclePO.java

@@ -147,6 +147,7 @@ public class VehiclePO extends CommonPO {
     private String relationCurveRightWheelAngleAndSteeringGearOutputJson;//右轮转角与转向器输出的关系
     private List<List<String>> relationCurveLeftWheelAngleAndSteeringGearOutput;//左轮转角与转向器输出的关系
     private String relationCurveLeftWheelAngleAndSteeringGearOutputJson;//左轮转角与转向器输出的关系
+    private String driverType;  // 驱动类型
     private String parFilePath;
 
 }

+ 2 - 0
api-common/src/main/java/api/common/pojo/po/project/SimulationManualProjectPo.java

@@ -2,12 +2,14 @@ package api.common.pojo.po.project;
 
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 import java.util.Date;
 
 /**
  * 运行项目数据
  */
+@ToString
 @Getter
 @Setter
 public class SimulationManualProjectPo extends BasePo {

+ 2 - 0
api-common/src/main/java/api/common/pojo/vo/model/VehicleVO.java

@@ -153,4 +153,6 @@ public class VehicleVO {
     private String relationCurveRightWheelAngleAndSteeringGearOutputJson;//右轮转角与转向器输出的关系
     private List<List<String>> relationCurveLeftWheelAngleAndSteeringGearOutput;//左轮转角与转向器输出的关系
     private String relationCurveLeftWheelAngleAndSteeringGearOutputJson;//左轮转角与转向器输出的关系
+
+    private String driverType;  // 驱动类型
 }

+ 38 - 43
simulation-resource-common/src/main/java/com/css/simulation/resource/common/controller/MinioController.java

@@ -10,7 +10,6 @@ import com.css.simulation.resource.common.configuration.minio.MinioConfiguration
 import com.css.simulation.resource.common.configuration.minio.SubMinioClient;
 import com.css.simulation.resource.common.util.MinioUtil;
 import io.minio.CreateMultipartUploadResponse;
-import io.minio.GetPresignedObjectUrlArgs;
 import io.minio.ListPartsResponse;
 import io.minio.errors.*;
 import io.minio.http.Method;
@@ -39,9 +38,6 @@ public class MinioController {
     @Resource
     private MinioConfiguration minioConfiguration;
 
-    @Resource(name = "minioClientPublic")
-    private SubMinioClient minioClientPublic;
-
 
     @PostMapping("/hello")
     public String hello() {
@@ -150,46 +146,45 @@ public class MinioController {
     @RequestMapping("/createMultipartUpload")
     @ResponseBody
     public ResponseBodyVO<Map<String, Object>> createMultipartUpload(@RequestBody Map<String, String> paramMap) throws Exception {
-        String objectName = paramMap.get("objectName");
-        String chunkSize = paramMap.get("chunkSize");
-        String type = paramMap.get("type");
-        if (ObjectUtil.isNull(objectName) || ObjectUtil.isNull(chunkSize) || ObjectUtil.isNull(type)) {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "请求参数缺失!");
-        }
-        Integer nowTime = TimeUtil.getRq(new Date(), 0);
-        if (type.equals(DictConstants.ALGORITHM_FILE)) {
-            objectName = "algorithm/" + nowTime + "/" + objectName;
-        }
-        Map<String, Object> result = new HashMap<>();//结果数据
-        CreateMultipartUploadResponse multipartUpload = minioClientPrivate.createMultipartUpload(minioConfiguration.getBucketName(), null, objectName, null, null);
-//        CreateMultipartUploadResponse multipartUpload = minioClientPublic.createMultipartUpload(minioConfiguration.getBucketName(), null, objectName, null, null);
-        String uploadId = multipartUpload.result().uploadId();
-        List<String> UrlList = new LinkedList<>();
-        Map<String, String> queryParam = new HashMap<>();
-        queryParam.put("uploadId", uploadId);
-        int size = Integer.parseInt(chunkSize);
-        for (int i = 1; i <= size; i++) {
-            queryParam.put("partNumber", String.valueOf(i));
-//            String presignedObjectUrl = minioClientPublic.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
-//                    .method(Method.PUT)
-//                    .bucket(minioConfiguration.getBucketName())
-//                    .object(objectName)
-//                    .expiry(60 * 60)//上传URL有效期
-//                    .extraQueryParams(queryParam)
-//                    .build());
-            String presignedObjectUrl = minioClientPrivate.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
-                    .method(Method.PUT)
-                    .bucket(minioConfiguration.getBucketName())
-                    .object(objectName)
-                    .expiry(60 * 60)//上传URL有效期
-                    .extraQueryParams(queryParam)
-                    .build());
-            UrlList.add(presignedObjectUrl);
+        try {
+            String objectName = paramMap.get("objectName");
+            String chunkSize = paramMap.get("chunkSize");
+            String type = paramMap.get("type");
+            if (ObjectUtil.isNull(objectName) || ObjectUtil.isNull(chunkSize) || ObjectUtil.isNull(type)) {
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "请求参数缺失!");
+            }
+            Integer nowTime = TimeUtil.getRq(new Date(), 0);
+            if (type.equals(DictConstants.ALGORITHM_FILE)) {
+                objectName = "algorithm/" + nowTime + "/" + objectName;
+            }
+            Map<String, Object> result = new HashMap<>();//结果数据
+            CreateMultipartUploadResponse multipartUpload = minioClientPrivate.createMultipartUpload(minioConfiguration.getBucketName(), null, objectName, null, null);
+            String uploadId = multipartUpload.result().uploadId();
+            List<String> UrlList = new LinkedList<>();
+            Map<String, String> queryParam = new HashMap<>();
+            queryParam.put("uploadId", uploadId);
+            int size = Integer.parseInt(chunkSize);
+            for (int i = 1; i <= size; i++) {
+                queryParam.put("partNumber", String.valueOf(i));
+                // 将 url 中的内网ip更换称外网ip
+                String presignedObjectUrl = MinioUtil.getPublicPreviewUrl2(
+                        minioClientPrivate,
+                        Method.PUT,
+                        minioConfiguration.getBucketName(),
+                        objectName,
+                        queryParam,
+                        minioConfiguration.getEndpointPrivate(),
+                        minioConfiguration.getEndpointPublic()
+                );
+                UrlList.add(presignedObjectUrl);
+            }
+            result.put("uploadId", uploadId);
+            result.put("uploadUrls", UrlList);
+            result.put("objectName", objectName);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, result);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
-        result.put("uploadId", uploadId);
-        result.put("uploadUrls", UrlList);
-        result.put("objectName", objectName);
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, result);
     }
 
     @RequestMapping("/completeMultipartUpload")

+ 32 - 4
simulation-resource-common/src/main/java/com/css/simulation/resource/common/util/MinioUtil.java

@@ -12,10 +12,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 public class MinioUtil {
 
@@ -156,6 +153,37 @@ public class MinioUtil {
                 .replace(privateIp, publicIp);
     }
 
+    /**
+     * 获取公网预览路径,需要设置 nginx 转发
+     *
+     * @param minioClient minio客户端
+     * @param method      请求方式
+     * @param bucket      bucket
+     * @param object      object
+     * @param privateIp   私网ip
+     * @param publicIp    公网ip
+     * @return 预览路径
+     */
+    @SneakyThrows
+    public static String getPublicPreviewUrl2(
+            MinioClient minioClient,
+            Method method,
+            String bucket,
+            String object,
+            Map<String, String> queryParam,
+            String privateIp,
+            String publicIp
+    ) {
+        return minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
+                        .method(method)
+                        .bucket(bucket)
+                        .object(object)
+                        .expiry(60 * 60)//上传URL有效期
+                        .extraQueryParams(queryParam)
+                        .build())
+                .replace(privateIp, publicIp);
+    }
+
     /**
      * 通过文件路径上传文件上传文件
      */

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -148,7 +148,7 @@ public class TaskManager {
                     taskMapper.updateSuccessStateWithStopTime(taskId, state, TimeUtil.getNowForMysql());
                     // 查询项目是否使用 gpu 生成视频(0是1否)
                     String isChoiceGpu = projectUtil.getProjectByProjectId(projectId).getIsChoiceGpu();
-                    log.info("项目 " + projectId + " 是否需要生成 gpu 视频:" + isChoiceGpu);
+                    log.info("项目 " + projectId + " 是否需要生成 gpu 视频(0是1否):" + isChoiceGpu);
                     if ("1".equals(isChoiceGpu)) {
                         FutureTask<ResponseBodyVO<String>> videoTask = new FutureTask<>(() -> videoService.generateVideo(projectId, projectType, maxSimulationTime, taskId));
                         new Thread(videoTask, "video-" + StringUtil.getRandomEightBitUUID()).start();

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/mapper/VehicleMapper.java

@@ -35,6 +35,6 @@ public interface VehicleMapper {
             "where model_label = #{oldModelLabel}")
     void updateModelLabel(@Param("oldModelLabel") String oldModelLabel, @Param("newModelLabel") String newModelLabel);
 
-    @Select("select parameter_type from model_vehicle where id = #{id}")
+    @Select("select parameter_type from model_vehicle where id = (select vehicle_id from model_config where id = #{id})")
     String selectParameterTypeById(@Param("id") String id);
 }

+ 6 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/VehicleService.java

@@ -406,7 +406,7 @@ public class VehicleService {
             String relationCurveLeftWheelAngleAndSteeringGearOutputJson = JsonUtil.listToJson(relationCurveLeftWheelAngleAndSteeringGearOutput);//
 
 
-            VehicleVO vehicleVO = VehicleVO.builder()
+            return VehicleVO.builder()
                     .wheelCenterToTop(wheelCenterToTop)
                     .wheelCenterToGround(wheelCenterToGround)
                     .centroidToFrontWheelCenter(centroidToFrontWheelCenter)
@@ -453,8 +453,8 @@ public class VehicleService {
                     .rearLeftWheelRelationCurveLongitudinalForceAndSideslipAngleJson(relationCurveLongitudinalForceAndSideslipAngleJson)
                     .rearRightWheelRelationCurveLongitudinalForceAndSideslipAngle(relationCurveLongitudinalForceAndSideslipAngle)
                     .rearRightWheelRelationCurveLongitudinalForceAndSideslipAngleJson(relationCurveLongitudinalForceAndSideslipAngleJson)
-                    .frontWheelSuspensionType("1")
-                    .rearWheelSuspensionType("1")
+                    .frontWheelSuspensionType("1")  //TODO  目前只使用独立悬架
+                    .rearWheelSuspensionType("1")   //TODO  目前只使用独立悬架
                     .frontWheelSuspensionKinematicsCoefficient(frontWheelSuspensionKinematicsCoefficient)
                     .rearWheelSuspensionKinematicsCoefficient(rearWheelSuspensionKinematicsCoefficient)
                     .frontWheelUnsprungMass(frontWheelUnsprungMass)
@@ -504,22 +504,19 @@ public class VehicleService {
                     .shiftTimeUp56Json(shiftTimeUp56Json)
                     .shiftTimeDown56(shiftTimeDown56)
                     .shiftTimeDown56Json(shiftTimeDown56Json)
-                    .brakeType("1")
+//                    .brakeType("1")   暂时不要制动类型
                     .frontLeftWheelBrakingTorque(frontBrakingTorque)
                     .frontRightWheelBrakingTorque(frontBrakingTorque)
                     .rearLeftWheelBrakingTorque(rearBrakingTorque)
                     .rearRightWheelBrakingTorque(rearBrakingTorque)
-                    .steeringType("1")
-                    .steeringGearType("1")
+                    .steeringType("1")  //TODO  暂时只用前轮转向
+                    .steeringGearType("2")  //TODO  暂时只用齿轮齿条转向器
                     .steeringGearRatio(steeringGearRatio)
                     .relationCurveRightWheelAngleAndSteeringGearOutput(relationCurveRightWheelAngleAndSteeringGearOutput)
                     .relationCurveRightWheelAngleAndSteeringGearOutputJson(relationCurveRightWheelAngleAndSteeringGearOutputJson)
                     .relationCurveLeftWheelAngleAndSteeringGearOutput(relationCurveLeftWheelAngleAndSteeringGearOutput)
                     .relationCurveLeftWheelAngleAndSteeringGearOutputJson(relationCurveLeftWheelAngleAndSteeringGearOutputJson)
                     .build();
-
-
-            return vehicleVO;
         } catch (JsonProcessingException e) {
             throw new RuntimeException(e);
         }

+ 11 - 12
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -280,15 +280,17 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             po.setFinishTime(null);
             int add = simulationProjectMapper.add(po);
             if (add <= 0) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "生成新工作失败。");
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "updateProjectNowRunState() 生成新工作失败。");
             }
-            // 00000 查询项目详情信息并保存
+            // 查询项目详情信息并保存,固定项目最原始的运行数据
             String projectId = po.getId();
-            ProjectDetailsVo info = selectProjectDetailsByIdBackUp(SimulationManualProjectParam.builder()
-                    .id(projectId)
-                    .projectType(DictConstants.PROJECT_TYPE_MANUAL).build()).getInfo();
+            ProjectDetailsVo info = selectProjectDetailsByIdBackUp(
+                    SimulationManualProjectParam.builder()
+                            .id(projectId)
+                            .projectType(DictConstants.PROJECT_TYPE_MANUAL)
+                            .build()
+            ).getInfo();
             String infoJson = JsonUtil.beanToJson(info);
-            log.info("updateProjectNowRunState() 项目 " + projectId + " 的详情信息为:" + infoJson);
             simulationProjectMapper.updateDetailsById(projectId, infoJson);
             // Kafka推送消息
             projectRunToKafka(po);
@@ -326,6 +328,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     private void projectRunToKafka(SimulationManualProjectPo po) {
         try {
+            log.info("projectRunToKafka() 准备发送项目消息:"+po);
             SimulationManualProjectKafkaParam kafkaParam = new SimulationManualProjectKafkaParam();
             kafkaParam.setProjectId(po.getId());
             kafkaParam.setAlgorithmId(po.getAlgorithm());
@@ -339,7 +342,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
             String data = JsonUtil.beanToJson(kafkaParam);
             kafkaParameter.setData(data);
-            log.info("推送项目运行消息到kafka:" + data);
+            log.info("projectRunToKafka() 推送项目运行消息到kafka:" + data);
             kafkaTemplate.send(kafkaParameter.getTopic(), kafkaParameter.getData()).addCallback(success -> {
                 // 消息发送到的topic
                 String topic = success.getRecordMetadata().topic();
@@ -347,11 +350,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 int partition = success.getRecordMetadata().partition();
                 // 消息在分区内的offset
                 long offset = success.getRecordMetadata().offset();
-                log.info("------- 发送消息成功:\n"
-                        + "主题 topic 为:" + topic + "\n"
-                        + "分区 partition 为:" + partition + "\n"
-                        + "偏移量为:" + offset + "\n"
-                        + "消息体为:" + kafkaParameter.getData());
+                log.info("------- 发送消息成功,主题 topic 为:" + topic + ",分区 partition 为:" + partition + ",偏移量为:" + offset + ",消息体为:" + kafkaParameter.getData());
             }, failure -> {
                 log.error("发送消息失败:" + failure.getMessage());
             });

+ 6 - 1
simulation-resource-server/src/main/resources/mapper/model/VehicleMapper.xml

@@ -108,6 +108,7 @@
         <result column="relationCurveRightWheelAngleAndSteeringGearOutput" property="relationCurveRightWheelAngleAndSteeringGearOutputJson" jdbcType="VARCHAR"/>
         <result column="relationCurveLeftWheelAngleAndSteeringGearOutput" property="relationCurveLeftWheelAngleAndSteeringGearOutputJson" jdbcType="VARCHAR"/>
         <result column="wheelCenterToTop" property="wheelCenterToTop" jdbcType="VARCHAR"/>
+        <result column="driver_type" property="driverType" jdbcType="VARCHAR"/>
     </resultMap>
 
     <select id="getVehicleList" parameterType="api.common.pojo.param.model.VehicleParam" resultMap="VehicleVOMap">
@@ -178,6 +179,7 @@
                wheelbase,
                share,
                parameter_type,
+               driver_type,
                wheelCenterToGround,
                centroidToFrontWheelCenter,
                centroidToGround,
@@ -305,6 +307,7 @@
                                   modify_user_id,
                                   is_deleted,
                                   parameter_type,
+                                  driver_type,
                                   par_file_path,
                                   wheelCenterToGround, centroidToFrontWheelCenter, centroidToGround, sprungMass,
                                   vehicleWidth,
@@ -374,6 +377,7 @@
                 #{modifyUserId,jdbcType=VARCHAR},
                 #{isDeleted,jdbcType=VARCHAR},
                 #{parameterType},
+                #{driverType},
                 #{parFilePath},
                 #{wheelCenterToGround},
                 #{centroidToFrontWheelCenter},
@@ -479,7 +483,8 @@
             wheelbase                                                     = #{wheelbase,jdbcType=DECIMAL},
             modify_time                                                   = #{modifyTime,jdbcType=TIMESTAMP},
             modify_user_id                                                = #{modifyUserId,jdbcType=VARCHAR},
-            parameter_type                                                 = #{parameterType},
+            parameter_type                                                = #{parameterType},
+            driver_type                                                   = #{driverType},
             par_file_path                                                 = #{parFilePath},
             wheelCenterToTop                                              = #{wheelCenterToTop},
             wheelCenterToGround                                           = #{wheelCenterToGround},