feat: 企标稽查-导出整改计划
This commit is contained in:
+7
@@ -133,4 +133,11 @@ public interface ILawsCommonService {
|
||||
* 三表通用带文件导出
|
||||
*/
|
||||
void exportDataWithFile(HttpServletResponse response, Map<String, Object> parameterMap, String sheetName, String fileName);
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
* @param response
|
||||
* @param tableName
|
||||
*/
|
||||
void templateDownload(HttpServletResponse response, String tableName);
|
||||
}
|
||||
|
||||
+15
@@ -1071,6 +1071,21 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void templateDownload(HttpServletResponse response, String tableName) {
|
||||
//TODO 模板下载
|
||||
// // 获取全部字段
|
||||
// List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
|
||||
//
|
||||
// // 筛选出新增要用的字段
|
||||
// fieldList = fieldList.stream().filter(lawsTag -> YesOrNoEnum.YES.getValue()
|
||||
// .equals(lawsTag.getIsShowFormCreate().toString())).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
//
|
||||
// return areaMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/8/24 9:53
|
||||
|
||||
-1
@@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+8
@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -128,4 +129,11 @@ public class EnterpriseStandardInspectController extends JeroController<Enterpri
|
||||
public void exportDataWithDelay(HttpServletResponse response, ESQueryCommonDTO esQueryCommonDTO) {
|
||||
esInspectService.exportDataWithDelay(response, esQueryCommonDTO, "企标稽查-延期数据", "企标稽查-延期数据");
|
||||
}
|
||||
|
||||
@AutoLog(value = "企标稽查-导出整改数据")
|
||||
@ApiOperation(value="企标稽查-导出整改数据", notes="企标稽查-导出整改数据")
|
||||
@GetMapping("/exportDataRectifyPlan")
|
||||
public void exportDataRectifyPlan(HttpServletResponse response, ESQueryCommonDTO esQueryCommonDTO) throws IOException {
|
||||
esInspectService.exportDataRectifyPlan(response, esQueryCommonDTO, "企标稽查-整改计划", "企标稽查-整改计划");
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -70,36 +71,42 @@ public class EnterpriseStandardInspectRectifyPlan implements Serializable {
|
||||
/**
|
||||
* 存在问题
|
||||
*/
|
||||
@Excel(name = "存在问题", width = 15, orderNum = "1")
|
||||
@ApiModelProperty(value = "存在问题")
|
||||
private String issue;
|
||||
|
||||
/**
|
||||
* 整改措施
|
||||
*/
|
||||
@Excel(name = "整改措施", width = 15, orderNum = "1")
|
||||
@ApiModelProperty(value = "整改措施")
|
||||
private String rectifyMeasure;
|
||||
|
||||
/**
|
||||
* 责任负责人
|
||||
* 整改负责人
|
||||
*/
|
||||
@ApiModelProperty(value = "责任负责人")
|
||||
@Excel(name = "整改负责人", width = 15, orderNum = "1")
|
||||
@ApiModelProperty(value = "整改负责人")
|
||||
private String responseUser;
|
||||
|
||||
/**
|
||||
* 整改计划完成时间
|
||||
*/
|
||||
@Excel(name = "整改计划完成时间", width = 15, orderNum = "1", format = "yyyy-MM-dd hh:mm:ss")
|
||||
@ApiModelProperty(value = "整改计划完成时间")
|
||||
private Date planCompleteDate;
|
||||
|
||||
/**
|
||||
* 整改实际完成时间
|
||||
*/
|
||||
@Excel(name = "整改实际完成时间", width = 15, orderNum = "1", format = "yyyy-MM-dd hh:mm:ss")
|
||||
@ApiModelProperty(value = "整改实际完成时间")
|
||||
private Date actualCompleteDate;
|
||||
|
||||
/**
|
||||
* 整改状态
|
||||
*/
|
||||
@Excel(name = "整改状态", width = 15, orderNum = "1", dicCode = "inspect_rectify_status")
|
||||
@Dict(dicCode = "inspect_rectify_status")
|
||||
@ApiModelProperty(value = "整改状态")
|
||||
private String rectifyStatus;
|
||||
|
||||
+12
@@ -7,6 +7,7 @@ import com.jero.modules.laws.enterprise.entity.dto.ESQueryCommonDTO;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardInspectVo;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
@@ -41,4 +42,15 @@ public interface EnterpriseStandardInspectService extends IService<EnterpriseSta
|
||||
* @param sheetName
|
||||
*/
|
||||
void exportDataWithDelay(HttpServletResponse response, ESQueryCommonDTO esQueryCommonDTO, String fileName, String sheetName);
|
||||
|
||||
/**
|
||||
* 企标稽查-导出整改计划
|
||||
*
|
||||
* 这里导出的是压缩包
|
||||
* @param response
|
||||
* @param esQueryCommonDTO
|
||||
* @param sheetName
|
||||
* @param fileName
|
||||
*/
|
||||
void exportDataRectifyPlan(HttpServletResponse response, ESQueryCommonDTO esQueryCommonDTO, String sheetName, String fileName) throws IOException;
|
||||
}
|
||||
|
||||
+81
@@ -7,11 +7,14 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspect;
|
||||
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectRectifyPlan;
|
||||
import com.jero.modules.laws.enterprise.entity.dto.ESQueryCommonDTO;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardDeclareVo;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardInspectDelayVo;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardInspectVo;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardRecheckPlanVo;
|
||||
import com.jero.modules.laws.enterprise.mapper.EnterpriseStandardInspectRectifyPlanMapper;
|
||||
import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectRectifyPlanService;
|
||||
import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectService;
|
||||
import com.jero.modules.laws.enterprise.mapper.EnterpriseStandardInspectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,8 +26,18 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
@@ -40,6 +53,9 @@ public class EnterpriseStandardInspectServiceImpl extends ServiceImpl<Enterprise
|
||||
@Resource
|
||||
private EnterpriseStandardInspectMapper esInspectMapper;
|
||||
|
||||
@Resource
|
||||
private EnterpriseStandardInspectRectifyPlanMapper esInspectRectifyPlanMapper;
|
||||
|
||||
@Override
|
||||
public IPage<EnterpriseStandardInspectVo> queryPageList(ESQueryCommonDTO esInspect, Integer pageNo, Integer pageSize) {
|
||||
IPage<EnterpriseStandardInspectVo> page = new Page<>(pageNo, pageSize);
|
||||
@@ -95,6 +111,71 @@ public class EnterpriseStandardInspectServiceImpl extends ServiceImpl<Enterprise
|
||||
throw new JeroBootException("导出excel异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportDataRectifyPlan(HttpServletResponse response, ESQueryCommonDTO esQueryCommonDTO, String sheetName, String fileName) {
|
||||
// 在内存中创建一个 Zip 输出流
|
||||
ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
|
||||
try (ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
||||
|
||||
// 获取需要导出的稽查报告
|
||||
IPage<EnterpriseStandardInspectVo> enterpriseStandardInspectVoIPage = this.queryPageList(esQueryCommonDTO, 1, Integer.MAX_VALUE);
|
||||
List<EnterpriseStandardInspectVo> records = enterpriseStandardInspectVoIPage.getRecords();
|
||||
|
||||
// 处理 inspectNo
|
||||
records.forEach(vo -> vo.setInspectNo(vo.getInspectNo().replace("/", "-")));
|
||||
|
||||
// 复制 records 列表以避免修改
|
||||
List<EnterpriseStandardInspectVo> copyRecords = new ArrayList<>(records);
|
||||
|
||||
for (EnterpriseStandardInspectVo vo : copyRecords) {
|
||||
try {
|
||||
IPage<EnterpriseStandardInspectRectifyPlan> page = new Page<>(1, Integer.MAX_VALUE);
|
||||
esInspectRectifyPlanMapper.page(page, vo.getId());
|
||||
List<EnterpriseStandardInspectRectifyPlan> rectifyPlanList = page.getRecords();
|
||||
|
||||
if (rectifyPlanList.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExportParams exportParams = new ExportParams(null, sheetName);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, EnterpriseStandardInspectRectifyPlan.class, rectifyPlanList);
|
||||
|
||||
// 创建一个字节数组输出流保存 Excel 数据
|
||||
ByteArrayOutputStream excelOutputStream = new ByteArrayOutputStream();
|
||||
workbook.write(excelOutputStream);
|
||||
workbook.close();
|
||||
|
||||
// 在 Zip 文件中为该 Excel 文件创建一个新目录
|
||||
String folderName = vo.getInspectNo(); // 根据需要更改文件夹名称
|
||||
ZipEntry folderZipEntry = new ZipEntry(folderName + "/");
|
||||
zos.putNextEntry(folderZipEntry);
|
||||
zos.closeEntry();
|
||||
|
||||
// 将 Excel 文件添加到这个新目录中
|
||||
ZipEntry zipEntry = new ZipEntry(folderName + "/" + fileName + ".xls");
|
||||
zos.putNextEntry(zipEntry);
|
||||
zos.write(excelOutputStream.toByteArray());
|
||||
zos.closeEntry();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("导出excel异常", e);
|
||||
throw new JeroBootException("导出excel异常", e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("创建ZIP文件时发生错误", e);
|
||||
}
|
||||
|
||||
// 将 Zip 文件写出到响应流中
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".zip");
|
||||
try {
|
||||
response.getOutputStream().write(zipOutputStream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
log.error("写入响应流时发生错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
@@ -207,4 +207,11 @@ public class LawsEnterpriseController {
|
||||
public void exportDataWithFile(HttpServletResponse response, @RequestBody(required = false) Map<String,Object> parameterMap) {
|
||||
lawsCommonService.exportDataWithFile(response, parameterMap, "企标导出", "企标导出");
|
||||
}
|
||||
|
||||
@AutoLog(value = "企业法规标准-模板下载")
|
||||
@ApiOperation(value="企业法规标准-模板下载", notes="企业法规标准-模板下载")
|
||||
@PostMapping("/templateDownload")
|
||||
public void templateDownload(HttpServletResponse response) {
|
||||
lawsCommonService.templateDownload(response, TableNameEnum.ENTERPRISE_STANDARDS.getTableName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user