58420修改。

This commit is contained in:
wangzhijiang
2022-08-19 16:31:43 +08:00
parent a90bc1d5a0
commit e543d213d6
@@ -360,66 +360,64 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
String cut = (String) params.get("cut");
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
this.disposeComplianceResult(exportData,cut);
if(CollectionUtils.isNotEmpty(exportData)){
String title = "";
String fileName = "";
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
fileName = "符合性结果" + ".xlsx";
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
title = "Responsible Field,Relevant Project,Design Compliance Confirmation,Pre-Homo Confirmation,Validation Compliance Confirmation";
fileName = "Compliance results" + ".xlsx";
String title = "";
String fileName = "";
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
fileName = "符合性结果" + ".xlsx";
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
title = "Responsible Field,Relevant Project,Design Compliance Confirmation,Pre-Homo Confirmation,Validation Compliance Confirmation";
fileName = "Compliance results" + ".xlsx";
}
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
try {
response.setHeader("Content-Disposition",
"attachment; filename=" + fileName);
response.setContentType("application/force-download");
HSSFSheet sheet = workbook.createSheet("sheet1");
CellStyle titleCellStyle = workbook.createCellStyle();
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
titleCellStyle.setWrapText(true);//自动换行
//创建表头
String[] firstLineTitleArr = title.split(",");
Row firstRow = sheet.createRow(0);
//设置居中、表头值。
for (int i = 0; i < firstLineTitleArr.length; i++){
sheet.setColumnWidth(i,8000);
Cell cell = firstRow.createCell(i);
cell.setCellStyle(titleCellStyle);
cell.setCellValue(firstLineTitleArr[i]);
}
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
try {
response.setHeader("Content-Disposition",
"attachment; filename=" + fileName);
response.setContentType("application/force-download");
HSSFSheet sheet = workbook.createSheet("sheet1");
CellStyle titleCellStyle = workbook.createCellStyle();
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
titleCellStyle.setWrapText(true);//自动换行
//创建表头
String[] firstLineTitleArr = title.split(",");
Row firstRow = sheet.createRow(0);
//设置居中、表头值。
for (int i = 0; i < firstLineTitleArr.length; i++){
sheet.setColumnWidth(i,8000);
Cell cell = firstRow.createCell(i);
cell.setCellStyle(titleCellStyle);
cell.setCellValue(firstLineTitleArr[i]);
}
//设置导出数据
if(CollectionUtils.isNotEmpty(exportData)) {
int rowIndex = 1;
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
Row dataRow = sheet.createRow(rowIndex);
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("dutyTerritory_dicText")));
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("projectName")));
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("designFlowTaskStatus_dicText")));
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("prehomoFlowTaskStatus_dicText")));
dataRow.createCell(4).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("verifyFlowTaskStatus_dicText")));
rowIndex ++;
}
}
os = response.getOutputStream();
workbook.write(os);
os.flush();
}catch (IOException ex){
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("下载文件失败");
}else{
throw new JeroBootException("Failed to download file");
//设置导出数据
if(CollectionUtils.isNotEmpty(exportData)) {
int rowIndex = 1;
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
Row dataRow = sheet.createRow(rowIndex);
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("dutyTerritory_dicText")));
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("projectName")));
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("designFlowTaskStatus_dicText")));
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("prehomoFlowTaskStatus_dicText")));
dataRow.createCell(4).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("verifyFlowTaskStatus_dicText")));
rowIndex ++;
}
}
os = response.getOutputStream();
workbook.write(os);
os.flush();
}catch (IOException ex){
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("下载文件失败");
}else{
throw new JeroBootException("Failed to download file");
}
}
}