You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

11 months ago
package com.yingji.quartz;
11 months ago
import cn.hutool.core.util.StrUtil;
11 months ago
import com.yingji.entity.QuartzLog;
11 months ago
import com.yingji.service.AccidentService;
11 months ago
import com.yingji.service.QuartzLogService;
11 months ago
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
11 months ago
import javax.annotation.Resource;
11 months ago
import java.time.LocalDateTime;
11 months ago
/**
* 120
*
* @author wu
* @since 2024/5/10 10:05
*/
@Configuration
@Transactional(rollbackFor = Exception.class)
11 months ago
public class AccidentQuartz {
public static final Logger log = LoggerFactory.getLogger(AccidentQuartz.class);
@Resource
private AccidentService accidentService;
11 months ago
@Resource
private QuartzLogService quartzLogService;
@Async
@Scheduled(cron = "*/10 * * * * ? ")
11 months ago
public void savaData() {
String accessToken = accidentService.getAuthorizeToken();
11 months ago
QuartzLog quartzLog = new QuartzLog();
quartzLog.setInterfaceName(3);
quartzLog.setCreateTime(LocalDateTime.now());
11 months ago
if (StrUtil.isNotEmpty(accessToken)) {
accidentService.getAccidentUrl(accessToken);
11 months ago
quartzLog.setStatus(1);
quartzLogService.save(quartzLog);
11 months ago
log.info("=================120定时任务结束===============");
} else {
11 months ago
quartzLog.setStatus(2);
quartzLogService.save(quartzLog);
11 months ago
log.info("=================120定时任务获取token失败===============");
}
11 months ago
}
}