|
@@ -395,296 +395,6 @@ public class QytdzzReportServiceImpl implements QytdzzReportService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //因子信息配置
|
|
|
- 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 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));
|
|
|
- pos++;
|
|
|
- }
|
|
|
-
|
|
|
- //结果
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
-// XWPFParagraph pageBreakParagraph2 = document.createParagraph();
|
|
|
-// XWPFRun pageBreakRun2 = pageBreakParagraph2.createRun();
|
|
|
-// pageBreakRun2.addBreak(BreakType.PAGE);
|
|
|
-
|
|
|
- Map sandiao = (Map) jgMap.get("sandiao");
|
|
|
- String v_mx_bsmmc_0 = (String) sandiao.get("mx_bsmmc");
|
|
|
- NpoiHelper.content(document, v_mx_bsmmc_0 + "; 分析结果如下:", pos++, ParagraphAlignment.CENTER);
|
|
|
-
|
|
|
- List<Map<String, Object>> v_mx_data_0 = (List<Map<String, Object>>) sandiao.get("mx_data");
|
|
|
- List sanDiaoTitles = new ArrayList<NpoiHelper.TableTitle>();
|
|
|
- NpoiHelper.TableTitle tableTitle1 = new NpoiHelper.TableTitle();
|
|
|
- tableTitle1.setKey("groupvalue");
|
|
|
- tableTitle1.setName("三调类型");
|
|
|
- tableTitle1.setWidth(2880);
|
|
|
- sanDiaoTitles.add(tableTitle1);
|
|
|
-
|
|
|
- tableTitle1 = new NpoiHelper.TableTitle();
|
|
|
- tableTitle1.setKey("sumvalue");
|
|
|
- tableTitle1.setName("三调类型面积(单位:㎡)");
|
|
|
- tableTitle1.setWidth(3000);
|
|
|
- sanDiaoTitles.add(tableTitle1);
|
|
|
- NpoiHelper.setComTable(document, sanDiaoTitles, v_mx_data_0, "", pos);
|
|
|
-
|
|
|
- List<WktsVo.WktInfo> sandiaoWtsList = new ArrayList<>();
|
|
|
- WktsVo.WktInfo wktInfoData0 = new WktsVo.WktInfo();
|
|
|
- wktInfoData0.setWkt(ewkt);
|
|
|
- sandiaoWtsList.add(wktInfoData0);
|
|
|
- if (v_mx_data_0 != null && v_mx_data_0.size() > 0) {
|
|
|
- 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 requestResult1 = spatialService.getImage(sandiaoWktsVo);
|
|
|
- if (requestResult1.isSuccess()) {
|
|
|
- Map<String, String> map = (Map<String, String>) requestResult1.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));
|
|
|
- pos++;
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- String mx_bsmmc = (String) yz_data.get("mx_bsmmc");
|
|
|
- String mx_bsm = (String) yz_data.get("mx_bsm");
|
|
|
- NpoiHelper.content(document, mx_bsmmc + "; 分析结果如下:", pos++, ParagraphAlignment.CENTER);
|
|
|
- List<Map> mx_data_list = (List<Map>) yz_data.get("mx_data");
|
|
|
- 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);
|
|
|
-
|
|
|
- if (res_1 != null && res_1.size() > 0) {
|
|
|
- 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));
|
|
|
- pos++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return pos;
|
|
|
- }
|
|
|
-
|
|
|
private String generateRandomColor() {
|
|
|
Random random = new Random();
|
|
|
int red = random.nextInt(256);
|
|
@@ -693,22 +403,4 @@ public class QytdzzReportServiceImpl implements QytdzzReportService {
|
|
|
return String.format("#%02x%02x%02x", red, green, blue);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
}
|