|
|
|
@ -2,12 +2,10 @@ package com.ruoyi.gysl.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ruoyi.common.annotation.Excel;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ChangeExcelUtil;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.docking.entity.SmartDeclaration;
|
|
|
|
|
import com.ruoyi.docking.service.SmartDeclarationService;
|
|
|
|
@ -15,24 +13,20 @@ import com.ruoyi.gysl.entity.*;
|
|
|
|
|
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 com.ruoyi.gysl.service.*;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 基本信息(BasicInformation)表控制层
|
|
|
|
@ -45,6 +39,19 @@ import java.util.*;
|
|
|
|
|
@RequestMapping("/gysl/basicInformation")
|
|
|
|
|
public class BasicInformationController extends BaseController {
|
|
|
|
|
|
|
|
|
|
// 1.审核通过之后再审核不要通知
|
|
|
|
|
// 2.项目评价配置和详情那边同步显示
|
|
|
|
|
// 3.换掉项目动态导出模板
|
|
|
|
|
// 6.项目不填项目起止日期导入失败
|
|
|
|
|
// 7.企业端统计项目总数有问题
|
|
|
|
|
// 9.项目基础信息时间查询改了格式
|
|
|
|
|
// 10.添加项目统计页面根据年份查找统计数据
|
|
|
|
|
|
|
|
|
|
// 4.项目汇编管理修改pdf
|
|
|
|
|
// 5.月度报告修改
|
|
|
|
|
// 8.企业和政务登录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 基本信息
|
|
|
|
|
*/
|
|
|
|
@ -133,7 +140,7 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
if (byId.getStatus() != 1) {
|
|
|
|
|
throw new ServiceException("暂不能提交!");
|
|
|
|
|
}
|
|
|
|
|
return success(basicInformationService.audit(req, 2));
|
|
|
|
|
return success(basicInformationService.audit(req, 2,byId.getStatus()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -147,7 +154,7 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
if (byId.getStatus() == 1) {
|
|
|
|
|
throw new ServiceException("请等待企业填报!");
|
|
|
|
|
}
|
|
|
|
|
return success(basicInformationService.audit(req, 3));
|
|
|
|
|
return success(basicInformationService.audit(req, 3,byId.getStatus()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -249,169 +256,15 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态导出基本信息(基本信息,建筑,规划)
|
|
|
|
|
* 导出项目数据
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
@ApiOperation("动态导出基本信息(基本信息,建筑,规划)")
|
|
|
|
|
// @PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
@ApiOperation("导出项目数据")
|
|
|
|
|
@PostMapping("/exportInfo")
|
|
|
|
|
public void exportInfo(HttpServletResponse response, @RequestParam List<Long> idList) throws NoSuchFieldException, IOException, IllegalAccessException {
|
|
|
|
|
//获取对应的基本信息的列表
|
|
|
|
|
List<ProjectExcelInfo> info = basicInformationService.selectList(idList);
|
|
|
|
|
|
|
|
|
|
System.out.println(info);
|
|
|
|
|
//excel 第一层单元格
|
|
|
|
|
List<String> yc = new ArrayList<>();
|
|
|
|
|
//excel 第二层单元格
|
|
|
|
|
List<String> ec = new ArrayList<>();
|
|
|
|
|
//excel 第三层单元格
|
|
|
|
|
List<String> sc = new ArrayList<>();
|
|
|
|
|
//项目建筑信息数据所有字段数量
|
|
|
|
|
int sczdData = 0;
|
|
|
|
|
//一共有几组厂房,不包括重复
|
|
|
|
|
int cfsl = 0;
|
|
|
|
|
//动态存储每个分组对应的字段数量
|
|
|
|
|
Map<String, Integer> zdsl = new LinkedHashMap<>();
|
|
|
|
|
Class<?> clazz = ProjectExcelInfo.class;
|
|
|
|
|
Class<?> classBuilding = ProjectBuildingExcel.class;
|
|
|
|
|
// 遍历除了建筑获取其他字段注解
|
|
|
|
|
for (int i = 0; i < info.size(); i++) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
if(info.get(i).getXmjzxx().isEmpty()){
|
|
|
|
|
throw new ServiceException("请选择有楼栋的项目!");
|
|
|
|
|
}
|
|
|
|
|
for (Field field : clazz.getDeclaredFields()) {
|
|
|
|
|
Excel excelColumn = field.getAnnotation(Excel.class);
|
|
|
|
|
if (excelColumn != null) {
|
|
|
|
|
if (yc.contains(excelColumn.group())) {
|
|
|
|
|
yc.add("");
|
|
|
|
|
} else {
|
|
|
|
|
yc.add(excelColumn.group());
|
|
|
|
|
}
|
|
|
|
|
if ("id".equals(excelColumn.name())) {
|
|
|
|
|
sc.add("");
|
|
|
|
|
} else {
|
|
|
|
|
sc.add(excelColumn.name());
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.equals(excelColumn.group(), "序号")) {
|
|
|
|
|
zdsl.merge(excelColumn.group(), 1, Integer::sum);
|
|
|
|
|
}
|
|
|
|
|
ec.add("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (ProjectBuildingExcel xmjzxx : info.get(i).getXmjzxx()) {
|
|
|
|
|
switch (xmjzxx.getFloor()) {
|
|
|
|
|
case 1:
|
|
|
|
|
if (!ec.contains("一层厂房")) {
|
|
|
|
|
ec.add("一层厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (!ec.contains("双层厂房")) {
|
|
|
|
|
ec.add("双层厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (!ec.contains("三层厂房")) {
|
|
|
|
|
ec.add("三层厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (!ec.contains("四层厂房")) {
|
|
|
|
|
ec.add("四层厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (!ec.contains("五层厂房")) {
|
|
|
|
|
ec.add("五层厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (!ec.contains("六层及以上厂房")) {
|
|
|
|
|
ec.add("六层及以上厂房");
|
|
|
|
|
cfsl += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (Field field : classBuilding.getDeclaredFields()) {
|
|
|
|
|
Excel excelColumn = field.getAnnotation(Excel.class);
|
|
|
|
|
if (excelColumn != null) {
|
|
|
|
|
if (!yc.contains("项目建筑信息")) {
|
|
|
|
|
yc.add("项目建筑信息");
|
|
|
|
|
} else {
|
|
|
|
|
yc.add("");
|
|
|
|
|
}
|
|
|
|
|
ec.add("");
|
|
|
|
|
sc.add(excelColumn.name());
|
|
|
|
|
sczdData += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ec.remove(ec.size() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//=======================sheet处理
|
|
|
|
|
// 第一步,创建一个Workbook,对应一个Excel文件
|
|
|
|
|
XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
|
|
// 第二步,在Workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
|
XSSFSheet sheet = wb.createSheet("sheet");
|
|
|
|
|
// 第三步,设置样式以及字体样式
|
|
|
|
|
XSSFCellStyle titleStyle = ChangeExcelUtil.createTitleCellStyle(wb);
|
|
|
|
|
XSSFCellStyle headerStyle = ChangeExcelUtil.createHeadCellStyle(wb);
|
|
|
|
|
XSSFCellStyle contentStyle = ChangeExcelUtil.createContentCellStyle(wb);
|
|
|
|
|
// 行号
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
// 创建第一页的第一行,索引从0开始
|
|
|
|
|
XSSFRow row0 = sheet.createRow(rowNum++);
|
|
|
|
|
row0.setHeight((short) 600);// 设置行高
|
|
|
|
|
sheet.setColumnWidth(1, 6000);
|
|
|
|
|
sheet.setColumnWidth(2, 6000);
|
|
|
|
|
//第二行
|
|
|
|
|
XSSFRow row1 = sheet.createRow(rowNum++);
|
|
|
|
|
row1.setHeight((short) 500);
|
|
|
|
|
//第三行
|
|
|
|
|
XSSFRow row2 = sheet.createRow(rowNum++);
|
|
|
|
|
row2.setHeight((short) 1000);
|
|
|
|
|
//合并单元格:excel,除了项目建筑信息的其余字段数量,项目建筑信息数据所有字段数量,一共有几组厂房,不包括重复
|
|
|
|
|
ChangeExcelUtil.extracted(sheet, zdsl, sczdData, cfsl);
|
|
|
|
|
|
|
|
|
|
// 创建第一行单元格
|
|
|
|
|
for (int i = 0; i < yc.size(); i++) {
|
|
|
|
|
XSSFCell c00 = row0.createCell(i);
|
|
|
|
|
c00.setCellValue(yc.get(i));
|
|
|
|
|
c00.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
// 创建第二行单元格
|
|
|
|
|
for (int i = 0; i < ec.size(); i++) {
|
|
|
|
|
XSSFCell tempCell = row1.createCell(i);
|
|
|
|
|
tempCell.setCellValue(ec.get(i));
|
|
|
|
|
tempCell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
// 创建第三行单元格
|
|
|
|
|
for (int i = 0; i < sc.size(); i++) {
|
|
|
|
|
XSSFCell tempCell = row2.createCell(i);
|
|
|
|
|
tempCell.setCellValue(sc.get(i));
|
|
|
|
|
tempCell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
//填充数据
|
|
|
|
|
basicInformationService.approvalMethodfillInData(sheet, contentStyle, rowNum, info, sc, ec, sczdData / cfsl);
|
|
|
|
|
|
|
|
|
|
// 1. 设置响应头(必须)
|
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
|
|
// 设置文件名(解决中文乱码)
|
|
|
|
|
String fileName = URLEncoder.encode("项目信息.xlsx", "UTF-8");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
|
|
try (ServletOutputStream out = response.getOutputStream()) {
|
|
|
|
|
// 3. 将 Workbook 写入响应流
|
|
|
|
|
wb.write(out);
|
|
|
|
|
out.flush();
|
|
|
|
|
} finally {
|
|
|
|
|
wb.close();
|
|
|
|
|
}
|
|
|
|
|
public void exportInfo(HttpServletResponse response){
|
|
|
|
|
List<ProjectExcelInfo> pE = basicInformationService.selectList();
|
|
|
|
|
ExcelUtil<ProjectExcelInfo> util = new ExcelUtil<>(ProjectExcelInfo.class);
|
|
|
|
|
util.exportExcel(response, pE, "项目数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -438,53 +291,43 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// @ApiOperation(value = "123")
|
|
|
|
|
//// @PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
// @PostMapping(value = "/import1", consumes = "multipart/form-data")
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
// public AjaxResult import1(@RequestPart("file") MultipartFile file) throws Exception {
|
|
|
|
|
// ExcelUtil<ProjectExcelInfo> util = new ExcelUtil<>(ProjectExcelInfo.class);
|
|
|
|
|
// List<ProjectExcelInfo> proList = util.importExcel(file.getInputStream());
|
|
|
|
|
// proList.forEach(x->{
|
|
|
|
|
// // 1. 分割字符串
|
|
|
|
|
// String[] dates = x.getA1().split("-");
|
|
|
|
|
// if (dates.length != 2) {
|
|
|
|
|
// throw new IllegalArgumentException("无效的日期范围格式");
|
|
|
|
|
// }
|
|
|
|
|
// BasicInformation basicInformation = new BasicInformation();
|
|
|
|
|
// basicInformation.setName(x.getName());
|
|
|
|
|
// basicInformation.setXmfrdwxz(x.getXmfrdwxz());
|
|
|
|
|
// basicInformation.setNature(x.getNature());
|
|
|
|
|
// basicInformation.setBegainTime(dates[0].replace(".","-").trim());
|
|
|
|
|
// basicInformation.setEndTime(dates[1].replace(".","-").trim());
|
|
|
|
|
// basicInformation.setXzfl(x.getXzfl());
|
|
|
|
|
// basicInformation.setJhtze(x.getJhtze());
|
|
|
|
|
// basicInformation.setProjectLeader(x.getProjectLeader());
|
|
|
|
|
// basicInformation.setPhone(x.getPhone());
|
|
|
|
|
// basicInformation.setJsjd(x.getJsjd());
|
|
|
|
|
// basicInformation.setJsms(x.getJsms());
|
|
|
|
|
// basicInformation.setPrioritize(x.getPrioritize());
|
|
|
|
|
// basicInformation.setStatus(3);
|
|
|
|
|
// PlanInformation planInformation = new PlanInformation();
|
|
|
|
|
// planInformation.setZydmj(x.getZydmj());
|
|
|
|
|
// planInformation.setRjl(x.getRjl());
|
|
|
|
|
// planInformation.setZjzmj(x.getZjzmj());
|
|
|
|
|
// planInformation.setBzcjzmj(x.getBzcjzmj());
|
|
|
|
|
// basicInformationService.save(basicInformation);
|
|
|
|
|
// planInformation.setXmId(basicInformation.getId());
|
|
|
|
|
// planInformationService.save(planInformation);
|
|
|
|
|
// });
|
|
|
|
|
// return AjaxResult.success();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|