浏览代码

Merge branch 'f-xiaogu' into dev

gushoubang 8 月之前
父节点
当前提交
39cb7afb7b

+ 0 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/FactorUseDTO.java

@@ -2,7 +2,6 @@ package com.onemap.analyse.domain;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.onemap.analyse.domain.vo.FactorSpatialVo;
 import lombok.Data;

+ 4 - 3
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/FzxzFactorDTO.java

@@ -21,7 +21,8 @@ public class FzxzFactorDTO {
     // 目录等级
     private Integer level;
     // 上级标识码
-    private String parent_id;
+    @TableField("parent_id")
+    private String parentId;
     // 是否包含影响值
     @TableField("order_index")
     @JsonIgnore
@@ -51,8 +52,8 @@ public class FzxzFactorDTO {
 
     // 判断是否为最后一级节点(没有子节点)
     private static FzxzFactorDTO getRootNode(FzxzFactorDTO node, Map<String, FzxzFactorDTO> nodeMap) {
-        if (node.getParent_id() != null && node.getParent_id() != "") {
-            return nodeMap.get(node.getParent_id());
+        if (node.getParentId() != null && !node.getParentId().equals("")) {
+            return getRootNode(nodeMap.get(node.getParentId()), nodeMap);
         } else {
             return node;
         }

+ 30 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/ReportServiceImpl.java

@@ -212,6 +212,8 @@ public class ReportServiceImpl implements IReportService {
                     List<FactorUseDTO> factorUseDTOS = factorImageMap.get(rootFactor.getId());
                     List<WktsVo.WktInfo> wktInfos = new ArrayList<>();
                     for (FactorUseDTO factorUseDTO : factorUseDTOS) {
+                        if (factorUseDTO.getFactorName().equals("坡度") || factorUseDTO.getFactorName().equals("高程"))
+                            continue;
                         String ewkt = getFactorWkt(geomRes.getGeom(), factorUseDTO.getFactorBsm());
 
                         Random random = new Random();
@@ -226,8 +228,19 @@ public class ReportServiceImpl implements IReportService {
 
                         wktInfos.add(wktInfo);
                     }
+                    if (wktInfos.size() == 0) continue;
 
                     String imagePath = reportImg(wktInfos);
+                    if (imagePath.equals("")) continue;
+                    // 获取插入图片
+                    NpoiHelper.content(document, rootFactor.getName(), pos++, ParagraphAlignment.CENTER);
+                    ReportImage reportImage = getPathImage(imagePath, 300);
+
+                    XWPFParagraph imageParagraph = document.createParagraph();
+                    imageParagraph.setAlignment(ParagraphAlignment.CENTER); // Center align the image
+                    XWPFRun imageRun = imageParagraph.createRun();
+                    imageRun.addPicture(reportImage.getInputStream(), XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(reportImage.getUseWidth()), Units.toEMU(reportImage.getUseHeight()));
+                    pos++;
                 }
             }
 
@@ -244,7 +257,7 @@ public class ReportServiceImpl implements IReportService {
             NpoiHelper.content(document, fwfx, pos++);
 
             // 获取插入图片
-            ReportImage reportImage = getReportImage(geomRes.getGeom(), 300);
+            ReportImage reportImage = getWktImage(geomRes.getGeom(), 300);
 
             XWPFParagraph imageParagraph = document.createParagraph();
             imageParagraph.setAlignment(ParagraphAlignment.CENTER); // Center align the image
@@ -328,7 +341,7 @@ public class ReportServiceImpl implements IReportService {
 
                 // 获取地块图片
                 String geomWkt = item.getGeom();
-                ReportImage imageTable = getReportImage(geomWkt, 300);
+                ReportImage imageTable = getWktImage(geomWkt, 300);
 
                 // 在合并后的单元格中创建一个新的段落
                 XWPFParagraph paraImag = row.getCell(0).addParagraph();
@@ -538,12 +551,25 @@ public class ReportServiceImpl implements IReportService {
      * 获取报告图片
      *
      * @param wkt
+     * @param with
      * @return
      * @throws IOException
      */
-    private ReportImage getReportImage(String wkt, int with) throws IOException {
-        ReportImage reportImage = new ReportImage();
+    private ReportImage getWktImage(String wkt, int with) throws IOException {
         String path = reportImg(wkt);
+        ReportImage reportImage = getPathImage(path, with);
+        return reportImage;
+    }
+
+    /**
+     * 根据图片路径获取报告图片
+     *
+     * @param path
+     * @return
+     * @throws IOException
+     */
+    private ReportImage getPathImage(String path, int with) throws IOException {
+        ReportImage reportImage = new ReportImage();
 
         System.out.println("图片路径path:" + path);
 

+ 15 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/utils/NpoiHelper.java

@@ -288,6 +288,21 @@ public class NpoiHelper {
         document.setParagraph(newParagraph(document, count, null), pos);
     }
 
+    /**
+     * 内容
+     * @param document
+     * @param text
+     * @param pos
+     * @param alignment
+     */
+    public static void content(XWPFDocument document, String text, int pos, ParagraphAlignment alignment) {
+        XWPFParagraph paragraph = document.createParagraph();
+        paragraph.setAlignment(alignment);
+        XWPFRun run = paragraph.createRun();
+        run.setText(text);
+        document.setParagraph(paragraph, pos);
+    }
+
     /**
      * 内容
      *

+ 3 - 0
onemap-modules/onemap-spatial/src/main/java/com/onemap/spatial/service/impl/ImageServiceImpl.java

@@ -92,6 +92,9 @@ public class ImageServiceImpl implements IImageService {
         ReferencedEnvelope combinedBounds = new ReferencedEnvelope(DefaultGeographicCRS.WGS84);
 
         for (WktsVo.WktInfo wktInfo : wktsVo.getWktInfos()) {
+            if(wktInfo.getWkt() == null || wktInfo.getWkt().isEmpty()){
+                continue;
+            }
             // 将 WKT 转换为几何对象并添加到图层
             WKTReader wktReader = new WKTReader(JTSFactoryFinder.getGeometryFactory());