You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-spms-java/src/main/java/com/glxp/api/task/AliRelCodeDetailTask.java

100 lines
4.1 KiB
Java

//package com.glxp.api.task;
//
//import cn.hutool.core.collection.CollUtil;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.glxp.api.common.res.BaseResponse;
//import com.glxp.api.dao.schedule.ScheduledDao;
//import com.glxp.api.entity.collect.RelCodeBatch;
//import com.glxp.api.entity.collect.RelCodeDetail;
//import com.glxp.api.entity.system.ScheduledEntity;
//import com.glxp.api.req.alihealth.AlihealthYljgSinglerelationReqeust;
//import com.glxp.api.req.system.ScheduledRequest;
//import com.glxp.api.res.alihealth.AlihealthYljgSinglerelationResponse;
//import com.glxp.api.service.collect.RelCodeBatchService;
//import com.glxp.api.service.collect.RelCodeDetailService;
//import com.glxp.api.util.CacheUtils;
//import com.glxp.api.util.DateUtil;
//import com.glxp.api.util.RedisUtil;
//import com.glxp.api.util.alihealth.AlihealthYljgUtils;
//import com.glxp.api.util.redis.RedisDelayedQueue;
//import lombok.extern.slf4j.Slf4j;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.SchedulingConfigurer;
//import org.springframework.scheduling.config.ScheduledTaskRegistrar;
//import org.springframework.scheduling.support.CronTrigger;
//import org.springframework.stereotype.Component;
//import redis.clients.jedis.resps.Tuple;
//
//import javax.annotation.Resource;
//import java.util.*;
//
//@Component
//@EnableScheduling
//@Slf4j
//public class AliRelCodeDetailTask implements SchedulingConfigurer {
//
// final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class);
// @Resource
// AsyncCompanyDlHelper udiCompanyTask;
// @Resource
// RedisUtil redisUtil;
//
// @Resource
// private ScheduledDao scheduledDao;
// @Resource
// private RedisDelayedQueue redisDelayedQueue;
// @Resource
// private AlihealthYljgUtils alihealthYljgUtils;
// @Resource
// private RelCodeBatchService relCodeBatchService;
// @Resource
// private RelCodeDetailService relCodeDetailService;
//
//
// @Override
// public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
// scheduledTaskRegistrar.addTriggerTask(() -> process(),
// triggerContext -> {
// ScheduledRequest scheduledRequest = new ScheduledRequest();
// scheduledRequest.setCronName("aliRelCodeDetailTask");
// ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
// if (scheduledEntity == null) {
// return null;
// }
// String cron = scheduledEntity.getCron();
// if (cron.isEmpty()) {
// logger.error("cron is null");
// }
// return new CronTrigger(cron).nextExecutionTime(triggerContext);
// });
// }
//
// private void process() {
//
// long currentTimestamp = System.currentTimeMillis() / 1000; // 当前时间戳(秒)
//
// // 获取所有超时的任务 (score <= 当前时间戳)
// List<Tuple> tasksToProcess = redisDelayedQueue.getJedis().zrangeByScoreWithScores("rel_code_queue", "-inf", String.valueOf(currentTimestamp));
//
// Iterator<Tuple> iterator = tasksToProcess.iterator();
// while (iterator.hasNext()) {
// Tuple task = iterator.next();
// String taskId = task.getElement();
// String[] codes = taskId.split("&&&");
// if (codes!=null && codes.length>0) {
// String code = codes[0];
// String erpId = codes[1];
// log.error("关联关系下载任务ID===" + code);
// // 处理阿里关联关系
// relCodeBatchService.addRelCodeAli(code,erpId);
// }
// // 从队列中删除已执行的任务
// redisDelayedQueue.getJedis().zrem("rel_code_queue", taskId);
// log.error("关联关系下载删除任务ID " + taskId + " removed from queue.");
// }
// }
//
//}