fix: scc导入问题
This commit is contained in:
+10
-16
@@ -1,16 +1,9 @@
|
||||
package com.jero.modules.activiti.process.standardComplianceCheck.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import com.jero.modules.laws.utils.ExcelExportUtilPro;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WithoutDistributeExcelTemplate {
|
||||
@@ -56,7 +49,7 @@ public class WithoutDistributeExcelTemplate {
|
||||
*/
|
||||
@ApiModelProperty(value = "合规评估结果")
|
||||
@Dict(dicCode = "evaluation_result")
|
||||
@Excel(name = "评估结果", width = 15, orderNum = "6", dicCode = "evaluation_result")
|
||||
@Excel(name = "评估结果", width = 15, orderNum = "6")
|
||||
private String result;
|
||||
|
||||
/**
|
||||
@@ -77,7 +70,7 @@ public class WithoutDistributeExcelTemplate {
|
||||
* 整改周期
|
||||
*/
|
||||
@ApiModelProperty(value = "整改周期")
|
||||
@Excel(name = "整改方案", width = 15, orderNum = "9")
|
||||
@Excel(name = "整改周期", width = 15, orderNum = "9")
|
||||
private String correctionPeriod;
|
||||
|
||||
/**
|
||||
@@ -111,23 +104,24 @@ public class WithoutDistributeExcelTemplate {
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
@ApiModelProperty(value = "佐证材料")
|
||||
@ExcelCollection(name = "", orderNum = "14")
|
||||
@TableField(exist = false)
|
||||
private List<ExcelExportUtilPro.FileDetails> fileList = Collections.emptyList();
|
||||
// @ApiModelProperty(value = "佐证材料")
|
||||
// @ExcelCollection(name = "", orderNum = "14")
|
||||
// @TableField(exist = false)
|
||||
// private List<ExcelExportUtilPro.FileDetails> fileList = Collections.emptyList();
|
||||
|
||||
/**
|
||||
* 佐证材料
|
||||
*/
|
||||
@ApiModelProperty(value = "佐证材料")
|
||||
@Excel(name = "佐证材料", width = 15, orderNum = "13")
|
||||
@Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name")
|
||||
private String material;
|
||||
|
||||
private String sort;
|
||||
|
||||
public List<String> obtainFileIds() {
|
||||
return material != null ? Arrays.asList(material.split(",")) : Collections.emptyList();
|
||||
}
|
||||
// public List<String> obtainFileIds() {
|
||||
// return material != null ? Arrays.asList(material.split(",")) : Collections.emptyList();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
+36
-37
@@ -513,10 +513,10 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
.copyBeanList(detailInfoList, WithoutDistributeExcelTemplate.class);
|
||||
List<WithoutDistributeExcelTemplate> newRecordsExport = new ArrayList<>(data);
|
||||
Workbook workbook = ExcelExportUtil
|
||||
.exportExcel(exportParams, WithoutDistributeExcelTemplate.class, detailInfoList);
|
||||
.exportExcel(exportParams, WithoutDistributeExcelTemplate.class, data);
|
||||
// 生成超链接
|
||||
excelExportUtilPro.generateHyperlink(newRecordsExport, workbook,
|
||||
WithoutDistributeExcelTemplate::getFileList, 13);
|
||||
// excelExportUtilPro.generateHyperlink(newRecordsExport, workbook,
|
||||
// WithoutDistributeExcelTemplate::getFileList, 13);
|
||||
// 导出excel
|
||||
workbook.write(fos);
|
||||
// 生成并导出zip
|
||||
@@ -578,24 +578,24 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
|
||||
// 获取Excel的header
|
||||
List<String> headers;
|
||||
try {
|
||||
headers = ExcelUtils.getHeaderFromExcel(file.getInputStream(), 0);
|
||||
} catch (Exception e) {
|
||||
errorMsgs.add("模板错误,请按照系统模板导入!");
|
||||
resultMap.put("msg", errorMsgs);
|
||||
resultMap.put("flag", YesOrNoEnum.NO.getValue());
|
||||
log.error(e.getMessage(), e);
|
||||
return resultMap; // 返回错误信息
|
||||
}
|
||||
|
||||
// 使用静态方法验证header
|
||||
boolean isMatched = headers.equals(ExcelUtils.getSortedHeadersFromClass(WithoutDistributeExcelTemplate.class));
|
||||
if (!isMatched) {
|
||||
errorMsgs.add("模板错误,请按照系统模板导入!");
|
||||
resultMap.put("msg", errorMsgs);
|
||||
resultMap.put("flag", YesOrNoEnum.NO.getValue());
|
||||
return resultMap; // 返回错误信息
|
||||
}
|
||||
// try {
|
||||
// headers = ExcelUtils.getHeaderFromExcel(file.getInputStream(), 0);
|
||||
// } catch (Exception e) {
|
||||
// errorMsgs.add("模板错误,请按照系统模板导入!");
|
||||
// resultMap.put("msg", errorMsgs);
|
||||
// resultMap.put("flag", YesOrNoEnum.NO.getValue());
|
||||
// log.error(e.getMessage(), e);
|
||||
// return resultMap; // 返回错误信息
|
||||
// }
|
||||
//
|
||||
// // 使用静态方法验证header
|
||||
// boolean isMatched = headers.equals(ExcelUtils.getSortedHeadersFromClass(WithoutDistributeExcelTemplate.class));
|
||||
// if (!isMatched) {
|
||||
// errorMsgs.add("模板错误,请按照系统模板导入!");
|
||||
// resultMap.put("msg", errorMsgs);
|
||||
// resultMap.put("flag", YesOrNoEnum.NO.getValue());
|
||||
// return resultMap; // 返回错误信息
|
||||
// }
|
||||
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(0);
|
||||
@@ -607,8 +607,6 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
InputStream inputStream = Files.newInputStream(excelfilelist.get(0).toPath());
|
||||
List<WithoutDistributeExcelTemplate> list = ExcelImportUtil
|
||||
.importExcel(inputStream, WithoutDistributeExcelTemplate.class, params);
|
||||
list.remove(0);
|
||||
list.remove(0);
|
||||
if (list.isEmpty()) {
|
||||
errorMsgs.add("文件暂无数据,请检查后重试。");
|
||||
resultMap.put("msg", errorMsgs);
|
||||
@@ -648,20 +646,21 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
item.setCommonalityCost(null);
|
||||
item.setRemark(null);
|
||||
item.setMaterial(null);
|
||||
}
|
||||
switch (result) {
|
||||
case CONFORM_TO:
|
||||
case NOT_INVOLVE:
|
||||
item.setUnsatisfiedRequire(null);
|
||||
item.setCorrectionSolution(null);
|
||||
item.setCorrectionCost(null);
|
||||
item.setCommonality(null);
|
||||
item.setCommonalityCost(null);
|
||||
break;
|
||||
case DISCREPANCY:
|
||||
case TO_BE_VERIFIED:
|
||||
item.setRemark(null);
|
||||
item.setMaterial(null);
|
||||
} else {
|
||||
switch (result) {
|
||||
case CONFORM_TO:
|
||||
case NOT_INVOLVE:
|
||||
item.setUnsatisfiedRequire(null);
|
||||
item.setCorrectionSolution(null);
|
||||
item.setCorrectionCost(null);
|
||||
item.setCommonality(null);
|
||||
item.setCommonalityCost(null);
|
||||
break;
|
||||
case DISCREPANCY:
|
||||
case TO_BE_VERIFIED:
|
||||
item.setRemark(null);
|
||||
item.setMaterial(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
@@ -127,6 +128,31 @@ public class ExcelUtils {
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HeadRow的文本内容
|
||||
*
|
||||
* @param is 文件输入流
|
||||
* @return HeadRow的List
|
||||
* @throws Exception
|
||||
*/
|
||||
public static List<String> getHeaderFromExcelXSSF(InputStream is, Integer index) throws Exception {
|
||||
List<String> headers = new ArrayList<>();
|
||||
|
||||
Workbook workbook = new XSSFWorkbook(is);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// HeadRow在index 1
|
||||
for (int rowIndex = index; rowIndex <= index; rowIndex++) {
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
for (Cell cell : row) {
|
||||
String cellValue = cell.getStringCellValue();
|
||||
// 否则,直接添加到列表
|
||||
headers.add(cellValue);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个类的所有带@Excel注解的字段的name属性值,并按照orderNum正序排序。
|
||||
*
|
||||
@@ -554,6 +580,9 @@ public class ExcelUtils {
|
||||
}
|
||||
|
||||
public String uploadFile(String material, Map<String, File> fileMap) {
|
||||
if (StrUtil.isBlank(material)) {
|
||||
return "";
|
||||
}
|
||||
return importUtil.convertFileIds(material, fileMap);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user