|
@@ -18,24 +18,23 @@ 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.*;
|
|
|
+import api.common.pojo.po.scene.SceneComplexityPO;
|
|
|
import api.common.pojo.po.scene.ScenePackagePO;
|
|
|
+import api.common.pojo.po.scene.SceneRiskPO;
|
|
|
import api.common.pojo.vo.algorithm.AlgorithmVO;
|
|
|
import api.common.pojo.vo.project.*;
|
|
|
import api.common.util.*;
|
|
|
import com.css.simulation.resource.server.domain.service.UserDomainService;
|
|
|
import com.css.simulation.resource.server.infra.db.mysql.mapper.*;
|
|
|
import com.css.simulation.resource.server.app.service.AlgorithmService;
|
|
|
-import com.css.simulation.resource.server.infra.util.AuthUtil;
|
|
|
-import com.css.simulation.resource.server.infra.util.PageUtil;
|
|
|
+import com.css.simulation.resource.server.infra.util.*;
|
|
|
import com.css.simulation.resource.server.infra.feign.service.AlgoPlatformService;
|
|
|
import com.css.simulation.resource.server.infra.feign.service.FileDownService;
|
|
|
import com.css.simulation.resource.server.infra.feign.service.MonitorService;
|
|
|
import com.css.simulation.resource.server.app.constant.ProjectRunStateEnum;
|
|
|
import com.css.simulation.resource.server.app.constant.SceneTypeEnum;
|
|
|
import com.css.simulation.resource.server.app.service.job_manage.SimulationProjectService;
|
|
|
-import com.css.simulation.resource.server.infra.util.PdfBuilder;
|
|
|
import com.css.simulation.resource.server.app.service.DictService;
|
|
|
-import com.css.simulation.resource.server.infra.util.ProjectUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import com.itextpdf.text.*;
|
|
@@ -48,6 +47,9 @@ import lombok.SneakyThrows;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.tomcat.util.buf.StringUtils;
|
|
|
+import org.jfree.chart.ChartUtils;
|
|
|
+import org.jfree.data.category.DefaultCategoryDataset;
|
|
|
+import org.jfree.data.general.DefaultPieDataset;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.kafka.core.KafkaTemplate;
|
|
|
import org.springframework.scheduling.support.CronExpression;
|
|
@@ -67,6 +69,7 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
@@ -114,6 +117,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
private VehicleMapper vehicleMapper;
|
|
|
@Resource
|
|
|
private UserDomainService userDomainService;
|
|
|
+ @Resource
|
|
|
+ private SceneComplexityMapper sceneComplexityMapper;
|
|
|
+ @Resource
|
|
|
+ private SceneRiskMapper sceneRiskMapper;
|
|
|
|
|
|
// * -------------------------------- Comment --------------------------------
|
|
|
|
|
@@ -3161,11 +3168,15 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
if ("1".equals(param.getProjectType())) {
|
|
|
// 场景评价
|
|
|
- addElement(document, "场景评价", null, bf3, 15, false, 30, true);
|
|
|
- addElement(document, " 场景测试包共包含" + totalSceneNum + "个场景.", null, bf3, 15, false, 30, false);
|
|
|
-// projectId
|
|
|
-// sceneScoreLi
|
|
|
-
|
|
|
+ List<String> sceneIds = sceneScoreLi.stream().map(SceneScListVo::getSceneId).collect(Collectors.toList());
|
|
|
+ // 查询复杂度和危险度
|
|
|
+ List<SceneComplexityPO> sceneComplexityPOS = sceneComplexityMapper.selectSceneComplexityEvaluationForExport(param.getProjectId(), sceneIds);
|
|
|
+ List<SceneRiskPO> sceneRiskPOS = sceneRiskMapper.selectSceneRiskEvaluationForExport(param.getProjectId(), sceneIds);
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneComplexityPOS) || CollectionUtil.isNotEmpty(sceneRiskPOS)) {
|
|
|
+ addElement(document, "场景评价", null, bf3, 15, false, 30, true);
|
|
|
+ addElement(document, " 场景测试包共包含" + totalSceneNum + "个场景.", null, bf3, 15, false, 30, false);
|
|
|
+ createBarAndPieImg(document, sceneComplexityPOS, sceneRiskPOS);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// ------- 4.详细得分说明 -------
|
|
@@ -3788,6 +3799,146 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
document.add(elm);
|
|
|
}
|
|
|
|
|
|
+ private void createBarAndPieImg(Document document, List<SceneComplexityPO> sceneComplexityPOS, List<SceneRiskPO> sceneRiskPOS) {
|
|
|
+ try {
|
|
|
+ // 饼图
|
|
|
+ DefaultPieDataset complexityDataSet = new DefaultPieDataset();
|
|
|
+ DefaultCategoryDataset complexityData = getBarDataSet();
|
|
|
+ DefaultCategoryDataset riskData = getBarDataSet();
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneComplexityPOS)) {
|
|
|
+ sceneComplexityPOS.forEach(sceneComplexityPO -> {
|
|
|
+ if (complexityDataSet.getValue(sceneComplexityPO.getComplexityLevel()) == null) {
|
|
|
+ complexityDataSet.setValue(sceneComplexityPO.getComplexityLevel(), 1);
|
|
|
+ } else {
|
|
|
+ int num = complexityDataSet.getValue(sceneComplexityPO.getComplexityLevel()).intValue();
|
|
|
+ complexityDataSet.setValue(sceneComplexityPO.getComplexityLevel(), ++num);
|
|
|
+ }
|
|
|
+ checkAndSetDataSetValue(complexityData, sceneComplexityPO.getComplexity());
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ByteArrayOutputStream pieBos = new ByteArrayOutputStream();
|
|
|
+ ChartUtils.writeChartAsJPEG(pieBos, ChartUtil.pieChart("复杂度等级分布图", complexityDataSet), 300, 188);
|
|
|
+ Image pieImage = Image.getInstance(pieBos.toByteArray());
|
|
|
+ pieImage.setAlignment(Element.ALIGN_CENTER);
|
|
|
+ pieBos.close();
|
|
|
+
|
|
|
+ // 饼图
|
|
|
+ DefaultPieDataset riskDataSet = new DefaultPieDataset();
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneRiskPOS)) {
|
|
|
+ sceneRiskPOS.forEach(sceneRiskPO -> {
|
|
|
+ if (riskDataSet.getValue(sceneRiskPO.getRiskLevel()) == null) {
|
|
|
+ riskDataSet.setValue(sceneRiskPO.getRiskLevel(), 1);
|
|
|
+ } else {
|
|
|
+ int num = riskDataSet.getValue(sceneRiskPO.getRiskLevel()).intValue();
|
|
|
+ riskDataSet.setValue(sceneRiskPO.getRiskLevel(), ++num);
|
|
|
+ }
|
|
|
+ checkAndSetDataSetValue(riskData, sceneRiskPO.getRisk());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ByteArrayOutputStream riskBos = new ByteArrayOutputStream();
|
|
|
+ ChartUtils.writeChartAsJPEG(riskBos, ChartUtil.pieChart("危险度等级分布图", riskDataSet), 300, 188);
|
|
|
+ Image riskLevelImage = Image.getInstance(riskBos.toByteArray());
|
|
|
+ riskLevelImage.setAlignment(Element.ALIGN_CENTER);
|
|
|
+ riskBos.close();
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneComplexityPOS) && CollectionUtil.isNotEmpty(sceneRiskPOS)) {
|
|
|
+ float[] floats = new float[2];
|
|
|
+ Arrays.fill(floats, 60);
|
|
|
+ PdfPTable table = new PdfPTable(floats);
|
|
|
+ table.setTotalWidth(600);
|
|
|
+ table.setLockedWidth(true);
|
|
|
+ table.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ table.getDefaultCell().setBorder(1);
|
|
|
+ PdfPCell complexityCell = new PdfPCell(pieImage);
|
|
|
+ pieImage.scaleAbsolute(300, 188);
|
|
|
+ complexityCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ complexityCell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
|
|
|
+ table.addCell(complexityCell);
|
|
|
+
|
|
|
+ PdfPCell riskCell = new PdfPCell(riskLevelImage);
|
|
|
+ riskLevelImage.scaleAbsolute(300, 188);
|
|
|
+ riskCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ riskCell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
|
|
|
+ table.addCell(riskCell);
|
|
|
+ document.add(table);
|
|
|
+ BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
|
|
+ Paragraph elements = new Paragraph(40, " ", new com.itextpdf.text.Font(font, 14));
|
|
|
+ document.add(elements);
|
|
|
+ } else if (CollectionUtil.isNotEmpty(sceneComplexityPOS)) {
|
|
|
+ document.add(pieImage);
|
|
|
+ } else if (CollectionUtil.isNotEmpty(sceneRiskPOS)) {
|
|
|
+ document.add(riskLevelImage);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneComplexityPOS)) {
|
|
|
+ ByteArrayOutputStream pieBos2 = new ByteArrayOutputStream();
|
|
|
+ ChartUtils.writeChartAsJPEG(pieBos2, ChartUtil.barChart("复杂度分布图", null, "复杂度", complexityData), 620, 200);
|
|
|
+ Image pieImage3 = Image.getInstance(pieBos2.toByteArray());
|
|
|
+ pieImage3.setAlignment(Element.ALIGN_CENTER);
|
|
|
+ document.add(pieImage3);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(sceneRiskPOS)) {
|
|
|
+ ByteArrayOutputStream pieBos3 = new ByteArrayOutputStream();
|
|
|
+ ChartUtils.writeChartAsJPEG(pieBos3, ChartUtil.barChart("危险度分布图", null, "危险度", riskData), 620, 200);
|
|
|
+ Image pieImage4 = Image.getInstance(pieBos3.toByteArray());
|
|
|
+ pieImage4.setAlignment(Element.ALIGN_CENTER);
|
|
|
+ document.add(pieImage4);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建饼图和柱状图失败. ", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private DefaultCategoryDataset getBarDataSet() {
|
|
|
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
|
|
|
+ dataset.addValue(0, "场景名称", "[0,10]");
|
|
|
+ dataset.addValue(0, "场景名称", "(10,20]");
|
|
|
+ dataset.addValue(0, "场景名称", "(20,30]");
|
|
|
+ dataset.addValue(0, "场景名称", "(30,40]");
|
|
|
+ dataset.addValue(0, "场景名称", "(40,50]");
|
|
|
+ dataset.addValue(0, "场景名称", "(50,60]");
|
|
|
+ dataset.addValue(0, "场景名称", "(60,70]");
|
|
|
+ dataset.addValue(0, "场景名称", "(70,80]");
|
|
|
+ dataset.addValue(0, "场景名称", "(80,90]");
|
|
|
+ dataset.addValue(0, "场景名称", "(90,100]");
|
|
|
+ return dataset;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkAndSetDataSetValue(DefaultCategoryDataset dataset, String value) {
|
|
|
+ int valInt = Integer.parseInt(value);
|
|
|
+ if (valInt >= 0 && valInt <= 10) {
|
|
|
+ int num = dataset.getValue("场景名称", "[0,10]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "[0,10]");
|
|
|
+ } else if (valInt > 10 && valInt <= 20) {
|
|
|
+ int num = dataset.getValue("场景名称", "(10,20]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(10,20]");
|
|
|
+ } else if (valInt > 20 && valInt <= 30) {
|
|
|
+ int num = dataset.getValue("场景名称", "(20,30]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(20,30]");
|
|
|
+ } else if (valInt > 30 && valInt <= 40) {
|
|
|
+ int num = dataset.getValue("场景名称", "(30,40]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(30,40]");
|
|
|
+ } else if (valInt > 40 && valInt <= 50) {
|
|
|
+ int num = dataset.getValue("场景名称", "(40,50]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(40,50]");
|
|
|
+ } else if (valInt > 50 && valInt <= 60) {
|
|
|
+ int num = dataset.getValue("场景名称", "(50,60]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(50,60]");
|
|
|
+ } else if (valInt > 60 && valInt <= 70) {
|
|
|
+ int num = dataset.getValue("场景名称", "(60,70]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(60,70]");
|
|
|
+ } else if (valInt > 70 && valInt <= 80) {
|
|
|
+ int num = dataset.getValue("场景名称", "(70,80]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(70,80]");
|
|
|
+ } else if (valInt > 80 && valInt <= 90) {
|
|
|
+ int num = dataset.getValue("场景名称", "(80,90]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(80,90]");
|
|
|
+ } else if (valInt > 90 && valInt <= 100) {
|
|
|
+ int num = dataset.getValue("场景名称", "(90,100]").intValue();
|
|
|
+ dataset.setValue(++num, "场景名称", "(90,100]");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取所有要合并的下标、每个下标索要合并的行数、要跳过创建表格的下标
|
|
|
*/
|