认证-参数模板-参数项导入模板-bug57066

This commit is contained in:
liyawei
2022-08-05 14:32:20 +08:00
parent 63ef236d3c
commit 5a1ef584e8
@@ -35,7 +35,8 @@ import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.aspectj.util.FileUtil;
import org.jeecgframework.poi.excel.ExcelExportUtil;
@@ -398,6 +399,63 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
}
workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.XSSF);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setWrapText(true);//自动换行
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 给模板添加填写说明
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
Sheet sheet = workbook.getSheetAt(numSheet);
String explanation = "";
int countLine = 0;
int lastCol = 0;
if (numSheet == 0) { // 企业参数表
countLine = 8;
lastCol = 10;
if (CutEnum.EN.getValue().equals(cut)) {
explanation = "Filling explanation\n"
+ "1.Import data starts at the third line, the first line is the header, the second line is the description, and the third line is the official data\n"
+ "2.All fields marked with * must be filled in\n"
+ "3.NIO Number,Params Name,Description,Control Values,Default Value fields are text type. Enter the text content\n"
+ "4.Is Must,Params Batch,Duty Territory,Control Type,Control Verify fields are single type,Must match the corresponding field option in the system\n"
+ "5.File Template fields are file type, must create a folder in the directory of the same level as the file with the name of the nio number and place the file in the folder. Assume that the file is saved in the A number B.pdf,Should fill in A/B.pdf\n";
} else {
explanation = "填写说明\n"
+ "1.导入数据从第三行开始,第一行为表头,第二行为填写说明,第三行是正式数据\n"
+ "2.所有带*号的字段必须填写\n"
+ "3.NIO编号,参数名称,参数说明,控件备选值,默认值字段为文本,填写文本内容\n"
+ "4.是否必填,参数批次,责任领域,控件类型,控件校验字段为单选属性,必须和系统中的对应字段选项相匹配\n"
+ "5.附件模板为文件属性,填写时需要在本文件同级目录下以NIO编号为名称建立文件夹,并在文件夹下放置文件,假设在A编号下放置了B.pdf,则应填写A/B.pdf\n";
}
} else { // 认证类别表
countLine = 6;
lastCol = 3;
if (CutEnum.EN.getValue().equals(cut)) {
explanation = "Filling explanation\n"
+ "1.Import data starts at the third line, the first line is the header, the second line is the description, and the third line is the official data\n"
+ "2.All fields marked with * must be filled in\n"
+ "3.NIO Number,Number,Params Name,Description fields are text type. Enter the text content\n";
} else {
explanation = "填写说明\n"
+ "1.导入数据从第三行开始,第一行为表头,第二行为填写说明,第三行是正式数据\n"
+ "2.所有带*号的字段必须填写\n"
+ "3.NIO编号,编号,参数名称,参数说明字段为文本,填写文本内容\n";
}
}
CellRangeAddress region1 =
new CellRangeAddress(1, 1, 0, lastCol); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
sheet.addMergedRegion(region1);
Row row = sheet.createRow(1);
row.setHeight((short) ((short) countLine * 252));
Cell cell = row.createCell(0);
cell.setCellStyle(cellStyle);
cell.setCellValue(explanation);
}
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition",
@@ -854,6 +912,7 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
ExcelImportResult<ParamsInfoCnImport> result = ExcelImportUtil.importExcelMore(excelfile, ParamsInfoCnImport.class, params);
paramsInfoEOList = result.getList();
}
} else { // 认证类别参数表
if (certCategoryMap.containsKey(sheetName)) {
List<CertCategoryParamsInfoCnImport> list = new ArrayList<>();
@@ -872,6 +931,7 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
list = result.getList();
}
if (CollectionUtil.isNotEmpty(list)) {
list.remove(0); // 去掉填写说明
for (CertCategoryParamsInfoCnImport certCategoryParamsInfoEO : list){
//判断此行数据是否全部为空,是则不读取
if (checkObjAllFieldsIsNull(certCategoryParamsInfoEO)) {
@@ -890,6 +950,9 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
if(paramsInfoEOList!=null &&!paramsInfoEOList.isEmpty()){
try {
String unzipfilepath = zipEntryName;
// 去掉填写说明
paramsInfoEOList.remove(0);
Result<?> message = importParamsInfoData(paramsInfoEOList,certCategoryParamsInfoEOListMap,unzipfilepath,paramsTemplateId,cut);
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);