|
@@ -1,22 +1,21 @@
|
|
|
package com.gyee.frame.service.export;
|
|
|
|
|
|
import com.gyee.frame.common.conf.ExportConfig;
|
|
|
+import com.gyee.frame.common.conf.ThreadPoolTaskConfig;
|
|
|
import com.gyee.frame.common.exception.QiNiuException;
|
|
|
import com.gyee.frame.common.exception.enums.QiNiuErrorEnum;
|
|
|
import com.gyee.frame.common.feign.RemoteServiceBuilder;
|
|
|
-import com.gyee.frame.model.auto.WindTurbineTestingPointAi2;
|
|
|
import com.gyee.frame.model.custom.export.TsPointData;
|
|
|
import com.gyee.frame.service.WindTurbineTestingPointAiService;
|
|
|
import com.gyee.frame.service.WindturbineService;
|
|
|
import com.gyee.frame.util.DateUtils;
|
|
|
+import com.gyee.frame.util.task.TaskTemplateCallable;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.Future;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -28,6 +27,8 @@ public class GoldenService {
|
|
|
@Resource
|
|
|
private ExportConfig exportConfig;
|
|
|
@Resource
|
|
|
+ private ThreadPoolTaskConfig taskConfig;
|
|
|
+ @Resource
|
|
|
private RemoteServiceBuilder remoteService;
|
|
|
@Resource
|
|
|
private WindturbineService windturbineService;
|
|
@@ -50,14 +51,14 @@ public class GoldenService {
|
|
|
* @param interval
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Object> getHistoryDataSingle(String station, String wtId, int templateId, long startTs, long endTs, int interval) {
|
|
|
- switch (templateId) {
|
|
|
- case 1:
|
|
|
- return getTemplateHistory1(station, wtId, startTs, endTs, interval);
|
|
|
- default:
|
|
|
- throw new QiNiuException(QiNiuErrorEnum.TEMPLATE_NO_SUPPORT);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -100,11 +101,24 @@ public class GoldenService {
|
|
|
if (winds == null)
|
|
|
return map;
|
|
|
|
|
|
+
|
|
|
+ List<Future<Map<String, List<Object>>>> list = new LinkedList<>();
|
|
|
for (String wind : winds) {
|
|
|
- List<Object> data = getTemplateHistory1(station, wind, startTs, endTs, interval);
|
|
|
- map.put(wind, data);
|
|
|
+ TaskTemplateCallable task = new TaskTemplateCallable(windService, remoteService.ShardingService(),
|
|
|
+ exportConfig.getTemplate1(), station, wind, startTs, endTs, interval);
|
|
|
+ Future submit = taskConfig.getExecutor().submit(task);
|
|
|
+ list.add(submit);
|
|
|
}
|
|
|
- } catch (QiNiuException e) {
|
|
|
+
|
|
|
+
|
|
|
+ for (Future<Map<String, List<Object>>> future: list){
|
|
|
+ Map<String, List<Object>> wtMap = future.get();
|
|
|
+ for (Map.Entry<String, List<Object>> entry : wtMap.entrySet()) {
|
|
|
+ map.put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new QiNiuException(QiNiuErrorEnum.ERROR_DATA);
|
|
|
}
|
|
@@ -123,50 +137,50 @@ public class GoldenService {
|
|
|
* @param interval
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Object> getTemplateHistory1(String station, String wtId, long startTs, long endTs, int interval) {
|
|
|
- List<Object> list = new ArrayList<>();
|
|
|
- List<String> codes = exportConfig.getTemplate1();
|
|
|
-
|
|
|
-
|
|
|
- List<String> intervals = dateInterval(startTs, endTs, interval);
|
|
|
- list.add(intervals);
|
|
|
-
|
|
|
- try {
|
|
|
- for (String code : codes) {
|
|
|
- List<WindTurbineTestingPointAi2> windPoints = windService.findPointsByUniformCodeAndStation(station, wtId, code);
|
|
|
- if (windPoints == null || windPoints.size() == 0)
|
|
|
- continue;
|
|
|
-
|
|
|
- WindTurbineTestingPointAi2 windPoint = windPoints.get(0);
|
|
|
- List<TsPointData> data = remoteService.ShardingService().getHistorySnap(windPoint.getId(), startTs, endTs, interval);
|
|
|
-
|
|
|
- List<Object> collect = new ArrayList<>();
|
|
|
-
|
|
|
- if (code.equals("GZZT") || code.equals("XDZT")) {
|
|
|
- if (data.size() == 0) {
|
|
|
- for (int i = 0; i < intervals.size(); i++)
|
|
|
- collect.add(0);
|
|
|
- } else {
|
|
|
- collect = data.stream().map(point -> (int) point.getDoubleValue()).collect(Collectors.toList());
|
|
|
- }
|
|
|
- list.add(collect);
|
|
|
- } else {
|
|
|
- if (data.size() == 0) {
|
|
|
- for (int i = 0; i < intervals.size(); i++)
|
|
|
- collect.add(0.0);
|
|
|
- } else {
|
|
|
- collect = data.stream().map(TsPointData::getDoubleValue).collect(Collectors.toList());
|
|
|
- }
|
|
|
- list.add(collect);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (QiNiuException e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- throw new QiNiuException(QiNiuErrorEnum.ERROR_DATA);
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|