diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java index 2584a85c..90d96017 100644 --- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java @@ -181,6 +181,11 @@ public class DefaultNumberConstants { */ public static final int FIVE_THOUSAND = 5000; + /** + * 五万 + */ + public static final int FIFTY_THOUSAND = 50000; + /** * 十万 */ diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DownRecordServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DownRecordServiceImpl.java index b123778e..f95c7ef2 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DownRecordServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DownRecordServiceImpl.java @@ -149,28 +149,33 @@ public class DownRecordServiceImpl implements DownRecordService { if (dtoArrayList.size() < DefaultNumberConstants.ONE_HUNDRED) { throw new BadRequestException(ResponseCode.SEND_MAIL_NUM_FRIEND.getDesc()); } - String uuid = IdUtil.fastSimpleUUID(); - String format = DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN); - String file = deliveryProperties.getFileUrl().concat(StrPool.SLASH).concat(uuid); - Integer num = (Integer) redisUtils.get(CacheKey.DMP_MANUAL_ID.concat(format)); - Integer batch = ObjectUtil.isNull(num) ? DefaultNumberConstants.ONE_NUMBER : num + DefaultNumberConstants.ONE_NUMBER; - 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); - String zipPath = file.concat(FileConstant.ZIP_FILE_SUB_NAME); - // 设置压缩文件 - CompressUtil.decryptionCompression - (zipPath, csvPath, deliveryProperties.getZipPassword()); - // 发送邮件 - MailUtil.sendMail(deliveryProperties.getEmailAddress(), - 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, - 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); + // 每次100000 数据 + List> partition = Lists.partition + (dtoArrayList, DefaultNumberConstants.FIFTY_THOUSAND); + for (List 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); + Integer num = (Integer) redisUtils.get(CacheKey.DMP_MANUAL_ID.concat(format)); + Integer batch = ObjectUtil.isNull(num) ? DefaultNumberConstants.ONE_NUMBER : num + DefaultNumberConstants.ONE_NUMBER; + 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(list, csvPath); + String zipPath = file.concat(FileConstant.ZIP_FILE_SUB_NAME); + // 设置压缩文件 + CompressUtil.decryptionCompression + (zipPath, csvPath, deliveryProperties.getZipPassword()); + // 发送邮件 + MailUtil.sendMail(deliveryProperties.getEmailAddress(), + 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, list.size(), null, + SecurityUtils.getCurrentUserId(), DefaultNumberConstants.TWO_NUMBER); + String filePath = deliveryProperties.getDmpDownPath().concat(uuid).concat(FileConstant.ZIP_FILE_SUB_NAME); + this.createRecord(list.size(), "超级管理员", taskName, zipPath, filePath, recordId, DefaultNumberConstants.TWO_NUMBER); + } return Boolean.TRUE; } } diff --git a/pom.xml b/pom.xml index afd64ce6..b285ed4d 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ 3.9.0 - 4.0.0 + 4.1.2 1.6.2 5.7.1 23.0