Browse Source

fit:定时任务优化

master
pengwei 1 month ago
parent
commit
1e07b6de2c
  1. 10
      src/main/java/com/biutag/supervision/job/Job.java
  2. 7
      src/test/java/com/biutag/supervision/SupervisionApplicationTests.java

10
src/main/java/com/biutag/supervision/job/Job.java

@ -17,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Month; import java.time.Month;
@ -117,11 +119,15 @@ public class Job {
// 每天一次 23:30:00 // 每天一次 23:30:00
//todo 维权信息 //todo 维权信息
@Scheduled(cron = "0 30 23 * * ?") @Scheduled(cron = "0 30 23 * * ?")
public void rights() { public void rights() throws ParseException {
log.info("rights--------------------"); log.info("rights--------------------");
log.info("维权信息抓取中---------------------"); log.info("维权信息抓取中---------------------");
// 维权 // 维权
List<DwdAsjZfbaShrxx2> shrxxList = dwdAsjZfbaShrxx2Service.listAll(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTime = sdf.parse("2025-01-01 00:00:00");
Date endTime = sdf.parse("2025-12-30 00:00:00");
List<DwdAsjZfbaShrxx2> shrxxList = dwdAsjZfbaShrxx2Service.list(startTime,endTime);
log.info("数据:{}条", shrxxList.size()); log.info("数据:{}条", shrxxList.size());
shrxxList.forEach(item -> { shrxxList.forEach(item -> {
RpcApplySupervise rpcApply = new RpcApplySupervise(); RpcApplySupervise rpcApply = new RpcApplySupervise();

7
src/test/java/com/biutag/supervision/SupervisionApplicationTests.java

@ -20,6 +20,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -52,15 +53,15 @@ class SupervisionApplicationTests {
private NegativeFileService negativeFileService; private NegativeFileService negativeFileService;
@Test @Test
void contextLoads() throws FileNotFoundException { void contextLoads() throws FileNotFoundException, ParseException {
List<NegativeFile> files = negativeFileService.list(new LambdaQueryWrapper<NegativeFile>().eq(NegativeFile::getFileName, "123.jpg")); List<NegativeFile> files = negativeFileService.list(new LambdaQueryWrapper<NegativeFile>().eq(NegativeFile::getFileName, "123.jpg"));
System.out.println(files); System.out.println(files);
testFun(); testFun();
} }
void testFun(){ void testFun() throws ParseException {
job.updateBaseData(); job.rights();
} }
public String getPathTrace(SupDepart depart) { public String getPathTrace(SupDepart depart) {

Loading…
Cancel
Save