|
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.lang.reflect.Field;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.net.URI;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -64,6 +65,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
private IPredictExaminService predictExaminService;
|
|
|
@Resource
|
|
|
private IStationInfoMin2Service stationInfoMin2Service;
|
|
|
+ @Resource
|
|
|
+ private IProjectInfoMin2Service projectInfoMin2Service;
|
|
|
|
|
|
@Override
|
|
|
public void execute() throws Exception {
|
|
@@ -3235,6 +3238,30 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
stationInfoMinService.saveOrUpdate(byMin);
|
|
|
}
|
|
|
|
|
|
+ public Map<Double, Long> calcSectionZtts(Date time, String stId, Function<PointInfo, String> fun) {
|
|
|
+ Map<Double, Long> diztTs = calcSectionDiztTs(time, stId, fun);
|
|
|
+ Map<Double, Long> aiztTs = calcSectionAiztTs(time, stId, fun);
|
|
|
+ if (diztTs.isEmpty()) {
|
|
|
+ return aiztTs;
|
|
|
+ } else if (aiztTs.isEmpty()) {
|
|
|
+ return diztTs;
|
|
|
+ } else if (diztTs.size() > aiztTs.size()) {
|
|
|
+ diztTs.forEach((k, v) -> {
|
|
|
+ long l = aiztTs.getOrDefault(k, 0L);
|
|
|
+ if (v == null) v = 0L;
|
|
|
+ v = v + l;
|
|
|
+ });
|
|
|
+ return diztTs;
|
|
|
+ } else {
|
|
|
+ aiztTs.forEach((k, v) -> {
|
|
|
+ long l = diztTs.getOrDefault(k, 0L);
|
|
|
+ if (v == null) v = 0L;
|
|
|
+ v = v + l;
|
|
|
+ });
|
|
|
+ return aiztTs;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public Map<Double, Long> calcSectionStationZtts(Date time, String stId) {
|
|
|
Map<Double, Long> diztTs = calcSectionStationDiztTs(time, stId);
|
|
|
Map<Double, Long> aiztTs = calcSectionStationAiztTs(time, stId);
|
|
@@ -3608,6 +3635,103 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return entityAiZt;
|
|
|
}
|
|
|
|
|
|
+ public Map<Double, Long> calcSectionDiztTs(Date time, String id, Function<PointInfo, String> fun) {
|
|
|
+ List<PointInfo> entity = new ArrayList<>();
|
|
|
+ List<PointInfo> result = new ArrayList<>();
|
|
|
+ List<PointInfo> entity0 = getEntity("MX000", "state");
|
|
|
+ List<PointInfo> entity1 = getEntity("MX001", "state");
|
|
|
+ List<PointInfo> entity2 = getEntity("MX002", "state");
|
|
|
+ List<PointInfo> entity4 = getEntity("MX004", "state");
|
|
|
+ List<PointInfo> entity6 = getEntity("MX006", "state");
|
|
|
+ entity.addAll(entity0);
|
|
|
+ entity.addAll(entity1);
|
|
|
+ entity.addAll(entity2);
|
|
|
+ entity.addAll(entity4);
|
|
|
+ entity.addAll(entity6);
|
|
|
+ entity = entity.stream().filter(pi -> id.equals(fun.apply(pi))).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(entity)) return new HashMap<>();
|
|
|
+ String keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
|
|
|
+ Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), keys, time.getTime());
|
|
|
+
|
|
|
+ Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
|
|
|
+ wtUcPis.forEach((wtId, map) -> {
|
|
|
+ PointInfo info2 = map.get("MX002");
|
|
|
+ PointData data2 = latest.get(info2.getPointKey());
|
|
|
+ if (data2.getValue() == 1.0) {
|
|
|
+ data2.setDoubleValue(2.0);
|
|
|
+ data2.setBooleanValue(false);
|
|
|
+ info2.setPointDatas(Collections.singletonList(data2));
|
|
|
+ result.add(info2);
|
|
|
+ } else {
|
|
|
+ PointInfo info0 = map.get("MX000");
|
|
|
+ PointData data0 = latest.get(info0.getPointKey());
|
|
|
+ if (data0.getValue() == 1.0) {
|
|
|
+ data0.setDoubleValue(0.0);
|
|
|
+ data0.setBooleanValue(false);
|
|
|
+ info0.setPointDatas(Collections.singletonList(data0));
|
|
|
+ result.add(info0);
|
|
|
+ } else {
|
|
|
+ PointInfo info6 = map.get("MX006");
|
|
|
+ PointData data6 = latest.get(info6.getPointKey());
|
|
|
+ if (data6.getValue() == 1.0) {
|
|
|
+ data6.setDoubleValue(6.0);
|
|
|
+ data6.setBooleanValue(false);
|
|
|
+ info6.setPointDatas(Collections.singletonList(data6));
|
|
|
+ result.add(info6);
|
|
|
+ } else {
|
|
|
+ PointInfo info4 = map.get("MX004");
|
|
|
+ PointData data4 = latest.get(info4.getPointKey());
|
|
|
+ if (data4.getValue() == 1.0) {
|
|
|
+ data4.setDoubleValue(4.0);
|
|
|
+ data4.setBooleanValue(false);
|
|
|
+ info4.setPointDatas(Collections.singletonList(data4));
|
|
|
+ result.add(info4);
|
|
|
+ } else {
|
|
|
+ PointInfo info1 = map.get("MX001");
|
|
|
+ PointData data1 = latest.get(info1.getPointKey());
|
|
|
+ if (data1.getValue() == 1.0) {
|
|
|
+ data1.setDoubleValue(1.0);
|
|
|
+ data1.setBooleanValue(false);
|
|
|
+ info1.setPointDatas(Collections.singletonList(data1));
|
|
|
+ result.add(info1);
|
|
|
+ } else {
|
|
|
+ System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
|
|
|
+ data1.setDoubleValue(2.0);
|
|
|
+ info1.setPointDatas(Collections.singletonList(data1));
|
|
|
+ result.add(info1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<Double, Long> longMap = result.stream().collect(Collectors.groupingBy(pi -> pi.getPointDatas().get(0).getValue(), Collectors.counting()));
|
|
|
+ return longMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<Double, Long> calcSectionAiztTs(Date time, String id, Function<PointInfo, String> fun) {
|
|
|
+ List<PointInfo> entityAiZt = getEntity("AI422", "state");
|
|
|
+ entityAiZt = entityAiZt.stream().filter(pi -> id.equals(fun.apply(pi))).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(entityAiZt)) return new HashMap<>();
|
|
|
+ List<StateAi> list = stateAiService.list();
|
|
|
+ //机型,源状态,目标状态
|
|
|
+ Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
|
|
|
+ String collect = entityAiZt.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
|
|
|
+ Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), collect, time.getTime());
|
|
|
+ for (PointInfo info : entityAiZt) {
|
|
|
+ PointData data = latest.get(info.getPointKey());
|
|
|
+ Integer m = collectAi.get(info.getSpare()).get((int) data.getValue());
|
|
|
+ if (m == null) {
|
|
|
+ m = 2;
|
|
|
+ System.out.println("ai状态未配对:" + data.getValue());
|
|
|
+ }
|
|
|
+ data.setDoubleValue(m);
|
|
|
+ info.setPointDatas(Collections.singletonList(data));
|
|
|
+ }
|
|
|
+ Map<Double, Long> longMap = entityAiZt.stream().collect(Collectors.groupingBy(pi -> pi.getPointDatas().get(0).getValue(), Collectors.counting()));
|
|
|
+ return longMap;
|
|
|
+ }
|
|
|
+
|
|
|
public void getAgoAvg(List<PointInfo> entity, Date start, Date end) {
|
|
|
for (PointInfo info : entity) {
|
|
|
DoubleStatData snap = adapter.getHistoryStat(goldenUri(), info.getPointKey(), start.getTime(), end.getTime());
|
|
@@ -4879,6 +5003,155 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
stationInfoMin2Service.save(min2);
|
|
|
}
|
|
|
|
|
|
+ public List<PointInfo> filterPointInfo(List<PointInfo> entity, String id, Function<PointInfo, String> fun) {
|
|
|
+ return entity.stream().filter(e -> id.equals(fun.apply(e))).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PointInfo> sortPointInfo(List<PointInfo> entity, Function<PointInfo, String> fun) {
|
|
|
+ return entity.stream().sorted(Comparator.comparing(fun)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void calcProjectPjfsHjwdMin2(Date begin, Date end, String stId, StationInfoMin2 min) {
|
|
|
+ //风速
|
|
|
+ List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
+ entityFs = filterPointInfo(entityFs, stId, PointInfo::getStationId);
|
|
|
+ Map<String, List<PointInfo>> pisMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getProjectId));
|
|
|
+ List<ProjectInfoMin2> min2s = new ArrayList<>();
|
|
|
+ pisMap.forEach((pjId, pis) -> {
|
|
|
+ List<PointInfo> infos = sortPointInfo(pis, PointInfo::getTurbineId);
|
|
|
+ List<Integer> fjidns = infos.stream().map(pi -> Integer.parseInt(pi.getTurbineId().replaceFirst("GJNY_SXGS_.+_F_WT_", "")
|
|
|
+ .replaceFirst("_EQ", ""))).collect(Collectors.toList());
|
|
|
+// Map<Double, Long> zttsMap = calcSectionZtts(end,pjId,PointInfo::getProjectId);
|
|
|
+// Long l = zttsMap.get(2.0);
|
|
|
+// if (l == null) l = 0L;
|
|
|
+ //日发电量
|
|
|
+// List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
|
|
|
+// entity=filterPointInfo(entity,pjId,PointInfo::getProjectId);
|
|
|
+// getSectionDataByEntity(entity, goldenUri(), begin, end);
|
|
|
+// double rfdl = entity.stream().mapToDouble(pi -> {
|
|
|
+// double v = (pi.getPointDatas().get(1).getValue() - pi.getPointDatas().get(0).getValue()) * pi.getCoef();
|
|
|
+// if (v < 0) v = 0;
|
|
|
+// return v;
|
|
|
+// }).sum();
|
|
|
+// if (rfdl >= 32500) rfdl = 32500.0;
|
|
|
+ ProjectInfoMin2 min2 = new ProjectInfoMin2();
|
|
|
+ min2.setStationId(stId);
|
|
|
+ min2.setProjectId(pjId);
|
|
|
+ min2.setRecordDate(end);
|
|
|
+// min2.setRfdl(rfdl);
|
|
|
+ min2.setRfdl(min.getRfdl());
|
|
|
+ min2.setHjwd(min.getHjwd());
|
|
|
+// min2.setYxts(l);
|
|
|
+ min2.setYxts(min.getYxts());
|
|
|
+ sm2fs2pm2(fjidns, min2, min);
|
|
|
+ min2s.add(min2);
|
|
|
+ });
|
|
|
+ projectInfoMin2Service.saveBatch(min2s);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ProjectInfoMin2 calcProjectPjfsHjwdMin2(Date end, String pjId) {
|
|
|
+ DateTime begin = DateUtil.offsetMinute(end, -15);
|
|
|
+ //风速
|
|
|
+ List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
+ entityFs = filterPointInfo(entityFs, pjId, PointInfo::getProjectId);
|
|
|
+ getRawDataByEntity(entityFs, goldenUri(), begin, end);
|
|
|
+ entityFs = sortPointInfo(entityFs, PointInfo::getTurbineId);
|
|
|
+ List<Double> fss = new ArrayList<>();
|
|
|
+ for (PointInfo ef : entityFs) {
|
|
|
+ double v = 0;
|
|
|
+ if (ef.getPointDatas() == null || ef.getPointDatas().isEmpty()) {
|
|
|
+ Map<String, PointData> latest = adapter.getLatest(goldenUri(), ef.getPointKey());
|
|
|
+ PointData data = latest.get(ef.getPointKey());
|
|
|
+ if (data!=null) v = data.getValue();
|
|
|
+ } else {
|
|
|
+ v = ef.getPointDatas().stream().mapToDouble(p -> p.getValue() > 23 ? 23.0 : p.getValue() < 0 ? 0.0 : p.getValue()).average().orElse(0.0);
|
|
|
+ }
|
|
|
+ fss.add(v);
|
|
|
+ }
|
|
|
+ //日发电量
|
|
|
+ List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
|
|
|
+ entity = filterPointInfo(entity, pjId, PointInfo::getProjectId);
|
|
|
+ getSectionDataByEntity(entity, goldenUri(), begin, end);
|
|
|
+ double rfdl = entity.stream().mapToDouble(pi -> {
|
|
|
+ double v = (pi.getPointDatas().get(1).getValue() - pi.getPointDatas().get(0).getValue()) * pi.getCoef();
|
|
|
+ if (v < 0) v = 0;
|
|
|
+ return v;
|
|
|
+ }).sum();
|
|
|
+ if (rfdl >= 32500) rfdl = 32500.0;
|
|
|
+ //环境温度
|
|
|
+ List<PointInfo> entityHjwd = getEntity("AI072", "turbine");
|
|
|
+ entityHjwd = filterPointInfo(entityHjwd, pjId, PointInfo::getProjectId);
|
|
|
+ getRawDataByEntity(entityHjwd, goldenUri(), begin, end);
|
|
|
+ List<Double> hjwds = new ArrayList<>();
|
|
|
+ for (PointInfo wd : entityHjwd) {
|
|
|
+ double v = wd.getPointDatas().stream().filter(p -> p.getValue() != 0.0).mapToDouble(PointData::getValue).average().orElse(0.0);
|
|
|
+ if (v > 83 || v < -60) v = 0;
|
|
|
+ if (v == 0) {
|
|
|
+ v = fjhjwd.getOrDefault(wd.getTurbineId(), 0.0);
|
|
|
+ } else {
|
|
|
+ fjhjwd.put(wd.getTurbineId(), v);
|
|
|
+ }
|
|
|
+ hjwds.add(v);
|
|
|
+ }
|
|
|
+
|
|
|
+ ProjectInfoMin2 min2 = new ProjectInfoMin2();
|
|
|
+ min2.setProjectId(pjId);
|
|
|
+ min2.setRecordDate(end);
|
|
|
+ min2.setRfdl(rfdl);
|
|
|
+ min2.setHjwd(hjwds.stream().filter(d -> d != 0.0).mapToDouble(Double::doubleValue).average().orElse(0.0));
|
|
|
+ sm2fs2pm2(fss, min2);
|
|
|
+ return min2;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sm2fs2pm2(List<Integer> is, ProjectInfoMin2 pjMin2, StationInfoMin2 stMin2) {
|
|
|
+ List<Double> r = new ArrayList<>();
|
|
|
+ String prefix1 = "getPjfs";
|
|
|
+ try {
|
|
|
+ for (Integer i : is) {
|
|
|
+ // 构造方法名
|
|
|
+ String methodName = prefix1 + i;
|
|
|
+ // 获取方法对象
|
|
|
+ Method method = stMin2.getClass().getMethod(methodName);
|
|
|
+ // 调用方法并获取返回值
|
|
|
+ Double result = (Double) method.invoke(stMin2);
|
|
|
+ // 将结果添加到列表中
|
|
|
+ r.add(result);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //setPjfs44(Double pjfs44)
|
|
|
+ String prefix2 = "setPjfs";
|
|
|
+ try {
|
|
|
+ for (int i = 0; i < r.size(); i++) {
|
|
|
+ // 构造方法名
|
|
|
+ String methodName = prefix2 + (i + 1);
|
|
|
+ // 获取方法对象
|
|
|
+ Method method = pjMin2.getClass().getMethod(methodName, Double.class);
|
|
|
+ // 调用方法并获取返回值
|
|
|
+ method.invoke(pjMin2, r.get(i));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sm2fs2pm2(List<Double> fs, ProjectInfoMin2 pjMin2) {
|
|
|
+ String prefix2 = "setPjfs";
|
|
|
+ try {
|
|
|
+ for (int i = 0; i < fs.size(); i++) {
|
|
|
+ // 构造方法名
|
|
|
+ String methodName = prefix2 + (i + 1);
|
|
|
+ // 获取方法对象
|
|
|
+ Method method = pjMin2.getClass().getMethod(methodName, Double.class);
|
|
|
+ // 调用方法并获取返回值
|
|
|
+ method.invoke(pjMin2, fs.get(i));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public StationInfoMin2 calcStationPjfsHjwdMin2(Date end, String stId) {
|
|
|
DateTime begin = DateUtil.offsetMinute(end, -15);
|
|
|
//出线
|
|
@@ -4957,31 +5230,31 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
switch (i) {
|
|
|
case 1:
|
|
|
- min2.setpjfs1(v);
|
|
|
+ min2.setPjfs1(v);
|
|
|
break;
|
|
|
case 2:
|
|
|
- min2.setpjfs2(v);
|
|
|
+ min2.setPjfs2(v);
|
|
|
break;
|
|
|
case 3:
|
|
|
- min2.setpjfs3(v);
|
|
|
+ min2.setPjfs3(v);
|
|
|
break;
|
|
|
case 4:
|
|
|
- min2.setpjfs4(v);
|
|
|
+ min2.setPjfs4(v);
|
|
|
break;
|
|
|
case 5:
|
|
|
- min2.setpjfs5(v);
|
|
|
+ min2.setPjfs5(v);
|
|
|
break;
|
|
|
case 6:
|
|
|
- min2.setpjfs6(v);
|
|
|
+ min2.setPjfs6(v);
|
|
|
break;
|
|
|
case 7:
|
|
|
- min2.setpjfs7(v);
|
|
|
+ min2.setPjfs7(v);
|
|
|
break;
|
|
|
case 8:
|
|
|
- min2.setpjfs8(v);
|
|
|
+ min2.setPjfs8(v);
|
|
|
break;
|
|
|
case 9:
|
|
|
- min2.setpjfs9(v);
|
|
|
+ min2.setPjfs9(v);
|
|
|
break;
|
|
|
case 10:
|
|
|
min2.setPjfs10(v);
|