fix:用户数据缓存时因无法序列化导致无法缓存的问题

This commit is contained in:
lulz1 2024-07-17 00:28:35 +08:00
parent f0c87d7f08
commit 02bd1ae0e9
4 changed files with 26 additions and 21 deletions

View File

@ -102,8 +102,11 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
.ifPresent(url -> {
ApprovalScheduleParam approvalScheduleParam = createApprovalScheduleParam(approvalData);
System.out.println(Json.gson().toJson(approvalScheduleParam));
CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class)
.getSuccess(), 0));
postRequest.post(url, approvalScheduleParam, ANResponse.class);
if(false){
CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class)
.getSuccess(), 6));
}
});
}

View File

@ -13,31 +13,31 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
@Component
public class ApprovalPlatformCommon implements ApprovalPlatform {
@Autowired
private SupplierRepository supplierRepository;
@Autowired
private ApprovalPlatformInfoRepository approvalPlatformInfoRepository;
@Autowired
private PostRequest postRequest;
@Autowired
private RedisTemplate<String, ApprovalPlatformInfo> redisTemplate;
// @Autowired
// private SupplierRepository supplierRepository;
//
// @Autowired
// private ApprovalPlatformInfoRepository approvalPlatformInfoRepository;
//
// @Autowired
// private PostRequest postRequest;
//
// @Autowired
// private RedisTemplate<String, ApprovalPlatformInfo> redisTemplate;
public static final String platformMark = "COMMON";
@PostConstruct
void init() {
approvalPlatformInfoRepository.findByPlatformMark(platformMark)
.ifPresent(approvalPlatformInfo -> {
String cacheKey = getCacheKey(approvalPlatformInfo.getPlatformName(),
approvalPlatformInfo.getPlatformMark());
redisTemplate.opsForValue().set(cacheKey, approvalPlatformInfo, 1L, TimeUnit.DAYS);
});
// approvalPlatformInfoRepository.findByPlatformMark(platformMark)
// .ifPresent(approvalPlatformInfo -> {
// String cacheKey = getCacheKey(approvalPlatformInfo.getPlatformName(),
// approvalPlatformInfo.getPlatformMark());
// redisTemplate.opsForValue().set(cacheKey, approvalPlatformInfo, 1L, TimeUnit.DAYS);
// });
}
private String getCacheKey(String platformName, String platformMark) {

View File

@ -73,7 +73,7 @@ public interface SupplierOrderSync extends SupplierAdapter {
boolean isValid = true;
// Process each leg
for (Leg leg : legList) {
for (Leg leg : needSyncLegs) {
// Perform product check based on leg type and update the isValid flag
switch (leg.getLegType()) {
case LEG_TYPE_TRAIN ->

View File

@ -53,6 +53,7 @@ public class PostRequest {
public <T> T post(String url, Object jsonRequest, Class<T> responseType) {
HttpPost post = new HttpPost(url);
String json = gson.toJson(jsonRequest);
log.info(url);
log.info(json);
post.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
return post(post, responseType);
@ -60,6 +61,7 @@ public class PostRequest {
public <T> T post(String url, String json, Class<T> responseType) {
HttpPost post = new HttpPost(url);
log.info(url);
log.info(json);
post.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
return post(post, responseType);