|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.yitter.idgen.YitIdHelper;
|
|
|
+import com.xy.dto.ExcelDTO;
|
|
|
import com.xy.dto.FileExportDto;
|
|
|
import com.xy.entity.FileExport;
|
|
|
import com.xy.enums.FileExportStatus;
|
|
@@ -18,6 +19,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.Cleanup;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
@@ -106,12 +108,18 @@ public class FileExportServiceImpl extends ServiceImpl<FileExportMapper, FileExp
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @param sheetName Excel sheet 名
|
|
|
- * @param head Excel head 头
|
|
|
- * @param data 数据列表
|
|
|
+ * excel导出
|
|
|
+ *
|
|
|
+ * @param excelDTO
|
|
|
* @param <T>
|
|
|
*/
|
|
|
- public <T> void exportExcelAsync(String sheetName, Class<T> head, List<T> data) {
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public <T> void exportExcelAsync(ExcelDTO<T> excelDTO) {
|
|
|
+ String sheetName = excelDTO.getSheetName();
|
|
|
+ Class<T> head = excelDTO.getHead();
|
|
|
+ List<T> data = excelDTO.getData();
|
|
|
+ FileExportType fileExportType = excelDTO.getFileExportType();
|
|
|
//新增导出记录
|
|
|
long id = YitIdHelper.nextId();
|
|
|
String fileName = fileUtils.getFileName(id);
|
|
@@ -119,7 +127,7 @@ public class FileExportServiceImpl extends ServiceImpl<FileExportMapper, FileExp
|
|
|
try {
|
|
|
FileExportDto.Save fileExport = new FileExportDto.Save().setId(id)
|
|
|
.setExportStatus(FileExportStatus.EXPORT_ING.getCode())
|
|
|
- .setFileType(FileExportType.DEVICE_INFO.getCode()).setFileName(fileName);
|
|
|
+ .setFileType(fileExportType.getCode()).setFileName(fileName);
|
|
|
this.save(fileExport);
|
|
|
@Cleanup OutputStream out = new FileOutputStream(pathName);
|
|
|
//本地生成文件
|