权益使用同步逻辑调整

This commit is contained in:
郭诚奇
2025-10-22 11:01:50 +08:00
parent bb32d13c0f
commit d67abd6095

View File

@@ -18,7 +18,6 @@ import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -46,13 +45,11 @@ public class SyncBenefitUseRecord implements Job {
private BenefitUsageRecordService benefitUsageRecordService;
@Autowired
private SyncBenefitUseRecord syncBenefitUseRecord;
@Autowired
private StringRedisTemplate redisTemplate;
@GetMapping("/syncBenefitUseRecord")
public void sync() {
try {
syncBenefitUseRecord.execute(null);
this.syncBenefitUseRecord.execute(null);
} catch (JobExecutionException e) {
log.info("", e);
}
@@ -63,17 +60,7 @@ public class SyncBenefitUseRecord implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
log.info("开始同步权益使用记录");
// 获取服务id映射列表
String key = "benefit_id_code_mapping";
List<ConfigCodeDTO> configCodeDTOList;
if (Boolean.TRUE.equals(redisTemplate.hasKey(key))) {
configCodeDTOList = JSON.parseArray(this.redisTemplate.opsForValue().get(key), ConfigCodeDTO.class);
} else {
configCodeDTOList = this.configCodeService.list(new ConfigCodeQueryDTO().setCodeType("benefit_id_code_mapping")).getContent();
this.redisTemplate.opsForValue().set(key, JSON.toJSONString(configCodeDTOList), 24, TimeUnit.HOURS);
}
if (CollUtil.isEmpty(configCodeDTOList)) {
configCodeDTOList = new ArrayList<>();
}
List<ConfigCodeDTO> configCodeDTOList = this.configCodeService.list(new ConfigCodeQueryDTO().setCodeType("benefit_id_code_mapping")).getContent();
// 查询上次同步时间
long startTime;
ConfigCodeQueryDTO configCodeQueryDTO = new ConfigCodeQueryDTO();