feat: 法规符合性评估-不符合项-导出

This commit is contained in:
2024-06-25 18:02:44 +08:00
parent 4b0de19a0c
commit 459c3ba8da
4 changed files with 87 additions and 25 deletions
@@ -9,8 +9,6 @@ import com.jero.common.system.base.controller.JeroController;
import com.jero.modules.assessmentLibrary.entity.LawsEvaluationNotMetLibrary;
import com.jero.modules.assessmentLibrary.service.ILawsEvaluationNotMetLibraryService;
import com.jero.modules.projectLibrary.common.AssessCommon;
import com.jero.modules.projectLibrary.entity.LawsEvaluationNotMet;
import com.jero.modules.projectLibrary.service.ILawsEvaluationNotMetService;
import com.jero.modules.system.vo.IdsMapBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -23,6 +21,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
@@ -37,10 +36,7 @@ import java.util.List;
@RestController
@RequestMapping("/assessment/lawsEvaluationNotMet")
@Slf4j
public class LawsEvaluationNotMetController extends JeroController<LawsEvaluationNotMet, ILawsEvaluationNotMetService> {
@Resource
private ILawsEvaluationNotMetService lawsEvaluationNotMetService;
public class LawsEvaluationNotMetController extends JeroController<LawsEvaluationNotMetLibrary, ILawsEvaluationNotMetLibraryService> {
@Resource
private ILawsEvaluationNotMetLibraryService lawsEvaluationNotMetLibraryService;
@@ -54,16 +50,15 @@ public class LawsEvaluationNotMetController extends JeroController<LawsEvaluatio
@RequiresPermissions("lawsEvaluationNotMet:search")
public Result<IPage<LawsEvaluationNotMetLibrary>> queryPageList(LawsEvaluationNotMetLibrary lawsEvaluationNotMet,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
IPage<LawsEvaluationNotMetLibrary> pageList = lawsEvaluationNotMetLibraryService.queryPage(lawsEvaluationNotMet, pageNo, pageSize, req);
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
IPage<LawsEvaluationNotMetLibrary> pageList = lawsEvaluationNotMetLibraryService.queryPage(lawsEvaluationNotMet, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 批量关闭
*/
@RequiresPermissions("inconformityItem:batchClose")
@RequiresPermissions("lawsEvaluationNotMet:batchClose")
@AutoLog(value = "不符合项-批量关闭")
@ApiOperation(value="不符合项-批量关闭", notes="项目库-批量关闭")
@PostMapping(value = "/batchClose")
@@ -77,14 +72,14 @@ public class LawsEvaluationNotMetController extends JeroController<LawsEvaluatio
if (!this.check(idList)) {
throw new JeroBootException(ResultCommon.CANNOT_CLOSE);
}
lawsEvaluationNotMetService.batchClose(idList);
lawsEvaluationNotMetLibraryService.batchClose(idList);
return Result.OK(ResultCommon.OK);
}
private boolean check(List<String> ids) {
List<LawsEvaluationNotMet> notMets = lawsEvaluationNotMetService.listByIds(ids);
for (LawsEvaluationNotMet notMet : notMets) {
String state = notMet.getState();
List<LawsEvaluationNotMetLibrary> notMets = lawsEvaluationNotMetLibraryService.listByIds(ids);
for (LawsEvaluationNotMetLibrary notMet : notMets) {
String state = notMet.getRectifyStatus();
//判断是否是待整改,超期,警示
if (!state.equals(AssessCommon.TO_BE_RECTIFIED)
&& !state.equals(AssessCommon.WARNING)
@@ -98,10 +93,12 @@ public class LawsEvaluationNotMetController extends JeroController<LawsEvaluatio
/**
* 导出excel
*/
@RequiresPermissions("inconformityItem:export")
@AutoLog(value = "不符合项-导出")
@ApiOperation(value="不符合项-导出", notes="项目库-导出")
@RequiresPermissions("lawsEvaluationNotMet:export")
@GetMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, LawsEvaluationNotMet lawsEvaluationNotMet) {
return super.exportXls(request, lawsEvaluationNotMet, LawsEvaluationNotMet.class, "不符合项");
public void exportXls(HttpServletResponse response, LawsEvaluationNotMetLibrary lawsEvaluationNotMet) {
lawsEvaluationNotMetLibraryService.export(response, lawsEvaluationNotMet, "不符合项", "不符合项");
}
}
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
@@ -67,23 +68,27 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
* 条款号
*/
@ApiModelProperty(value = "条款号")
@Excel(name = "条款号", width = 15, orderNum = "5")
private String termNumber;
/**
* 条款内容
*/
@ApiModelProperty(value = "条款内容")
@Excel(name = "条款内容", width = 15, orderNum = "6")
private String termContent;
/**
* 车型
*/
@Excel(name = "车型", width = 15, orderNum = "1")
@ApiModelProperty(value = "车型")
private String model;
/**
* 车型状态
*/
@Excel(name = "车型", width = 15, dicCode = "model_status", orderNum = "2")
@ApiModelProperty(value = "车型状态")
@Dict(dicCode = "model_status")
private String modelStatus;
@@ -93,12 +98,14 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
*/
@ApiModelProperty(value = "责任部门")
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@Excel(name = "责任部门", width = 15, orderNum = "7", dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
private String authDept;
/**
* 评估人
*/
@ApiModelProperty(value = "评估人")
@Excel(name = "评估人", width = 15, orderNum = "8", dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
private String userId;
@@ -161,12 +168,14 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
*/
@ApiModelProperty(value = "整改状态")
@Dict(dicCode = "rectify_status")
@Excel(name = "整改状态", width = 15, orderNum = "10", dicCode = "rectify_status")
private String rectifyStatus;
/**
* pcr编号
* PCR编号
*/
@ApiModelProperty(value = "pcr编号")
@ApiModelProperty(value = "PCR编号")
@Excel(name = "PCR编号", width = 15, orderNum = "11")
private String pcrNo;
/**
@@ -174,6 +183,7 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
*/
@ApiModelProperty(value = "问题类型")
@Dict(dicCode = "problem_type")
@Excel(name = "问题类型", width = 15, orderNum = "9", dicCode = "problem_type")
private String problemType;
/**
@@ -189,6 +199,7 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
@ApiModelProperty(value = "整改完成日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@Excel(name = "整改完成日期", width = 15, orderNum = "12", format = "yyyy-MM-dd")
private Date rectifyCompleteDate;
/**
@@ -209,6 +220,7 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
*/
@TableField(exist = false)
@ApiModelProperty(value = "标准编号")
@Excel(name = "标准编号", width = 15, orderNum = "3")
private String standardNumber;
/**
@@ -216,6 +228,7 @@ public class LawsEvaluationNotMetLibrary implements Serializable {
*/
@TableField(exist = false)
@ApiModelProperty(value = "标准名称")
@Excel(name = "标准编号", width = 15, orderNum = "4")
private String standardName;
@@ -3,9 +3,12 @@ package com.jero.modules.assessmentLibrary.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.assessmentLibrary.entity.LawsEvaluationNotMetLibrary;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.enterprise.entity.dto.ESPlanQueryDTO;
import com.jero.modules.projectLibrary.entity.LawsEvaluationNotMet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author ThinkBook
@@ -20,9 +23,11 @@ public interface ILawsEvaluationNotMetLibraryService extends IService<LawsEvalua
* @param lawsEvaluationNotMet
* @param pageNo
* @param pageSize
* @param req
* @return
*/
IPage<LawsEvaluationNotMetLibrary> queryPage(LawsEvaluationNotMetLibrary lawsEvaluationNotMet, Integer pageNo, Integer pageSize, HttpServletRequest req);
IPage<LawsEvaluationNotMetLibrary> queryPage(LawsEvaluationNotMetLibrary lawsEvaluationNotMet, Integer pageNo, Integer pageSize);
void batchClose(List<String> ids);
void export(HttpServletResponse response, LawsEvaluationNotMetLibrary lawsEvaluationNotMet, String fileName, String sheetName);
}
@@ -1,21 +1,29 @@
package com.jero.modules.assessmentLibrary.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.assessmentLibrary.entity.LawsConformityAssessmentLibrary;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.assessmentLibrary.entity.LawsEvaluationNotMetLibrary;
import com.jero.modules.assessmentLibrary.mapper.LawsEvaluationNotMetLibraryMapper;
import com.jero.modules.assessmentLibrary.service.ILawsEvaluationNotMetLibraryService;
import com.jero.modules.laws.enterprise.entity.vo.EnterpriseStandardPlanVo;
import com.jero.modules.projectLibrary.common.AssessCommon;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
/**
* @author ThinkBook
@@ -31,7 +39,7 @@ public class LawsEvaluationNotMetLibraryServiceImpl extends ServiceImpl<LawsEval
private LawsEvaluationNotMetLibraryMapper notMetMapper;
@Override
public IPage<LawsEvaluationNotMetLibrary> queryPage(LawsEvaluationNotMetLibrary lawsEvaluationNotMet, Integer pageNo, Integer pageSize, HttpServletRequest req) {
public IPage<LawsEvaluationNotMetLibrary> queryPage(LawsEvaluationNotMetLibrary lawsEvaluationNotMet, Integer pageNo, Integer pageSize) {
QueryWrapper<LawsEvaluationNotMetLibrary> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(lawsEvaluationNotMet.getStandardNumber()),
"d.standard_number", lawsEvaluationNotMet.getStandardNumber());
@@ -50,6 +58,45 @@ public class LawsEvaluationNotMetLibraryServiceImpl extends ServiceImpl<LawsEval
Page<LawsEvaluationNotMetLibrary> page = new Page<>(pageNo, pageSize);
return notMetMapper.pageList(page, queryWrapper, lawsEvaluationNotMet);
}
@Override
public void batchClose(List<String> ids) {
if (ids == null || ids.isEmpty()) {
return;
}
LambdaUpdateWrapper<LawsEvaluationNotMetLibrary> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(LawsEvaluationNotMetLibrary::getRectifyStatus, AssessCommon.CLOSED);
wrapper.in(LawsEvaluationNotMetLibrary::getId, ids);
update(wrapper);
}
@Override
public void export(HttpServletResponse response, LawsEvaluationNotMetLibrary lawsEvaluationNotMet, String fileName, String sheetName) {
try {
// 获取数据
IPage<LawsEvaluationNotMetLibrary> lawsEvaluationNotMets = this.queryPage(lawsEvaluationNotMet, 1, Integer.MAX_VALUE);
List<LawsEvaluationNotMetLibrary> records = lawsEvaluationNotMets.getRecords();
// 设置导出参数
ExportParams exportParams = new ExportParams(null, sheetName); // 可以为标题添加更多的配置
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, EnterpriseStandardPlanVo.class, records);
// 设置响应头和内容类型
response.setContentType("application/vnd.ms-excel;charset=UTF-8"); // 显式设置字符编码
response.setCharacterEncoding("UTF-8"); // 这行确保响应流使用UTF-8编码
// 处理文件名乱码问题
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()).replace("+", "%20");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName + ".xls");
// 写出到响应流
workbook.write(response.getOutputStream());
workbook.close();
} catch (Exception e) {
log.error("导出excel异常", e);
throw new JeroBootException("导出excel异常", e);
}
}
}