数据删除策略定时任务

This commit is contained in:
liuyusheng 2024-04-10 09:15:59 +08:00
parent d66484f149
commit 20f62a7ddb
2 changed files with 28 additions and 0 deletions

View File

@ -34,6 +34,10 @@
<groupId>com.inspur</groupId>
<artifactId>tzipc-common</artifactId>
</dependency>
<dependency>
<groupId>com.inspur</groupId>
<artifactId>tzipc-system</artifactId>
</dependency>
</dependencies>

View File

@ -0,0 +1,24 @@
package com.inspur.quartz.task;
import com.inspur.common.utils.spring.SpringUtils;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
@Component("expDataDeletionTask")
public class ExpDataDeletionTask {
public void deleteExpDataByDate(Integer params)
{
System.out.println("执行有参方法:" + params);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
StringBuffer sql1 = new StringBuffer("");
StringBuffer sql2 = new StringBuffer("");
sql1.append("SELECT * FROM ").append(IpcConstant.PLC_MEASUREMENT).append(" where isAlarm = '0' and time < '").append(LocalDate.now().toString()).append("T00:00:00Z' -8h -").append(params.toString()).append("d");
sql2.append("SELECT * FROM ").append(IpcConstant.SENSOR_MEASUREMENT).append(" where isAlarm = '0' and time < '").append(LocalDate.now().toString()).append("T00:00:00Z' -8h -").append(params.toString()).append("d");
i.query(sql1.toString());
i.query(sql2.toString());
}
}