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 -> { .ifPresent(url -> {
ApprovalScheduleParam approvalScheduleParam = createApprovalScheduleParam(approvalData); ApprovalScheduleParam approvalScheduleParam = createApprovalScheduleParam(approvalData);
System.out.println(Json.gson().toJson(approvalScheduleParam)); System.out.println(Json.gson().toJson(approvalScheduleParam));
postRequest.post(url, approvalScheduleParam, ANResponse.class);
if(false){
CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class) CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class)
.getSuccess(), 0)); .getSuccess(), 6));
}
}); });
} }

View File

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

View File

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

View File

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