|
@@ -1,9 +1,11 @@
|
|
|
package com.gyee.sampleimpala.service.custom;
|
|
|
|
|
|
|
|
|
+import com.gyee.sampleimpala.common.config.UniformcodeConfig;
|
|
|
import com.gyee.sampleimpala.common.exception.CustomException;
|
|
|
import com.gyee.sampleimpala.common.feign.RemoteServiceBuilder;
|
|
|
import com.gyee.sampleimpala.common.result.ResultCode;
|
|
|
+import com.gyee.sampleimpala.common.util.DateUtil;
|
|
|
import com.gyee.sampleimpala.model.custom.TsPointData;
|
|
|
import com.gyee.sampleimpala.model.kudu.Caseperformance;
|
|
|
import com.gyee.sampleimpala.model.kudu.Windturbinepoint;
|
|
@@ -13,10 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -31,39 +30,42 @@ public class GoldenService {
|
|
|
|
|
|
@Autowired
|
|
|
private CaseperformanceService caseperformanceService;
|
|
|
+ @Autowired
|
|
|
+ private UniformcodeConfig uniformcodeConfig;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询原始数据
|
|
|
+ *
|
|
|
* @param points
|
|
|
* @param startTs 精确到毫秒
|
|
|
* @param endTs
|
|
|
* @param interval
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map> getOriginalData(String[] points, long startTs, long endTs, int interval){
|
|
|
+ public List<Map> getCurveScatter(String[] points, long startTs, long endTs, int interval) {
|
|
|
|
|
|
List<Map> list = new ArrayList<>();
|
|
|
|
|
|
- try{
|
|
|
+ try {
|
|
|
|
|
|
- for (String point :points){
|
|
|
- Windturbinepoint w = windturbinepointService.getByPoint(point);
|
|
|
+ for (String point : points) {
|
|
|
+ Windturbinepoint w = windturbinepointService.getByPoint(point);
|
|
|
List<TsPointData> data = new ArrayList<>();
|
|
|
Map m = new HashMap();
|
|
|
- if (interval <= 0){
|
|
|
+ if (interval <= 0) {
|
|
|
data = remoteService.ShardingService().getHistoryRaw(point, startTs, endTs);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
data = remoteService.ShardingService().getHistorySnap(point, startTs, endTs, interval);
|
|
|
}
|
|
|
- m.put("name",w.getPointdes());
|
|
|
- m.put("code",w.getWidgetcode());
|
|
|
- m.put("point",w.getPoint());
|
|
|
- m.put("list",data);
|
|
|
+ m.put("name", w.getPointdes());
|
|
|
+ m.put("code", w.getWidgetcode());
|
|
|
+ m.put("point", w.getPoint());
|
|
|
+ m.put("list", data);
|
|
|
list.add(m);
|
|
|
}
|
|
|
|
|
|
- } catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
}
|
|
@@ -72,16 +74,50 @@ public class GoldenService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * H获取风速和转速的曲线数据
|
|
|
+ *
|
|
|
+ * @param ids ids
|
|
|
+ * @param interval 数据时间间隔
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, List> getCurveScatter(Integer[] ids, int interval) {
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ Map<String, List> maps = new HashMap<>();
|
|
|
+ for (Integer id : ids) {
|
|
|
+ List<String> codeList = uniformcodeConfig.getUniformcode();
|
|
|
+ String[] codes = codeList.toArray(new String[codeList.size()]);
|
|
|
+ Caseperformance cp = caseperformanceService.getPerformanceByid(id);
|
|
|
+ List<Windturbinepoint> windturbinepoints = windturbinepointService.getListByStationAndWtIdAndUniformCode(cp.getStationen(), cp.getWindturbineid(), codes);
|
|
|
+ List<TsPointData> data1 = remoteService.ShardingService().getHistorySnap(windturbinepoints.get(0).getPoint(), DateUtil.covertDateTimestamp(cp.getStarttime()),
|
|
|
+ DateUtil.covertDateTimestamp(cp.getEndtime()), interval);
|
|
|
+ List<TsPointData> data2 = remoteService.ShardingService().getHistorySnap(windturbinepoints.get(1).getPoint(), DateUtil.covertDateTimestamp(cp.getStarttime()),
|
|
|
+ DateUtil.covertDateTimestamp(cp.getEndtime()), interval);
|
|
|
+ if (null != data1 && null != data2 && data1.size() == data2.size()) {
|
|
|
+ List list = new ArrayList();
|
|
|
+ List<Map> lp = new ArrayList<>();
|
|
|
+ for (int i = 0; i < data1.size(); i++) {
|
|
|
+ List l = new ArrayList();
|
|
|
+ Map c = new HashMap();
|
|
|
+ l.add(data1.get(i).getDoubleValue());
|
|
|
+ l.add(data2.get(i).getDoubleValue());
|
|
|
+ c.put("fs", data1.get(i).getDoubleValue());
|
|
|
+ c.put("zs", data2.get(i).getDoubleValue());
|
|
|
+ list.add(l);
|
|
|
+ lp.add(c);
|
|
|
+ }
|
|
|
+ maps.put("S_" + id + "_" + cp.getWindturbineid(), list);
|
|
|
+ maps.put("C_" + id + "_" + cp.getWindturbineid(), lp);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- public List<Map> getOriginalData(Integer[] id, int interval){
|
|
|
- for (Integer i :id ){
|
|
|
- Caseperformance cp = caseperformanceService.getPerformanceByid(i);
|
|
|
-
|
|
|
-// data = remoteService.ShardingService().getHistorySnap(point, startTs, endTs, interval);
|
|
|
+ return maps;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
-
|
|
|
}
|
|
|
}
|