|
@@ -5,15 +5,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
|
|
|
|
|
+import com.sckw.slope.detection.model.dos.mysql.KwsThreshold;
|
|
|
|
|
+import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
|
|
+import com.sckw.slope.detection.model.vo.DeviceVo;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author lfdc
|
|
* @author lfdc
|
|
@@ -29,10 +38,13 @@ public class ReportTemplateTaskService {
|
|
|
@Resource
|
|
@Resource
|
|
|
KwsReportTemplateMapper reportTemplateMapper;
|
|
KwsReportTemplateMapper reportTemplateMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ SlopeDataMapper slopeDataMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 报表生成定时任务-天
|
|
* 报表生成定时任务-天
|
|
|
*/
|
|
*/
|
|
|
- // @Scheduled(cron = "* * * * * *")
|
|
|
|
|
|
|
+ //@Scheduled(cron = "* * * * * *")
|
|
|
public void templateTaskDay() {
|
|
public void templateTaskDay() {
|
|
|
List<KwsReportTemplate> kwsReportTemplates = reportTemplateMapper.selectList(new LambdaQueryWrapper<KwsReportTemplate>()
|
|
List<KwsReportTemplate> kwsReportTemplates = reportTemplateMapper.selectList(new LambdaQueryWrapper<KwsReportTemplate>()
|
|
|
.eq(KwsReportTemplate::getStatus, 0)
|
|
.eq(KwsReportTemplate::getStatus, 0)
|
|
@@ -44,9 +56,40 @@ public class ReportTemplateTaskService {
|
|
|
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1);
|
|
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1);
|
|
|
LocalDateTime dateEnd = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeEnd(localDateTime.toLocalDate());
|
|
LocalDateTime dateEnd = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeEnd(localDateTime.toLocalDate());
|
|
|
LocalDateTime dateStart = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeStart(localDateTime.toLocalDate());
|
|
LocalDateTime dateStart = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeStart(localDateTime.toLocalDate());
|
|
|
- //
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String date1 = dateStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ String date2 = dateEnd.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ String[] part = kwsReportTemplate.getPartNames().split(",");
|
|
|
|
|
+ String[] intergration = kwsReportTemplate.getIntergrationNames().split(",");
|
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
|
+ list.addAll(Arrays.asList(part));
|
|
|
|
|
+ list.addAll(Arrays.asList(intergration));
|
|
|
|
|
+ String projectId = kwsReportTemplate.getProjectId();
|
|
|
|
|
+ //首先查询模板中的要素关联的设备-项目中的设备
|
|
|
|
|
+ List<DeviceVo> devices = reportTemplateMapper.selectDeviceByProjectId(projectId,list);
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ for (DeviceVo vo : devices){
|
|
|
|
|
+ List<SlopeData> selectedData = slopeDataMapper.selectLineListByList(vo.getSnCode(), list, "2022-1-1 00:00:00", date2);
|
|
|
|
|
+ if(Objects.nonNull(selectedData)){
|
|
|
|
|
+ Map<String,List<SlopeData>> map = selectedData.stream().collect(Collectors.groupingBy(SlopeData::getMsgId));
|
|
|
|
|
|
|
|
|
|
+ List<Object> list1 = new ArrayList<>();
|
|
|
|
|
+ map.forEach((key,value) -> {
|
|
|
|
|
+ Map<Object,Object> mapdata = new HashMap<>();
|
|
|
|
|
+ value.forEach(valuetemp->{
|
|
|
|
|
+ mapdata.put("ts",sdf.format(valuetemp.getTs()));
|
|
|
|
|
+ for (int i = 0;i< list.size();i++){
|
|
|
|
|
+ // if(valuetemp.getLine().equals(list[i].get("line"))){
|
|
|
|
|
+ mapdata.put(valuetemp.getLine(),valuetemp.getVal());
|
|
|
|
|
+ //}
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ list1.add(map);
|
|
|
|
|
+ });
|
|
|
|
|
+ vo.setData(list1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("aaa:{}",devices);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|