parent
66675bcc87
commit
1df4784507
@ -1,19 +0,0 @@
|
||||
package com.xjs.run;
|
||||
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* springboot启动成功后执行
|
||||
* @author xiejs
|
||||
* @since 2022-01-19
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationRunnerImpl implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
System.out.println("-----------------启动成功!!!---------------------");
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.xjs.run;
|
||||
|
||||
import com.xjs.domain.ApiRecord;
|
||||
import com.xjs.handler.RecordDateHandler;
|
||||
import com.xjs.service.ApiWarningService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* springboot启动成功后执行
|
||||
* @author xiejs
|
||||
* @since 2022-01-19
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationRunnerImpl extends RecordDateHandler implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private ApiWarningService apiWarningService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
System.out.println("-----------------启动成功!!!---------------------");
|
||||
|
||||
//启动后处理每日预警数量
|
||||
List<ApiRecord> apiRecordList = apiWarningService.selectApiRecordList(new ApiRecord());
|
||||
List<ApiRecord> handleDate = super.handleDate(apiRecordList);
|
||||
handleDate.forEach(data ->{
|
||||
apiWarningService.updateApiRecordByUrl(data);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.xjs.task;
|
||||
|
||||
import com.xjs.domain.ApiRecord;
|
||||
import com.xjs.handler.RecordDateHandler;
|
||||
import com.xjs.service.ApiWarningService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 预警相关定时任务
|
||||
* @author xiejs
|
||||
* @since 2022-01-21
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class WarningTask extends RecordDateHandler {
|
||||
|
||||
@Autowired
|
||||
private ApiWarningService apiWarningService;
|
||||
|
||||
/**
|
||||
* 处理预警api信息的每天调用次数<br>
|
||||
* 最近10次运行:<br>
|
||||
* 2022-01-22 00:00:10<br>
|
||||
* 2022-01-23 00:00:10<br>
|
||||
* 2022-01-24 00:00:10<br>
|
||||
* 2022-01-25 00:00:10<br>
|
||||
* 2022-01-26 00:00:10<br>
|
||||
* 2022-01-27 00:00:10<br>
|
||||
* 2022-01-28 00:00:10<br>
|
||||
* 2022-01-29 00:00:10<br>
|
||||
* 2022-01-30 00:00:10<br>
|
||||
* 2022-01-31 00:00:10<br>
|
||||
*/
|
||||
@Scheduled(cron = "10 0 0 * * ? ")
|
||||
public void handleRecordDate() {
|
||||
List<ApiRecord> apiRecordList = apiWarningService.selectApiRecordList(new ApiRecord());
|
||||
List<ApiRecord> handleDate = super.handleDate(apiRecordList);
|
||||
handleDate.forEach(data ->{
|
||||
apiWarningService.updateApiRecordByUrl(data);
|
||||
});
|
||||
log.info("定时任务处理预警api信息的每天调用次数完毕");
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue