From 479b759f08218794c2fba1fee4215504634b0583 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期四, 16 十一月 2023 20:33:08 +0800 Subject: [PATCH] 代码优化 --- ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java b/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java index 6dab4e5..088f683 100644 --- a/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java +++ b/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java @@ -17,6 +17,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -112,6 +113,19 @@ public void setLocaleDocumentService(IOdsLocaleDocumentService localeDocumentService) { this.localeDocumentService = localeDocumentService; } + + @PostConstruct + public void start() { + alarmMsgTask(); + queryDataDetectorDaily2Task(); + queryTenMinData(); + listLocale(); + listAlarmRecord(); + listCurAlarm(); + listDataDetectorDailyStats(); + listDetectorDaily(); + } + @Scheduled(cron = "0 0 1 * * ?") // 姣忓ぉ闆剁偣鎵ц // @Scheduled(cron = "0/1 * * * * ?") // 姣忕鎵ц @@ -289,7 +303,7 @@ list.forEach(o -> { try { o.setCustomerString(JSON.toJSONString(o.getCustomer())); - localeService.save(o); + localeService.saveOrUpdate(o); } catch (Exception ex) { System.out.printf(ex.getMessage()); } @@ -354,7 +368,7 @@ list.forEach(o -> { try { o.setAlarmRecordPicsString(JSON.toJSONString(o.getAlarmRecordPics())); - alarmRecordService.save(o); + alarmRecordService.saveOrUpdate(o); } catch (Exception ex) { System.out.printf(ex.getMessage()); } @@ -498,7 +512,7 @@ String listLocaleJson = "{\"Param\":{\"id\":\"" + locale.getId() + "\"}}"; String listLocale = HttpUtil.HttpPostWithJson(host + "/admin/listLocale", listLocaleJson, auth); - String detectorDailyJson = "{\"LocaleId\":\"" + locale.getId() + "\",\"AcquitAtBegin\":" + (dates[1]- 7*86400) + ",\"AcquitAtEnd\":" + dates[1] + "}"; + String detectorDailyJson = "{\"LocaleId\":\"" + locale.getId() + "\",\"AcquitAtBegin\":" + (dates[1] - 7 * 86400) + ",\"AcquitAtEnd\":" + dates[1] + "}"; String detectorDaily = HttpUtil.HttpPostWithJson(host + "/admin/queryDataDetectorDaily", detectorDailyJson, auth); String listIntimeDataJson = "{\"StartAt\":0,\"Size\":20,\"mn\":\"" + locale.getMnLast() + "\",\"typ\":2,\"at\":0}"; -- Gitblit v1.8.0