|
@@ -1,6 +1,7 @@
|
|
|
package com.onemap.analyse.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
|
|
import com.onemap.analyse.domain.FactorUseDTO;
|
|
|
import com.onemap.analyse.domain.FzxzEntityDTO;
|
|
|
import com.onemap.analyse.domain.FzxzReport;
|
|
@@ -20,17 +21,15 @@ import com.onemap.analyse.utils.NumberUtil;
|
|
|
import com.onemap.analyse.utils.UnitsUtil;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.poi.util.Units;
|
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
|
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
|
|
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
|
|
|
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
|
|
-import org.python.antlr.ast.Num;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
-import java.math.BigInteger;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -109,7 +108,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());
|
|
@@ -295,80 +294,32 @@ public class ReportServiceImpl implements IReportService {
|
|
|
NpoiHelper.mergeHorizontal(table, dkList.size() + 2, 0, 3);
|
|
|
table.getRow(dkList.size() + 2).getCell(0).setParagraph(NpoiHelper.setCellText(table, "地块位置", optionIsBold));
|
|
|
|
|
|
- // String mapF = "";
|
|
|
- // String mapM = "";
|
|
|
- //
|
|
|
- // // TODO 生成位置图片
|
|
|
- // // if (imgList != null && imgList.size() > 0) {
|
|
|
- // // for (int j = 0; j < imgList.size(); j++) {
|
|
|
- // // String s = imgList.get(j);
|
|
|
- // // if (s.indexOf(item.getBsm() + "_F") >= 0) {
|
|
|
- // // mapF = s;// 全局
|
|
|
- // // }
|
|
|
- // // if (s.indexOf(item.getBsm() + "_M") >= 0) {
|
|
|
- // // mapM = s;// 局部
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // if (StringUtils.isNotEmpty(mapF)) {
|
|
|
- // FileInputStream fis = null;
|
|
|
- // try {
|
|
|
- // fis = new FileInputStream(new File(mapF));
|
|
|
- // XWPFParagraph paragraph = table.getRow(4).getCell(0).addParagraph();
|
|
|
- // paragraph.setAlignment(ParagraphAlignment.CENTER);
|
|
|
- // XWPFRun run = paragraph.createRun();
|
|
|
- // run.addPicture(fis, // 条形码图片的位置
|
|
|
- // Document.PICTURE_TYPE_JPEG, // 图片类型
|
|
|
- // item.getBsm() + "_F.jpeg", // 图片名称
|
|
|
- // 2200000, // 图片的长
|
|
|
- // 1700000 // 图片的宽
|
|
|
- // );
|
|
|
- // run.addBreak(BreakType.TEXT_WRAPPING);
|
|
|
- // run.setText("(宏观位置)");
|
|
|
- // } catch (Exception e) {
|
|
|
- // System.out.println(e.toString());
|
|
|
- // } finally {
|
|
|
- // if (fis != null) {
|
|
|
- // try {
|
|
|
- // fis.close();
|
|
|
- // } catch (IOException e) {
|
|
|
- // throw e;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (StringUtils.isNotEmpty(mapM)) {
|
|
|
- // FileInputStream fis = null;
|
|
|
- // try {
|
|
|
- // fis = new FileInputStream(new File(mapM));
|
|
|
- // XWPFParagraph paragraph = table.getRow(4).getCell(2).addParagraph();
|
|
|
- // paragraph.setAlignment(ParagraphAlignment.CENTER);
|
|
|
- // XWPFRun run = paragraph.createRun();
|
|
|
- // run.addPicture(fis, // 条形码图片的位置
|
|
|
- // Document.PICTURE_TYPE_JPEG, // 图片类型
|
|
|
- // item.getBsm() + "_M.jpeg", // 图片名称
|
|
|
- // 2200000, // 图片的长
|
|
|
- // 1700000 // 图片的宽
|
|
|
- // );
|
|
|
- // run.addBreak(BreakType.TEXT_WRAPPING);
|
|
|
- // run.setText("(具体位置)");
|
|
|
- // } catch (Exception e) {
|
|
|
- // System.out.println(e.toString());
|
|
|
- // throw e;
|
|
|
- // } finally {
|
|
|
- // if (fis != null) {
|
|
|
- // try {
|
|
|
- // fis.close();
|
|
|
- // } catch (IOException e) {
|
|
|
- // throw e;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
// Table 图片
|
|
|
NpoiHelper.mergeHorizontal(table, dkList.size() + 3, 0, 3);
|
|
|
- XWPFParagraph para6 = table.getRow(dkList.size() + 3).getCell(0).addParagraph();
|
|
|
- para6.setAlignment(ParagraphAlignment.LEFT);
|
|
|
+ XWPFTableRow row = table.getRow(dkList.size() + 3);
|
|
|
+
|
|
|
+ // 在合并后的单元格中清除所有段落,确保没有多余的段落
|
|
|
+ XWPFTableCell cell = row.getCell(0);
|
|
|
+ while (cell.getParagraphs().size() > 0) {
|
|
|
+ cell.removeParagraph(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 在合并后的单元格中创建一个新的段落
|
|
|
+ XWPFParagraph paraImag = row.getCell(0).addParagraph();
|
|
|
+ paraImag.setAlignment(ParagraphAlignment.CENTER); // 居中对齐
|
|
|
+
|
|
|
+ XWPFRun run = paraImag.createRun();
|
|
|
+ File imageFile = new File("states.png");
|
|
|
+ BufferedImage bufferedImage = ImageIO.read(imageFile);
|
|
|
+
|
|
|
+ int originalWidth = bufferedImage.getWidth();
|
|
|
+ int originalHeight = bufferedImage.getHeight();
|
|
|
+
|
|
|
+ int useWidth = 300;
|
|
|
+ int useHeight = useWidth * originalHeight / originalWidth;
|
|
|
+
|
|
|
+ InputStream is = new FileInputStream(imageFile);
|
|
|
+ run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(useWidth), Units.toEMU(useHeight));
|
|
|
}
|
|
|
File fileDoc = new File(reportPath);
|
|
|
if (fileDoc.exists()) {
|
|
@@ -479,9 +430,9 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
Map<String, String> row4ItemMap = new HashMap<>();
|
|
|
row4ItemMap.put("colum0", "容积率上限");
|
|
|
- row4ItemMap.put("colum1", NumberUtil.double2TwoDecimal(UnitsUtil.m2ToMu((Double)rawTable.get("rjld"))) + "");
|
|
|
+ row4ItemMap.put("colum1", NumberUtil.double2TwoDecimal(UnitsUtil.m2ToMu((Double) rawTable.get("rjld"))) + "");
|
|
|
row4ItemMap.put("colum2", "容积率下限");
|
|
|
- row4ItemMap.put("colum3", NumberUtil.double2TwoDecimal(UnitsUtil.m2ToMu((Double)rawTable.get("rjlx"))) + "");
|
|
|
+ row4ItemMap.put("colum3", NumberUtil.double2TwoDecimal(UnitsUtil.m2ToMu((Double) rawTable.get("rjlx"))) + "");
|
|
|
rows.add(row4ItemMap);
|
|
|
|
|
|
Map<String, String> row5ItemMap = new HashMap<>();
|