From 5eb9d01170386cc5d539c6f261cc7ff8e9249ad3 Mon Sep 17 00:00:00 2001 From: bynt Date: Fri, 25 Nov 2022 16:08:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E5=A4=A9=E7=BB=9F=E8=AE=A1=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/repository/TaskImeiRepository.java | 10 ++++++++ .../system/service/TaskImeiService.java | 10 ++++++++ .../service/impl/TaskImeiServiceImpl.java | 6 +++++ .../com/baiye/timed/DeliveryBalanceTask.java | 25 ++++++++----------- .../java/com/baiye/task/MailSourceTask.java | 2 +- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskImeiRepository.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskImeiRepository.java index 90841f76..44802ab4 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskImeiRepository.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskImeiRepository.java @@ -56,4 +56,14 @@ public interface TaskImeiRepository extends JpaRepository, JpaSp @Modifying @Query("UPDATE TaskImei i set i.status = ?1,i.taskName = ?2,i.updateTime = ?3 where i.taskId = ?4 and i.id >= ?5 and i.id <= ?6") int updateImeiByTaskNameId(Integer num, String taskImeiName, DateTime date, Long taskId, Long minId, Long maxId); + + /** + * 统计今天数量 + * @param userId + * @param num + * @return + */ + @Query(value = "select count(1) from tb_task_imei where" + + " to_days(create_time) = to_days(now()) and user_id = ?1 and status = ?2", nativeQuery = true) + Integer countByUserId( Long userId, Integer num); } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/TaskImeiService.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/TaskImeiService.java index 65955984..21e53d93 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/TaskImeiService.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/TaskImeiService.java @@ -1,5 +1,6 @@ package com.baiye.modules.system.service; +import cn.hutool.core.date.DateTime; import com.baiye.modules.system.domain.TaskImei; import com.baiye.modules.system.service.dto.PlatformTransmitDTO; @@ -51,4 +52,13 @@ public interface TaskImeiService { * @return */ Boolean updateBath(Long taskId, String taskImeiName, Integer num, Long minId, Long maxId); + + /** + * 天统计条数 + * + * @param userId + * @param num + * @return + */ + Integer countByUserIdAndDate(Long userId, Integer num); } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/TaskImeiServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/TaskImeiServiceImpl.java index 20f7862d..4f09ba4e 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/TaskImeiServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/TaskImeiServiceImpl.java @@ -1,5 +1,6 @@ package com.baiye.modules.system.service.impl; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.baiye.constant.DefaultNumberConstants; import com.baiye.modules.system.domain.TaskImei; @@ -82,5 +83,10 @@ public class TaskImeiServiceImpl implements TaskImeiService { (num, taskImeiName, DateUtil.date(), taskId, minId, maxId) > DefaultNumberConstants.ZERO_NUMBER; } + @Override + public Integer countByUserIdAndDate( Long userId, Integer num) { + return taskImeiRepository.countByUserId(userId, num); + } + } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java b/manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java index da4fc68f..cde9804f 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java @@ -52,11 +52,8 @@ public class DeliveryBalanceTask { private final DeliveryProperties deliveryProperties; - private final CallDeductService callDeductService; - private final DeliveryRecordService deliveryRecordService; - /** * 修改时间 为8点至21点 */ @@ -87,8 +84,7 @@ public class DeliveryBalanceTask { // 截取数据 if (ObjectUtil.isNotNull(companyByUserId.getDmpLimitNum()) && companyByUserId.getDmpLimitNum() > DefaultNumberConstants.ZERO_NUMBER - && list.size() > companyByUserId.getDmpLimitNum()) { - + && list.size() > companyByUserId.getDmpLimitNum()) { downList = CollUtil.sub(list, companyByUserId.getDmpLimitNum(), list.size()); list = CollUtil.sub(list, DefaultNumberConstants.ZERO_NUMBER, companyByUserId.getDmpLimitNum()); } @@ -115,11 +111,14 @@ public class DeliveryBalanceTask { if (max.isPresent()) { maxId = max.get().getId(); } - if (minId > DefaultNumberConstants.ZERO_NUMBER && maxId > DefaultNumberConstants.ZERO_NUMBER) { + if (minId > DefaultNumberConstants.ZERO_NUMBER + && maxId > DefaultNumberConstants.ZERO_NUMBER) { // 转换DTO List toList = Convert.toList(ImeiDTO.class, taskImeiList); - Integer batch = ObjectUtil.isNull(num) ? DefaultNumberConstants.ONE_NUMBER : num + DefaultNumberConstants.ONE_NUMBER; - String taskImeiName = "BY".concat(StrPool.UNDERLINE).concat(format).concat(StrPool.UNDERLINE).concat(String.valueOf(batch)); + Integer batch = ObjectUtil.isNull(num) ? + DefaultNumberConstants.ONE_NUMBER : num + DefaultNumberConstants.ONE_NUMBER; + String taskImeiName = "BY".concat(StrPool.UNDERLINE).concat + (format).concat(StrPool.UNDERLINE).concat(String.valueOf(batch)); String file = fileUrl.concat(StrPool.SLASH).concat(taskImeiName); // 保存文件 String csvPath = file.concat(".csv"); @@ -131,16 +130,13 @@ public class DeliveryBalanceTask { // 发送邮件 MailUtil.sendMail(deliveryProperties.getEmailAddress(), deliveryProperties.getEmailPassword(), - deliveryProperties.getToEmailAddress(), zipPath, taskImeiName); - + deliveryProperties.getToEmailAddress(), zipPath, taskImeiName); // 保存发送记录 deliveryRecordService.saveDeliveryRecord(zipPath, taskImeiName, taskImeiList.size(), taskId, userId, DefaultNumberConstants.ONE_NUMBER); // 保存批次号 redisUtils.set(CacheKey.DMP_REQUEST_ID.concat(format), batch, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); // 批次修改状态 taskImeiService.updateBath(taskId, CharSequenceUtil.EMPTY, DefaultNumberConstants.ONE_NUMBER, minId, maxId); - // 修改余额 - // companyService.updateUserBalanceByCompanyId(sub.doubleValue(), companyByUserId.getId()); // 删除文件 boolean csvResult = FileUtil.del(csvPath); @@ -154,6 +150,7 @@ public class DeliveryBalanceTask { log.info("============================= down list size as {} =============================", downList.size()); Long minId = (long) DefaultNumberConstants.ZERO_NUMBER; Long maxId = (long) DefaultNumberConstants.ZERO_NUMBER; + TaskTagDto taskTagDto = taskService.queryDmpTask(taskId); Comparator comparing = Comparator.comparing(TaskImei::getId); // 最小id Optional min = downList.stream().min(comparing); @@ -175,9 +172,7 @@ public class DeliveryBalanceTask { String zipPath = file.concat(".zip"); String filePath = deliveryProperties.getDmpDownPath().concat(uuid).concat(".zip"); // 设置压缩文件 - CompressUtil.decryptionCompression - (zipPath, csvPath, deliveryProperties.getZipPassword()); - TaskTagDto taskTagDto = taskService.queryDmpTask(taskId); + CompressUtil.decryptionCompression(zipPath, csvPath, deliveryProperties.getZipPassword()); downRecordService.createRecord(downList.size(), companyByUserId.getCompanyName(), taskTagDto.getTaskName(), zipPath, filePath, null, DefaultNumberConstants.ONE_NUMBER); // 修改状态 taskImeiService.updateBath(taskId, CharSequenceUtil.EMPTY, DefaultNumberConstants.ONE_NUMBER, minId, maxId); diff --git a/services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java b/services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java index b14b6108..de172410 100644 --- a/services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java +++ b/services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java @@ -121,7 +121,7 @@ public class MailSourceTask { List phoneSets = Lists.newArrayList(Sets.newHashSet(phoneList)); log.info("=============== the phone list as {} ==================", phoneList.size()); // 集合分割 - List> partitions = ListUtil.partition(phoneSets, 200); + List> partitions = ListUtil.partition(phoneSets, DefaultNumberConstants.TWO_HUNDRED); for (List partition : partitions) { String join = Joiner.on(StrPool.COMMA).skipNulls().join(partition); // 批量解析号码