|
@@ -8,10 +8,11 @@ import cn.hutool.http.Method;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.ruoyi.biz.tools.Tools;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
-import java.time.Instant;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
+import java.time.*;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* Test$
|
|
@@ -21,15 +22,43 @@ import java.time.ZoneId;
|
|
|
*/
|
|
|
public class Test {
|
|
|
public static void main(String[] args) {
|
|
|
- long timestamp = 1714860159579l;
|
|
|
- LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
|
|
|
- System.err.println(dateTime);
|
|
|
-// String table = "root.tl.suxi.knittings2_plc1";
|
|
|
-// for (String table : tables) {
|
|
|
-// query(table, "1");
|
|
|
-//// for (String filed : fileds) {
|
|
|
-//// query(table, filed);
|
|
|
-//// }
|
|
|
+ test("2024-06-05", 1L);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void test(String date, Long lastPeriod) {
|
|
|
+ Date d = DateUtils.parseDate(date);
|
|
|
+ LocalDate localDate = DateUtils.toLocalDate(d);
|
|
|
+ if (lastPeriod == 12L) {
|
|
|
+ localDate = localDate.plusDays(1);
|
|
|
+ lastPeriod = 1L;
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
|
|
|
+ start = start.plusHours(lastPeriod * 2);
|
|
|
+ LocalDateTime end = start.plusHours(2);
|
|
|
+
|
|
|
+ LocalDateTime stop = Tools.currWholeTime();
|
|
|
+ //当前时间之前的偶数时间段
|
|
|
+ stop = stop.minusHours(stop.getHour() % 2);
|
|
|
+ do {
|
|
|
+ start = start.minusSeconds(1);
|
|
|
+ System.err.println(start + "\t" + end);
|
|
|
+ start = end;
|
|
|
+ end = end.plusHours(2);
|
|
|
+ } while (!end.isAfter(stop));
|
|
|
+// for (; sp <= ep; sp++) {
|
|
|
+// //先删除数据,再进行
|
|
|
+// LocalDateTime start = ldt.plusHours(2 * sp).minusHours(2);
|
|
|
+// LocalDateTime end = start.plusHours(2);
|
|
|
+// Long startTime = start.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+// Long endTime = end.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+// String sql = "DELETE FROM TWIN_CALC_2HR WHERE DATA_DATE=? AND TIME_PERIOD=?";
|
|
|
+// jdbcTemplate.update(sql, date, sp);
|
|
|
+// sql = "DELETE FROM TWIN_RECORD_ALARMS WHERE DATA_TIME>=? AND DATA_TIME<=?";
|
|
|
+// jdbcTemplate.update(sql, new Date(startTime), new Date(endTime));
|
|
|
+// sql = "DELETE FROM TWIN_PAN_HEAD_INFO WHERE RECORD_TIME>=? AND RECORD_TIME<=?";
|
|
|
+// jdbcTemplate.update(sql, new Date(startTime), new Date(endTime));
|
|
|
+// taskService.calc(date, sp);
|
|
|
// }
|
|
|
}
|
|
|
|