feat: 企标计划导出功能
This commit is contained in:
@@ -185,6 +185,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
//在线编辑 日志 (包含把17的文件下载到16)
|
||||
addInterceptor.excludePathPatterns("/api/lawss/activiti/selectOnlineFile");
|
||||
|
||||
// 标准法规库-企标计划导出接口
|
||||
addInterceptor.excludePathPatterns("/api/esRevisePlan/es-revise-plan/exportEsRevisePlanInfoExcel");
|
||||
|
||||
|
||||
// // 添加自定义拦截器,并拦截对应 url
|
||||
addInterceptor.addPathPatterns("/**");
|
||||
|
||||
+91
@@ -1,23 +1,36 @@
|
||||
package com.adc.da.slrs.esRevisePlan.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.adc.da.common.ReadExcel;
|
||||
import com.adc.da.exception.AdcDaBaseException;
|
||||
import com.adc.da.http.PageInfo;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.esRevisePlan.service.IEsRevisePlanService;
|
||||
import com.adc.da.slrs.sarEnterpriseStandardEvaluation.dao.QualityEvaluationDao;
|
||||
import com.adc.da.slrs.sarEnterpriseStandardEvaluation.entity.QualityEvaluation;
|
||||
import com.adc.da.utils.util.EsRevisePlanExportUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,6 +47,8 @@ import java.util.List;
|
||||
@RequestMapping("api/esRevisePlan/es-revise-plan")
|
||||
public class EsRevisePlanController extends BaseController<EsRevisePlan> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(EsRevisePlanController.class);
|
||||
|
||||
@Autowired
|
||||
IEsRevisePlanService iEsRevisePlanService;
|
||||
@Autowired
|
||||
@@ -61,6 +76,82 @@ public class EsRevisePlanController extends BaseController<EsRevisePlan> {
|
||||
return esRevisePlans;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "企标计划导出excel")
|
||||
@GetMapping(value = "/exportEsRevisePlanInfoExcel")
|
||||
public void exportStandardsInfoExcel(EsRevisePlan esRevisePlan, HttpServletResponse response,
|
||||
HttpServletRequest request) throws Exception {
|
||||
esRevisePlan.setExportFlag(true);
|
||||
OutputStream os = null;
|
||||
Workbook workbook = null;
|
||||
try {
|
||||
if (StrUtil.isNotBlank(esRevisePlan.getExportIds())) {
|
||||
esRevisePlan.setExportIdList(Arrays.asList(esRevisePlan.getExportIds().split(",")));
|
||||
}
|
||||
if(org.apache.commons.lang3.StringUtils.isEmpty(esRevisePlan.getExportName())||esRevisePlan.getExportName().equals("null")){
|
||||
esRevisePlan.setExportName("标准法规信息");
|
||||
}
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + ReadExcel.encodeFileName(esRevisePlan.getExportName()+".xlsx",
|
||||
request));
|
||||
// 导出所有数据
|
||||
List<EsRevisePlan> datas = iEsRevisePlanService.queryAllPlans(esRevisePlan);
|
||||
for (EsRevisePlan revisePlan : datas){
|
||||
String area = revisePlan.getArea();
|
||||
if (StringUtils.isNotBlank(area)){
|
||||
if (area.startsWith("[") && area.endsWith("]")){
|
||||
area = area.substring(1,area.length() - 1);
|
||||
area = area.replace("\"","");
|
||||
}
|
||||
}
|
||||
revisePlan.setArea(area);
|
||||
//查评分
|
||||
if (ObjectUtils.isNotEmpty(revisePlan.getStandId())) {
|
||||
List<Double> last = new ArrayList<>();
|
||||
List<QualityEvaluation> evaluations = qualityEvaluationDao.getEvaluationForm(new QueryWrapper<QualityEvaluation>().eq("law_id", revisePlan.getStandId()).eq("evaluation_type", "quality"));
|
||||
for (QualityEvaluation evaluation : evaluations) {
|
||||
Double score;
|
||||
String value;
|
||||
if (evaluation.getProcessNode()==null){
|
||||
value="";
|
||||
}else {
|
||||
value=evaluation.getProcessNode();
|
||||
}
|
||||
String evaluationScore = ObjectUtils.isEmpty(evaluation.getScore()) ? "0" : evaluation.getScore();
|
||||
switch (value){
|
||||
case "征求意见":
|
||||
score=Double.valueOf(evaluationScore) * 0.3;
|
||||
break;
|
||||
case "技术委员会评审、评审意见修改":
|
||||
score=Double.valueOf(evaluationScore) * 0.4;
|
||||
break;
|
||||
case "重新技术委员会评审、评审意见修改":
|
||||
score=Double.valueOf(evaluationScore) * 0.4;
|
||||
break;
|
||||
case "标准化复审":
|
||||
score=Double.valueOf(evaluationScore) * 0.15;
|
||||
break;
|
||||
case "标准法规部高级经理审核":
|
||||
score=Double.valueOf(evaluationScore) * 0.15;
|
||||
break;
|
||||
default: score=Double.valueOf(evaluationScore);
|
||||
}
|
||||
last.add(score);
|
||||
}
|
||||
revisePlan.setScore(last.stream().mapToDouble(Double::doubleValue).sum());
|
||||
}
|
||||
}
|
||||
workbook = EsRevisePlanExportUtil.exportDatas(datas);
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new AdcDaBaseException("下载文件失败,请重试");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "多条件查询企标计划")
|
||||
@PostMapping("queryAllPlans")
|
||||
public ResponseMessage<Object> queryAllPlans(EsRevisePlan esRevisePlan){
|
||||
|
||||
@@ -169,4 +169,20 @@ public class EsRevisePlan extends BasePage {
|
||||
@ApiModelProperty(value = "OA是否已经发送")
|
||||
@TableField("OA_IS_SEND")
|
||||
private String oaIsSend;
|
||||
|
||||
@ApiModelProperty(value = "导出的文件名")
|
||||
@TableField(exist = false)
|
||||
private String exportName;
|
||||
|
||||
@ApiModelProperty(value = "是否为导出标识")
|
||||
@TableField(exist = false)
|
||||
private boolean exportFlag;
|
||||
|
||||
@ApiModelProperty(value = "被前端选中的记录的ids")
|
||||
@TableField(exist = false)
|
||||
private String exportIds;
|
||||
|
||||
@ApiModelProperty(value = "从ids转换过来的id集合")
|
||||
@TableField(exist = false)
|
||||
private List<String> exportIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.adc.da.utils.util;
|
||||
|
||||
import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/8/29 17:27
|
||||
*/
|
||||
public class EsRevisePlanExportUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BussStandExportUtil.class);
|
||||
|
||||
|
||||
public static Workbook exportDatas(List<EsRevisePlan> datas) {
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
try {
|
||||
StringBuilder attrBud = new StringBuilder();
|
||||
//定义表头
|
||||
String header = FieldConvertUtil.exportFieldNamesEsRevisePlan + "," + attrBud.toString();
|
||||
//创建工作表对象
|
||||
Sheet sheet = workbook.createSheet();
|
||||
// 创建头部
|
||||
createHeader(workbook, sheet, header);
|
||||
// 创建数据
|
||||
createDatas(workbook, sheet, datas, header);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static void createHeader(Workbook workbook, Sheet sheet, String header) {
|
||||
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
Row rowHeader = sheet.createRow(0);//开始创建标题行
|
||||
if (StringUtils.isNotBlank(header)) {
|
||||
String[] headerArr = header.split(",");
|
||||
for (int i = 0; i < headerArr.length; i++) {
|
||||
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void createDatas(Workbook workbook, Sheet sheet, List<EsRevisePlan> datas,
|
||||
String header) throws Exception {
|
||||
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
if (datas != null && !datas.isEmpty()) {
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
EsRevisePlan esRevisePlan = datas.get(i);
|
||||
Row row = sheet.createRow(i + 1);
|
||||
String[] headerArr = header.split(",");
|
||||
int sheetNum = 0;
|
||||
for (String headerName : headerArr) {
|
||||
String value = getValueByName(headerName, esRevisePlan);
|
||||
if (StringUtils.isBlank(value) || "null".equals(value)) {
|
||||
value = "";
|
||||
}
|
||||
row.createCell(sheetNum).setCellValue(value);
|
||||
sheetNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 根据表头返回相应值
|
||||
public static String getValueByName(String name, EsRevisePlan esRevisePlan) throws Exception{
|
||||
String value = "";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
switch (name) {
|
||||
case "企标类别":
|
||||
value = esRevisePlan.getBussSort();
|
||||
break;
|
||||
case "企标编号":
|
||||
value = esRevisePlan.getStandNumber();
|
||||
break;
|
||||
case "企标名称":
|
||||
value = esRevisePlan.getEsName();
|
||||
break;
|
||||
case "计划状态":
|
||||
value = esRevisePlan.getPlanStatus();
|
||||
break;
|
||||
case "制修订类型":
|
||||
value = esRevisePlan.getReviseStatus();
|
||||
break;
|
||||
case "起草人":
|
||||
value = esRevisePlan.getDrafterName();
|
||||
break;
|
||||
case "内部评审责任人":
|
||||
value = esRevisePlan.getResPersonName();
|
||||
break;
|
||||
case "技术委员会评审负责人":
|
||||
value = esRevisePlan.getWgLeaderName();
|
||||
break;
|
||||
case "计划标准初稿完成时间":
|
||||
String draftTime = null;
|
||||
if (esRevisePlan.getDraftTime() != null){
|
||||
draftTime = sdf.format(esRevisePlan.getDraftTime());
|
||||
}
|
||||
value = draftTime;
|
||||
break;
|
||||
case "计划标准发布时间":
|
||||
String releaseTime = null;
|
||||
if (esRevisePlan.getReleaseTime() != null){
|
||||
releaseTime = sdf.format(esRevisePlan.getReleaseTime());
|
||||
}
|
||||
value = releaseTime;
|
||||
break;
|
||||
case "起草责任单位":
|
||||
value = esRevisePlan.getUnitName();
|
||||
break;
|
||||
case "实际标准发布时间":
|
||||
String actualTime = null;
|
||||
if (esRevisePlan.getActualTime() != null){
|
||||
actualTime = sdf.format(esRevisePlan.getActualTime());
|
||||
}
|
||||
value = actualTime;
|
||||
break;
|
||||
case "质量评分":
|
||||
value = String.valueOf(esRevisePlan.getScore());
|
||||
break;
|
||||
default:
|
||||
value = null;
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.adc.da.utils.util;
|
||||
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -56,6 +55,9 @@ public class FieldConvertUtil {
|
||||
|
||||
public static String exportBaseFieldNamesBuss = "企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态";
|
||||
|
||||
// 企标计划 表头
|
||||
public static String exportFieldNamesEsRevisePlan = "企标类别,企标编号,企标名称,计划状态,制修订类型,起草人,内部评审责任人,技术委员会评审负责人,计划标准初稿完成时间,计划标准发布时间,起草责任单位,实际标准发布时间,质量评分";
|
||||
|
||||
public static String exportBaseFieldNamesBussCode = "起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车VPPS编码,关联模块--卡车vpps中文名称";
|
||||
|
||||
public static String exportAttrFieldNamesBuss = "SVPPS,规范性引用文件,废止日期,复审日期,密级,授权,相关部门," +
|
||||
|
||||
@@ -265,9 +265,18 @@
|
||||
<if test="unit != null and unit != ''">
|
||||
and (select group_concat(ts_institution.name) from ts_institution where find_in_set(ts_institution.id,unit)) like concat('%',#{unit},'%')
|
||||
</if>
|
||||
<if test="exportFlag and exportIdList != null and exportIdList.size() > 0">
|
||||
AND es_revise_plan.id in
|
||||
<foreach item="item" index="index" collection="exportIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
</where>
|
||||
<include refid="pages">
|
||||
</include>
|
||||
<if test="!exportFlag">
|
||||
<include refid="pages">
|
||||
</include>
|
||||
</if>
|
||||
</select>
|
||||
<!-- 查询详情-->
|
||||
<select id="selectOne" parameterType="java.lang.String" resultMap="BaseInfoMap">
|
||||
|
||||
Reference in New Issue
Block a user