From 7c4cd64b1d444dbbea40c660e7be47d1b6258da3 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 03 十一月 2023 21:33:51 +0800
Subject: [PATCH] 文档
---
ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 46 insertions(+), 4 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 db0e45e..8038a21 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
@@ -1,6 +1,9 @@
package com.ycl.smoke.task;
import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ycl.service.redis.RedisService;
import com.ycl.smoke.entity.*;
import com.ycl.smoke.dto.*;
@@ -31,6 +34,8 @@
IOdsInTimeService inTimeService;
+ IOdsInTimeCountService iOdsInTimeCountService;
+
IOdsLocaleService localeService;
IOdsCustomerService customerService;
@@ -45,6 +50,11 @@
@Autowired
public void setSmokeDetectionService(ISmokeDetectionService smokeDetectionService) {
this.smokeDetectionService = smokeDetectionService;
+ }
+
+ @Autowired
+ public void setIOdsInTimeCountService(IOdsInTimeCountService iOdsInTimeCountService) {
+ this.iOdsInTimeCountService = iOdsInTimeCountService;
}
@Autowired
@@ -186,20 +196,52 @@
// @Scheduled(cron = "0 0 1 * * ?") // 姣忓ぉ闆剁偣鎵ц
- @Scheduled(cron = "0 */5 * * * ?") // 姣�5鍒嗛挓鎵ц
- public void listDataIntime() {
- try {
- DataIntimeParamDto paramDto = DataIntimeParamDto.builder().build();
+ @Scheduled(cron = "0 */1 * * * ?") // 姣�5鍒嗛挓鎵ц
+ public void listDataInTime() {
+ DataIntimeParamDto paramDto = DataIntimeParamDto.builder().build();
+ // {"StartAt":0,"Size":20,"Typ":2,"SortBy":"status","SortMode":"asc","Param":{"StatusOfRecord":"NORMAL"}}
+ paramDto.setSize(20);
+ paramDto.setStartAt(0);
+ paramDto.setTyp(2);
+ paramDto.setSortBy("status");
+ paramDto.setSortMode("asc");
+ DataIntimeParamChildDto paramChildDto = new DataIntimeParamChildDto();
+ paramChildDto.setStatusOfRecord("NORMAL");
+ paramDto.setParam(paramChildDto);
+
+ getInTimeData(paramDto);
+
+ paramDto.setTyp(1);
+ getInTimeData(paramDto);
+ }
+
+ private void getInTimeData(DataIntimeParamDto paramDto) {
+ try {
+ String jj = JSON.toJSONString(paramDto);
String json = smokeDetectionService.listDataIntime(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString());
SmokeResultResponseDto responseDto = JSON.parseObject(json, SmokeResultResponseDto.class);
if (responseDto.getStatus() == 200) {
DataIntimeResponseDto dataIntimeResponseDto = JSON.parseObject(responseDto.getData().toString(), DataIntimeResponseDto.class);
List<OdsInTime> list = dataIntimeResponseDto.getContent();
+
+ OdsInTimeCount odsInTimeCount = new OdsInTimeCount();
+ LambdaQueryWrapper<OdsInTimeCount> queryWrapper = new LambdaQueryWrapper<OdsInTimeCount>().eq(OdsInTimeCount::getType, paramDto.getTyp());
+ List<OdsInTimeCount> countList = iOdsInTimeCountService.list(queryWrapper);
+ if (countList.size() > 0) {
+ odsInTimeCount = countList.get(0);
+ }
+ odsInTimeCount.setDeviceNum(dataIntimeResponseDto.getDeviceNum());
+ odsInTimeCount.setLocaleNum(dataIntimeResponseDto.getLocaleNum());
+ odsInTimeCount.setOnlineNum(dataIntimeResponseDto.getOnlineNum());
+ odsInTimeCount.setTotal(dataIntimeResponseDto.getTotal());
+ iOdsInTimeCountService.saveOrUpdate(odsInTimeCount);
+
list.forEach(o -> {
try {
o.setModifyTime(LocalDateTime.now());
+ o.setTyp(paramDto.getTyp());
inTimeService.saveOrUpdate(o);
} catch (Exception ex) {
System.out.printf(ex.getMessage());
--
Gitblit v1.8.0