|
@@ -100,10 +100,6 @@ public class WindDirectionService {
|
|
|
map.put("speeedtime", WindALG.speedtimeNewRoses(lslist));//风速
|
|
|
map.put("roses", WindALG.fxysNewRoses(lslist));//风速、风向
|
|
|
map.put("count", WindALG.fxNewCountRoses(lslist));//风速、风向
|
|
|
- int[] count = WindALG.windDeviationRatio(lslist);//风向、对风误差
|
|
|
- List<Point> scatter = WindALG.windDeviationScatter(lslist);//风速、风向、对风误差
|
|
|
- map.put("countpcl", count);
|
|
|
- map.put("scatter", scatter);
|
|
|
map.put("radar", WindALG.fxRadarRoses(lslist));//对风误差
|
|
|
map.put("frequency", WindALG.windDeviationPoint(lslist)); //风速、风向、明细状态、功率、偏航角度
|
|
|
result.add(map);
|
|
@@ -111,7 +107,63 @@ public class WindDirectionService {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 对风偏差率
|
|
|
+
|
|
|
+ */
|
|
|
+ public List<Object> windDeviationRatio(String wtid, String kssj, String jssj) throws ParseException {
|
|
|
+
|
|
|
+ Date[] sjcl = sjcl(kssj, jssj);
|
|
|
+
|
|
|
+ // 获取 startDate 和 endDate
|
|
|
+ Date startDate = sjcl[0];
|
|
|
+ Date endDate = sjcl[1];
|
|
|
+
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ // 初始化设备点
|
|
|
+ Map<EquipmentPointType, ProBasicEquipmentPoint> points = Arrays.stream(EquipmentPointType.values())
|
|
|
+ .collect(Collectors.toMap(type -> type, type -> getEquipmentPoint(wtid, type)));
|
|
|
+
|
|
|
+ // 获取历史数据
|
|
|
+ Map<EquipmentPointType, List<TsDoubleData>> historyData = points.entrySet().stream()
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey,
|
|
|
+ entry -> getSortedHistory(entry.getValue(), startDate.getTime(), endDate.getTime(), 900)));
|
|
|
+
|
|
|
+ // 创建时间戳到数据的映射表
|
|
|
+ Map<Long, TsDoubleData> pjfsMap = historyData.get(EquipmentPointType.PJFS).stream()
|
|
|
+ .collect(Collectors.toMap(TsDoubleData::getTs, Function.identity(), (a, b) -> a));
|
|
|
+ Map<Long, TsDoubleData> dfwcMap = historyData.get(EquipmentPointType.DFWC).stream()
|
|
|
+ .collect(Collectors.toMap(TsDoubleData::getTs, Function.identity(), (a, b) -> a));
|
|
|
|
|
|
+ // 构造结果数据
|
|
|
+ List<PowerPointData> lslist = new ArrayList<>();
|
|
|
+ for (TsDoubleData fxData : historyData.get(EquipmentPointType.PJFX)) {
|
|
|
+ long ts = fxData.getTs();
|
|
|
+ TsDoubleData fsData = pjfsMap.get(ts);
|
|
|
+ TsDoubleData dfwcData = dfwcMap.get(ts);
|
|
|
+
|
|
|
+ PowerPointData data = new PowerPointData();
|
|
|
+ data.setTime(formatTimestamp(ts));
|
|
|
+ data.setFx(fxData.getDoubleValue());
|
|
|
+ data.setSpeed(fsData != null ? fsData.getDoubleValue() : 0);
|
|
|
+ data.setDfwc(dfwcData != null ? dfwcData.getDoubleValue() : 0);
|
|
|
+ lslist.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProBasicEquipment> listObj = CacheContext.wtls.stream().filter(wt -> wtid.equals(wt.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ listObj.forEach(obj -> {
|
|
|
+ int[] count = WindALG.windDeviationRatio(lslist);//风向、对风误差
|
|
|
+ List<Point> scatter = WindALG.windDeviationScatter(lslist);//风速、风向、对风误差
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("wtId", obj.getAname());
|
|
|
+ map.put("count", count);
|
|
|
+ map.put("scatter", scatter);
|
|
|
+ list.add(map);
|
|
|
+ });
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
private Date[] sjcl (String kssj,String jssj) throws ParseException {
|
|
|
|
|
|
// 时间格式,格式是 "yyyy-MM-dd HH:mm"
|