hhw
何浩玮 2 weeks ago
parent ab80e0b5d9
commit d4c0ee62ce

@ -24,7 +24,7 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>5.8.23</version> <version>5.8.37</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
@ -118,7 +118,13 @@
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId> <artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version> <version>4.4.0</version>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.itextpdf</groupId>--> <!-- <groupId>com.itextpdf</groupId>-->
<!-- <artifactId>html2pdf</artifactId>--> <!-- <artifactId>html2pdf</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->

@ -1,6 +1,9 @@
package com.ruoyi.gysl.controller; package com.ruoyi.gysl.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -22,11 +25,15 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import javax.validation.constraints.Size;
import java.util.Arrays; import java.io.*;
import java.util.List; import java.util.*;
import java.util.zip.ZipEntry;
import static java.lang.System.out;
/** /**
* (BasicInformation) * (BasicInformation)
@ -140,7 +147,7 @@ public class BasicInformationController extends BaseController {
if (byId.getStatus() != 1) { if (byId.getStatus() != 1) {
throw new ServiceException("暂不能提交!"); throw new ServiceException("暂不能提交!");
} }
return success(basicInformationService.audit(req, 2,byId.getStatus())); return success(basicInformationService.audit(req, 2, byId.getStatus()));
} }
/** /**
@ -154,7 +161,7 @@ public class BasicInformationController extends BaseController {
if (byId.getStatus() == 1) { if (byId.getStatus() == 1) {
throw new ServiceException("请等待企业填报!"); throw new ServiceException("请等待企业填报!");
} }
return success(basicInformationService.audit(req, 3,byId.getStatus())); return success(basicInformationService.audit(req, 3, byId.getStatus()));
} }
/** /**
@ -261,7 +268,7 @@ public class BasicInformationController extends BaseController {
// @PreAuthorize("@ss.hasAnyRoles('admin,common')") // @PreAuthorize("@ss.hasAnyRoles('admin,common')")
@ApiOperation("导出项目数据") @ApiOperation("导出项目数据")
@PostMapping("/exportInfo") @PostMapping("/exportInfo")
public void exportInfo(HttpServletResponse response){ public void exportInfo(HttpServletResponse response) {
List<ProjectExcelInfo> pE = basicInformationService.selectList(); List<ProjectExcelInfo> pE = basicInformationService.selectList();
ExcelUtil<ProjectExcelInfo> util = new ExcelUtil<>(ProjectExcelInfo.class); ExcelUtil<ProjectExcelInfo> util = new ExcelUtil<>(ProjectExcelInfo.class);
util.exportExcel(response, pE, "项目数据"); util.exportExcel(response, pE, "项目数据");
@ -292,7 +299,8 @@ public class BasicInformationController extends BaseController {
} }
// @ApiOperation(value = "123") // @ApiOperation(value = "123")
//// @PreAuthorize("@ss.hasAnyRoles('admin,common')")
/// / @PreAuthorize("@ss.hasAnyRoles('admin,common')")
// @PostMapping(value = "/import1", consumes = "multipart/form-data") // @PostMapping(value = "/import1", consumes = "multipart/form-data")
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
// public AjaxResult import1(@RequestPart("file") MultipartFile file) throws Exception { // public AjaxResult import1(@RequestPart("file") MultipartFile file) throws Exception {
@ -329,5 +337,161 @@ public class BasicInformationController extends BaseController {
// }); // });
// return AjaxResult.success(); // return AjaxResult.success();
// } // }
@ApiOperation(value = "导出word")
@PostMapping("/wordExport")
public void wordExport(HttpServletResponse response, @RequestBody List<Long> ids) throws Exception {
// 创建临时 ZIP 文件
java.io.File tempZipFile = java.io.File.createTempFile("archive", ".zip");
// 设置文件
try {
List<File> fileList = CollUtil.newArrayList();
for (long id : ids) {
BasicInformationResponse a1 = basicInformationService.selectOne(id);
Map<String, Object> map = new HashMap<>();
map.put("name", a1.getBasicInformation().getName() != null ? a1.getBasicInformation().getName() : "/");
map.put("ssgnq", a1.getBasicInformation().getSsgnq() != null ? a1.getBasicInformation().getSsgnq() : "/");
map.put("jsdd", a1.getBasicInformation().getJsdd() != null ? a1.getBasicInformation().getJsdd() : "/");
map.put("xmfrdwxz", a1.getBasicInformation().getXmfrdwxz() != null ? a1.getBasicInformation().getXmfrdwxz() : "/");
map.put("tyshxydm", a1.getBasicInformation().getTyshxydm() != null ? a1.getBasicInformation().getTyshxydm() : "/");
map.put("sgdw", a1.getBasicInformation().getSgdw() != null ? a1.getBasicInformation().getSgdw() : "/");
map.put("sjdw", a1.getBasicInformation().getSjdw() != null ? a1.getBasicInformation().getSjdw() : "/");
map.put("begainTime", a1.getBasicInformation().getBegainTime() != null ? a1.getBasicInformation().getBegainTime() : "/");
map.put("endTime", a1.getBasicInformation().getEndTime() != null ? a1.getBasicInformation().getEndTime() : "/");
map.put("prioritize",a1.getBasicInformation().getPrioritize() != null ? a1.getBasicInformation().getPrioritize() : "/");
map.put("label",a1.getBasicInformation().getLabel() != null ? a1.getBasicInformation().getLabel() : "/");
map.put("projectLeader", a1.getBasicInformation().getProjectLeader() != null ? a1.getBasicInformation().getProjectLeader() : "/");
map.put("phone", a1.getBasicInformation().getPhone() != null ? a1.getBasicInformation().getPhone() : "/");
map.put("zydmj", a1.getBasicInformation().getZydmj() != null ? a1.getBasicInformation().getZydmj() : "/");
if(a1.getPlanInformation()!=null) {
map.put("rjl", a1.getPlanInformation().getRjl() != null ? a1.getPlanInformation().getRjl() : "/");
map.put("zjzmj", a1.getPlanInformation().getZjzmj() != null ? a1.getPlanInformation().getZjzmj() : "/");
map.put("jzds", a1.getPlanInformation().getJzds() != null ? a1.getPlanInformation().getJzds() : "/");
map.put("bzcjzmj",a1.getPlanInformation().getBzcjzmj() !=null ? a1.getPlanInformation().getBzcjzmj() :"/");
map.put("bzczmj", a1.getPlanInformation().getBzcjzmj() != null ? a1.getPlanInformation().getBzcjzmj() : "/");
map.put("jzmd", a1.getPlanInformation().getJzmd() != null ? a1.getPlanInformation().getJzmd() : "/");
map.put("zgjzcs", a1.getPlanInformation().getZgjzcs() != null ? a1.getPlanInformation().getZgjzcs() : "/");
map.put("zgjzgd", a1.getPlanInformation().getZgjzgd() != null ? a1.getPlanInformation().getZgjzgd() : "/");
map.put("fhdj", a1.getPlanInformation().getFhdj() != null ? a1.getPlanInformation().getFhdj() : "/");
map.put("jdctcw", a1.getPlanInformation().getJdctcw() != null ? a1.getPlanInformation().getJdctcw() : "/");
map.put("fjdctcw", a1.getPlanInformation().getFjdctcw() != null ? a1.getPlanInformation().getFjdctcw() : "/");
}
else{
map.put("rjl","/");
map.put("zjzmj","/");
map.put("jzds","/");
map.put("bzcjzmj","/");
map.put("bzczmj","/");
map.put("jzmd","/");
map.put("zgjzcs","/");
map.put("zgjzgd","/");
map.put("fhdj","/");
map.put("jdctcw","/");
map.put("fjdctcw","/");
}
if (a1.getBasicInformation().getNature() != null) {
switch (a1.getBasicInformation().getNature()) {
case 1:
map.put("nature", "国企");
break;
case 2:
map.put("nature", "外资企业");
break;
case 3:
map.put("nature", "民营企业");
break;
case 4:
map.put("nature", "其他");
break;
default:
map.put("nature", "/");
}
} else {
map.put("nature", "/");
}
map.put("jhtze", a1.getBasicInformation().getJhtze() != null ? a1.getBasicInformation().getJhtze() : "/");
map.put("ztze", a1.getBasicInformation().getZtze() != null ? a1.getBasicInformation().getZtze() : "/");
if (a1.getBasicInformation().getXzfl() != null) {
switch (a1.getBasicInformation().getXzfl()) {
case 1:
map.put("xzfl", "已建");
break;
case 2:
map.put("xzfl", "在建");
break;
case 3:
map.put("xzfl", "拟建");
break;
default:
map.put("xzfl", "/");
}
} else {
map.put("xzfl", "/");
}
map.put("begainTime1", a1.getBasicInformation().getBegainTime() != null ? a1.getBasicInformation().getBegainTime() : "/");
map.put("jsjd", (a1.getBasicInformation().getJsjd() != null)
? a1.getBasicInformation().getJsjd()
: "/");
if (a1.getQyrzInformation()!=null) {
map.put("rzqys", (a1.getQyrzInformation().getRzqys() != null) ? a1.getQyrzInformation().getRzqys() : "/");
map.put("rzqyhylx", a1.getQyrzInformation().getRzqyhylx() != null ? a1.getQyrzInformation().getRzqyhylx() : "/");
map.put("rysl", a1.getQyrzInformation().getRysl() != null ? a1.getQyrzInformation().getRysl() : "/");
map.put("rzl", a1.getQyrzInformation().getRzl() != null ? a1.getQyrzInformation().getRzl() : "/");
map.put("yczmj", a1.getQyrzInformation().getYczmj() != null ? a1.getQyrzInformation().getYczmj() : "/");
map.put("kzczmj",a1.getQyrzInformation().getKzczmj() != null ? a1.getQyrzInformation().getKzczmj() : "/");
map.put("gycfpjzj", a1.getQyrzInformation().getGycfpjzj() != null ? a1.getQyrzInformation().getGycfpjzj() : "/");
}else{
map.put("rzqys","/");
map.put("rzqyhylx","/");
map.put("rysl","/");
map.put("rzl","/");
map.put("yczmj","/");
map.put("kzczmj","/");
map.put("gycfpjzj","/");
}
File wordFile = new File(a1.getBasicInformation().getName() + ".docx");
try (InputStream inputStream = basicInformationService.generateDocument(map);
OutputStream outputStream = new FileOutputStream(a1.getBasicInformation().getName() + ".docx")) {
if (inputStream != null) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
}
} catch (IOException e) {
e.printStackTrace();
}
fileList.add(wordFile);
}
// 将生成的 Word 文件添加到 ZIP 文件中
ZipUtil.zip(tempZipFile, false, fileList.toArray(new File[fileList.size()]));
// 设置响应头
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition", "attachment; filename=archive.zip");
// 将 ZIP 文件内容写入响应输出流
try (InputStream zipInputStream = FileUtil.getInputStream(tempZipFile);
OutputStream responseOutputStream = response.getOutputStream()) {
IoUtil.copy(zipInputStream, responseOutputStream);
}
}
finally {
// 删除临时 ZIP 文件
if (tempZipFile.exists()) {
FileUtil.del(tempZipFile);
}
// 清理生成的 Word 文件
for (long id : ids) {
BasicInformationResponse a1 = basicInformationService.selectOne(id);
File wordFile = new File(a1.getBasicInformation().getName() + ".docx");
if (wordFile.exists()) {
FileUtil.del(wordFile);
}
}
}
}
} }

@ -6,11 +6,9 @@ import com.ruoyi.gysl.entity.BasicInformation;
import com.ruoyi.gysl.entity.request.AuditRequest; import com.ruoyi.gysl.entity.request.AuditRequest;
import com.ruoyi.gysl.entity.request.BasicInformationPageReq; import com.ruoyi.gysl.entity.request.BasicInformationPageReq;
import com.ruoyi.gysl.entity.response.BasicInformationResponse; import com.ruoyi.gysl.entity.response.BasicInformationResponse;
import com.ruoyi.gysl.entity.response.ProjectBuildingExcel;
import com.ruoyi.gysl.entity.response.ProjectExcelInfo; import com.ruoyi.gysl.entity.response.ProjectExcelInfo;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import java.io.ByteArrayInputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -94,6 +92,6 @@ public interface BasicInformationService extends IService<BasicInformation> {
*/ */
BasicInformationResponse stagingInfo(Long id); BasicInformationResponse stagingInfo(Long id);
void generateDocument(String filePath, Map<String, String> data)throws Exception; ByteArrayInputStream generateDocument(Map<String, Object> map)throws Exception;
} }

@ -3,7 +3,6 @@ package com.ruoyi.gysl.service.impl;
import cn.hutool.core.io.resource.ClassPathResource; import cn.hutool.core.io.resource.ClassPathResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.docking.entity.SmartDeclaration; import com.ruoyi.docking.entity.SmartDeclaration;
@ -15,14 +14,9 @@ import com.ruoyi.gysl.entity.request.BasicInformationPageReq;
import com.ruoyi.gysl.entity.request.RemarkPageReq; import com.ruoyi.gysl.entity.request.RemarkPageReq;
import com.ruoyi.gysl.entity.request.ZwIdPageReq; import com.ruoyi.gysl.entity.request.ZwIdPageReq;
import com.ruoyi.gysl.entity.response.BasicInformationResponse; import com.ruoyi.gysl.entity.response.BasicInformationResponse;
import com.ruoyi.gysl.entity.response.ProjectBuildingExcel;
import com.ruoyi.gysl.entity.response.ProjectExcelInfo; import com.ruoyi.gysl.entity.response.ProjectExcelInfo;
import com.ruoyi.gysl.mapper.BasicInformationMapper; import com.ruoyi.gysl.mapper.BasicInformationMapper;
import com.ruoyi.gysl.service.*; import com.ruoyi.gysl.service.*;
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.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFRun;
@ -30,10 +24,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.FileOutputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -129,7 +123,6 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap
} }
/** /**
* *
*/ */
@ -289,7 +282,7 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Long audit(AuditRequest req, int status,int oldStatus) { public Long audit(AuditRequest req, int status, int oldStatus) {
//企业端提交审核直接修改,不需要挂起等待审批 //企业端提交审核直接修改,不需要挂起等待审批
//修改项目基本信息,和是否是负面清单 //修改项目基本信息,和是否是负面清单
List<WysmxInformation> collect1 = req.getWysmxInformations().stream().filter(x -> List<WysmxInformation> collect1 = req.getWysmxInformations().stream().filter(x ->
@ -322,12 +315,12 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap
otherInfoService.saveBatch(req.getProjectOtherInfos()); otherInfoService.saveBatch(req.getProjectOtherInfos());
if (status == 2) { if (status == 2) {
if(oldStatus==1){ if (oldStatus == 1) {
userService.getAllZwUser("关于" + req.getBasicInformation().getName() + "项目,待审核的通知", req.getBasicInformation().getId(), null, null); userService.getAllZwUser("关于" + req.getBasicInformation().getName() + "项目,待审核的通知", req.getBasicInformation().getId(), null, null);
} }
} }
if (status == 3) { if (status == 3) {
if(oldStatus==2) { if (oldStatus == 2) {
SmartDeclaration sd = new SmartDeclaration(); SmartDeclaration sd = new SmartDeclaration();
sd.setTyshxydm((req.getBasicInformation().getTyshxydm())); sd.setTyshxydm((req.getBasicInformation().getTyshxydm()));
sd.setProjectId(req.getBasicInformation().getId()); sd.setProjectId(req.getBasicInformation().getId());
@ -487,27 +480,42 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap
} }
@Override @Override
public void generateDocument(String filePath, Map<String, String> data) throws Exception { public ByteArrayInputStream generateDocument(Map<String, Object> map) throws Exception {
// 加载模板文件 // 加载模板文件
try (InputStream inputStream = new ClassPathResource("template.docx").getStream()) { // InputStream inputStream = new ClassPathResource("xmdpcl.docx").getStream()
ClassPathResource classPathResource = new ClassPathResource("xmdpcl.docx");
try (InputStream inputStream = classPathResource.getStream()) {
XWPFDocument document = new XWPFDocument(inputStream); XWPFDocument document = new XWPFDocument(inputStream);
// 替换模板中的占位符 // 替换模板中的占位符
for (XWPFParagraph paragraph : document.getParagraphs()) { for (XWPFParagraph paragraph : document.getParagraphs()) {
for (String key : data.keySet()) { for (String key : map.keySet()) {
String text = paragraph.getText(); StringBuilder textBuilder = new StringBuilder();
if (text.contains("{" + key + "}")) { for (XWPFRun run : paragraph.getRuns()) {
text = text.replace("{" + key + "}", data.get(key)); if (run != null && run.getText(0) != null) {
paragraph.removeRun(0); // 删除原有内容 textBuilder.append(run.getText(0));
}
}
String text = textBuilder.toString();
if (text.contains("${" + key + "}")) {
text = text.replace("${" + key + "}", map.get(key).toString());
// 删除原有内容
while (paragraph.getRuns().size() > 0) {
paragraph.removeRun(0);
}
XWPFRun run = paragraph.createRun(); XWPFRun run = paragraph.createRun();
run.setText(text); // 设置替换后的内容 run.setText(text); // 设置替换后的内容
} }
} }
} }
// 输出生成的文档 // 将文档内容写入 ByteArrayOutputStream
try (FileOutputStream out = new FileOutputStream(filePath)) { try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
document.write(out); document.write(byteArrayOutputStream);
// 将 ByteArrayOutputStream 转换为 ByteArrayInputStream 并返回
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
} }
} }
} }
} }

@ -1,16 +0,0 @@
{{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