|
@@ -1,20 +1,21 @@
|
|
|
package com.onemap.analyse.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.onemap.analyse.domain.FactorUseDTO;
|
|
|
-import com.onemap.analyse.domain.FzxzEntityDTO;
|
|
|
-import com.onemap.analyse.domain.FzxzReport;
|
|
|
-import com.onemap.analyse.domain.SelectionResDTO;
|
|
|
+import com.onemap.analyse.domain.*;
|
|
|
import com.onemap.analyse.domain.calculation.ReportImage;
|
|
|
import com.onemap.analyse.domain.res.GeomRes;
|
|
|
import com.onemap.analyse.domain.vo.FactorSpatialVo;
|
|
|
+import com.onemap.analyse.domain.vo.TableNameIdsVo;
|
|
|
import com.onemap.analyse.mapper.FactorUseMapper;
|
|
|
+import com.onemap.analyse.mapper.FzxzFactorMapper;
|
|
|
import com.onemap.analyse.mapper.FzxzMapper;
|
|
|
import com.onemap.analyse.mapper.base.FzxzResMapper;
|
|
|
import com.onemap.analyse.mapper.base.ShpFileMapper;
|
|
|
import com.onemap.analyse.mapper.vector.GhdkaMapper;
|
|
|
+import com.onemap.analyse.service.CreateUtilsDBService;
|
|
|
import com.onemap.analyse.service.ILogService;
|
|
|
import com.onemap.analyse.service.IReportService;
|
|
|
+import com.onemap.analyse.service.ITableDateService;
|
|
|
import com.onemap.analyse.utils.JsonUtils;
|
|
|
import com.onemap.analyse.utils.NpoiHelper;
|
|
|
import com.onemap.analyse.utils.NumberUtil;
|
|
@@ -31,10 +32,12 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 生成报告
|
|
@@ -50,6 +53,8 @@ public class ReportServiceImpl implements IReportService {
|
|
|
private ILogService iLogService;
|
|
|
@Resource
|
|
|
private FactorUseMapper fzxzXzyzMapper;
|
|
|
+ @Resource
|
|
|
+ private FzxzFactorMapper fzxzFactorMapper;
|
|
|
|
|
|
@Resource
|
|
|
ShpFileMapper shpFileMapper;
|
|
@@ -63,6 +68,11 @@ public class ReportServiceImpl implements IReportService {
|
|
|
@Resource
|
|
|
SpatialService spatialService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ CreateUtilsDBService createUtilsDBService;
|
|
|
+ @Resource
|
|
|
+ ITableDateService tableDateService;
|
|
|
+
|
|
|
// 根据选址任务生成报告
|
|
|
public FzxzReport createReport(String bsm, List<String> dkIds) {
|
|
|
// 保存生成报告日志
|
|
@@ -82,7 +92,6 @@ public class ReportServiceImpl implements IReportService {
|
|
|
f.mkdirs();
|
|
|
}
|
|
|
String reportPath = "选址报告_" + timeStamp + ".docx";
|
|
|
- // TODO ###选址报告耗时,暂时隐藏###
|
|
|
createReport(res, allPath + "/" + reportPath, dkIds);
|
|
|
// 生成返回结果
|
|
|
fzxzReport.setReportfile(filePath + "/" + reportPath);
|
|
@@ -154,6 +163,22 @@ public class ReportServiceImpl implements IReportService {
|
|
|
tableTitle.setAlign(ParagraphAlignment.CENTER);
|
|
|
tableTitle.setWidth(2880);
|
|
|
tabYzTitles.add(tableTitle);
|
|
|
+
|
|
|
+ // 获取全部的因子,用于进行因子分类
|
|
|
+ QueryWrapper<FzxzFactorDTO> factorWrapper = new QueryWrapper<>();
|
|
|
+ factorWrapper.eq("status", 1);
|
|
|
+ factorWrapper.orderByAsc("order_index");
|
|
|
+ List<FzxzFactorDTO> fzxzFactorDTOS = fzxzFactorMapper.selectList(factorWrapper);
|
|
|
+
|
|
|
+ List<FzxzFactorDTO> rootFactors = new ArrayList<>();
|
|
|
+ for (FzxzFactorDTO fzxzFactorDTO : fzxzFactorDTOS) {
|
|
|
+ if (fzxzFactorDTO.getLevel() == 0) rootFactors.add(fzxzFactorDTO);
|
|
|
+ }
|
|
|
+ // 获取最后一级节点与根节点的对应关系
|
|
|
+ Map<String, FzxzFactorDTO> rootMap = FzxzFactorDTO.getLastLevelToRootMapping(fzxzFactorDTOS);
|
|
|
+ // 因子按照大类区分
|
|
|
+ Map<String, List<FactorUseDTO>> factorImageMap = new HashMap<>();
|
|
|
+
|
|
|
// 查询选址因子,并且转换为List<Map> 因子条件(包含:C、不包含:N、分析:A)
|
|
|
QueryWrapper<FactorUseDTO> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("task_id", res.getBsm());
|
|
@@ -170,11 +195,45 @@ public class ReportServiceImpl implements IReportService {
|
|
|
map.put("YXYZMC", fzxzXzyzDTO.getFactorName());
|
|
|
map.put("YZTJ_TEXT", factorMap.get("YZTJ_TEXT"));
|
|
|
map.put("YXZ", factorMap.get("YXZ"));
|
|
|
-
|
|
|
dataTablelist.add(map);
|
|
|
+
|
|
|
+ // 添加因子图片
|
|
|
+ FzxzFactorDTO factorRoot = rootMap.get(fzxzXzyzDTO.getFactorBsm());
|
|
|
+ if (factorImageMap.containsKey(factorRoot.getId())) {
|
|
|
+ factorImageMap.get(factorRoot.getId()).add(fzxzXzyzDTO);
|
|
|
+ } else {
|
|
|
+ List<FactorUseDTO> factorUseDTOS = new ArrayList<>();
|
|
|
+ factorUseDTOS.add(fzxzXzyzDTO);
|
|
|
+ factorImageMap.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) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ reportImg(wktInfos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 添加分页
|
|
|
XWPFParagraph pageBreakParagraph0 = document.createParagraph();
|
|
|
XWPFRun pageBreakRun0 = pageBreakParagraph0.createRun();
|
|
@@ -193,8 +252,7 @@ public class ReportServiceImpl implements IReportService {
|
|
|
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()));
|
|
|
+ imageRun.addPicture(reportImage.getInputStream(), XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(reportImage.getUseWidth()), Units.toEMU(reportImage.getUseHeight()));
|
|
|
pos++;
|
|
|
|
|
|
// 添加分页
|
|
@@ -279,8 +337,7 @@ public class ReportServiceImpl implements IReportService {
|
|
|
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()));
|
|
|
+ run.addPicture(imageTable.getInputStream(), XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(imageTable.getUseWidth()), Units.toEMU(imageTable.getUseHeight()));
|
|
|
}
|
|
|
File fileDoc = new File(reportPath);
|
|
|
if (fileDoc.exists()) {
|
|
@@ -438,7 +495,7 @@ public class ReportServiceImpl implements IReportService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导出报告图片
|
|
|
+ * 导出单个矢量图片
|
|
|
*
|
|
|
* @param wkt
|
|
|
* @return
|
|
@@ -460,6 +517,26 @@ public class ReportServiceImpl implements IReportService {
|
|
|
return path;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出多个矢量图片
|
|
|
+ *
|
|
|
+ * @param wktInfos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String reportImg(List<WktsVo.WktInfo> wktInfos) {
|
|
|
+ String path = "";
|
|
|
+
|
|
|
+ WktsVo wktsVo = new WktsVo();
|
|
|
+ wktsVo.setWktInfos(wktInfos);
|
|
|
+
|
|
|
+ RequestResult requestResult = spatialService.getImage(wktsVo);
|
|
|
+ if (requestResult.isSuccess()) {
|
|
|
+ Map<String, String> map = (Map<String, String>) requestResult.get("data");
|
|
|
+ path = map.get("path");
|
|
|
+ }
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取报告图片
|
|
|
*
|
|
@@ -485,4 +562,19 @@ public class ReportServiceImpl implements IReportService {
|
|
|
reportImage.setUseHeight(useHeight);
|
|
|
return reportImage;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取选址因子的矢量数据
|
|
|
+ *
|
|
|
+ * @param ewkt
|
|
|
+ * @param tableName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getFactorWkt(String ewkt, String tableName) {
|
|
|
+ String tempName = createUtilsDBService.intersectionTableWkt(tableName, null, ewkt);
|
|
|
+ TableNameIdsVo tableNameIdsVo = new TableNameIdsVo();
|
|
|
+ tableNameIdsVo.setTableName(tempName);
|
|
|
+ String ewktRes = tableDateService.getGeomUnion(tableNameIdsVo);
|
|
|
+ return ewktRes;
|
|
|
+ }
|
|
|
}
|