|
@@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.Field;
|
|
@@ -52,7 +51,6 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
|
|
|
List<String> txtList = new ArrayList();
|
|
|
FileOutputStream fos = null;
|
|
|
SXSSFWorkbook wb = null;
|
|
|
- boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
|
|
|
File file = null;
|
|
|
int y = 0, min = 0;
|
|
|
try {
|
|
@@ -85,25 +83,15 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
|
|
|
List subList = roomCodeExportDtoList.subList(min, max);
|
|
|
//绘制数据
|
|
|
for (; y < subList.size(); y++) {
|
|
|
- RoomCodeExportDto roomCodeExportDto = roomCodeExportDtoList.get(y);
|
|
|
+ RoomCodeExportDto roomCodeExportDto = (RoomCodeExportDto) subList.get(y);
|
|
|
int firstRow = y + 1;
|
|
|
cellIndex = 0;
|
|
|
- Row hssfRow = sheet.createRow(firstRow);
|
|
|
-
|
|
|
- Cell cell = hssfRow.createCell(cellIndex);
|
|
|
- cell.setCellValue(roomCodeExportDto.getRoomCode());
|
|
|
- cell.setCellStyle(style);
|
|
|
- cellIndex++;
|
|
|
-
|
|
|
- cell = hssfRow.createCell(cellIndex);
|
|
|
- cell.setCellValue(roomCodeExportDto.getRoomName());
|
|
|
- cell.setCellStyle(style);
|
|
|
- cellIndex++;
|
|
|
-
|
|
|
- cell = hssfRow.createCell(cellIndex);
|
|
|
- cell.setCellValue(roomCodeExportDto.getName());
|
|
|
- cell.setCellStyle(style);
|
|
|
- cellIndex++;
|
|
|
+ Row sxssfRow = sheet.createRow(firstRow);
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(roomCodeExportDto), style);
|
|
|
+ cellIndex++;
|
|
|
+ }
|
|
|
}
|
|
|
txtList = taskExportCommon.progress(max, min, size, txtList);
|
|
|
if (max == size) {
|
|
@@ -119,10 +107,7 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
|
|
|
//写入excel并上传附件
|
|
|
fos = new FileOutputStream(file);
|
|
|
wb.write(fos);
|
|
|
- if (oss) {//上传至oss
|
|
|
- taskExportCommon.getOssUtil().ossUpload(taskExportCommon.getOssEnv(), file.getPath(), new FileInputStream(file));
|
|
|
- file.delete();
|
|
|
- }
|
|
|
+ taskExportCommon.ossUpload(file);
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("导出考场数据结束,============耗时============:{}秒", (end - start) / 1000);
|
|
|
} catch (Exception e) {
|