|
@@ -0,0 +1,476 @@
|
|
|
+package com.onemap.analyse.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.onemap.analyse.domain.HgxfxDTO;
|
|
|
+import com.onemap.analyse.domain.vo.HgxfxReportVo;
|
|
|
+import com.onemap.analyse.mapper.HgxfxMapper;
|
|
|
+import com.onemap.analyse.service.GdbhReportService;
|
|
|
+import com.onemap.analyse.service.HgxfxJgReportService;
|
|
|
+import com.onemap.analyse.service.ILogService;
|
|
|
+import com.onemap.analyse.utils.NpoiHelper;
|
|
|
+import com.onemap.analyse.utils.NumberUtil;
|
|
|
+import com.onemap.analyse.utils.UnitsUtil;
|
|
|
+import com.onemap.common.core.utils.DateUtils;
|
|
|
+import com.onemap.common.core.utils.StringUtils;
|
|
|
+import com.onemap.common.core.web.domain.RequestResult;
|
|
|
+import com.onemap.system.api.ApplyService;
|
|
|
+import com.onemap.system.api.SpatialService;
|
|
|
+import com.onemap.system.api.domain.WktsVo;
|
|
|
+import jnr.ffi.annotations.In;
|
|
|
+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.python.antlr.ast.Str;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class GdbhReportServiceImpl implements GdbhReportService {
|
|
|
+ @Resource
|
|
|
+ private SpatialService spatialService;
|
|
|
+ @Value("${Hgxfx.temp}")
|
|
|
+ private String temp;
|
|
|
+ @Resource
|
|
|
+ private ILogService iLogService;
|
|
|
+ @Resource
|
|
|
+ private ApplyService applyService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String GdbhCenerateDocx(Map gdbhJgMap) throws Exception {
|
|
|
+ Map d_xmxx_0 = (Map) gdbhJgMap.get("xmxx");
|
|
|
+ String bsm = (String) d_xmxx_0.get("bsm");
|
|
|
+ iLogService.saveLog(bsm, "耕地保护分析", "耕地保护生成报告开始", "info");
|
|
|
+
|
|
|
+ // 文件硬盘真实路径
|
|
|
+ String timeStamp = DateUtils.dateTimeNow() + "";
|
|
|
+ String tempPath = temp;
|
|
|
+ String rootPath = File.separator + "耕地保护分析报告" + File.separator + bsm;
|
|
|
+ String docxName = "耕地保护分析报告_" + timeStamp + ".docx";
|
|
|
+ File f = new File(tempPath + rootPath);
|
|
|
+ if (!f.exists()) {
|
|
|
+ f.mkdirs();
|
|
|
+ }
|
|
|
+ String path = tempPath + rootPath + File.separator + docxName;
|
|
|
+ String xDpath = rootPath + File.separator + docxName;
|
|
|
+ System.out.println(path);
|
|
|
+ createReport(gdbhJgMap, path);
|
|
|
+ iLogService.saveLog(bsm, "耕地保护分析", "生成耕地保护分析报告完成。", "info");
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void createReport(Map gdbhJgMap, String reportPath) throws Exception {
|
|
|
+ Map d_xmxx_0 = (Map) gdbhJgMap.get("xmxx");
|
|
|
+ String bsm = (String) d_xmxx_0.get("bsm");
|
|
|
+ String xmmc = (String) d_xmxx_0.get("xmmc");
|
|
|
+ Integer sumNumber = (Integer) d_xmxx_0.get("sumNumber");
|
|
|
+ Double xzmj = (Double) d_xmxx_0.get("xzmj");
|
|
|
+
|
|
|
+ XWPFDocument document = null;
|
|
|
+ OutputStream outputStream = null;// 把doc输出到输出流
|
|
|
+ try {
|
|
|
+ RequestResult res_0 = applyService.QueryGdbhJgGeom(bsm);
|
|
|
+ if (res_0.isError()) {
|
|
|
+ throw new Exception(String.valueOf(res_0.get(RequestResult.MSG_TAG)));
|
|
|
+ }
|
|
|
+
|
|
|
+ Map res_1 = (Map) res_0.get(RequestResult.DATA_TAG);
|
|
|
+ String ewkt = (String) res_1.get("geom");
|
|
|
+
|
|
|
+ document = new XWPFDocument();
|
|
|
+
|
|
|
+ int pos = 0;
|
|
|
+ // 0、文本标题
|
|
|
+ NpoiHelper.title(document, "耕地保护分析报告", pos++);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+
|
|
|
+ // 1、项目选址信息
|
|
|
+ NpoiHelper.catalog(document, "一、耕地保护分析信息", pos++);
|
|
|
+ List<String> listTemp = new ArrayList<>();
|
|
|
+ listTemp.add("\t项目名称:" + xmmc);
|
|
|
+ listTemp.add("\t图斑个数:" + sumNumber + "个");
|
|
|
+ listTemp.add("\t图斑面积:" + xzmj + "㎡");
|
|
|
+ listTemp.add("\t分析时间:" + DateUtils.getTime());
|
|
|
+ listTemp.add("\t分析因子:");
|
|
|
+ NpoiHelper.content(document, listTemp, pos++);
|
|
|
+ //因子
|
|
|
+ factorWrite(document, pos++, gdbhJgMap);
|
|
|
+ NpoiHelper.content(document, "分析范围", pos++);
|
|
|
+
|
|
|
+ WktsVo wktsVo = new WktsVo();
|
|
|
+ List<WktsVo.WktInfo> wktInfos = new ArrayList<>();
|
|
|
+ WktsVo.WktInfo wktInfoData = new WktsVo.WktInfo();
|
|
|
+ wktInfoData.setWkt(ewkt);
|
|
|
+ wktInfos.add(wktInfoData);
|
|
|
+ wktsVo.setWktInfos(wktInfos);
|
|
|
+ RequestResult requestResult = spatialService.getImage(wktsVo);
|
|
|
+ if (requestResult.isSuccess()) {
|
|
|
+ Map<String, String> map = (Map<String, String>) requestResult.get("data");
|
|
|
+ String path = map.get("path");
|
|
|
+ InputStream is = new FileInputStream(path);
|
|
|
+ BufferedImage bufferedImage = ImageIO.read(new File(path));
|
|
|
+ int originalWidth = bufferedImage.getWidth();
|
|
|
+ int originalHeight = bufferedImage.getHeight();
|
|
|
+ int useWidth = 400; // Set the desired width
|
|
|
+ int useHeight = useWidth * originalHeight / originalWidth;
|
|
|
+ XWPFRun run = document.createParagraph().createRun();
|
|
|
+ run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(useWidth), Units.toEMU(useHeight));
|
|
|
+ }
|
|
|
+
|
|
|
+ //结果
|
|
|
+ NpoiHelper.catalog(document, "二、耕地保护分析结果", pos++);
|
|
|
+ NpoiHelper.content(document, "\t按照耕地保护选址范围和分析模型,经对所选范围内的所有模型进行分析,分析结果如下:", pos++);
|
|
|
+ jiefuo(document, pos, gdbhJgMap, bsm, ewkt);
|
|
|
+ File fileDoc = new File(reportPath);
|
|
|
+ if (fileDoc.exists()) {
|
|
|
+ FileUtils.forceDelete(fileDoc);
|
|
|
+ }
|
|
|
+ // word文件输出流
|
|
|
+ outputStream = new FileOutputStream(reportPath);
|
|
|
+ document.write(outputStream);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ // 插入任务日志
|
|
|
+ // TODO 插入任务日志
|
|
|
+ iLogService.saveLog(bsm, "耕地保护分析", "生成耕地保护分析报告错误:" + e.getMessage(), "error");
|
|
|
+ throw e;
|
|
|
+ } finally {
|
|
|
+ if (document != null) {
|
|
|
+ try {
|
|
|
+ document.close();
|
|
|
+ } catch (Exception ex) {
|
|
|
+ System.out.println(ex.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getScxList(List<Map> jdList, Map<String, Object> factorMap, int level) {
|
|
|
+ List<Map<String, Object>> retList = new ArrayList<>();
|
|
|
+ for (Map mapData : jdList) {
|
|
|
+ String scxname = (String) mapData.get("scxname");
|
|
|
+
|
|
|
+ Map<String, Object> factorMap00 = new HashMap<>();
|
|
|
+ factorMap00.put("YXYZMCI", "");
|
|
|
+ factorMap00.put("YXYZMCⅡ", "");
|
|
|
+ factorMap00.put("YXYZMCⅢ", "");
|
|
|
+ factorMap00.put("YXZ", "");
|
|
|
+ if (factorMap != null) {
|
|
|
+ factorMap00.putAll(factorMap);
|
|
|
+ }
|
|
|
+ if (level == 0) {
|
|
|
+ factorMap00.put("YXYZMCI", scxname);
|
|
|
+ } else if (level == 1) {
|
|
|
+ factorMap00.put("YXYZMCⅡ", scxname);
|
|
|
+ } else if (level == 2) {
|
|
|
+ factorMap00.put("YXYZMCⅢ", scxname);
|
|
|
+ }
|
|
|
+ Object distanceObj = mapData.get("distance");
|
|
|
+ if (StringUtils.isNotNull(distanceObj)) {
|
|
|
+ factorMap00.put("YXZ", distanceObj);
|
|
|
+ }
|
|
|
+ retList.add(factorMap00);
|
|
|
+ Object childrenObj = mapData.get("children");
|
|
|
+ if (StringUtils.isNotNull(childrenObj)) {
|
|
|
+ List<Map> childrenList = (List<Map>) childrenObj;
|
|
|
+ List<Map<String, Object>> childrenMap = getScxList(childrenList, factorMap00, level + 1);
|
|
|
+ retList.addAll(childrenMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int jiefuo(XWPFDocument document, int pos, Map jgMap, String rwbsm, String ewkt) throws Exception {
|
|
|
+ if (StringUtils.isNull(jgMap)) {
|
|
|
+ return pos;
|
|
|
+ }
|
|
|
+ Map sandiao = (Map) jgMap.get("sandiao");
|
|
|
+ String v_mx_bsmmc_0 = (String) sandiao.get("mx_bsmmc");
|
|
|
+ List<Map<String, Object>> v_mx_data_0 = (List<Map<String, Object>>) sandiao.get("mx_data");
|
|
|
+ NpoiHelper.content(document, v_mx_data_0 + "; 分析结果如下:", pos++);
|
|
|
+
|
|
|
+ List sanDiaoTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
+ NpoiHelper.TableTitle tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("groupvalue");
|
|
|
+ tableTitle.setName("三调类型");
|
|
|
+ tableTitle.setWidth(2880);
|
|
|
+ sanDiaoTitles.add(tableTitle);
|
|
|
+
|
|
|
+ tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("sumvalue");
|
|
|
+ tableTitle.setName("三调类型面积(单位:㎡)");
|
|
|
+ tableTitle.setWidth(3000);
|
|
|
+ sanDiaoTitles.add(tableTitle);
|
|
|
+ NpoiHelper.setComTable(document, sanDiaoTitles, v_mx_data_0, "", pos);
|
|
|
+
|
|
|
+ //TODO 先测试
|
|
|
+ List<WktsVo.WktInfo> sandiaoWtsList = new ArrayList<>();
|
|
|
+ WktsVo.WktInfo wktInfoData0 = new WktsVo.WktInfo();
|
|
|
+ wktInfoData0.setWkt(ewkt);
|
|
|
+ sandiaoWtsList.add(wktInfoData0);
|
|
|
+
|
|
|
+ for (Map map_0 : v_mx_data_0) {
|
|
|
+ WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
|
|
|
+ String geom = (String) map_0.get("geom");
|
|
|
+ wktInfo.setWkt(geom);
|
|
|
+ String colorString = generateRandomColor();
|
|
|
+ wktInfo.setFillColor(colorString);
|
|
|
+ wktInfo.setBorderColor(colorString);
|
|
|
+ sandiaoWtsList.add(wktInfo);
|
|
|
+ }
|
|
|
+ WktsVo sandiaoWktsVo = new WktsVo();
|
|
|
+ sandiaoWktsVo.setWktInfos(sandiaoWtsList);
|
|
|
+ RequestResult requestResult = spatialService.getImage(sandiaoWktsVo);
|
|
|
+ if (requestResult.isSuccess()) {
|
|
|
+ Map<String, String> map = (Map<String, String>) requestResult.get("data");
|
|
|
+ String path = map.get("path");
|
|
|
+ InputStream is = new FileInputStream(path);
|
|
|
+ BufferedImage bufferedImage = ImageIO.read(new File(path));
|
|
|
+ int originalWidth = bufferedImage.getWidth();
|
|
|
+ int originalHeight = bufferedImage.getHeight();
|
|
|
+ int useWidth = 400; // Set the desired width
|
|
|
+ int useHeight = useWidth * originalHeight / originalWidth;
|
|
|
+ XWPFRun run = document.createParagraph().createRun();
|
|
|
+ run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(useWidth), Units.toEMU(useHeight));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<Map> yzjg = (List<Map>) jgMap.get("yzjg");
|
|
|
+ for (Map yz_data : yzjg) {
|
|
|
+
|
|
|
+ XWPFParagraph pageBreakParagraph1 = document.createParagraph();
|
|
|
+ XWPFRun pageBreakRun1 = pageBreakParagraph1.createRun();
|
|
|
+ pageBreakRun1.addBreak(BreakType.PAGE);
|
|
|
+ pos++;
|
|
|
+
|
|
|
+ List<Map> mx_data_list = (List<Map>) yz_data.get("mx_data");
|
|
|
+ String mx_bsmmc = (String) yz_data.get("mx_bsmmc");
|
|
|
+ String mx_bsm = (String) yz_data.get("mx_bsm");
|
|
|
+ NpoiHelper.content(document, mx_bsmmc + "; 分析结果如下:", pos++);
|
|
|
+
|
|
|
+ for (Map d0_yz_data : mx_data_list) {
|
|
|
+ Integer d0_sumcount = (Integer) d0_yz_data.get("sumcount");
|
|
|
+ String d0_bsmmc = (String) d0_yz_data.get("bsmmc");
|
|
|
+ Double d0_sumvalue = (Double) d0_yz_data.get("sumvalue");
|
|
|
+ String d0_bsm = (String) d0_yz_data.get("bsm");
|
|
|
+
|
|
|
+ List tabYzTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
+ NpoiHelper.TableTitle tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("sumcount");
|
|
|
+ tableTitle.setName(d0_bsmmc + "个数");
|
|
|
+ tableTitle.setWidth(2880);
|
|
|
+ tabYzTitles.add(tableTitle);
|
|
|
+
|
|
|
+ tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("sumvalue");
|
|
|
+ tableTitle.setName(d0_bsmmc + "面积(单位:㎡)");
|
|
|
+ tableTitle.setWidth(3000);
|
|
|
+ tabYzTitles.add(tableTitle);
|
|
|
+ List<Map<String, Object>> dataTablelist = new ArrayList<>();
|
|
|
+ dataTablelist.add(d0_yz_data);
|
|
|
+ NpoiHelper.setComTable(document, tabYzTitles, dataTablelist, "", pos);
|
|
|
+
|
|
|
+ RequestResult res_0 = applyService.QueryGdbhJgYz(rwbsm, mx_bsm, d0_bsm);
|
|
|
+ if (res_0.isError()) {
|
|
|
+ throw new Exception(String.valueOf(res_0.get(RequestResult.MSG_TAG)));
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 先测试
|
|
|
+ List<Map> res_1 = (List<Map>) res_0.get(RequestResult.DATA_TAG);
|
|
|
+ WktsVo wktsVo = new WktsVo();
|
|
|
+ List<WktsVo.WktInfo> wktInfos = new ArrayList<>();
|
|
|
+ WktsVo.WktInfo wktInfoData = new WktsVo.WktInfo();
|
|
|
+ wktInfoData.setWkt(ewkt);
|
|
|
+ wktInfos.add(wktInfoData);
|
|
|
+
|
|
|
+ for (Map map_0 : res_1) {
|
|
|
+ WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
|
|
|
+ String geom = (String) map_0.get("geom");
|
|
|
+ wktInfo.setWkt(geom);
|
|
|
+ String colorString = generateRandomColor();
|
|
|
+ wktInfo.setFillColor(colorString);
|
|
|
+ wktInfo.setBorderColor(colorString);
|
|
|
+ wktInfos.add(wktInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ wktsVo.setWktInfos(wktInfos);
|
|
|
+ RequestResult requestResult = spatialService.getImage(wktsVo);
|
|
|
+ if (requestResult.isSuccess()) {
|
|
|
+ Map<String, String> map = (Map<String, String>) requestResult.get("data");
|
|
|
+ String path = map.get("path");
|
|
|
+ InputStream is = new FileInputStream(path);
|
|
|
+ BufferedImage bufferedImage = ImageIO.read(new File(path));
|
|
|
+ int originalWidth = bufferedImage.getWidth();
|
|
|
+ int originalHeight = bufferedImage.getHeight();
|
|
|
+ int useWidth = 400; // Set the desired width
|
|
|
+ int useHeight = useWidth * originalHeight / originalWidth;
|
|
|
+ XWPFRun run = document.createParagraph().createRun();
|
|
|
+ run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(useWidth), Units.toEMU(useHeight));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return pos;
|
|
|
+ }
|
|
|
+
|
|
|
+// private int jiefuo2(XWPFDocument document, int pos, Map jgMap) throws IOException, InvalidFormatException {
|
|
|
+// if (StringUtils.isNull(jgMap)) {
|
|
|
+// return pos;
|
|
|
+// }
|
|
|
+// List<Map> yzjg = (List<Map>) jgMap.get("yzjg");
|
|
|
+//
|
|
|
+//
|
|
|
+// int i = 0;
|
|
|
+// NpoiHelper.Option optionIsBold = new NpoiHelper.Option();
|
|
|
+// optionIsBold.setBold(true);//
|
|
|
+// for (Map jgMap : jgList) {
|
|
|
+// List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
+// Object dataListObj = jgMap.get("dataList");
|
|
|
+// if (dataListObj != null) {
|
|
|
+// dataList = (List<Map<String, Object>>) dataListObj;
|
|
|
+// }
|
|
|
+// Integer scxstyle = (Integer) jgMap.get("scxstyle");
|
|
|
+// String scxname = (String) jgMap.get("scxname");
|
|
|
+// String d_tiles = tiles + (i + 1);
|
|
|
+// document.setParagraph(NpoiHelper.newParagraph(document, d_tiles + "、分析因子 " + scxname, optionIsBold), pos++);
|
|
|
+// if (scxstyle != null && 0 == scxstyle && dataList.size() > 0) {
|
|
|
+// List tabYzTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
+// NpoiHelper.TableTitle tableTitle = new NpoiHelper.TableTitle();
|
|
|
+// tableTitle.setKey("yslx_name");
|
|
|
+// tableTitle.setName("名称");
|
|
|
+// tableTitle.setWidth(3760);
|
|
|
+// tabYzTitles.add(tableTitle);
|
|
|
+// tableTitle = new NpoiHelper.TableTitle();
|
|
|
+// tableTitle.setKey("mj");
|
|
|
+// tableTitle.setName("面积(亩)");
|
|
|
+// tableTitle.setWidth(5640);
|
|
|
+// tabYzTitles.add(tableTitle);
|
|
|
+// // 查询选址因子,并且转换为List<Map> 因子条件(包含:C、不包含:N、分析:A)
|
|
|
+// List<Map<String, Object>> dataTablelist = dataList;
|
|
|
+// NpoiHelper.setComTable(document, tabYzTitles, dataTablelist, scxname + "结果", pos++);
|
|
|
+// } else if (scxstyle != null && 1 == scxstyle && dataList.size() > 0) {
|
|
|
+// List tabYzTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
+// NpoiHelper.TableTitle tableTitle = new NpoiHelper.TableTitle();
|
|
|
+// tableTitle.setKey("yslx_name");
|
|
|
+// tableTitle.setName("名称");
|
|
|
+// tableTitle.setWidth(3760);
|
|
|
+// tabYzTitles.add(tableTitle);
|
|
|
+// tableTitle = new NpoiHelper.TableTitle();
|
|
|
+// tableTitle.setKey("mj");
|
|
|
+// tableTitle.setName("距离(米)");
|
|
|
+// tableTitle.setWidth(5640);
|
|
|
+// tabYzTitles.add(tableTitle);
|
|
|
+// // 查询选址因子,并且转换为List<Map> 因子条件(包含:C、不包含:N、分析:A)
|
|
|
+// List<Map<String, Object>> dataTablelist = dataList;
|
|
|
+// NpoiHelper.setComTable(document, tabYzTitles, dataTablelist, scxname + "结果", pos++);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (dataList.size() > 0) {
|
|
|
+// pos++;
|
|
|
+// WktsVo wktsVo = new WktsVo();
|
|
|
+// List<WktsVo.WktInfo> wktInfos = new ArrayList<>();
|
|
|
+// WktsVo.WktInfo wktInfoData = new WktsVo.WktInfo();
|
|
|
+// wktInfoData.setWkt(ewkt);
|
|
|
+// wktInfos.add(wktInfoData);
|
|
|
+//
|
|
|
+// for (Map<String, Object> dataMap : dataList) {
|
|
|
+// WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
|
|
|
+// String geom = (String) dataMap.get("geom");
|
|
|
+// wktInfo.setWkt(geom);
|
|
|
+// String colorString = generateRandomColor();
|
|
|
+// wktInfo.setFillColor(colorString);
|
|
|
+// wktInfo.setBorderColor(colorString);
|
|
|
+// wktInfos.add(wktInfo);
|
|
|
+// }
|
|
|
+//
|
|
|
+// wktsVo.setWktInfos(wktInfos);
|
|
|
+// RequestResult requestResult = spatialService.getImage(wktsVo);
|
|
|
+// if (requestResult.isSuccess()) {
|
|
|
+// Map<String, String> map = (Map<String, String>) requestResult.get("data");
|
|
|
+// String path = map.get("path");
|
|
|
+// InputStream is = new FileInputStream(path);
|
|
|
+// BufferedImage bufferedImage = ImageIO.read(new File(path));
|
|
|
+// int originalWidth = bufferedImage.getWidth();
|
|
|
+// int originalHeight = bufferedImage.getHeight();
|
|
|
+// int useWidth = 400; // Set the desired width
|
|
|
+// int useHeight = useWidth * originalHeight / originalWidth;
|
|
|
+// XWPFRun run = document.createParagraph().createRun();
|
|
|
+// run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, null, Units.toEMU(useWidth), Units.toEMU(useHeight));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// List<Map> children = (List<Map>) jgMap.get("children");
|
|
|
+// pos = jiefuo(document, pos, children, d_tiles + ".", ewkt);
|
|
|
+// i++;
|
|
|
+//
|
|
|
+// }
|
|
|
+// return pos;
|
|
|
+// }
|
|
|
+
|
|
|
+ private String generateRandomColor() {
|
|
|
+ Random random = new Random();
|
|
|
+ int red = random.nextInt(256);
|
|
|
+ int green = random.nextInt(256);
|
|
|
+ int blue = random.nextInt(256);
|
|
|
+ return String.format("#%02x%02x%02x", red, green, blue);
|
|
|
+ }
|
|
|
+
|
|
|
+ //因子信息配置
|
|
|
+ private void factorWrite(XWPFDocument document, int pos, Map jdList) {
|
|
|
+ List tabYzTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
+
|
|
|
+ NpoiHelper.TableTitle tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("YXYZMCI");
|
|
|
+ tableTitle.setName("分析模型");
|
|
|
+ tableTitle.setWidth(1880);
|
|
|
+ tabYzTitles.add(tableTitle);
|
|
|
+
|
|
|
+ tableTitle = new NpoiHelper.TableTitle();
|
|
|
+ tableTitle.setKey("YXYZMCⅡ");
|
|
|
+ tableTitle.setName("数据名称");
|
|
|
+ tableTitle.setWidth(1880);
|
|
|
+ tabYzTitles.add(tableTitle);
|
|
|
+ List<Map<String, Object>> dataTablelist = getScxList(jdList);
|
|
|
+ NpoiHelper.setComTable(document, tabYzTitles, dataTablelist, "分析模型", pos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getScxList(Map factorMap) {
|
|
|
+ List<Map<String, Object>> retList = new ArrayList<>();
|
|
|
+ List<Map> jdList = (List<Map>) factorMap.get("yzjg");
|
|
|
+ for (Map mapData : jdList) {
|
|
|
+ String scxname = (String) mapData.get("mx_bsmmc");
|
|
|
+ List<Map> mx_data = (List<Map>) mapData.get("mx_data");
|
|
|
+ for (Map mapMxData : mx_data) {
|
|
|
+ String bsmmc = (String) mapMxData.get("bsmmc");
|
|
|
+ Map<String, Object> factorMap00 = new HashMap<>();
|
|
|
+ factorMap00.put("YXYZMCI", scxname);
|
|
|
+ factorMap00.put("YXYZMCⅡ", bsmmc);
|
|
|
+ retList.add(factorMap00);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|