From 86cc5d1bdb1582c529868da7bb58fdf172dfc95c Mon Sep 17 00:00:00 2001 From: ninftao <13586541001@163.com> Date: Sun, 26 Feb 2023 14:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/baiye/util/CacheKey.java | 6 ++++++ .../platform/rest/DownRecordController.java | 2 ++ .../service/impl/TaskImeiServiceImpl.java | 4 ++-- .../com/baiye/feign/DownRecordClient.java | 5 ++++- .../java/com/baiye/task/MailSourceTask.java | 21 +++++++++---------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/CacheKey.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/CacheKey.java index 65f10243..cb09bc74 100644 --- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/CacheKey.java +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/CacheKey.java @@ -91,6 +91,12 @@ public interface CacheKey { String USER_DETAILS = "user_details"; + /** + * 用户信息缓存 + */ + String UPLOAD_BATCH = "upload::batch::"; + + /** * oauth 客户端信息 */ diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/DownRecordController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/DownRecordController.java index 9bcb45e2..973fd339 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/DownRecordController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/DownRecordController.java @@ -1,6 +1,7 @@ package com.baiye.modules.platform.rest; +import com.baiye.annotation.Inner; import com.baiye.modules.platform.service.DownRecordService; import com.baiye.modules.platform.service.dto.DownRecordQueryCriteria; import io.swagger.annotations.Api; @@ -46,6 +47,7 @@ public class DownRecordController { return new ResponseEntity<>(downRecordService.uploadFile(files, taskName), HttpStatus.OK); } + @Inner @ApiOperation("修改下载链接") @GetMapping("/update/path") public ResponseEntity updatePath(String path, Long recordId) { diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java index a6c17ce4..c59833a9 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java @@ -131,7 +131,7 @@ public class TaskImeiServiceImpl implements TaskImeiService { (DefaultNumberConstants.ZERO_NUMBER, ResponseCode.SEND_MAIL_MAX_NUM_FRIEND.getDesc()); } - if (redisUtils.get(taskImeiDTO.getBatchNo()) != null) { + if (redisUtils.get(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo())) != null) { DeliveryRecord byBatchNo = deliveryRecordService.findByBatchNo(taskImeiDTO.getBatchNo()); if (ObjectUtil.isNotNull(byBatchNo) && ObjectUtil.isNotNull(byBatchNo.getId())) { return CommonResponse.createByErrorCodeMessage @@ -158,7 +158,7 @@ public class TaskImeiServiceImpl implements TaskImeiService { Long recordId = deliveryRecordService.saveDeliveryRecord(zipPath, taskImeiDTO.getBatchNo(), dtoList.size(), null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.THREE_NUMBER); // 缓存三天 - redisUtils.set(taskImeiDTO.getBatchNo(), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); + redisUtils.set(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); } return CommonResponse.createBySuccess(DefaultNumberConstants.TWO_HUNDRED); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/DownRecordClient.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/DownRecordClient.java index 81517e8b..96ca7916 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/DownRecordClient.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/DownRecordClient.java @@ -1,10 +1,12 @@ package com.baiye.feign; +import com.baiye.constant.SecurityConstants; import com.baiye.feign.fallback.OrganizeClientFallback; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; /** @@ -20,11 +22,12 @@ public interface DownRecordClient { * * @param path * @param recordId + * @param from * @return */ @ApiOperation("修改下载链接") @GetMapping(PAY_PREFIX + "/update/path") - ResponseEntity updatePath(@RequestParam("path") String path, @RequestParam("recordId") Long recordId); + ResponseEntity updatePath(@RequestParam("path") String path, @RequestParam("recordId") Long recordId, @RequestHeader(SecurityConstants.FROM) String from); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java index a4bdfe9d..4871cc65 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java @@ -15,12 +15,13 @@ import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import com.baiye.config.properties.DeliveryProperties; import com.baiye.constant.DefaultNumberConstants; +import com.baiye.constant.SecurityConstants; import com.baiye.exception.BadRequestException; import com.baiye.feign.DownRecordClient; import com.baiye.feign.TaskClient; +import com.baiye.http.DmpDataDTO; import com.baiye.http.DmpResponse; import com.baiye.http.ResponseCode; -import com.baiye.http.DmpDataDTO; import com.baiye.module.dao.ClueTalkRepository; import com.baiye.module.entity.DeliveryRecord; import com.baiye.module.entity.Task; @@ -72,7 +73,6 @@ public class MailSourceTask { /** * 十分钟获取邮件内容 - * */ @Scheduled(cron = "0 0/10 * * * ? ") @Transactional(rollbackFor = Exception.class) @@ -87,8 +87,8 @@ public class MailSourceTask { if (deliveryProperties.getToEmailAddress().equalsIgnoreCase (MailUtil.getFrom((MimeMessage) message))) { String taskName = message.getSubject(); - String str = (String) redisUtils.get(taskName); - if (StringUtils.isNotBlank(str)) { + Object objCache = redisUtils.get(taskName); + if (ObjectUtil.isNotNull(objCache)) { continue; } // 设置十分钟缓存 @@ -134,7 +134,7 @@ public class MailSourceTask { // 批量解析号码 SecretResponseBean responseBean = DecryptPnoUtil.batchDecryptPno (Base64.encode(StringUtils.substringBeforeLast(join, StrPool.COMMA))); - if (Objects.nonNull(responseBean)) { + if (ObjectUtil.isNotNull(responseBean) && ObjectUtil.isNotNull(responseBean.getTels())) { String decodeStr = Base64.decodeStr(responseBean.getTels()); String[] split = decodeStr.split(StrPool.COMMA); if (split.length > DefaultNumberConstants.ZERO_NUMBER) { @@ -157,7 +157,7 @@ public class MailSourceTask { FileUtil.del(path); FileUtil.del(unzipPath); taskClient.updateTask(task); - deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER,decryptList.size(), taskName); + deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); } log.info("============== message parsing succeeded file path as {} unzip path as {} ===============", path, unzipPath); } @@ -175,11 +175,10 @@ public class MailSourceTask { } dmpResponse.setBatchNo(taskName); dmpResponse.setDecryptList(arrayList); - map.put("status",DefaultNumberConstants.TWO_HUNDRED); + map.put("status", DefaultNumberConstants.TWO_HUNDRED); map.put("msg", ResponseCode.SUCCESS.getDesc()); - map.put("data",dmpResponse); - String post = HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map)); - log.info("=============== the send request result as {} =============",JSONUtil.toJsonStr(post)); + map.put("data", dmpResponse); + HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map)); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); } } @@ -187,7 +186,7 @@ public class MailSourceTask { log.info("========================= the path as {} =========================", path); String filePath = path.substring(path.lastIndexOf(StrPool.SLASH) + DefaultNumberConstants.ONE_NUMBER); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); - downRecordClient.updatePath(deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getId()); + downRecordClient.updatePath(deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getId(), SecurityConstants.FROM_IN); } } }