root vor 2 Jahren
Ursprung
Commit
62d166a715

+ 21 - 7
pom.xml

@@ -59,6 +59,8 @@
         <kubernetes-client.version>15.0.1</kubernetes-client.version>
         <snakeyaml.version>1.30</snakeyaml.version>
         <docker-java.version>3.2.13</docker-java.version>
+        <itextpdf.version>5.5.13.3</itextpdf.version>
+        <itext-asian.version>5.2.0</itext-asian.version>
     </properties>
 
 
@@ -72,6 +74,19 @@
                 <version>${logback-classic.version}</version>
             </dependency>
 
+            <!-- pdf - 开始 -->
+            <dependency>
+                <groupId>com.itextpdf</groupId>
+                <artifactId>itextpdf</artifactId>
+                <version>${itextpdf.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.itextpdf</groupId>
+                <artifactId>itext-asian</artifactId>
+                <version>${itext-asian.version}</version>
+            </dependency>
+            <!-- pdf - 结束 -->
+
             <!-- docker 客户端 -->
             <dependency>
                 <groupId>com.github.docker-java</groupId>
@@ -146,12 +161,12 @@
             <!-- 权限认证 - 结束 -->
 
 
-<!--            &lt;!&ndash; api 文档 &ndash;&gt;-->
-<!--            <dependency>-->
-<!--                <groupId>io.github.yedaxia</groupId>-->
-<!--                <artifactId>japidocs</artifactId>-->
-<!--                <version>${japidocs.version}</version>-->
-<!--            </dependency>-->
+            <!--            &lt;!&ndash; api 文档 &ndash;&gt;-->
+            <!--            <dependency>-->
+            <!--                <groupId>io.github.yedaxia</groupId>-->
+            <!--                <artifactId>japidocs</artifactId>-->
+            <!--                <version>${japidocs.version}</version>-->
+            <!--            </dependency>-->
 
             <!-- 数据库 - 开始 -->
             <!-- page helper -->
@@ -207,7 +222,6 @@
             </dependency>
 
 
-
             <!-- lombok -->
             <dependency>
                 <groupId>org.projectlombok</groupId>

+ 6 - 7
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/consumer/ProjectConsumer.java

@@ -577,18 +577,17 @@ public class ProjectConsumer {
     }
     //* -------------------------------- 结束 --------------------------------
 
+    /**
+     * {
+     * "projectId": "sadfasdfs",	// 项目 id
+     * "type": "1",	// 项目类型
+     * }
+     */
     @KafkaListener(groupId = "simulation-resource-scheduler", topics = "${scheduler.stop-topic}")
     @SneakyThrows
     public void stopProject(ConsumerRecord<String, String> stopRecord) {
         log.info("接收到的项目终止消息为:" + stopRecord);
         //1 读取 kafka 的项目停止信息
-        /*
-            {
-                "projectId": "sadfasdfs",	// 项目 id
-                "type": "1",	// 项目类型
-            }
-         */
-
         String json = stopRecord.value();
         ObjectMapper objectMapper = new ObjectMapper();
         JsonNode jsonNode = objectMapper.readTree(json);

+ 2 - 5
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/VehicleMapper.java

@@ -46,12 +46,9 @@ public interface VehicleMapper {
             "       height_distance,\n" +
             "       wheelbase\n" +
             "from model_vehicle\n" +
-            "where is_deleted = '0'\n" +
-            "  and id = (\n" +
-            "    select mc.vehicle_id\n" +
+            "where id = (select mc.vehicle_id\n" +
             "    from model_config mc\n" +
-            "    where mc.id = #{vehicleConfigId}\n" +
-            ")")
+            "    where mc.id = #{vehicleConfigId})")
     VehicleEntity selectByVehicleConfigId(@Param("vehicleConfigId") String vehicleConfigId);
 
     @Select("select par_file_path\n" +

+ 0 - 2
simulation-resource-server/pom.xml

@@ -125,12 +125,10 @@
         <dependency>
             <groupId>com.itextpdf</groupId>
             <artifactId>itextpdf</artifactId>
-            <version>5.5.13.3</version>
         </dependency>
         <dependency>
             <groupId>com.itextpdf</groupId>
             <artifactId>itext-asian</artifactId>
-            <version>5.2.0</version>
         </dependency>
 
     </dependencies>

+ 29 - 51
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -2608,10 +2608,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     public void exportProjectReport(SimulationManualProjectParam param) {
 
         OutputStream os;
-        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
+        HttpServletResponse response = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getResponse();
         //获取要生成的数据
-        ResponseBodyVO bodyVO = selectProjectReportById(param);
-        ProjectReportVo vo = (ProjectReportVo) bodyVO.getInfo();
+        ResponseBodyVO<ProjectReportVo> bodyVO = selectProjectReportById(param);
+        ProjectReportVo vo = bodyVO.getInfo();
         //下载 or 保存本地
         if (param.getIsCreateLocalPdfFile() != null && param.getIsCreateLocalPdfFile()) {
             File file = new File(param.getLocalPdfFilePath());
@@ -2624,33 +2624,36 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         }
         // 监听生成pdf数据
         Document document = new Document(PageSize.A4);
-        PdfWriter.getInstance(document, os);
-        // 以下生成PDF
-        BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
-        //标题
         document.open();
-        Font titleFont = new Font(font, 20); //字体
-        Paragraph titleElements = new Paragraph("评价报告", titleFont);
-        titleElements.setAlignment(Element.ALIGN_CENTER); //居中
-        document.add(titleElements);
+        PdfWriter.getInstance(document, os);
+        BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+        //* -------------------------------- 第一页 --------------------------------
+        Paragraph paragraph1 = new Paragraph("评价报告", new Font(baseFont, 20));
+        paragraph1.setAlignment(Element.ALIGN_CENTER); //居中
+        document.add(paragraph1);
+
+//        // 新的一页,横向显示
+//        document.setPageSize(PageSize.A4.rotate());
+//        document.newPage();
+
         //算法名称、算法得分、测试等级
         Paragraph algorithmNanmeElements = new Paragraph(
                 50,
                 "          算法名称:" + vo.getAlgorithmName()
                         + "         算法得分:" + vo.getAlgorithmScore()
                         + "         测试等级:" + vo.getEvaluationLevel(),
-                defaultFont(font));
+                defaultFont(baseFont));
         algorithmNanmeElements.setAlignment(Element.ALIGN_LEFT); //靠左
         document.add(algorithmNanmeElements);
         //算法描述
         Paragraph algorithmDescribeFontElements = new Paragraph(
                 30,
                 "          算法描述:" + vo.getAlgorithmDescribe(),
-                defaultFont(font));
+                defaultFont(baseFont));
         algorithmDescribeFontElements.setAlignment(Element.ALIGN_LEFT); //居中
         document.add(algorithmDescribeFontElements);
         //算法简评
-        Font algorithmEvaluateFont = new Font(font, 14); //字体
+        Font algorithmEvaluateFont = new Font(baseFont, 14); //字体
         Paragraph algorithmEvaluateElements = new Paragraph(
                 30,
                 "          算法简评:" + vo.getAlgorithmEvaluation(),
@@ -2663,14 +2666,14 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         Paragraph scoreTableElements = new Paragraph(
                 50,
                 "测试得分表",
-                defaultFont(font));
+                defaultFont(baseFont));
         scoreTableElements.setAlignment(Element.ALIGN_CENTER); //居中
         document.add(scoreTableElements);
-        setBlankLineSpacing(20, font, document);
+        setBlankLineSpacing(20, baseFont, document);
         // 表头
         PdfPTable pdfPTable = new PdfPTable(5);
         pdfPTable.setHeaderRows(1);//换页每页显示表头
-        addTitleList(pdfPTable, font, new String[]{"测试项目", "场景数量", "测试权重(%)", "测试得分", "得分率(%)"});
+        addTitleList(pdfPTable, baseFont, new String[]{"测试项目", "场景数量", "测试权重(%)", "测试得分", "得分率(%)"});
 
         // 数据
         List<AlgorithmScoreVo> algorithmScoreList = vo.getAlgorithmScoreList();
@@ -2678,25 +2681,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             String[] data = new String[]{
                     asv.getProjectName(), String.valueOf(asv.getSceneNum()), asv.getWeight(), String.valueOf(asv.getScore()), String.valueOf(asv.getScoreRatio())
             };
-            addDataList(pdfPTable, font, data);
+            addDataList(pdfPTable, baseFont, data);
         }
         document.add(pdfPTable);
-        // 评价等级(已去掉)
-//            Paragraph levelTableElements = new Paragraph(
-//                    50,
-//                    "评价等级",
-//                    defaultFont(font));
-//            levelTableElements.setAlignment(Element.ALIGN_CENTER); //居中
-//            document.add(levelTableElements);
-//
-//            setBlankLineSpacing(20, font, document);
-//
-//            PdfPTable pdfPTable1 = new PdfPTable(5);
-//            addTitleList(pdfPTable1, font, new String[]{"测试项目", "90<总分<100", "80<总分<90", "70<总分<80", "0<总分<70"});
-//            addDataList(pdfPTable1, font, new String[]{"评价等级", "优秀(G)", "良好(A)", "一般(M)", "较差(P)",
-//                    "评价等级", "++++++", "+++++", "++++", "+++",});
-//            document.add(pdfPTable1);
-
 
         // 新的一页,横向显示
         document.setPageSize(PageSize.A4.rotate());
@@ -2706,10 +2693,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         Paragraph subListScoreElements = new Paragraph(
                 50,
                 "算法测试评分细则",
-                defaultFont(font));
+                defaultFont(baseFont));
         subListScoreElements.setAlignment(Element.ALIGN_CENTER); //居中
         document.add(subListScoreElements);
-        setBlankLineSpacing(20, font, document);
+        setBlankLineSpacing(20, baseFont, document);
         List<Map> subListScoreLiTitle = vo.getSubListScoreLiTitle();
         int size = subListScoreLiTitle.size();
         PdfPTable pdfPTable2 = new PdfPTable(size);
@@ -2718,7 +2705,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         for (int i = 0; i < size; i++) {
             slt[i] = subListScoreLiTitle.get(i).get("label").toString();
         }
-        addTitleList(pdfPTable2, font, slt);
+        addTitleList(pdfPTable2, baseFont, slt);
         List<SubScListVo> subListScoreLi = vo.getSubListScoreLi();
         List<String[]> list = new ArrayList<>();
         int fieldNumber = 7;
@@ -2782,7 +2769,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 if (contains) {
                     continue;
                 }
-                PdfPCell pdfPCell = new PdfPCell(new Paragraph(strings[j], defaultFont(font)));
+                PdfPCell pdfPCell = new PdfPCell(new Paragraph(strings[j], defaultFont(baseFont)));
                 //是否要合并
                 Integer n = combineCoordList.get(coord);
                 if (n != null) {
@@ -2797,11 +2784,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             /*
             场景得分列表
              */
-        Paragraph sceneScoreElements = new Paragraph(50, "详细得分情况", defaultFont(font));
+        Paragraph sceneScoreElements = new Paragraph(50, "详细得分情况", defaultFont(baseFont));
         sceneScoreElements.setAlignment(Element.ALIGN_CENTER); //居中
         document.add(sceneScoreElements);
 
-        setBlankLineSpacing(20, font, document);
+        setBlankLineSpacing(20, baseFont, document);
 
         List<Map> scoreLiTitle = vo.getSceneScoreLiTitle();
         int size2 = scoreLiTitle.size();
@@ -2811,7 +2798,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         for (int i = 0; i < size2; i++) {
             slt2[i] = scoreLiTitle.get(i).get("label").toString();
         }
-        addTitleList(pdfPTable3, font, slt2);
+        addTitleList(pdfPTable3, baseFont, slt2);
         List<SceneScListVo> sceneScoreLi = vo.getSceneScoreLi();
 
         List<String[]> list2 = new ArrayList<>();
@@ -2863,7 +2850,6 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
             list2.add(ssli);
 
-//                addDataList(pdfPTable3, font, ssli);
         }
 
         Map map2 = getSceneScListCombineCoord(sceneScoreLi, size2);
@@ -2871,8 +2857,6 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         Map<String, Integer> combineCoordList2 = (Map<String, Integer>) map2.get("combineCoordList");
         List<String> skipCoordList2 = (List<String>) map2.get("skipCoordList");
 
-        boolean b2 = false;
-        int num2 = 0;
         for (int i = 0; i < list2.size(); i++) {
             String[] strings = list2.get(i);
             for (int j = 0; j < strings.length; j++) {
@@ -2883,7 +2867,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 if (contains) {
                     continue;
                 }
-                PdfPCell pdfPCell = new PdfPCell(new Paragraph(strings[j], defaultFont(font)));
+                PdfPCell pdfPCell = new PdfPCell(new Paragraph(strings[j], defaultFont(baseFont)));
                 //是否要合并
                 Integer n = combineCoordList2.get(coord);
                 if (n != null) {
@@ -3030,12 +3014,6 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         }
 
-        /*List<CombineCoordVo> combineCoordVoList = new ArrayList<>();
-
-        for(String k : map.keySet()){
-            combineCoordVoList.add(map.get(k));
-        }*/
-
         for (String k : map.keySet()) {
             CombineCoordVo combineCoordVo = map.get(k);
             combineCoordMap.put(combineCoordVo.getCoord(), combineCoordVo.getRepetitionNum());