|
@@ -3,10 +3,12 @@ package com.sckw.slope.detection.service.task;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
|
|
|
+import com.sckw.core.model.enums.DictItemEnum;
|
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.excel.annotation.ExcelContext;
|
|
import com.sckw.excel.annotation.ExcelContext;
|
|
|
import com.sckw.excel.utils.ExcelUtil;
|
|
import com.sckw.excel.utils.ExcelUtil;
|
|
|
|
|
+import com.sckw.slope.detection.dao.mysql.KwsDeviceIntegrationMapper;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsProjectDeviceMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsProjectDeviceMapper;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
@@ -15,8 +17,10 @@ import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
|
|
|
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.tdengine.SlopeData;
|
|
import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
|
|
+import com.sckw.slope.detection.model.vo.DeviceIntegrationVo;
|
|
|
import com.sckw.slope.detection.model.vo.DeviceVo;
|
|
import com.sckw.slope.detection.model.vo.DeviceVo;
|
|
|
import com.sckw.slope.detection.model.vo.excel.TaskReportExportVO;
|
|
import com.sckw.slope.detection.model.vo.excel.TaskReportExportVO;
|
|
|
|
|
+import com.sckw.slope.detection.service.CommonService;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -63,11 +67,19 @@ public class ReportTemplateTaskService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
SlopeDataMapper slopeDataMapper;
|
|
SlopeDataMapper slopeDataMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ CommonService commonService;
|
|
|
|
|
+
|
|
|
public void report(KwsReportTemplate kwsReportTemplate, String date1, String date2) throws NoSuchAlgorithmException, IOException {
|
|
public void report(KwsReportTemplate kwsReportTemplate, String date1, String date2) throws NoSuchAlgorithmException, IOException {
|
|
|
|
|
|
|
|
String[] title = "推送时间".split(",");
|
|
String[] title = "推送时间".split(",");
|
|
|
String[] part = kwsReportTemplate.getPartNames().split(",");
|
|
String[] part = kwsReportTemplate.getPartNames().split(",");
|
|
|
- String[] intergration = kwsReportTemplate.getIntergrationNames().split(",");
|
|
|
|
|
|
|
+ String[] intergrationName = kwsReportTemplate.getIntergrationNames().split(",");
|
|
|
|
|
+
|
|
|
|
|
+ List<String> intergration = DictItemEnum.getAll();//获取系统中的全部基础要素
|
|
|
List<String> list = new ArrayList<>();
|
|
List<String> list = new ArrayList<>();
|
|
|
list.addAll(Arrays.asList(title));
|
|
list.addAll(Arrays.asList(title));
|
|
|
list.addAll(Arrays.asList(part));
|
|
list.addAll(Arrays.asList(part));
|
|
@@ -81,13 +93,22 @@ public class ReportTemplateTaskService {
|
|
|
Map<String, List<Object>> map1 = new HashMap<>();
|
|
Map<String, List<Object>> map1 = new HashMap<>();
|
|
|
for (DeviceVo vo : devices) {
|
|
for (DeviceVo vo : devices) {
|
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByList(vo.getSnCode(), list, "2022-1-1 00:00:00", date2);
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByList(vo.getSnCode(), list, "2022-1-1 00:00:00", date2);
|
|
|
|
|
+ /*List<Object> listm = new ArrayList<Object>();
|
|
|
|
|
+ if(Objects.nonNull(kwsReportTemplate.getIntergrationNames())){//集成要素不为空时
|
|
|
|
|
+ List<DeviceIntegrationVo> intergData = deviceIntegrationMapper.selectListParamsAndInterNameByDeviceId(vo.getId());
|
|
|
|
|
+ for (DeviceIntegrationVo listvo : intergData){
|
|
|
|
|
+ listm = commonService.returnIntegrationDataArray(vo.getSnCode(),"2022-1-1 00:00:00",date2,listvo,"time","offset");
|
|
|
|
|
+ }
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
if (Objects.nonNull(selectedData)) {
|
|
if (Objects.nonNull(selectedData)) {
|
|
|
Map<String, List<SlopeData>> map = selectedData.stream().collect(Collectors.groupingBy(SlopeData::getMsgId));
|
|
Map<String, List<SlopeData>> map = selectedData.stream().collect(Collectors.groupingBy(SlopeData::getMsgId));
|
|
|
|
|
|
|
|
List<Object> list1 = new ArrayList<>();
|
|
List<Object> list1 = new ArrayList<>();
|
|
|
for (List<SlopeData> value : map.values()) {
|
|
for (List<SlopeData> value : map.values()) {
|
|
|
List<Object> listObject = new ArrayList<>();
|
|
List<Object> listObject = new ArrayList<>();
|
|
|
- listObject.add(sdf.format(value.get(0).getTs()));
|
|
|
|
|
|
|
+ listObject.add(sdf.format(value.get(0).getRawId()));
|
|
|
|
|
+
|
|
|
for (int i = 1; i < list.size(); i++) {
|
|
for (int i = 1; i < list.size(); i++) {
|
|
|
for (SlopeData slopeData : value) {
|
|
for (SlopeData slopeData : value) {
|
|
|
if (slopeData.getLine().equals(list.get(i))) {
|
|
if (slopeData.getLine().equals(list.get(i))) {
|
|
@@ -95,11 +116,20 @@ public class ReportTemplateTaskService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ /*if(listm.size()>0){
|
|
|
|
|
+ for(Object obj:listm){
|
|
|
|
|
+ Map<String,String> map2 = new HashMap<>();
|
|
|
|
|
+ map2 = (Map<String ,String>) obj;
|
|
|
|
|
+ if(map2.get("time").equals(sdf.format(value.get(0).getRawId()))){
|
|
|
|
|
+ listObject.add(map2.get("offset"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }*/
|
|
|
list1.add(listObject);
|
|
list1.add(listObject);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
map1.put(vo.getName(), list1);
|
|
map1.put(vo.getName(), list1);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
ExcelContext excelContext = TaskReportExportVO.class.getAnnotation(ExcelContext.class);
|
|
ExcelContext excelContext = TaskReportExportVO.class.getAnnotation(ExcelContext.class);
|
|
|
if (devices.size() > 0) {
|
|
if (devices.size() > 0) {
|
|
@@ -128,7 +158,7 @@ public class ReportTemplateTaskService {
|
|
|
/**
|
|
/**
|
|
|
* 报表生成定时任务-天
|
|
* 报表生成定时任务-天
|
|
|
*/
|
|
*/
|
|
|
- // @Scheduled(cron = "* * * * * *")
|
|
|
|
|
|
|
+ //@Scheduled(cron = "* * * * * *")
|
|
|
public void templateTaskDay() throws IOException, NoSuchAlgorithmException {
|
|
public void templateTaskDay() throws IOException, NoSuchAlgorithmException {
|
|
|
List<KwsReportTemplate> kwsReportTemplates = reportTemplateMapper.selectList(new LambdaQueryWrapper<KwsReportTemplate>()
|
|
List<KwsReportTemplate> kwsReportTemplates = reportTemplateMapper.selectList(new LambdaQueryWrapper<KwsReportTemplate>()
|
|
|
.eq(KwsReportTemplate::getStatus, 0)
|
|
.eq(KwsReportTemplate::getStatus, 0)
|