数据分割

master
bynt 1 year ago
parent fbe13f5da5
commit 4e43e3cce9

@ -181,6 +181,11 @@ public class DefaultNumberConstants {
*/
public static final int FIVE_THOUSAND = 5000;
/**
*
*/
public static final int FIFTY_THOUSAND = 50000;
/**
*
*/

@ -149,6 +149,10 @@ public class DownRecordServiceImpl implements DownRecordService {
if (dtoArrayList.size() < DefaultNumberConstants.ONE_HUNDRED) {
throw new BadRequestException(ResponseCode.SEND_MAIL_NUM_FRIEND.getDesc());
}
// 每次100000 数据
List<List<ImeiDTO>> partition = Lists.partition
(dtoArrayList, DefaultNumberConstants.FIFTY_THOUSAND);
for (List<ImeiDTO> list : partition) {
String uuid = IdUtil.fastSimpleUUID();
String format = DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN);
String file = deliveryProperties.getFileUrl().concat(StrPool.SLASH).concat(uuid);
@ -157,7 +161,7 @@ public class DownRecordServiceImpl implements DownRecordService {
String taskImeiName = FileConstant.MM.concat(StrPool.UNDERLINE).concat(format).concat(StrPool.UNDERLINE).concat(String.valueOf(batch));
// 保存文件
String csvPath = file.concat(StrPool.DOT).concat(FileConstant.CSV_FILE_SUB_NAME);
CSVFileUtil.createCsvFile(dtoArrayList, csvPath);
CSVFileUtil.createCsvFile(list, csvPath);
String zipPath = file.concat(FileConstant.ZIP_FILE_SUB_NAME);
// 设置压缩文件
CompressUtil.decryptionCompression
@ -167,10 +171,11 @@ public class DownRecordServiceImpl implements DownRecordService {
deliveryProperties.getEmailPassword(), deliveryProperties.getToEmailAddress(), zipPath, taskImeiName);
// 保存批次号
redisUtils.set(CacheKey.DMP_MANUAL_ID.concat(format), batch, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
Long recordId = deliveryRecordService.saveDeliveryRecord(zipPath, taskImeiName, dtoArrayList.size(), null,
Long recordId = deliveryRecordService.saveDeliveryRecord(zipPath, taskImeiName, list.size(), null,
SecurityUtils.getCurrentUserId(), DefaultNumberConstants.TWO_NUMBER);
String filePath = deliveryProperties.getDmpDownPath().concat(uuid).concat(FileConstant.ZIP_FILE_SUB_NAME);
this.createRecord(dtoArrayList.size(), "超级管理员", taskName, zipPath, filePath, recordId, DefaultNumberConstants.TWO_NUMBER);
this.createRecord(list.size(), "超级管理员", taskName, zipPath, filePath, recordId, DefaultNumberConstants.TWO_NUMBER);
}
return Boolean.TRUE;
}
}

@ -32,7 +32,7 @@
<properties>
<jwt.version>3.9.0</jwt.version>
<poi.version>4.0.0</poi.version>
<poi.version>4.1.2</poi.version>
<mail.version>1.6.2</mail.version>
<oshi.version>5.7.1</oshi.version>
<guava.version>23.0</guava.version>

Loading…
Cancel
Save