|
@@ -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);
|
|
|
}
|
|
|
|