diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 3cb5b52..5afd3f6 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -24,7 +24,7 @@ <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> - <version>5.8.23</version> + <version>5.8.37</version> </dependency> <dependency> <groupId>org.jsoup</groupId> diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/BasicInformationController.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/BasicInformationController.java index 63b37d5..86ec07c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/BasicInformationController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/BasicInformationController.java @@ -1,9 +1,12 @@ package com.ruoyi.gysl.controller; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.ZipUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; @@ -15,8 +18,10 @@ import com.ruoyi.gysl.entity.request.BasicInformationPageReq; import com.ruoyi.gysl.entity.response.BasicInformationResponse; import com.ruoyi.gysl.entity.response.ProjectExcelInfo; import com.ruoyi.gysl.service.*; +import com.ruoyi.system.mapper.SysDictDataMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -24,9 +29,15 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.*; /** * 基本信息(BasicInformation)表控制层 @@ -38,7 +49,8 @@ import java.util.List; @RestController @RequestMapping("/gysl/basicInformation") public class BasicInformationController extends BaseController { - + @Value("${ruoyi.profile}") + private String fileAddress; // 1.审核通过之后再审核不要通知 // 2.项目评价配置和详情那边同步显示 // 3.换掉项目动态导出模板 @@ -51,7 +63,8 @@ public class BasicInformationController extends BaseController { // 5.月度报告修改 // 8.企业和政务登录 - + @Resource + private SysDictDataMapper sysDictDataMapper; /** * 基本信息 */ @@ -140,7 +153,7 @@ public class BasicInformationController extends BaseController { if (byId.getStatus() != 1) { throw new ServiceException("暂不能提交!"); } - return success(basicInformationService.audit(req, 2,byId.getStatus())); + return success(basicInformationService.audit(req, 2, byId.getStatus())); } /** @@ -154,7 +167,7 @@ public class BasicInformationController extends BaseController { if (byId.getStatus() == 1) { throw new ServiceException("请等待企业填报!"); } - return success(basicInformationService.audit(req, 3,byId.getStatus())); + return success(basicInformationService.audit(req, 3, byId.getStatus())); } /** @@ -261,7 +274,7 @@ public class BasicInformationController extends BaseController { // @PreAuthorize("@ss.hasAnyRoles('admin,common')") @ApiOperation("导出项目数据") @PostMapping("/exportInfo") - public void exportInfo(HttpServletResponse response){ + public void exportInfo(HttpServletResponse response) { List<ProjectExcelInfo> pE = basicInformationService.selectList(); ExcelUtil<ProjectExcelInfo> util = new ExcelUtil<>(ProjectExcelInfo.class); util.exportExcel(response, pE, "项目数据"); @@ -329,5 +342,88 @@ public class BasicInformationController extends BaseController { // }); // return AjaxResult.success(); // } + + @ApiOperation(value = "导出单片材料") + @PostMapping("/wordExport") + public void wordExport(HttpServletResponse response, @RequestBody List<Long> ids) throws Exception { + List<SysDictData> sysDictData = sysDictDataMapper.selectDictDataList(new SysDictData()); + String fatherFile = fileAddress + "/项目压缩文件"; + FileUtil.mkdir(fatherFile); + for (long id : ids) { + BasicInformationResponse a1 = basicInformationService.selectOne(id); + Map<String, Object> map = new HashMap<>(); + map.put("issuingTime", a1.getBasicInformation().getIssuingTime() != null ? a1.getBasicInformation().getIssuingTime() : "/"); + map.put("jsjd", a1.getBasicInformation().getJsjd() != null ? a1.getBasicInformation().getJsjd() : "/"); + map.put("xzfl", a1.getBasicInformation().getXzfl() != null ? + basicInformationService.getDictLabel("xzfl", String.valueOf(a1.getBasicInformation().getXzfl()),sysDictData) : "/"); + map.put("nature", a1.getBasicInformation().getNature() != null ? + basicInformationService.getDictLabel("xmfrdwxz", String.valueOf(a1.getBasicInformation().getNature()),sysDictData) : "/"); + map.put("name", a1.getBasicInformation().getName() != null ? a1.getBasicInformation().getName() : "/"); + map.put("ssgnq", a1.getBasicInformation().getSsgnq() != null ? + basicInformationService.getDictLabel("ssgnq", String.valueOf(a1.getBasicInformation().getSsgnq()),sysDictData) : "/"); + 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.getPlanInformation().getZydmj() != null ? a1.getPlanInformation().getZydmj() : "/"); + 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("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() : "/"); + map.put("jhtze", a1.getBasicInformation().getJhtze() != null ? a1.getBasicInformation().getJhtze() : "/"); + map.put("ztze", a1.getBasicInformation().getZtze() != null ? a1.getBasicInformation().getZtze() : "/"); + + 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() : "/"); + try { + String itemsFileName = fatherFile + "/" + a1.getBasicInformation().getName()+".docx"; + Path targetPath = Paths.get(itemsFileName); + Files.createDirectories(targetPath.getParent()); + // 2. 打开输出流(自动覆盖已有文件) + try (OutputStream out = new BufferedOutputStream( + Files.newOutputStream(targetPath, + StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING))) { + basicInformationService.generateDocument(map,"xmdtcl.docx",out); + } + } catch (Exception e) { + throw new RuntimeException("文件下载失败"); + } + } + // 压缩后的文件路径 + String zipFilePath = fatherFile + ".zip"; + ZipUtil.zip(fatherFile, zipFilePath); + File file = new File(zipFilePath);// 创建File对象 + response.setContentType("application/zip");// 设置内容类型为ZIP文件 + response.setHeader("Content-Disposition", "attachment; filename=\"file.zip\"");//设置文件名 + try (FileInputStream fileInputStream = new FileInputStream(file); + OutputStream outputStream = response.getOutputStream()) { + byte[] buffer = new byte[4096]; + int by; + while ((by = fileInputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, by); + } + } + FileUtil.del(zipFilePath); + FileUtil.del(fatherFile); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/ZwStatsController.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/ZwStatsController.java index f88684c..629941a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/ZwStatsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/ZwStatsController.java @@ -1,8 +1,6 @@ package com.ruoyi.gysl.controller; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.resource.ClassPathResource; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -14,11 +12,6 @@ import com.ruoyi.gysl.service.BasicInformationService; import com.ruoyi.gysl.service.ZwStatsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; -import org.apache.poi.xwpf.usermodel.XWPFRun; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,8 +20,9 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.io.*; -import java.net.URLEncoder; +import javax.validation.constraints.NotBlank; +import java.io.IOException; +import java.io.OutputStream; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,8 +42,6 @@ public class ZwStatsController extends BaseController { @Resource private ZwStatsService zwStatsService; - @Value("${ruoyi.profile}") - private String fileAddress; @Resource private BasicInformationService basicInformationService; @@ -143,7 +135,8 @@ public class ZwStatsController extends BaseController { */ @ApiOperation(value = "导出项目总体报告") @PostMapping(value = "/exportBg") - public void exportBg(HttpServletResponse response,@Valid String years) throws Exception { + public void exportBg(HttpServletResponse response, @Valid @NotBlank String years) + throws Exception { // 设置响应内容类型和头部 response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); @@ -154,82 +147,57 @@ public class ZwStatsController extends BaseController { List<RibbonResponse> ribbon = zwStatsService.ribbon(years); //获取投资主体 List<RibbonResponse> investors = zwStatsService.investors(years); - Map<String,Object> dt = new HashMap<>(); - dt.put("{{years}}",years); - dt.put("{{allProject}}",allProjectResponse.getAllProject()); - dt.put("{{allGrossArea}}",allProjectResponse.getAllGrossArea()); - dt.put("{{allBuilding1}}",allProjectResponse.getAllBuilding1()); - dt.put("{{allBuilding2}}",allProjectResponse.getAllBuilding2()); - dt.put("{{allBuilding3}}",allProjectResponse.getAllBuilding3()); - dt.put("{{currentYearProject}}",allProjectResponse.getCurrentYearProject()); - dt.put("{{currentYearGrossArea}}",allProjectResponse.getCurrentYearGrossArea()); - dt.put("{{currentBuilding1}}",allProjectResponse.getCurrentBuilding1()); - dt.put("{{currentBuilding2}}",allProjectResponse.getCurrentBuilding2()); - dt.put("{{currentBuilding3}}",allProjectResponse.getCurrentBuilding3()); - ribbon.forEach(x->{ + Map<String, Object> dt = new HashMap<>(); + dt.put("{{years}}", years); + dt.put("{{allProject}}", allProjectResponse.getAllProject()); + dt.put("{{allGrossArea}}", allProjectResponse.getAllGrossArea()); + dt.put("{{allBuilding1}}", allProjectResponse.getAllBuilding1()); + dt.put("{{allBuilding2}}", allProjectResponse.getAllBuilding2()); + dt.put("{{allBuilding3}}", allProjectResponse.getAllBuilding3()); + dt.put("{{currentYearProject}}", allProjectResponse.getCurrentYearProject()); + dt.put("{{currentYearGrossArea}}", allProjectResponse.getCurrentYearGrossArea()); + dt.put("{{currentBuilding1}}", allProjectResponse.getCurrentBuilding1()); + dt.put("{{currentBuilding2}}", allProjectResponse.getCurrentBuilding2()); + dt.put("{{currentBuilding3}}", allProjectResponse.getCurrentBuilding3()); + ribbon.forEach(x -> { switch (x.getSsgnq()) { case "高端制造与国际贸易区": - dt.put("{{gn1}}",x.getCount()); + dt.put("{{gn1}}", x.getCount()); break; case "阳澄湖半岛旅游度假区": - dt.put("{{gn2}}",x.getCount()); + dt.put("{{gn2}}", x.getCount()); break; case "金鸡湖商务区": - dt.put("{{gn3}}",x.getCount()); + dt.put("{{gn3}}", x.getCount()); break; case "苏相合作区": - dt.put("{{gn4}}",x.getCount()); + dt.put("{{gn4}}", x.getCount()); break; case "独墅湖科教创新区": - dt.put("{{gn5}}",x.getCount()); + dt.put("{{gn5}}", x.getCount()); break; default: break; } }); - investors.forEach(x->{ + investors.forEach(x -> { switch (x.getSsgnq()) { case "国企": - dt.put("{{tz1}}",x.getCount()); + dt.put("{{tz1}}", x.getCount()); break; case "民营企业": - dt.put("{{tz2}}",x.getCount()); + dt.put("{{tz2}}", x.getCount()); break; case "外资企业": - dt.put("{{tz3}}",x.getCount()); + dt.put("{{tz3}}", x.getCount()); break; default: break; } }); - ClassPathResource classPathResource = new ClassPathResource("ztbgmb.docx"); - try ( - InputStream inputStream = classPathResource.getStream(); - // 使用 Apache POI 处理 Word 文件(需提前引入依赖) - XWPFDocument doc = new XWPFDocument(inputStream); - ) { - // 增强的占位符替换逻辑(改进部分) - for (XWPFParagraph paragraph : doc.getParagraphs()) { - List<XWPFRun> runs = paragraph.getRuns(); - if (runs == null) continue; - for (XWPFRun run : runs) { - String text = run.getText(0); - if (text == null) continue; - // 动态替换所有模板变量 - for (Map.Entry<String, Object> entry : dt.entrySet()) { - if (text.contains(entry.getKey())) { - text = text.replace(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : ""); - run.setText(text, 0); - } - } - } - } - // 将文档写入到响应输出流 - try (OutputStream out = response.getOutputStream()) { - doc.write(out); - } - } catch (IOException e) { - e.printStackTrace(); + // 4. 生成并写入文档 + try (OutputStream out = response.getOutputStream()) { + basicInformationService.generateDocument(dt, "ztbgmb.docx", out); } } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/BasicInformationService.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/BasicInformationService.java index f33b0ca..99b8ec2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/BasicInformationService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/BasicInformationService.java @@ -2,15 +2,15 @@ package com.ruoyi.gysl.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; import com.ruoyi.gysl.entity.BasicInformation; import com.ruoyi.gysl.entity.request.AuditRequest; import com.ruoyi.gysl.entity.request.BasicInformationPageReq; import com.ruoyi.gysl.entity.response.BasicInformationResponse; -import com.ruoyi.gysl.entity.response.ProjectBuildingExcel; import com.ruoyi.gysl.entity.response.ProjectExcelInfo; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFSheet; +import java.io.OutputStream; import java.io.Serializable; import java.util.List; import java.util.Map; @@ -93,5 +93,16 @@ public interface BasicInformationService extends IService<BasicInformation> { * @return 单条数据 */ BasicInformationResponse stagingInfo(Long id); + + + /** + * 根据材料返回输chu流 + */ + void generateDocument(Map<String, Object> map, String docx, OutputStream sr) throws Exception; + + /** + * 根据dict_type和dict_value返回 + */ + String getDictLabel(String dictType, String dictValue, List<SysDictData> sysDictData); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/BasicInformationServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/BasicInformationServiceImpl.java index c6b67c3..33d8815 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/BasicInformationServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/BasicInformationServiceImpl.java @@ -1,8 +1,9 @@ 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; +import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.docking.entity.SmartDeclaration; @@ -14,21 +15,22 @@ import com.ruoyi.gysl.entity.request.BasicInformationPageReq; import com.ruoyi.gysl.entity.request.RemarkPageReq; import com.ruoyi.gysl.entity.request.ZwIdPageReq; 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.mapper.BasicInformationMapper; 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.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.IOException; +import java.io.InputStream; +import java.io.OutputStream; 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; @@ -122,7 +124,6 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap } - /** * 导出项目数据 */ @@ -132,125 +133,6 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap } -// /** -// * 填充数据 -// */ -// @Override -// public void approvalMethodfillInData(XSSFSheet sheet, XSSFCellStyle contentStyle, int rowNum, List<ProjectExcelInfo> info, List<String> sc, List<String> ec, int num) { -// Class<?> classBuilding = ProjectBuildingExcel.class; -// for (ProjectExcelInfo projectExcelInfo : info) { -// XSSFRow tempRow = sheet.createRow(rowNum++); -// tempRow.setHeight((short) 1400); -// int i1; -// for (i1 = 0; i1 < sc.size(); i1++) { -// XSSFCell tempCell = tempRow.createCell(i1); -// tempCell.setCellStyle(contentStyle); -// if (!ec.get(i1).endsWith("厂房")) { -// if (Objects.equals(sc.get(i1), "")) { -// tempCell.setCellValue(projectExcelInfo.getId()); -// } else { -// tempCell.setCellValue(getExcelData(projectExcelInfo, sc.get(i1))); -// } -// } -// } -//// XSSFCell tempCell = tempRow.createCell(8); -//// tempCell.setCellStyle(contentStyle); -//// tempCell.setCellValue("12312321"); -// -// for (int i2 = 0; i2 < projectExcelInfo.getXmjzxx().size(); i2++) { -// switch (projectExcelInfo.getXmjzxx().get(i2).getFloor()) { -// case 1: -// i1 = ec.indexOf("一层厂房"); -// break; -// case 2: -// i1 = ec.indexOf("双层厂房"); -// break; -// case 3: -// i1 = ec.indexOf("三层厂房"); -// break; -// case 4: -// i1 = ec.indexOf("四层厂房"); -// break; -// case 5: -// i1 = ec.indexOf("五层厂房"); -// break; -// default: -// i1 = ec.indexOf("六层及以上厂房"); -// } -// for (Field field : classBuilding.getDeclaredFields()) { -// XSSFCell tempCell = tempRow.createCell(i1); -// tempCell.setCellStyle(contentStyle); -// Excel excelColumn = field.getAnnotation(Excel.class); -// if (excelColumn != null) { -// tempCell.setCellValue(getBuildingData(projectExcelInfo.getXmjzxx().get(i2), sc.get(i1))); -// i1++; -// } -// } -// } -// } -// } -// -// /** -// * 填充数据-项目基础信息获取 -// */ -// @Override -// public String getExcelData(ProjectExcelInfo item, String str) { -// String a = null; -// switch (str) { -// case "": -// a = item.getId() == null ? "-" : item.getId(); -// break; -// case "项目名称": -// a = item.getName() == null ? "-" : item.getName(); -// break; -// case "项目法人单位": -// a = item.getXmfrdwxz() == null ? "-" : item.getXmfrdwxz(); -// break; -// case "项目法人单位性质": -// a = String.valueOf(item.getNature() == null ? "-" : item.getNature()); -// break; -// case "总用地面积": -// a = String.valueOf(item.getZydmj() == null ? "-" : item.getZydmj()); -// break; -// case "容积率": -// a = String.valueOf(item.getRjl() == null ? "-" : item.getRjl()); -// break; -// case "总建筑面积": -// a = String.valueOf(item.getZjzmj() == null ? "-" : item.getZjzmj()); -// break; -// case "标准层建筑面积": -// a = String.valueOf(item.getBzcjzmj() == null ? "-" : item.getBzcjzmj()); -// break; -// } -// return a; -// } -// -// /** -// * 填充数据-项目建筑信息获取 -// */ -// @Override -// public String getBuildingData(ProjectBuildingExcel item, String str) { -// String a = null; -// switch (str) { -// case "层数": -// a = item.getFloor() == null ? "-" : String.valueOf(item.getFloor()); -// break; -// case "总建筑高度": -// a = item.getTotalBuildingHeight() == null ? "-" : String.valueOf(item.getTotalBuildingHeight()); -// break; -// case "首层高度": -// a = String.valueOf(item.getScgd() == null ? "-" : item.getScgd()); -// break; -// case "2至4层高": -// a = String.valueOf(item.getTwoAndFourCg() == null ? "-" : item.getTwoAndFourCg()); -// break; -// case "4层以上层高": -// a = String.valueOf(item.getFourYscg() == null ? "-" : item.getFourYscg()); -// break; -// } -// return a; -// } - /** * 有经纬度的项目列表 */ @@ -282,25 +164,14 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap */ @Transactional(rollbackFor = Exception.class) @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 -> - "危化品等级".equals(x.getZdname()) - ) - .collect(Collectors.toList()); - List<WysmxInformation> collect2 = req.getWysmxInformations().stream().filter(x -> - "生产火灾危险等级".equals(x.getZdname()) - ) - .collect(Collectors.toList()); - List<WysmxInformation> collect3 = req.getWysmxInformations().stream().filter(x -> - "环境保护".equals(x.getZdname())) - .collect(Collectors.toList()); + List<WysmxInformation> collect1 = req.getWysmxInformations().stream().filter(x -> "危化品等级".equals(x.getZdname())).collect(Collectors.toList()); + List<WysmxInformation> collect2 = req.getWysmxInformations().stream().filter(x -> "生产火灾危险等级".equals(x.getZdname())).collect(Collectors.toList()); + List<WysmxInformation> collect3 = req.getWysmxInformations().stream().filter(x -> "环境保护".equals(x.getZdname())).collect(Collectors.toList()); if (!collect1.isEmpty() && !collect2.isEmpty() && !collect3.isEmpty()) { - req.getBasicInformation().setIsFmqd(wysmxInformationService.canGoUpstairs( - collect1.get(0).getZdinfor(), - collect2.get(0).getZdinfor(), - collect3.get(0).getZdinfor()) ? 1 : 0); + req.getBasicInformation().setIsFmqd(wysmxInformationService.canGoUpstairs(collect1.get(0).getZdinfor(), collect2.get(0).getZdinfor(), collect3.get(0).getZdinfor()) ? 1 : 0); } //修改项目规划信息 @@ -315,12 +186,12 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap otherInfoService.saveBatch(req.getProjectOtherInfos()); if (status == 2) { - if(oldStatus==1){ + if (oldStatus == 1) { userService.getAllZwUser("关于" + req.getBasicInformation().getName() + "项目,待审核的通知", req.getBasicInformation().getId(), null, null); } } if (status == 3) { - if(oldStatus==2) { + if (oldStatus == 2) { SmartDeclaration sd = new SmartDeclaration(); sd.setTyshxydm((req.getBasicInformation().getTyshxydm())); sd.setProjectId(req.getBasicInformation().getId()); @@ -344,9 +215,11 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap BasicInformationResponse basicInformationResponse = new BasicInformationResponse(); //项目基本信息 - basicInformationResponse.setBasicInformation(getById(id)); + BasicInformation byId = getById(id); + basicInformationResponse.setBasicInformation(byId == null ? new BasicInformation() : byId); //项目规划信息 - basicInformationResponse.setPlanInformation(planInformationService.lambdaQuery().eq(PlanInformation::getXmId, id).one()); + PlanInformation one = planInformationService.lambdaQuery().eq(PlanInformation::getXmId, id).one(); + basicInformationResponse.setPlanInformation(one == null ? new PlanInformation() : one); //项目建筑信息 basicInformationResponse.setBuildingInformation(buildingInformationService.lambdaQuery().eq(BuildingInformation::getXmId, id).list()); //五要素模型信息 @@ -354,7 +227,8 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap zwIdPageReq.setXmId(id); basicInformationResponse.setWysmxResponses(wysmxInformationService.list(zwIdPageReq)); //企业入驻信息 - basicInformationResponse.setQyrzInformation(qyrzInformationService.selectAll(zwIdPageReq)); + QyrzInformation qyrzInformation = qyrzInformationService.selectAll(zwIdPageReq); + basicInformationResponse.setQyrzInformation(qyrzInformation == null ? new QyrzInformation() : qyrzInformation); //项目图例 basicInformationResponse.setProjectLegendResponses(projectLegendService.page(zwIdPageReq)); //项目巡礼 @@ -434,14 +308,16 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap if (bs != null) { basicInformationResponse.setBasicInformation(bs); } else { - basicInformationResponse.setBasicInformation(getById(id)); + BasicInformation byId = getById(id); + basicInformationResponse.setBasicInformation(byId == null ? new BasicInformation() : byId); } //项目规划信息 PlanInformation pl = baseMapper.select2(id); if (pl != null) { basicInformationResponse.setPlanInformation(pl); } else { - basicInformationResponse.setPlanInformation(planInformationService.lambdaQuery().eq(PlanInformation::getXmId, id).one()); + PlanInformation one = planInformationService.lambdaQuery().eq(PlanInformation::getXmId, id).one(); + basicInformationResponse.setPlanInformation(one == null ? new PlanInformation() : one); } //项目建筑信息 basicInformationResponse.setBuildingInformation(buildingInformationService.lambdaQuery().eq(BuildingInformation::getXmId, id).list()); @@ -459,7 +335,8 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap if (qi != null) { basicInformationResponse.setQyrzInformation(qi); } else { - basicInformationResponse.setQyrzInformation(qyrzInformationService.selectAll(zwIdPageReq)); + QyrzInformation qyrzInformation = qyrzInformationService.selectAll(zwIdPageReq); + basicInformationResponse.setQyrzInformation(qyrzInformation == null ? new QyrzInformation() : qyrzInformation); } //项目图例 basicInformationResponse.setProjectLegendResponses(projectLegendService.page(zwIdPageReq)); @@ -478,4 +355,51 @@ public class BasicInformationServiceImpl extends ServiceImpl<BasicInformationMap } return basicInformationResponse; } + + /** + * 根据材料返回输chu流 + */ + @Override + public void generateDocument(Map<String, Object> map, String docx, OutputStream sr) throws IOException { + ClassPathResource resource = new ClassPathResource(docx); + try (InputStream is = resource.getStream(); + XWPFDocument doc = new XWPFDocument(is); + ) { + // 处理段落 + for (XWPFParagraph paragraph : doc.getParagraphs()) { + List<XWPFRun> runs = paragraph.getRuns(); + if (runs == null) continue; + for (XWPFRun run : runs) { + String text = run.getText(0); + if (text == null) continue; + // 动态替换所有模板变量 + for (Map.Entry<String, Object> entry : map.entrySet()) { + if (text.contains(entry.getKey())) { + text = text.replace(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : ""); + run.setText(text, 0); + } + } + } + } + doc.write(sr); + } catch (Exception e) { + throw new IOException("文档生成失败", e); + } + } + + + /** + * 根据dict_type和dict_value返回 + */ + @Override + public String getDictLabel(String dictType, String dictValue,List<SysDictData> sysDictData) { + List<SysDictData> collect = sysDictData.stream().filter(x -> + x.getDictType().equals(dictType) && x.getDictValue().equals(dictValue)) + .collect(Collectors.toList()); + if (collect.isEmpty()){ + return "/"; + }else { + return collect.get(0).getDictLabel(); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/XmpjqdServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/XmpjqdServiceImpl.java index 0283212..45ae25f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/XmpjqdServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/service/impl/XmpjqdServiceImpl.java @@ -67,9 +67,11 @@ public class XmpjqdServiceImpl extends ServiceImpl<XmpjqdMapper, Xmpjqd> impleme List<XmpjqdOneResponse> xmpjqdOneResponses = xmpjqdMapper.selectOnePj(id); //获取项目评价配置 pjpzService.list().forEach(x -> { - XmpjqdOneResponse xr = new XmpjqdOneResponse(); - xr.setYsmc(x.getPjys()); - xmpjqdOneResponses.add(xr); + if(!Objects.equals(x.getPjys(), "总投资额")){ + XmpjqdOneResponse xr = new XmpjqdOneResponse(); + xr.setYsmc(x.getPjys()); + xmpjqdOneResponses.add(xr); + } }); return xmpjqdOneResponses; } diff --git a/ruoyi-admin/src/main/resources/xmdtcl.docx b/ruoyi-admin/src/main/resources/xmdtcl.docx new file mode 100644 index 0000000..cf94618 --- /dev/null +++ b/ruoyi-admin/src/main/resources/xmdtcl.docx @@ -0,0 +1,15 @@ + + 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,计划投资额度jhtze亿元,实际总投资额ztze万人民币。 + 当前进展情况 + 目前,该项目属于xzfl,于 issuingTime日正式施工,截至目前jsjd。 + 企业运营情况 + 目前,该项目入驻企业数量共rzqys,入驻企业行业类型为rzqyhylx,人员数量共计rysl人,入住率为rzl,其中已出租面积yczmj平方米,空置房屋kzczmj万平方米,工业厂房平均租金gycfpjzj元/平方米*月。 + 存在困难问题 + 暂无。