添加数量缓存

master
ninftao 10 months ago
parent 8a8598321b
commit 08884619b4

@ -73,6 +73,12 @@ public interface CacheKey {
String DMP_TRIPARTITE_URL = "dmp::tripartite::url::";
/**
*
*/
String DMP_TRIPARTITE_NUM = "dmp::tripartite::num::";
/**
* dmp

@ -37,6 +37,7 @@ import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.springframework.stereotype.Service;
@ -164,7 +165,7 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
}
@SneakyThrows
@SneakyThrows(value = ZipException.class)
private void downResource(String taskName, DeliveryRecord
byTaskName, List<List<String>> originalList, List<String> responseList) {
String uuid = IdUtil.fastSimpleUUID();
@ -218,19 +219,20 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
redisUtils.set(CacheKey.DMP_DOWN_URL.concat(String.valueOf(byTaskName.getDownId())), zipPath, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
}
@SneakyThrows
private void downReceptionResource(String bathNo, DeliveryRecord byTaskName, List<String> responseList) {
@SneakyThrows(value = ZipException.class)
private void downReceptionResource(String bathNo, DeliveryRecord byTaskName, List<String> responseList) {
String uuid = IdUtil.fastSimpleUUID();
String format = DateUtil.format(DateUtil.date(), DatePattern.NORM_DATE_PATTERN);
String file = deliveryProperties.getFileUrl().concat(StrPool.SLASH).concat(uuid);
Object objPath = redisUtils.get(CacheKey.DMP_TRIPARTITE_URL.concat(format));
Object downNum = redisUtils.get(CacheKey.DMP_TRIPARTITE_NUM.concat(format));
String path = ObjectUtil.isNotNull(objPath) ?
String.valueOf(objPath) : deliveryRecordClient.queryTripartitePath(format, byTaskName.getUserId(), SecurityConstants.FROM_IN).getBody();
if (ObjectUtil.isNotNull(path)) {
// 解压文件
String unzipPath = CompressUtil.unzipFiles
(deliveryProperties.getFileUrl(), path, deliveryProperties.getZipPassword());
File unzipFile = new File(unzipPath);
File parseFile = Objects.requireNonNull
(unzipFile.listFiles())[DefaultNumberConstants.ZERO_NUMBER];
@ -242,11 +244,14 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
// 追加新内容
originSet.addAll(responseList.stream().map
(str -> EncryptUtil.aesEncrypt(str, AdPlatFormConstants.PLAT_DECRYPTION)).collect(Collectors.toSet()));
Integer originSize = originSet.size() +
(downNum != null ? Integer.parseInt(downNum.toString()) : DefaultNumberConstants.ZERO_NUMBER);
FileZipUtil.writeToCsv(Lists.newArrayList(originSet), parseFile.getPath(), Boolean.TRUE);
// 设置压缩文件
CompressUtil.decryptionCompression(path, parseFile.getPath(), null);
deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, responseList.size(), bathNo);
deliveryRecordClient.updateOriginAndSize(byTaskName.getUserId(), format, originSet.size(), SecurityConstants.FROM_IN);
deliveryRecordClient.updateOriginAndSize(byTaskName.getUserId(), format, originSize, SecurityConstants.FROM_IN);
redisUtils.set(CacheKey.DMP_TRIPARTITE_NUM.concat(format), originSize, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
FileUtil.del(unzipPath);
return;
}
@ -267,6 +272,7 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, responseList.size(), bathNo);
deliveryRecordClient.savePathAndSetDateStr(byTaskName.getUserId(), stringSet.size(), zipPath, downUrl, format, SecurityConstants.FROM_IN);
redisUtils.set(CacheKey.DMP_TRIPARTITE_URL.concat(format), zipPath, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
redisUtils.set(CacheKey.DMP_TRIPARTITE_NUM.concat(format), responseList.size(), DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
}
private static void aggregateData(InterfaceResponseDTO responseDTO, DeliveryRecord byTaskName,

Loading…
Cancel
Save