|  | @@ -25,6 +25,7 @@ import com.onemap.common.core.web.domain.RequestResult;
 | 
	
		
			
				|  |  |  import com.onemap.system.api.SpatialService;
 | 
	
		
			
				|  |  |  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;
 | 
	
	
		
			
				|  | @@ -174,7 +175,7 @@ public class ReportServiceImpl implements IReportService {
 | 
	
		
			
				|  |  |              // 获取最后一级节点与根节点的对应关系
 | 
	
		
			
				|  |  |              Map<String, FzxzFactorDTO> rootMap = FzxzFactorDTO.getLastLevelToRootMapping(fzxzFactorDTOS);
 | 
	
		
			
				|  |  |              // 因子按照大类区分
 | 
	
		
			
				|  |  | -            Map<String, List<FactorUseDTO>> factorImageMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            Map<String, List<FactorUseDTO>> factorTypeMap = new HashMap<>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // 查询选址因子,并且转换为List<Map> 因子条件(包含:C、不包含:N、分析:A)
 | 
	
		
			
				|  |  |              QueryWrapper<FactorUseDTO> wrapper = new QueryWrapper<>();
 | 
	
	
		
			
				|  | @@ -196,59 +197,59 @@ public class ReportServiceImpl implements IReportService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  // 添加因子图片
 | 
	
		
			
				|  |  |                  FzxzFactorDTO factorRoot = rootMap.get(factorUseDTO.getFactorId());
 | 
	
		
			
				|  |  | -                if (factorImageMap.containsKey(factorRoot.getId())) {
 | 
	
		
			
				|  |  | -                    factorImageMap.get(factorRoot.getId()).add(factorUseDTO);
 | 
	
		
			
				|  |  | +                if (factorTypeMap.containsKey(factorRoot.getId())) {
 | 
	
		
			
				|  |  | +                    factorTypeMap.get(factorRoot.getId()).add(factorUseDTO);
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |                      List<FactorUseDTO> factorUseDTOS = new ArrayList<>();
 | 
	
		
			
				|  |  |                      factorUseDTOS.add(factorUseDTO);
 | 
	
		
			
				|  |  | -                    factorImageMap.put(factorRoot.getId(), factorUseDTOS);
 | 
	
		
			
				|  |  | +                    factorTypeMap.put(factorRoot.getId(), factorUseDTOS);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              NpoiHelper.setComTable(document, tabYzTitles, dataTablelist, "表1:选址影响因子", pos++);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            // 生成因子图片
 | 
	
		
			
				|  |  | -            for (FzxzFactorDTO rootFactor : rootFactors) {
 | 
	
		
			
				|  |  | -                if (factorImageMap.containsKey(rootFactor.getId())) {
 | 
	
		
			
				|  |  | -                    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();
 | 
	
		
			
				|  |  | -                        int rgb = random.nextInt(0xFFFFFF + 1);
 | 
	
		
			
				|  |  | -                        String color = String.format("#%06X", rgb);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
 | 
	
		
			
				|  |  | -                        wktInfo.setWkt(ewkt);
 | 
	
		
			
				|  |  | -                        wktInfo.setBorderColor(color);
 | 
	
		
			
				|  |  | -                        wktInfo.setBorderColor(color);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        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++;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 添加分页
 | 
	
		
			
				|  |  | -            XWPFParagraph pageBreakParagraph0 = document.createParagraph();
 | 
	
		
			
				|  |  | -            XWPFRun pageBreakRun0 = pageBreakParagraph0.createRun();
 | 
	
		
			
				|  |  | -            pageBreakRun0.addBreak(BreakType.PAGE);
 | 
	
		
			
				|  |  | -            pos++;
 | 
	
		
			
				|  |  | +            // // 生成因子图片
 | 
	
		
			
				|  |  | +            // for (FzxzFactorDTO rootFactor : rootFactors) {
 | 
	
		
			
				|  |  | +            //     if (factorImageMap.containsKey(rootFactor.getId())) {
 | 
	
		
			
				|  |  | +            //         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();
 | 
	
		
			
				|  |  | +            //             int rgb = random.nextInt(0xFFFFFF + 1);
 | 
	
		
			
				|  |  | +            //             String color = String.format("#%06X", rgb);
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            //             WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
 | 
	
		
			
				|  |  | +            //             wktInfo.setWkt(ewkt);
 | 
	
		
			
				|  |  | +            //             wktInfo.setBorderColor(color);
 | 
	
		
			
				|  |  | +            //             wktInfo.setBorderColor(color);
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            //             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, 400);
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            //         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++;
 | 
	
		
			
				|  |  | +            //     }
 | 
	
		
			
				|  |  | +            // }
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            // // 添加分页
 | 
	
		
			
				|  |  | +            // XWPFParagraph pageBreakParagraph0 = document.createParagraph();
 | 
	
		
			
				|  |  | +            // XWPFRun pageBreakRun0 = pageBreakParagraph0.createRun();
 | 
	
		
			
				|  |  | +            // pageBreakRun0.addBreak(BreakType.PAGE);
 | 
	
		
			
				|  |  | +            // pos++;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // TODO 二、选址范围分析
 | 
	
		
			
				|  |  |              NpoiHelper.catalog(document, "二、选址范围分析", pos++);
 | 
	
	
		
			
				|  | @@ -257,7 +258,7 @@ public class ReportServiceImpl implements IReportService {
 | 
	
		
			
				|  |  |              NpoiHelper.content(document, fwfx, pos++);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // 获取插入图片
 | 
	
		
			
				|  |  | -            ReportImage reportImage = getWktImage(geomRes.getGeom(), 300);
 | 
	
		
			
				|  |  | +            ReportImage reportImage = getWktImage(geomRes.getGeom(), 400);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              XWPFParagraph imageParagraph = document.createParagraph();
 | 
	
		
			
				|  |  |              imageParagraph.setAlignment(ParagraphAlignment.CENTER); // Center align the image
 | 
	
	
		
			
				|  | @@ -348,7 +349,12 @@ public class ReportServiceImpl implements IReportService {
 | 
	
		
			
				|  |  |                  paraImag.setAlignment(ParagraphAlignment.CENTER); // 居中对齐
 | 
	
		
			
				|  |  |                  XWPFRun run = paraImag.createRun();
 | 
	
		
			
				|  |  |                  run.addPicture(imageTable.getInputStream(), XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(imageTable.getUseWidth()), Units.toEMU(imageTable.getUseHeight()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 插入因子
 | 
	
		
			
				|  |  | +                insertFactorImage(geomRes.getGeom(), geomWkt, rootFactors, factorTypeMap, document, pos);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              File fileDoc = new File(reportPath);
 | 
	
		
			
				|  |  |              if (fileDoc.exists()) {
 | 
	
		
			
				|  |  |                  FileUtils.forceDelete(fileDoc);
 | 
	
	
		
			
				|  | @@ -382,6 +388,68 @@ public class ReportServiceImpl implements IReportService {
 | 
	
		
			
				|  |  |          System.out.println(outfilepath);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 插入因子图片
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void insertFactorImage(String scopeEwkt, String landEwkt, List<FzxzFactorDTO> rootFactors, Map<String, List<FactorUseDTO>> factorTypeMap, XWPFDocument document, int pos) throws IOException, InvalidFormatException {
 | 
	
		
			
				|  |  | +        // 生成因子图片
 | 
	
		
			
				|  |  | +        for (FzxzFactorDTO rootFactor : rootFactors) {
 | 
	
		
			
				|  |  | +            if (factorTypeMap.containsKey(rootFactor.getId())) {
 | 
	
		
			
				|  |  | +                List<FactorUseDTO> factorUseDTOS = factorTypeMap.get(rootFactor.getId());
 | 
	
		
			
				|  |  | +                List<WktsVo.WktInfo> wktInfos = new ArrayList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 选址范围
 | 
	
		
			
				|  |  | +                WktsVo.WktInfo wktInfo0 = new WktsVo.WktInfo();
 | 
	
		
			
				|  |  | +                wktInfo0.setWkt(scopeEwkt);
 | 
	
		
			
				|  |  | +                wktInfo0.setBorderColor("#FF0000");
 | 
	
		
			
				|  |  | +                wktInfos.add(wktInfo0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 地块范围
 | 
	
		
			
				|  |  | +                WktsVo.WktInfo wktInfo1 = new WktsVo.WktInfo();
 | 
	
		
			
				|  |  | +                wktInfo1.setWkt(landEwkt);
 | 
	
		
			
				|  |  | +                wktInfo1.setBorderColor("#FF0000");
 | 
	
		
			
				|  |  | +                wktInfos.add(wktInfo1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                for (FactorUseDTO factorUseDTO : factorUseDTOS) {
 | 
	
		
			
				|  |  | +                    if (factorUseDTO.getFactorName().equals("坡度") || factorUseDTO.getFactorName().equals("高程"))
 | 
	
		
			
				|  |  | +                        continue;
 | 
	
		
			
				|  |  | +                    String ewkt = getFactorWkt(scopeEwkt, factorUseDTO.getFactorBsm());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    Random random = new Random();
 | 
	
		
			
				|  |  | +                    int rgb = random.nextInt(0xFFFFFF + 1);
 | 
	
		
			
				|  |  | +                    String color = String.format("#%06X", rgb);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
 | 
	
		
			
				|  |  | +                    wktInfo.setWkt(ewkt);
 | 
	
		
			
				|  |  | +                    wktInfo.setBorderColor(color);
 | 
	
		
			
				|  |  | +                    wktInfo.setFillColor(color);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    wktInfos.add(wktInfo);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (wktInfos.size() == 2) continue;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                String imagePath = reportImg(wktInfos);
 | 
	
		
			
				|  |  | +                if (imagePath.equals("")) continue;
 | 
	
		
			
				|  |  | +                // 获取插入图片
 | 
	
		
			
				|  |  | +                NpoiHelper.content(document, rootFactor.getName(), pos++, ParagraphAlignment.CENTER);
 | 
	
		
			
				|  |  | +                ReportImage reportImage = getPathImage(imagePath, 400);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                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++;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // // 添加分页
 | 
	
		
			
				|  |  | +        // XWPFParagraph pageBreakParagraph0 = document.createParagraph();
 | 
	
		
			
				|  |  | +        // XWPFRun pageBreakRun0 = pageBreakParagraph0.createRun();
 | 
	
		
			
				|  |  | +        // pageBreakRun0.addBreak(BreakType.PAGE);
 | 
	
		
			
				|  |  | +        // pos++;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取因子内容
 | 
	
		
			
				|  |  |       *
 |