|
@@ -1,138 +1,44 @@
|
|
|
package com.onemap.sanya.controller;
|
|
|
|
|
|
-import com.alibaba.fastjson.util.IOUtils;
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
+
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.deepoove.poi.config.Configure;
|
|
|
import com.deepoove.poi.data.PictureRenderData;
|
|
|
import com.deepoove.poi.data.PictureType;
|
|
|
import com.deepoove.poi.data.Pictures;
|
|
|
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
|
|
-import com.deepoove.poi.template.MetaTemplate;
|
|
|
-import com.deepoove.poi.template.run.RunTemplate;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
|
import com.onemap.common.core.web.controller.BaseController;
|
|
|
import com.onemap.sanya.domain.*;
|
|
|
import com.onemap.sanya.domain.CQBC.CompensateEstimateReport;
|
|
|
-import com.onemap.sanya.domain.mergeCell.AnalyseDetailTablePolicy;
|
|
|
import com.onemap.sanya.domain.mergeCell.JZDJTableRenderPolicy;
|
|
|
-import org.apache.poi.xwpf.usermodel.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
-import org.springframework.util.ClassUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author Zzz
|
|
|
*/
|
|
|
-//@CrossOrigin(origins = "*")
|
|
|
+
|
|
|
@RestController
|
|
|
-@RequestMapping("/sanya")
|
|
|
+@RequestMapping("/exportWord")
|
|
|
public class SanYaController extends BaseController {
|
|
|
private static final Logger log = LoggerFactory.getLogger(SanYaController.class);
|
|
|
|
|
|
- private static final String[] LvArray = {"Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ"};
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出选址报告word
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping("/exportWord1")
|
|
|
- private void exportWord1(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- try {
|
|
|
- SiteSelectionReport siteSelectionReport = setWordData1();
|
|
|
- if (siteSelectionReport == null) {
|
|
|
- log.info("选址报告数据为空,导出失败!");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template/word/"+"01-选址报告-02.docx");
|
|
|
- InputStream inputStream = classPathResource.getInputStream();
|
|
|
-
|
|
|
-
|
|
|
- Configure configure = Configure.builder()
|
|
|
- .bind("tableList", new LoopRowTableRenderPolicy())
|
|
|
- .bind("analyseList", new AnalyseDetailTablePolicy()).build();
|
|
|
- // 通过 XWPFTemplate 编译文件并渲染数据到模板中
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(siteSelectionReport);
|
|
|
- //生成临时文件存放地址
|
|
|
- //String temDir = basePath;
|
|
|
- //生成文件名
|
|
|
- String wordName = "01-选址报告-02" + "-" + System.currentTimeMillis();
|
|
|
- writeWord(response, null, wordName, template);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("选址报告导出异常,{}" + e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出选址报告word
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping("/exportWord2")
|
|
|
- private void exportWord2(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- try {
|
|
|
- ComplianceAnalysisReport complianceAnalysisReport = setWordData2();
|
|
|
- if (complianceAnalysisReport == null) {
|
|
|
- log.info("合规性分析报告数据为空,导出失败!");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template/word/"+"02-合规性分析报告-02.docx");
|
|
|
- InputStream inputStream = classPathResource.getInputStream();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Configure configure = Configure.builder()
|
|
|
- .bind("tableList01", new LoopRowTableRenderPolicy())
|
|
|
- .bind("tableList02", new LoopRowTableRenderPolicy())
|
|
|
- .bind("analyseList01", new AnalyseDetailTablePolicy())
|
|
|
- .bind("analyseList02", new AnalyseDetailTablePolicy()).build();
|
|
|
- // 通过 XWPFTemplate 编译文件并渲染数据到模板中
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(complianceAnalysisReport);
|
|
|
- List<MetaTemplate> elementTemplates = template.getElementTemplates();
|
|
|
- for (MetaTemplate elementTemplate : elementTemplates) {
|
|
|
- String variable = elementTemplate.variable();
|
|
|
- if ("{{tableList01}}".equals(variable) || "{{tableList02}}".equals(variable)) {
|
|
|
- RunTemplate runTemplate = (RunTemplate) elementTemplate;
|
|
|
- XWPFRun run = runTemplate.getRun();
|
|
|
- XWPFTableCell cell = (XWPFTableCell) ((XWPFParagraph) run.getParent()).getBody();
|
|
|
- List<XWPFTableRow> rows = cell.getTableRow().getTable().getRows();
|
|
|
- int rowIndex = rows.indexOf(cell.getTableRow());
|
|
|
- XWPFTable table = cell.getTableRow().getTable();
|
|
|
- table.removeRow(rowIndex);
|
|
|
- }
|
|
|
- }
|
|
|
- //生成临时文件存放地址
|
|
|
- //String temDir = basePath;
|
|
|
- //生成文件名
|
|
|
- String wordName = "02-合规性分析报告-02" + "-" + System.currentTimeMillis();
|
|
|
- writeWord(response, null, wordName, template);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("合规性分析报告导出异常,{}" + e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 导出征收补偿预估报告word
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
- @RequestMapping("/exportWord3")
|
|
|
+ @PostMapping("/exportWord3")
|
|
|
private void exportWord3(@RequestBody CompensateEstimateReport compensateEstimateReport, HttpServletRequest request, HttpServletResponse response) {
|
|
|
try {
|
|
|
|
|
@@ -166,7 +72,8 @@ public class SanYaController extends BaseController {
|
|
|
//生成临时文件存放地址
|
|
|
//String temDir = basePath;
|
|
|
//生成文件名
|
|
|
- String wordName = "03-征收补偿预估报告-02" + "-" + System.currentTimeMillis();
|
|
|
+// String wordName = "03-征收补偿预估报告-02" + "-" + System.currentTimeMillis();
|
|
|
+ String wordName =compensateEstimateReport.getName();
|
|
|
writeWord(response, null, wordName, template);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -179,7 +86,7 @@ public class SanYaController extends BaseController {
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
- @RequestMapping("/exportWord4")
|
|
|
+ @PostMapping("/exportWord4")
|
|
|
private void exportWord4(@RequestBody BenchmarkLandPriceReport benchmarkLandPriceReport, HttpServletRequest request, HttpServletResponse response) {
|
|
|
try {
|
|
|
if (benchmarkLandPriceReport == null) {
|
|
@@ -225,7 +132,13 @@ public class SanYaController extends BaseController {
|
|
|
// 将Map转换为ArrayList
|
|
|
List<BenchmarkLandPriceTotal> benchmarkLandPriceTotals = new ArrayList<>();
|
|
|
for (Map.Entry<String, Double[]> entry : groupSums.entrySet()) {
|
|
|
- benchmarkLandPriceTotals.add(new BenchmarkLandPriceTotal(entry.getKey(), entry.getValue()[0], entry.getValue()[1]));
|
|
|
+
|
|
|
+ DecimalFormat format = new DecimalFormat("#.00");
|
|
|
+ String str0 = format.format(entry.getValue()[0]);
|
|
|
+ double Value0 = Double.parseDouble(str0);
|
|
|
+ String str1 = format.format(entry.getValue()[1]);
|
|
|
+ double Value1 = Double.parseDouble(str1);
|
|
|
+ benchmarkLandPriceTotals.add(new BenchmarkLandPriceTotal(entry.getKey(), Value0, Value1));
|
|
|
}
|
|
|
benchmarkLandPriceReport.setBenchmarkLandPriceTotalList(benchmarkLandPriceTotals);
|
|
|
|
|
@@ -240,7 +153,8 @@ public class SanYaController extends BaseController {
|
|
|
|
|
|
|
|
|
//生成文件名
|
|
|
- String wordName = "04-基准地价报告-02" + "-" + System.currentTimeMillis();
|
|
|
+// String wordName = "04-基准地价报告-02" + "-" + System.currentTimeMillis();
|
|
|
+ String wordName = benchmarkLandPriceReport.getProjectName();
|
|
|
writeWord(response, null, wordName, template);
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -250,392 +164,6 @@ public class SanYaController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 下载分析文档
|
|
|
- * @param fileName
|
|
|
- * @param response
|
|
|
- */
|
|
|
-
|
|
|
- @RequestMapping("/getWord")
|
|
|
- private void getWord( String fileName,HttpServletResponse response) {
|
|
|
- String filePath = ClassUtils.getDefaultClassLoader().getResource("").getPath() + "template/storageword/";
|
|
|
- // 设置请求头
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes(), StandardCharsets.UTF_8) + "\"");
|
|
|
- response.setHeader("download-filename", fileName);
|
|
|
- // 开放请求头download-filename前端获取权限
|
|
|
- response.setHeader("Access-Control-Expose-Headers", "download-filename");
|
|
|
- FileInputStream fis = null;
|
|
|
- OutputStream os = null;
|
|
|
- try {
|
|
|
- // 输出
|
|
|
- os = response.getOutputStream();
|
|
|
- File file = new File(filePath+fileName);
|
|
|
- if (!file.exists()) {
|
|
|
- throw new FileNotFoundException(filePath+fileName);
|
|
|
- }
|
|
|
- fis = new FileInputStream(file);
|
|
|
- byte[] b = new byte[1024];
|
|
|
- int length;
|
|
|
- while ((length = fis.read(b)) > 0) {
|
|
|
- os.write(b, 0, length);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- IOUtils.close(os);
|
|
|
- IOUtils.close(fis);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 封装-选址报告导出数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- private SiteSelectionReport setWordData1() {
|
|
|
- try {
|
|
|
- SiteSelectionReport siteSelectionReport = new SiteSelectionReport();
|
|
|
-// // 模拟数据 读取静态JSON文件填充数据 根据resource文件路径,生成文件
|
|
|
-// File jsonFile = ResourceUtils.getFile("classpath:template/json/word.json");
|
|
|
-// // 解析文件为指定编码的字符串
|
|
|
-// String json = FileUtils.readFileToString(jsonFile, "UTF-8");
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template/json/word.json");
|
|
|
- InputStream inputStream = classPathResource.getInputStream();
|
|
|
- String json = org.apache.commons.io.IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
|
|
-
|
|
|
- // 转换格式
|
|
|
- JSONObject jsonObject = JSON.parseObject(json);
|
|
|
- // 读取模拟数据 并赋值给导出对象
|
|
|
- String wordDataJson = jsonObject.get("wordData1").toString();
|
|
|
- siteSelectionReport = JSON.parseObject(wordDataJson, SiteSelectionReport.class);
|
|
|
-
|
|
|
- //模拟 影响因子数据 赋值给导出对象
|
|
|
- List<FactorData> factorDataList = new ArrayList<>();
|
|
|
- for (int i = 0; i < 6; i++) {
|
|
|
- factorDataList.add(new FactorData().FactorDataForSiteSelectionReport("测试因子名称" + i, "测试计算方法" + i, "测试因子约束" + i));
|
|
|
- }
|
|
|
- siteSelectionReport.setTableList(factorDataList);
|
|
|
-
|
|
|
- //模拟读取静态图片 赋值给导出对象
|
|
|
- String imgPath = ClassUtils.getDefaultClassLoader().getResource("").getPath() + "template/img/test.png";
|
|
|
- PictureRenderData pictureRenderData = Pictures.ofLocal(imgPath).size(300, 200).create();
|
|
|
- List<PicData> picList = new ArrayList<>();
|
|
|
- picList.add(new PicData(pictureRenderData));
|
|
|
- picList.add(new PicData(pictureRenderData));
|
|
|
- picList.add(new PicData(pictureRenderData));
|
|
|
- siteSelectionReport.setPicList(picList);
|
|
|
-
|
|
|
- // 读取分析JSON 用于生成选址范围现状分析导出数据格式
|
|
|
- String analyseJson = jsonObject.get("analyseJson").toString();
|
|
|
- List<JsonConvert> analyseConList = JSON.parseArray(analyseJson, JsonConvert.class);
|
|
|
- List<AnalyseData> analyseList = new ArrayList<>();
|
|
|
- Double totalArea = 0.0;
|
|
|
- String detail = "";
|
|
|
- //遍历选址范围现状分析 封装数据 默认数据为0-100
|
|
|
- for (JsonConvert jsonConvert : analyseConList) {
|
|
|
- String key = jsonConvert.getKey();
|
|
|
- String value = jsonConvert.getValue();
|
|
|
- List<JsonConvert> children = jsonConvert.getChildren();
|
|
|
- AnalyseData analyseData = null;
|
|
|
- if (children != null && children.size() > 0) {
|
|
|
- for (JsonConvert child : children) {
|
|
|
- String cKey = child.getKey();
|
|
|
- String cValue = child.getValue();
|
|
|
- //封装一级,二级,模拟设置分析值
|
|
|
- analyseData = new AnalyseData(key, value, cKey, cValue, new Random().nextDouble()*100, new Random().nextDouble()*100);
|
|
|
- analyseList.add(analyseData);
|
|
|
- //计算总面积
|
|
|
- if (analyseData.getAreaValue() != null) {
|
|
|
- totalArea = totalArea + analyseData.getAreaValue();
|
|
|
- }
|
|
|
- //拼接范围说明字符
|
|
|
- if (analyseData.getAreaValue() != null && analyseData.getPercentValue() != null) {
|
|
|
- detail = detail + analyseData.getSecondName() + analyseData.getAreaValue() + "平方米,占比" + analyseData.getPercentValue() + "%;";
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- analyseData = new AnalyseData(key, value, "", "", null, null);
|
|
|
- analyseList.add(analyseData);
|
|
|
- }
|
|
|
- }
|
|
|
- // 赋值导出对象
|
|
|
- siteSelectionReport.setTotalArea(totalArea + "");
|
|
|
- siteSelectionReport.setDetail(detail);
|
|
|
- siteSelectionReport.setAnalyseList(analyseList);
|
|
|
- return siteSelectionReport;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("选址报告数据封装异常,{}" + e);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 封装-合规性分析报告导出数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- private ComplianceAnalysisReport setWordData2() {
|
|
|
- try {
|
|
|
- ComplianceAnalysisReport complianceAnalysisReport = new ComplianceAnalysisReport();
|
|
|
-// // 模拟数据 读取静态JSON文件填充数据 根据resource文件路径,生成文件
|
|
|
-// File jsonFile = ResourceUtils.getFile("classpath:template/json/word.json");
|
|
|
-// // 解析文件为指定编码的字符串
|
|
|
-// String json = FileUtils.readFileToString(jsonFile, "UTF-8");
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template/json/word.json");
|
|
|
- InputStream inputStream = classPathResource.getInputStream();
|
|
|
- String json = org.apache.commons.io.IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
|
|
-
|
|
|
- // 转换格式
|
|
|
- JSONObject jsonObject = JSON.parseObject(json);
|
|
|
- // 读取模拟数据 并赋值给导出对象
|
|
|
- String wordDataJson = jsonObject.get("wordData2").toString();
|
|
|
- complianceAnalysisReport = JSON.parseObject(wordDataJson, ComplianceAnalysisReport.class);
|
|
|
-
|
|
|
- // 读取分析JSON 用于生成选址范围现状分析导出数据格式
|
|
|
- String analyseJson = jsonObject.get("analyseJson").toString();
|
|
|
- List<JsonConvert> analyseConList = JSON.parseArray(analyseJson, JsonConvert.class);
|
|
|
- List<AnalyseData> analyseList01 = new ArrayList<>();
|
|
|
- List<AnalyseData> analyseList02 = new ArrayList<>();
|
|
|
- Double totalArea01 = 0.0;
|
|
|
- String detail01 = "";
|
|
|
- Double totalArea02 = 0.0;
|
|
|
- String detail02 = "";
|
|
|
- //遍历选址范围 生成现状分析和控制性详细规划分析 封装数据 默认数据为0-100
|
|
|
- for (JsonConvert jsonConvert : analyseConList) {
|
|
|
- String key = jsonConvert.getKey();
|
|
|
- String value = jsonConvert.getValue();
|
|
|
- List<JsonConvert> children = jsonConvert.getChildren();
|
|
|
- AnalyseData analyseData01 = null;
|
|
|
- AnalyseData analyseData02 = null;
|
|
|
- if (children != null && children.size() > 0) {
|
|
|
- for (JsonConvert child : children) {
|
|
|
- String cKey = child.getKey();
|
|
|
- String cValue = child.getValue();
|
|
|
- //封装一级,二级,模拟设置分析值
|
|
|
- analyseData01 = new AnalyseData(key, value, cKey, cValue, new Random().nextDouble()*100, new Random().nextDouble()*100);
|
|
|
- analyseData02 = new AnalyseData(key, value, cKey, cValue, new Random().nextDouble()*100, new Random().nextDouble()*100);
|
|
|
- analyseList01.add(analyseData01);
|
|
|
- analyseList02.add(analyseData02);
|
|
|
- //计算现状分析总面积
|
|
|
- if (analyseData01.getAreaValue() != null) {
|
|
|
- totalArea01 = totalArea01 + analyseData01.getAreaValue();
|
|
|
- }
|
|
|
- //拼接现状分析范围说明字符
|
|
|
- if (analyseData01.getAreaValue() != null && analyseData01.getPercentValue() != null) {
|
|
|
- detail01 = detail01 + analyseData01.getSecondName() + analyseData01.getAreaValue() + "平方米,占比" + analyseData01.getPercentValue() + "%;";
|
|
|
- }
|
|
|
- //计算控制性详细规划分析总面积
|
|
|
- if (analyseData02.getAreaValue() != null) {
|
|
|
- totalArea02 = totalArea02 + analyseData02.getAreaValue();
|
|
|
- }
|
|
|
- //拼接控制性详细规划分析范围说明字符
|
|
|
- if (analyseData02.getAreaValue() != null && analyseData02.getPercentValue() != null) {
|
|
|
- detail02 = detail02 + analyseData02.getSecondName() + analyseData02.getAreaValue() + "平方米,占比" + analyseData02.getPercentValue() + "%;";
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- analyseData01 = new AnalyseData(key, value, "", "", null, null);
|
|
|
- analyseData02 = new AnalyseData(key, value, "", "", null, null);
|
|
|
- analyseList01.add(analyseData01);
|
|
|
- analyseList02.add(analyseData02);
|
|
|
- }
|
|
|
- }
|
|
|
- //生成分析因子->现状分析 数据 根据现状上面的现状分析计算而来
|
|
|
- List<FactorData> tableList01 = new ArrayList<>();
|
|
|
- if (analyseList01 != null && analyseList01.size() > 0) {
|
|
|
- Map<String, List<AnalyseData>> analyseCollect01 = analyseList01.stream().collect(Collectors.groupingBy(AnalyseData::getFirstCode));
|
|
|
- if (analyseCollect01 != null && analyseCollect01.size() > 0) {
|
|
|
- analyseCollect01.entrySet()
|
|
|
- .stream()
|
|
|
- .sorted(Map.Entry.comparingByKey())
|
|
|
- .forEach(entry -> {
|
|
|
- List<AnalyseData> analyseDataList = entry.getValue();
|
|
|
- Double sum = analyseDataList.stream().mapToDouble(obj -> obj.getAreaValue() != null ? obj.getAreaValue() : 0).sum();
|
|
|
- AnalyseData analyseData = analyseDataList.get(0);
|
|
|
- String firstCode = analyseData.getFirstCode();
|
|
|
- String firstName = analyseData.getFirstName();
|
|
|
- tableList01.add(new FactorData().FactorDataForComplianceAnalysisReport01(firstCode + " " + firstName, sum + ""));
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- //生成分析因子->控制性详细规划分析 数据 根据现状上面的控制性详细规划分析计算而来
|
|
|
- List<FactorData> tableList02 = new ArrayList<>();
|
|
|
- if (analyseList02 != null && analyseList02.size() > 0) {
|
|
|
- Map<String, List<AnalyseData>> analyseCollect02 = analyseList02.stream().collect(Collectors.groupingBy(AnalyseData::getFirstCode));
|
|
|
- if (analyseCollect02 != null && analyseCollect02.size() > 0) {
|
|
|
- analyseCollect02.entrySet()
|
|
|
- .stream()
|
|
|
- .sorted(Map.Entry.comparingByKey())
|
|
|
- .forEach(entry -> {
|
|
|
- List<AnalyseData> analyseDataList = entry.getValue();
|
|
|
- Double sum = analyseDataList.stream().mapToDouble(obj -> obj.getAreaValue() != null ? obj.getAreaValue() : 0).sum();
|
|
|
- AnalyseData analyseData = analyseDataList.get(0);
|
|
|
- String firstCode = analyseData.getFirstCode();
|
|
|
- String firstName = analyseData.getFirstName();
|
|
|
- tableList02.add(new FactorData().FactorDataForComplianceAnalysisReport02(firstCode + " " + firstName, sum + ""));
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- // 赋值导出对象
|
|
|
- complianceAnalysisReport.setTableList01(tableList01);
|
|
|
- complianceAnalysisReport.setTableList02(tableList02);
|
|
|
- complianceAnalysisReport.setAnalyseList01(analyseList01);
|
|
|
- complianceAnalysisReport.setTotalArea01(totalArea01);
|
|
|
- complianceAnalysisReport.setDetail01(detail01);
|
|
|
- complianceAnalysisReport.setAnalyseList02(analyseList02);
|
|
|
- complianceAnalysisReport.setTotalArea02(totalArea02);
|
|
|
- complianceAnalysisReport.setDetail02(detail02);
|
|
|
- return complianceAnalysisReport;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("合规性分析报告封装异常,{}" + e);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 封装-征收补偿预估报告导出数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
-// private CompensateEstimateReport setWordData3() {
|
|
|
-// try {
|
|
|
-// CompensateEstimateReport compensateEstimateReport = new CompensateEstimateReport();
|
|
|
-//// // 模拟数据 读取静态JSON文件填充数据 根据resource文件路径,生成文件
|
|
|
-//// File jsonFile = ResourceUtils.getFile("classpath:template/json/word.json");
|
|
|
-//// // 解析文件为指定编码的字符串
|
|
|
-//// String json = FileUtils.readFileToString(jsonFile, "UTF-8");
|
|
|
-//
|
|
|
-// ClassPathResource classPathResource = new ClassPathResource("template/json/word.json");
|
|
|
-// InputStream inputStream = classPathResource.getInputStream();
|
|
|
-// String json = org.apache.commons.io.IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
|
|
-//
|
|
|
-// // 转换格式
|
|
|
-// JSONObject jsonObject = JSON.parseObject(json);
|
|
|
-// // 读取模拟数据 并赋值给导出对象
|
|
|
-// String wordDataJson = jsonObject.get("wordData3").toString();
|
|
|
-// compensateEstimateReport = JSON.parseObject(wordDataJson, CompensateEstimateReport.class);
|
|
|
-// //模拟读取静态图片 赋值给导出对象
|
|
|
-// String imgPath = ClassUtils.getDefaultClassLoader().getResource("").getPath() + "template/img/test.png";
|
|
|
-// PictureRenderData pictureRenderData = Pictures.ofLocal(imgPath).size(300, 200).create();
|
|
|
-// List<PicData> picList = new ArrayList<>();
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// compensateEstimateReport.setPicList(picList);
|
|
|
-//
|
|
|
-// //模拟 3.2房屋补偿费预估->各个房屋补偿情况 数据
|
|
|
-// List<HouseCompensate> tableList01 = new ArrayList<>();
|
|
|
-// for (int i = 0; i < 10; i++) {
|
|
|
-// tableList01.add(new HouseCompensate(i, "房屋编号" + i, "产权人" + i, new Random().nextInt(100), "房屋结构" + i, new Random().nextInt(100), "房屋地址" + i));
|
|
|
-// }
|
|
|
-// //根据各个房屋补偿情况统计面积,拆迁款等内容 初始为0
|
|
|
-// int numberEHD = 0;
|
|
|
-// int feeECHD = 0;
|
|
|
-// int totalFA = 0;
|
|
|
-// int averageFeeECHD = 0;
|
|
|
-// if (tableList01 != null && tableList01.size() > 0) {
|
|
|
-// numberEHD = tableList01.size();
|
|
|
-// feeECHD = tableList01.stream().mapToInt(obj -> obj.getFeeCHD() != null ? obj.getFeeCHD() : 0).sum();
|
|
|
-// totalFA = tableList01.stream().mapToInt(obj -> obj.getFloorArea() != null ? obj.getFloorArea() : 0).sum();
|
|
|
-// averageFeeECHD = feeECHD / totalFA;
|
|
|
-// }
|
|
|
-// // 赋值导出对象
|
|
|
-// compensateEstimateReport.setTableList01(tableList01);
|
|
|
-// compensateEstimateReport.setNumberEHD(numberEHD);
|
|
|
-// compensateEstimateReport.setFeeECHD(feeECHD);
|
|
|
-// compensateEstimateReport.setTotalFA(totalFA);
|
|
|
-// compensateEstimateReport.setAverageFeeECHD(averageFeeECHD);
|
|
|
-// return compensateEstimateReport;
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// log.error("征收补偿预估报告封装异常,{}" + e);
|
|
|
-// }
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 封装-基准地价报告导出数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
-// private BenchmarkLandPriceReport setWordData4() {
|
|
|
-// try {
|
|
|
-// BenchmarkLandPriceReport benchmarkLandPriceReport = new BenchmarkLandPriceReport();
|
|
|
-// // 模拟数据 读取静态JSON文件填充数据 根据resource文件路径,生成文件
|
|
|
-// File jsonFile = ResourceUtils.getFile("classpath:template/json/word.json");
|
|
|
-// // 解析文件为指定编码的字符串
|
|
|
-// String json = FileUtils.readFileToString(jsonFile, "UTF-8");
|
|
|
-// // 转换格式
|
|
|
-// JSONObject jsonObject = JSON.parseObject(json);
|
|
|
-// // 读取模拟数据 并赋值给导出对象
|
|
|
-// String wordDataJson = jsonObject.get("wordData4").toString();
|
|
|
-// benchmarkLandPriceReport = JSON.parseObject(wordDataJson, BenchmarkLandPriceReport.class);
|
|
|
-//
|
|
|
-// //模拟读取静态图片 赋值给导出对象
|
|
|
-// String imgPath = ClassUtils.getDefaultClassLoader().getResource("").getPath() + "template/img/test.png";
|
|
|
-// PictureRenderData pictureRenderData = Pictures.ofLocal(imgPath).size(300, 200).create();
|
|
|
-// List<PicData> picList = new ArrayList<>();
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// picList.add(new PicData(pictureRenderData));
|
|
|
-// benchmarkLandPriceReport.setPicList(picList);
|
|
|
-//
|
|
|
-// //模拟 用地地价预估情况 数据,分为 国有建设用地 集体建设用地
|
|
|
-// List<LandPriceEstimation> tableList01 = new ArrayList<>();
|
|
|
-// List<LandPriceEstimation> tableList02 = new ArrayList<>();
|
|
|
-// for (int i = 0; i < 6; i++) {
|
|
|
-// tableList01.add(new LandPriceEstimation(LvArray[i], new Random().nextDouble()*100, new Random().nextDouble()*100, new Random().nextDouble()*100));
|
|
|
-// tableList02.add(new LandPriceEstimation(LvArray[i], new Random().nextDouble()*100, new Random().nextDouble()*100, new Random().nextDouble()*100));
|
|
|
-// }
|
|
|
-//
|
|
|
-// //国有建设用地面积 国有土地地价预估 默认0
|
|
|
-// Double areaSCL = 0.0;
|
|
|
-// Double landPriceESCL = 0.0;
|
|
|
-// //集体建设用地面积 集体土地地价预估 默认0
|
|
|
-// Double areaCCL = 0.0;
|
|
|
-// Double landPriceECCL = 0.0;
|
|
|
-// //总面积 总地价预估 默认0
|
|
|
-// Double totalArea = 0.0;
|
|
|
-// Double totalLandPrice = 0.0;
|
|
|
-// if (tableList01 != null && tableList01.size() > 0) {
|
|
|
-// areaSCL = tableList01.stream().mapToDouble(obj -> obj.getArea() != null ? obj.getArea() : 0).sum();
|
|
|
-// landPriceESCL = tableList01.stream().mapToDouble(obj -> obj.getLandPriceES() != null ? obj.getLandPriceES() : 0).sum();
|
|
|
-// }
|
|
|
-// if (tableList02 != null && tableList02.size() > 0) {
|
|
|
-// areaCCL = tableList02.stream().mapToDouble(obj -> obj.getArea() != null ? obj.getArea() : 0).sum();
|
|
|
-// landPriceECCL = tableList02.stream().mapToDouble(obj -> obj.getLandPriceES() != null ? obj.getLandPriceES() : 0).sum();
|
|
|
-// }
|
|
|
-// if (areaSCL > 0 && areaCCL > 0) {
|
|
|
-// totalArea = areaSCL + areaCCL;
|
|
|
-// }
|
|
|
-// if (landPriceESCL > 0 && landPriceECCL > 0) {
|
|
|
-// totalLandPrice = landPriceESCL + landPriceECCL;
|
|
|
-// }
|
|
|
-// // 赋值导出对象
|
|
|
-// benchmarkLandPriceReport.setTableList01(tableList01);
|
|
|
-// benchmarkLandPriceReport.setTableList02(tableList02);
|
|
|
-// benchmarkLandPriceReport.setTotalArea(totalArea);
|
|
|
-// benchmarkLandPriceReport.setTotalLandPrice(totalLandPrice);
|
|
|
-// benchmarkLandPriceReport.setAreaSCL(areaSCL);
|
|
|
-// benchmarkLandPriceReport.setLandPriceESCL(landPriceESCL);
|
|
|
-// benchmarkLandPriceReport.setAreaCCL(areaCCL);
|
|
|
-// benchmarkLandPriceReport.setLandPriceECCL(landPriceECCL);
|
|
|
-// return benchmarkLandPriceReport;
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// log.error("基准地价报告数据封装异常,{}" + e);
|
|
|
-// }
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* word写出
|
|
|
*
|
|
@@ -670,29 +198,4 @@ public class SanYaController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * word存储
|
|
|
- *
|
|
|
- * @param response
|
|
|
- * @param temDir
|
|
|
- * @param wordName
|
|
|
- * @param template
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private String storageWord(HttpServletResponse response, String temDir, String wordName, XWPFTemplate template) throws Exception {
|
|
|
- // 生成的word格式
|
|
|
- String formatSuffix = ".docx";
|
|
|
- // 拼接后的文件名 文件名.带后缀
|
|
|
- String fileName = wordName + formatSuffix;
|
|
|
-
|
|
|
- File file = new File(temDir + fileName);
|
|
|
- FileOutputStream out = new FileOutputStream(file);
|
|
|
- template.write(out);
|
|
|
- out.close();
|
|
|
- return fileName;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|