|
@@ -117,6 +117,7 @@ public class DownloadRecordService {
|
|
|
record.setAdminId(currentAdminId);
|
|
|
record.setAdminName(currentAdminName);
|
|
|
record.setCreateTime(new Date());
|
|
|
+ record.setDeleted(false);
|
|
|
record.setParamMd5(paramMd5);
|
|
|
record.setParamJson(paramJson);
|
|
|
record.setParamUrl(paramUrl);
|
|
@@ -199,7 +200,7 @@ public class DownloadRecordService {
|
|
|
}
|
|
|
DownloadRecord record = downloadRecordRepository.findOne(downloadRecordId);
|
|
|
if (!Checker.isNone(record)) {
|
|
|
- String fileName = record.getFileName() + ".xlsx";
|
|
|
+ String fileName = record.getFileName();
|
|
|
httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), Constants.CHARSET_NAME));
|
|
|
httpServletResponse.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
httpServletResponse.setHeader("Pragma", "no-cache");
|
|
@@ -234,16 +235,21 @@ public class DownloadRecordService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void createFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<ExcelCollectPojo> itemList) throws Exception {
|
|
|
- fileName = fileName + FormatUtil.formatDate(new Date(), FormatUtil.FORMAT_DATE_SECOND_NUMBER);
|
|
|
+ // 前缀(路径)
|
|
|
String preLocalPath = ConstantDef.LOCAL_DOWNLOAD_FILE_PATH;
|
|
|
- // 写到服务器上
|
|
|
- String localPath = preLocalPath + fileName + ".xlsx";
|
|
|
- ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
|
|
|
+ // 后缀(下载时间和格式)
|
|
|
+ String suffixFormat = FormatUtil.formatDate(new Date(), FormatUtil.FORMAT_DATE_SECOND_NUMBER) + ConstantDef.EXCEL_SUFFIX_FORMAT;
|
|
|
+ // 写到本地,拼凑本地路径
|
|
|
+ String localPath = preLocalPath + fileName + suffixFormat;
|
|
|
+
|
|
|
// 生成本地文件
|
|
|
+ ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
|
|
|
excelDownloadSrv.generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
|
|
|
+
|
|
|
+ // 本地文件上传到oss,文件名带后缀
|
|
|
String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));
|
|
|
- // 本地文件上传到oss
|
|
|
- DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, fileName, ossPath);
|
|
|
+ String ossFileName = fileName + suffixFormat;
|
|
|
+ DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath);
|
|
|
if (dataResponse.getCode() == BaseResponse.SUCCEED) {
|
|
|
// 上传成功,将上传状态和地址保存到数据库
|
|
|
saveUrlAndStatus(downloadRecordId, dataResponse.getData().toString(), DownloadRecordStatusEnum.SUCCESS.getValue());
|