From fac3ab9d2f648af3cb6985f1b995cb47c70aff3c Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 7 Jun 2022 08:55:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=81=AB=E7=82=B9=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E5=BC=80=E5=85=B3=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=201=E3=80=81=E6=97=A9=E4=B8=8A=E5=85=AB=E7=82=B9=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=81=AB=E7=82=B9=E5=AE=A1=E6=A0=B8=E5=BC=80=E5=85=B3?= =?UTF-8?q?=202=E3=80=81=E6=99=9A=E4=B8=8A=E5=8D=81=E7=82=B9=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E7=81=AB=E7=82=B9=E5=AE=A1=E6=A0=B8=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/common/StaticScheduleTask.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/com/xkrs/common/StaticScheduleTask.java diff --git a/src/main/java/com/xkrs/common/StaticScheduleTask.java b/src/main/java/com/xkrs/common/StaticScheduleTask.java new file mode 100644 index 0000000..397510b --- /dev/null +++ b/src/main/java/com/xkrs/common/StaticScheduleTask.java @@ -0,0 +1,45 @@ +package com.xkrs.common; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +import java.util.HashMap; +import java.util.Map; + +import static com.xkrs.utils.WDHttpClientUtils.sendHttpPost; + +/** + * 火点审核开关计划任务 + */ +@Configuration +@EnableScheduling +public class StaticScheduleTask { + + //早上八点打开火点审核开关 + @Scheduled(cron = "0 0 8 * * ?") + private void openVerifySwitch() { + try { + String url = "http://118.24.27.47:6801/updateswitchstate"; + Map map = new HashMap<>(); + map.put("switchState", "1"); + sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //晚上十点关闭火点审核开关 + @Scheduled(cron = "0 0 22 * * ?") + private void closeVerifySwitch() { + try { + String url = "http://118.24.27.47:6801/updateswitchstate"; + Map map = new HashMap<>(); + map.put("switchState", "0"); + sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file