58420修改。
This commit is contained in:
+54
-56
@@ -360,66 +360,64 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
|||||||
String cut = (String) params.get("cut");
|
String cut = (String) params.get("cut");
|
||||||
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||||
this.disposeComplianceResult(exportData,cut);
|
this.disposeComplianceResult(exportData,cut);
|
||||||
if(CollectionUtils.isNotEmpty(exportData)){
|
String title = "";
|
||||||
String title = "";
|
String fileName = "";
|
||||||
String fileName = "";
|
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
||||||
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
||||||
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
fileName = "符合性结果" + ".xlsx";
|
||||||
fileName = "符合性结果" + ".xlsx";
|
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
||||||
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
title = "Responsible Field,Relevant Project,Design Compliance Confirmation,Pre-Homo Confirmation,Validation Compliance Confirmation";
|
||||||
title = "Responsible Field,Relevant Project,Design Compliance Confirmation,Pre-Homo Confirmation,Validation Compliance Confirmation";
|
fileName = "Compliance results" + ".xlsx";
|
||||||
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",
|
if(CollectionUtils.isNotEmpty(exportData)) {
|
||||||
"attachment; filename=" + fileName);
|
int rowIndex = 1;
|
||||||
response.setContentType("application/force-download");
|
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
|
||||||
|
Row dataRow = sheet.createRow(rowIndex);
|
||||||
HSSFSheet sheet = workbook.createSheet("sheet1");
|
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("dutyTerritory_dicText")));
|
||||||
|
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("projectName")));
|
||||||
CellStyle titleCellStyle = workbook.createCellStyle();
|
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("designFlowTaskStatus_dicText")));
|
||||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
|
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("prehomoFlowTaskStatus_dicText")));
|
||||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
|
dataRow.createCell(4).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("verifyFlowTaskStatus_dicText")));
|
||||||
titleCellStyle.setWrapText(true);//自动换行
|
rowIndex ++;
|
||||||
|
|
||||||
//创建表头
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user