微调
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.jbsyncdata.service.impl;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.io.file.FileWriter;
|
||||||
import cn.hutool.core.text.StrPool;
|
import cn.hutool.core.text.StrPool;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
@@ -24,6 +25,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -58,6 +60,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void queryTelemetryData(String startTime, String endTime) {
|
public void queryTelemetryData(String startTime, String endTime) {
|
||||||
|
List<String> noDataUser = new ArrayList<>();
|
||||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||||
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||||
if (null == tokenWithRestTemplate) {
|
if (null == tokenWithRestTemplate) {
|
||||||
@@ -91,6 +94,12 @@ public class BusinessServiceImpl implements IBusinessService {
|
|||||||
//指标类型集合
|
//指标类型集合
|
||||||
List<String> typeList = MeasTypeEnum.getMeasList();
|
List<String> typeList = MeasTypeEnum.getMeasList();
|
||||||
jsonObjectSub.set("telemetryTypes", typeList);
|
jsonObjectSub.set("telemetryTypes", typeList);
|
||||||
|
//将指标+客户编号组合起来匹配返回数据的第一条记录:userId@measType
|
||||||
|
List<String> userIdConcatMeasType = new ArrayList<>();
|
||||||
|
for (String measType : typeList) {
|
||||||
|
List<String> temp = generationUserIDList.stream().map(t -> t.concat(StrPool.AT).concat(measType)).collect(Collectors.toList());
|
||||||
|
userIdConcatMeasType.addAll(temp);
|
||||||
|
}
|
||||||
jsonObject.set("filter", jsonObjectSub);
|
jsonObject.set("filter", jsonObjectSub);
|
||||||
//组装好json开始发送请求
|
//组装好json开始发送请求
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
@@ -105,12 +114,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|||||||
log.error("起始时间:{},截止时间:{},无遥测数据;", startTime, endTime);
|
log.error("起始时间:{},截止时间:{},无遥测数据;", startTime, endTime);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//将指标+客户编号组合起来匹配返回数据的第一条记录:userId@measType
|
|
||||||
List<String> userIdConcatMeasType = new ArrayList<>();
|
|
||||||
for (String measType : typeList) {
|
|
||||||
List<String> temp = generationUserIDList.stream().map(t -> t.concat(StrPool.AT).concat(measType)).collect(Collectors.toList());
|
|
||||||
userIdConcatMeasType.addAll(temp);
|
|
||||||
}
|
|
||||||
//处理各个record的数据,因用户下可能有多个测量点,按指标循环,默认采用第一个匹配上的做数据处理
|
//处理各个record的数据,因用户下可能有多个测量点,按指标循环,默认采用第一个匹配上的做数据处理
|
||||||
for (CommonTelemetry commonTelemetry : records) { // 最多循环500*16次
|
for (CommonTelemetry commonTelemetry : records) { // 最多循环500*16次
|
||||||
String dataIdentify = commonTelemetry.getConsNo().concat(StrPool.AT).concat(commonTelemetry.getMeasTypeCode());
|
String dataIdentify = commonTelemetry.getConsNo().concat(StrPool.AT).concat(commonTelemetry.getMeasTypeCode());
|
||||||
@@ -137,12 +141,20 @@ public class BusinessServiceImpl implements IBusinessService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//没有匹配上的就是该用户没有数据
|
||||||
|
noDataUser.addAll(userIdConcatMeasType);
|
||||||
|
|
||||||
}
|
}
|
||||||
//每片数据获取完毕后,将数据处理入influxdb库
|
//每片数据获取完毕后,将数据处理入influxdb库
|
||||||
batchInsertData(typeData);
|
batchInsertData(typeData);
|
||||||
}
|
}
|
||||||
|
//最后输出没有数据的用户编号
|
||||||
|
noDataUser = noDataUser.stream().map(t -> t.substring(t.indexOf(StrPool.AT+1)))
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
FileWriter writer = FileWriter.create(new File("/usr/local/" + startTime + "-" + endTime + ".txt"));
|
||||||
|
File file = writer.writeLines(noDataUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!--日志输出格式-->
|
<!--日志输出格式-->
|
||||||
<property name="log.homeDir" value="d:\logs"/>
|
<property name="log.homeDir" value="/usr/local/logs"/>
|
||||||
<property name="log.pattern"
|
<property name="log.pattern"
|
||||||
value="|-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%level} ${log.projectName} -- %t %logger{100}.%M ==> %m%n${Log_EXCEPTION_CONVERSION_WORD:-%ec}}}"/>
|
value="|-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%level} ${log.projectName} -- %t %logger{100}.%M ==> %m%n${Log_EXCEPTION_CONVERSION_WORD:-%ec}}}"/>
|
||||||
<property name="log.maxHistory" value="30"/>
|
<property name="log.maxHistory" value="30"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user