瀏覽代碼

Merge branch 'dev' of http://114.244.114.158:8802/siwei/sanya-data-management-back into dev

LAPTOP-BJJ3IV5R\SIWEI 9 月之前
父節點
當前提交
b455413dac

+ 15 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/FzssController.java

@@ -106,7 +106,8 @@ public class FzssController extends BaseController {
     public RequestResult SaveWordFile(@RequestBody DkReportVo dkReportVo) {
         FzxzReport fzxzReport = iReportService.createReport(dkReportVo.getBsm(), dkReportVo.getDkIds());
         Map<String, String> resMap = new HashMap<>();
-        resMap.put("fxbg", fzxzReport.getReportfile());
+        resMap.put("fxbg", fzxzReport.getReportFile());
+        resMap.put("fxbgPdf", fzxzReport.getReportPdfFile());
         return RequestResult.success("查询成功!", resMap);
     }
 
@@ -129,4 +130,17 @@ public class FzssController extends BaseController {
             FileUtils.writeBytes(realFileName, response.getOutputStream());
         }
     }
+
+    @GetMapping("/ShowReport")
+    public void fileShow(String filePath, HttpServletResponse response) throws IOException {
+        String realFileName = temp + filePath;
+        File file = new File(realFileName);
+        // 取得文件名。
+        String downloadName = file.getName();
+
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("application/pdf");
+        response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(downloadName, "UTF-8"));
+        FileUtils.writeBytes(realFileName, response.getOutputStream());
+    }
 }

+ 2 - 2
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/FzxzReport.java

@@ -7,8 +7,8 @@ import java.util.List;
 @Data
 public class FzxzReport {
     private String message = "检查完成";/// 消息内容
-    private String reportfile;/// 选址报告文件
-    // private String rootPath;/// 根目录
+    private String reportFile;/// 选址报告文件
+    private String reportPdfFile;/// 根目录
 
     private String bsm;
     // private String fxbg;

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

@@ -27,7 +27,6 @@ import com.onemap.system.api.SpatialService;
 import com.onemap.system.api.domain.PolygonDataVo;
 import com.onemap.system.api.domain.WktsVo;
 import org.apache.commons.io.FileUtils;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Units;
 import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.beans.factory.annotation.Value;
@@ -98,7 +97,8 @@ public class ReportServiceImpl implements IReportService {
             String reportPath = "选址报告_" + timeStamp + ".docx";
             createReport(res, allPath + "/" + reportPath, dkIds);
             // 生成返回结果
-            fzxzReport.setReportfile(filePath + "/" + reportPath);
+            fzxzReport.setReportFile(filePath + "/" + reportPath);
+            fzxzReport.setReportPdfFile(filePath + "/" + reportPath.replace(".docx", ".pdf"));
             fzxzReport.setBsm(bsm);
             // fzxzReport.setFxbg(fzxzReport.getReportfile());
             fzxzReport.setJsdw(res.getJsdw());
@@ -119,7 +119,7 @@ public class ReportServiceImpl implements IReportService {
      *
      * @param res
      * @param reportPath
-     * @param dkIds      没有导出全部地块
+     * @param dkIds      没有导出全部地块
      */
     private void createReport(FzxzEntityDTO res, String reportPath, List<String> dkIds) {
         GeomRes geomRes = shpFileMapper.getOne(res.getGeomId());
@@ -371,6 +371,7 @@ public class ReportServiceImpl implements IReportService {
                 String scopeEwkt = geomRes.getGeom();
                 String landEwkt = geomWkt;
                 for (Map.Entry<String, List<FactorUseDTO>> entry : factorTypeMap.entrySet()) {
+                    // 遍历大的因子分类
                     String key = entry.getKey(); // 获取Map中的键
                     String factorName = rootMap.get(key).getName();
 
@@ -389,11 +390,18 @@ public class ReportServiceImpl implements IReportService {
                     wktInfo1.setBorderColor("#FF0000");
                     wktInfos.add(wktInfo1);
 
+                    List<String> warnings = new ArrayList<>();
                     for (FactorUseDTO factorUseDTO : factorUseDTOS) {
                         if (factorUseDTO.getFactorName().equals("坡度") || factorUseDTO.getFactorName().equals("高程"))
                             continue;
                         String ewkt = getFactorWkt(scopeEwkt, factorUseDTO.getFactorBsm());
 
+                        if (ewkt == null && factorUseDTO.getConditionInfoObj().getSpatialType().equals("distance")) {
+                            String warn = factorUseDTO.getFactorName() + "距离大于" + factorUseDTO.getConditionInfoObj().getDefaultValue() + "米";
+                            warnings.add(warn);
+                            continue;
+                        }
+
                         Random random = new Random();
                         int rgb = random.nextInt(0xFFFFFF + 1);
                         String color = String.format("#%06X", rgb);
@@ -412,7 +420,13 @@ public class ReportServiceImpl implements IReportService {
                     if (imagePath.equals("")) continue;
                     // 获取插入标题、图片
                     NpoiHelper.content(document, "", pos++, ParagraphAlignment.CENTER);
+                    // 图片标题
                     NpoiHelper.content(document, factorName, pos++, ParagraphAlignment.CENTER);
+                    // 插入距离较远的因子说明
+                    for (String warning : warnings) {
+                        NpoiHelper.content(document, warning, pos++, ParagraphAlignment.LEFT);
+                    }
+
                     ReportImage reportImageFactor = getPathImage(imagePath, 400);
 
                     XWPFParagraph imageParagraphFactor = document.createParagraph();
@@ -453,7 +467,7 @@ public class ReportServiceImpl implements IReportService {
         }
         // 转PDF
         String outfilepath = reportPath.replace(".docx", ".pdf");
-        // NpoiHelper.doc2pdf(reportPath, outfilepath);
+        NpoiHelper.doc2pdf(reportPath, outfilepath);
         System.out.println(outfilepath);
     }
 

+ 2 - 0
sql/change

@@ -0,0 +1,2 @@
+nacos: onemap-gateway-dev加白名单
+      - /analyse/fzss/ShowReport