|
@@ -3,9 +3,12 @@ package com.ruoyi.biz.task;
|
|
import com.ruoyi.biz.service.IApiService;
|
|
import com.ruoyi.biz.service.IApiService;
|
|
import com.ruoyi.biz.service.ITaskService;
|
|
import com.ruoyi.biz.service.ITaskService;
|
|
import com.ruoyi.biz.service.ITwinCalcDayService;
|
|
import com.ruoyi.biz.service.ITwinCalcDayService;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.time.*;
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 定时任务调度测试
|
|
* 定时任务调度测试
|
|
@@ -20,6 +23,8 @@ public class TwinTask {
|
|
private ITwinCalcDayService dayService;
|
|
private ITwinCalcDayService dayService;
|
|
@Resource
|
|
@Resource
|
|
private IApiService apiService;
|
|
private IApiService apiService;
|
|
|
|
+ @Resource
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 计算上一个小时数据
|
|
* 计算上一个小时数据
|
|
@@ -48,4 +53,22 @@ public class TwinTask {
|
|
public void indexAlarms() {
|
|
public void indexAlarms() {
|
|
apiService.indexAlarms();
|
|
apiService.indexAlarms();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 清理数据
|
|
|
|
+ *
|
|
|
|
+ * @param day 天数
|
|
|
|
+ */
|
|
|
|
+ public void clean(Integer day) {
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
|
+ LocalDateTime ldt = LocalDateTime.of(localDate, LocalTime.MIN).minusDays(day);
|
|
|
|
+ Date date = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
|
+// Long time = ldt.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
+ String sql = "DELETE FROM TWIN_CALC_ALARMS WHERE DATA_DATE<?";
|
|
|
|
+ jdbcTemplate.update(sql, date);
|
|
|
|
+ sql = "DELETE FROM TWIN_RECORD_ALARMS WHERE DATA_DATE<?";
|
|
|
|
+ jdbcTemplate.update(sql, date);
|
|
|
|
+ sql = "DELETE FROM TWIN_RECORD_STOP WHERE DATA_DATE<?";
|
|
|
|
+ jdbcTemplate.update(sql, date);
|
|
|
|
+ }
|
|
}
|
|
}
|