From 20f62a7ddbd9c1d261e77005cd37a19ed507abd8 Mon Sep 17 00:00:00 2001 From: liuyusheng Date: Wed, 10 Apr 2024 09:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=A0=E9=99=A4=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tzipc-server/tzipc-quartz/pom.xml | 4 ++++ .../quartz/task/ExpDataDeletionTask.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/task/ExpDataDeletionTask.java diff --git a/tzipc-server/tzipc-quartz/pom.xml b/tzipc-server/tzipc-quartz/pom.xml index f42c085..31c5138 100644 --- a/tzipc-server/tzipc-quartz/pom.xml +++ b/tzipc-server/tzipc-quartz/pom.xml @@ -34,6 +34,10 @@ com.inspur tzipc-common + + com.inspur + tzipc-system + diff --git a/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/task/ExpDataDeletionTask.java b/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/task/ExpDataDeletionTask.java new file mode 100644 index 0000000..03a59ce --- /dev/null +++ b/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/task/ExpDataDeletionTask.java @@ -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()); + } +}