|
@@ -178,7 +178,7 @@ public class ReportServiceImpl implements IReportService {
|
|
|
// 获取最后一级节点与根节点的对应关系
|
|
|
Map<String, FzxzFactorDTO> rootMap = FzxzFactorDTO.getLastLevelToRootMapping(fzxzFactorDTOS);
|
|
|
// 因子按照大类区分
|
|
|
- Map<String, List<FactorUseDTO>> factorTypeMap = new HashMap<>();
|
|
|
+ LinkedHashMap<String, List<FactorUseDTO>> factorTypeMap = new LinkedHashMap<>();
|
|
|
|
|
|
// 查询选址因子,并且转换为List<Map> 因子条件(包含:C、不包含:N、分析:A)
|
|
|
QueryWrapper<FactorUseDTO> wrapper = new QueryWrapper<>();
|
|
@@ -250,7 +250,7 @@ public class ReportServiceImpl implements IReportService {
|
|
|
polygonDataVo.setSourceLayerId(tableSortRes.get(0).get("tableId"));
|
|
|
polygonDataVo.setSourceLayerType("1");
|
|
|
|
|
|
-
|
|
|
+ // 遍历地块信息
|
|
|
for (int i = 0; i < fzxzJgGisDTOList.size(); i++) {
|
|
|
if (i != 0) {
|
|
|
// 添加分页
|
|
@@ -259,23 +259,25 @@ public class ReportServiceImpl implements IReportService {
|
|
|
pageBreakRun2.addBreak(BreakType.PAGE);
|
|
|
pos++;
|
|
|
}
|
|
|
- SelectionResDTO item = fzxzJgGisDTOList.get(i);
|
|
|
-
|
|
|
- String dkidStr = item.getDkid().toString();
|
|
|
- List<String> dkidList = Arrays.asList(dkidStr.split(","));
|
|
|
- // 地块信息
|
|
|
- List<Map<String, String>> dkList = getDkList(item.getSjyb(), dkidList.get(0));
|
|
|
|
|
|
NpoiHelper.Option optionIsBold = new NpoiHelper.Option();
|
|
|
optionIsBold.setBold(true);// 加粗
|
|
|
-
|
|
|
document.setParagraph(NpoiHelper.newParagraph(document, i + 1 + "、方案" + NumberUtil.int2chineseNum(i + 1), optionIsBold), pos++);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1、地块基本信息,存储到表格中
|
|
|
+ */
|
|
|
+ // 获取地块信息
|
|
|
+ SelectionResDTO item = fzxzJgGisDTOList.get(i);
|
|
|
+ String dkidStr = item.getDkid().toString();
|
|
|
+ List<String> dkidList = Arrays.asList(dkidStr.split(","));
|
|
|
+ List<Map<String, String>> dkList = getDkList(item.getSjyb(), dkidList.get(0));
|
|
|
+ // 穿件表格
|
|
|
XWPFTable table = document.createTable(dkList.size() + 3, 4);// 创建表格
|
|
|
table.setWidth(8300);// 总宽度
|
|
|
|
|
|
for (int j = 0; j < dkList.size(); j++) {
|
|
|
Map<String, String> rowMap = dkList.get(j);
|
|
|
-
|
|
|
if (rowMap.size() == 2) {
|
|
|
NpoiHelper.mergeHorizontal(table, j, 1, 3);
|
|
|
table.getRow(j).getCell(0).setParagraph(NpoiHelper.setCellText(table, rowMap.get("colum0"), null));
|
|
@@ -287,8 +289,6 @@ public class ReportServiceImpl implements IReportService {
|
|
|
table.getRow(j).getCell(3).setParagraph(NpoiHelper.setCellText(table, rowMap.get("colum3"), null));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
// 准地价预估(万元)
|
|
|
NpoiHelper.mergeHorizontal(table, dkList.size(), 1, 3);// 合并单元格
|
|
|
table.getRow(dkList.size()).getCell(0).setParagraph(NpoiHelper.setCellText(table, "准地价预估(万元)", null));
|
|
@@ -300,24 +300,23 @@ public class ReportServiceImpl implements IReportService {
|
|
|
NpoiHelper.mergeHorizontal(table, dkList.size() + 2, 0, 3);
|
|
|
XWPFTableRow row = table.getRow(dkList.size() + 2);
|
|
|
|
|
|
- // 在合并后的单元格中清除所有段落,确保没有多余的段落
|
|
|
+ // 在合并后的单元格中清除所有段落,确保没有多余的段落,确保图片前面没有空行
|
|
|
XWPFTableCell cell = row.getCell(0);
|
|
|
while (cell.getParagraphs().size() > 0) {
|
|
|
cell.removeParagraph(0);
|
|
|
}
|
|
|
|
|
|
- // // 获取地块图片
|
|
|
+ // 插入地块图片
|
|
|
String geomWkt = item.getGeom();
|
|
|
ReportImage imageTable = getWktImage(geomWkt, 300);
|
|
|
-
|
|
|
- // 在合并后的单元格中创建一个新的段落
|
|
|
XWPFParagraph paraImag = row.getCell(0).addParagraph();
|
|
|
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()));
|
|
|
|
|
|
-
|
|
|
- // 获取地块信息
|
|
|
+ /**
|
|
|
+ * 2、地块规划信息
|
|
|
+ */
|
|
|
for (int j = 0; j < tableSortRes.size(); j++) {
|
|
|
if (j == 0) {
|
|
|
continue;
|
|
@@ -327,16 +326,9 @@ public class ReportServiceImpl implements IReportService {
|
|
|
polygonDataVo.setQueryTableId(tableSortRes.get(j).get("tableId"));
|
|
|
|
|
|
Map<String, Object> mapData = getTableData(polygonDataVo);
|
|
|
- // if (j == 1) {
|
|
|
- // String dataName = (String) mapData.get("dataname");// 土地现状
|
|
|
-
|
|
|
List<Object> d_list = new ArrayList<>();
|
|
|
|
|
|
- // String column1 = "";
|
|
|
if (mapData.containsKey("child")) {
|
|
|
- // column1 = "权属";
|
|
|
- // mapData.get("datalist");
|
|
|
- // mapData.get("dataname");
|
|
|
List<Object> v_1 = (List<Object>) mapData.get("child");
|
|
|
System.out.println("");
|
|
|
d_list.addAll(v_1);
|
|
@@ -346,7 +338,6 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
for (int i1 = 0; i1 < d_list.size(); i1++) {
|
|
|
Map<String, Object> v1_MapData = (Map<String, Object>) d_list.get(i1);
|
|
|
- // if (j == 1) {
|
|
|
String dataName = (String) v1_MapData.get("dataname");// 土地现状
|
|
|
List tabPlanTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
NpoiHelper.TableTitle planC1Title = new NpoiHelper.TableTitle();
|
|
@@ -373,14 +364,66 @@ public class ReportServiceImpl implements IReportService {
|
|
|
}
|
|
|
NpoiHelper.setComTable(document, tabPlanTitles, dataPlanlist, dataName, pos++);
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3、地块因子图片
|
|
|
+ */
|
|
|
+ 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();
|
|
|
+
|
|
|
+ List<FactorUseDTO> factorUseDTOS = entry.getValue(); // 获取Map中的值(List<FactorUseDTO>)
|
|
|
+ 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, "", pos++, ParagraphAlignment.CENTER);
|
|
|
+ NpoiHelper.content(document, factorName, pos++, ParagraphAlignment.CENTER);
|
|
|
+ ReportImage reportImageFactor = getPathImage(imagePath, 400);
|
|
|
+
|
|
|
+ XWPFParagraph imageParagraphFactor = document.createParagraph();
|
|
|
+ imageParagraphFactor.setAlignment(ParagraphAlignment.CENTER); // Center align the image
|
|
|
+ XWPFRun imageRunFactor = imageParagraphFactor.createRun();
|
|
|
+ imageRunFactor.addBreak();
|
|
|
+ imageRunFactor.addPicture(reportImageFactor.getInputStream(), XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(reportImageFactor.getUseWidth()), Units.toEMU(reportImageFactor.getUseHeight()));
|
|
|
+ pos++;
|
|
|
|
|
|
}
|
|
|
- // 插入因子
|
|
|
- insertFactorImage(geomRes.getGeom(), geomWkt, rootFactors, factorTypeMap, document, pos);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
File fileDoc = new File(reportPath);
|
|
|
if (fileDoc.exists()) {
|
|
|
FileUtils.forceDelete(fileDoc);
|
|
@@ -414,67 +457,6 @@ 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++;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取因子内容
|