hhw
何浩玮 2 weeks ago
parent a1c2f09c30
commit 6c47bed5aa

@ -437,5 +437,54 @@ public class BasicInformationController extends BaseController {
ExcelUtil<BasicInformation> util = new ExcelUtil<>(BasicInformation.class);
util.exportExcel(response, filteredList, "基本信息");
}
/**
* word
*/
@ApiOperation(value = "word导出")
@PostMapping(value = "/word_export")
public void word_export(HttpServletResponse response, @RequestParam List<Long> ids) throws Exception {
//设置n值为0 用来检查是否为一个文件
int n = 0;
for (Long id : ids) {
n++;
//b1是word里面需要的值
BasicInformationResponse b1 = basicInformationService.selectOne(id);
Map<String, Object> data = new HashMap<>();
data.put("name", b1.getBasicInformation().getName());
data.put("ssgnq", b1.getBasicInformation().getSsgnq());
data.put("jsdd", b1.getBasicInformation().getJsdd());
data.put("xmfrdwxz",b1.getBasicInformation().getXmfrdwxz());
data.put("tyshxydm",b1.getBasicInformation().getTyshxydm());
data.put("sgdw",b1.getBasicInformation().getSgdw());
data.put("sjdw",b1.getBasicInformation().getSjdw());
data.put("begainTime",b1.getBasicInformation().getBegainTime());
data.put("endTime",b1.getBasicInformation().getEndTime());
data.put("projectLeader",b1.getBasicInformation().getProjectLeader());
data.put("phone",b1.getBasicInformation().getPhone());
data.put("zydmj",b1.getBasicInformation().getZydmj());
data.put("rjl",b1.getPlanInformation().getRjl());
data.put("zjzmj",b1.getPlanInformation().getZjzmj());
data.put("jzds",b1.getPlanInformation().getJzds());
data.put("bzcjzmj",b1.getPlanInformation().getBzcjzmj());
data.put("jzmd",b1.getPlanInformation().getJzmd());
data.put("");
data.put("");
data.put("");
data.put("");
data.put("");
data.put("");
}
//如果n=1的时候就输出一个word
if (n == 1) {
}
//如果n>1的时候输出zip
else {
}
}
}

@ -93,5 +93,7 @@ public interface BasicInformationService extends IService<BasicInformation> {
* @return
*/
BasicInformationResponse stagingInfo(Long id);
void generateDocument(String filePath, Map<String, String> data)throws Exception;
}

@ -1,5 +1,6 @@
package com.ruoyi.gysl.service.impl;
import cn.hutool.core.io.resource.ClassPathResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.Excel;
@ -22,13 +23,19 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@ -473,4 +480,29 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap
}
return basicInformationResponse;
}
@Override
public void generateDocument(String filePath, Map<String, String> data) throws Exception {
// 加载模板文件
try (InputStream inputStream = new ClassPathResource("template.docx").getStream()) {
XWPFDocument document = new XWPFDocument(inputStream);
// 替换模板中的占位符
for (XWPFParagraph paragraph : document.getParagraphs()) {
for (String key : data.keySet()) {
String text = paragraph.getText();
if (text.contains("{" + key + "}")) {
text = text.replace("{" + key + "}", data.get(key));
paragraph.removeRun(0); // 删除原有内容
XWPFRun run = paragraph.createRun();
run.setText(text); // 设置替换后的内容
}
}
}
// 输出生成的文档
try (FileOutputStream out = new FileOutputStream(filePath)) {
document.write(out);
}
}
}
}

@ -0,0 +1,16 @@
{{name}}项目单片材料
投资主体简介
该项目位于{{ssgnq}},建设地点位于{{jsdd}},由{{xmfrdwxz}}
有限公司,统一信用代码为{{tyshxydm}}投资,由{{sgdw}}有限公司施工,设计单位是{{sjdw}}有限公司,建设起止时间于{{begainTime}} - {{endTime}},其重点发展产业为{{prioritize}},该项目的项目标签是{{label}},整体的项目由{{projectLeader}}负责,联系方式是{{phone}}。
规划信息
该项目总用地面积约{{zydmj}}平方米,容积率占{{rjl}},总建筑面积为{{zjzmj}}万平方米,共有{{jzds}}栋,标准建筑面积为{{bzcjzmj}}平方米,建筑密度为{{jzmd}}%,最高建筑层数{{zgjzcs}}层,最高建筑高度{{zgjzgd}}米,其防火等级为{{fhdj}},机动车停车位{{jdctcw}}辆和非机动车听车辆{{fjdctcw}}辆。
计划总投资及建设计划
该项目投资主体性质是{{nature}}计划投资额度xxx亿元实际总投资额{{ztze}}万人民币。
当前进展情况
目前,该项目属于{{xzfl}},于 {{begainTime}}日正式施工,截至目前{{jsjd}}。
企业运营情况
目前,该项目入驻企业数量共{{rzqys}}家,入驻企业行业类型为{{rzqyhylx}},人员数量共计{{eysl}}人,入住率为{{rzl}}%,其中已出租面积{{yczmj}}平方米,空置房屋{{kzczmj}}万平方米,工业厂房平均租金{{gycfpjzj}}元/平方米*月。
存在困难问题
暂无。
Loading…
Cancel
Save