|
@@ -1050,12 +1050,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
|
|
|
|
|
|
// Map<String, Map<Double,Double>> fitMap = new HashMap<>();
|
|
|
- int i = 0;
|
|
|
for (PointInfo ef : entityFs) {
|
|
|
- if (i < 280) {
|
|
|
- i++;
|
|
|
- continue;
|
|
|
- }
|
|
|
String wtId = ef.getTurbineId();
|
|
|
PointInfo glInfo = glMap.get(wtId);
|
|
|
getSnapDataByEntity(ef, start, end, 60);
|
|
@@ -1081,125 +1076,13 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
ef.setPointDatas(null);
|
|
|
glInfo.setPointDatas(null);
|
|
|
- stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
|
|
|
+ stringRedisTemplate.opsForValue().set("edfs:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
|
|
|
}
|
|
|
System.out.println("苹果天涯");
|
|
|
// stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
|
|
|
}
|
|
|
|
|
|
- //算额定风速
|
|
|
- public void calcGlqxnh_edfs(Date start, Date end) {
|
|
|
- //风速
|
|
|
- List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
- //功率
|
|
|
- List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
- Map<String, PointInfo> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
-
|
|
|
- Map<String, EquipmentModel> map = equipmentModelService.map();
|
|
|
-
|
|
|
- List<PointInfo> entity = 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);
|
|
|
- List<String> keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.toList());
|
|
|
- Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), String.join(",", keys), start.getTime());
|
|
|
- Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
|
|
|
-
|
|
|
- List<PointInfo> entityAiZt = getEntity("AI422", "state");
|
|
|
- Map<String, PointInfo> aiztMap = entityAiZt.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
- List<StateAi> list = stateAiService.list();
|
|
|
- Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(
|
|
|
- StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
|
|
|
-
|
|
|
-// Map<String, Map<Double,Double>> fitMap = new HashMap<>();
|
|
|
- int i = 0;
|
|
|
- for (PointInfo ef : entityFs) {
|
|
|
- String wtId = ef.getTurbineId();
|
|
|
- PointInfo glInfo = glMap.get(wtId);
|
|
|
- getSnapDataByEntity(ef, start, end, 60);
|
|
|
- getSnapDataByEntity(glInfo, start, end, 60);
|
|
|
- List<PointData> peek = ef.getPointDatas().stream().peek(pd -> pd.setDoubleValue(
|
|
|
- NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
|
|
|
- ef.setPointDatas(peek);
|
|
|
-
|
|
|
- PointInfo turbineZt = calcTurbineDizt2(wtUcPis.get(wtId), latest, start, end, 60);
|
|
|
- PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
|
|
|
- Map<Double, Double> fit = new TreeMap<>();
|
|
|
- double capacity = 2000;
|
|
|
- if (turbineZt != null) {
|
|
|
- capacity = map.get(turbineZt.getSpare()).getPowerProduction();
|
|
|
- fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
|
|
|
-// fitMap.put(wtId, fit);
|
|
|
- turbineZt.setPointDatas(null);
|
|
|
- }
|
|
|
- if (turbineAizt != null) {
|
|
|
- capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
|
|
|
- fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
|
|
|
-// fitMap.put(wtId, fit);
|
|
|
- turbineAizt.setPointDatas(null);
|
|
|
- }
|
|
|
- ef.setPointDatas(null);
|
|
|
- glInfo.setPointDatas(null);
|
|
|
-
|
|
|
- //存redis
|
|
|
-// stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
|
|
|
-
|
|
|
|
|
|
- //符合条件的风速和
|
|
|
- List<Double> listDouble = new ArrayList<>();
|
|
|
- //遍历fit集合,取出值与capacity相等的key
|
|
|
- if (!fit.isEmpty()) {
|
|
|
- for (double key : fit.keySet()) {
|
|
|
- Double v = fit.get(key);
|
|
|
- //如果v-capacity的值小于10大于-10,则把key加入listDouble
|
|
|
- if ((Math.abs(v - capacity) <= 10) && Math.abs(v - capacity) >= -10) {
|
|
|
- listDouble.add(key);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //取出listDouble的值求平均值
|
|
|
- double agValue = 0;
|
|
|
- if (!listDouble.isEmpty()) {
|
|
|
- for (Double aDouble : listDouble) {
|
|
|
- agValue += aDouble;
|
|
|
- }
|
|
|
- agValue = agValue / listDouble.size();
|
|
|
- }
|
|
|
- System.out.println("wtId:" + wtId + "agValue平均额定风速:" + agValue);
|
|
|
-
|
|
|
-
|
|
|
- //存入数据库
|
|
|
- System.out.println(wtId + " " + start);
|
|
|
- QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
|
|
|
- turbineInfoDayQueryWrapper.eq("turbine_id", wtId);
|
|
|
- turbineInfoDayQueryWrapper.eq("record_date", start);
|
|
|
- TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
|
|
|
- System.out.println(one);
|
|
|
- if (one == null) {
|
|
|
- TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
|
|
|
- turbineInfoDay.setTurbineId(wtId);
|
|
|
- turbineInfoDay.setRecordDate(start);
|
|
|
- turbineInfoDay.setEdfs(agValue);
|
|
|
- System.out.println(turbineInfoDay);
|
|
|
- turbineInfoDayService.save(turbineInfoDay);
|
|
|
- } else {
|
|
|
- one.setEdfs(agValue);
|
|
|
- System.out.println(one);
|
|
|
- turbineInfoDayService.updateById(one);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-// stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
|
|
|
- }
|
|
|
|
|
|
public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
|
|
|
List<PointData> fsPds = fsPI.getPointDatas();
|
|
@@ -1501,17 +1384,125 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //算额定风速
|
|
|
+ public void calcGlqxnh_edfs() {
|
|
|
|
|
|
- //满发下风速
|
|
|
- @Test
|
|
|
- public void fullSpeedWindSpeed() {
|
|
|
//date当天零点
|
|
|
- DateTime timeNow = DateUtil.beginOfDay(new Date());
|
|
|
+ Date end = DateUtil.beginOfDay(new Date()).toJdkDate();
|
|
|
//date昨天零点
|
|
|
- DateTime timeBegin = DateUtil.offsetDay(timeNow, -1);
|
|
|
+ Date start = DateUtil.offsetDay(end, -1).toJdkDate();
|
|
|
+
|
|
|
+ //风速
|
|
|
+ List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
+ //功率
|
|
|
+ List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
+ Map<String, PointInfo> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+
|
|
|
+ Map<String, EquipmentModel> map = equipmentModelService.map();
|
|
|
+
|
|
|
+ List<PointInfo> entity = 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);
|
|
|
+ List<String> keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.toList());
|
|
|
+ Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), String.join(",", keys), start.getTime());
|
|
|
+ Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
|
|
|
+
|
|
|
+ List<PointInfo> entityAiZt = getEntity("AI422", "state");
|
|
|
+ Map<String, PointInfo> aiztMap = entityAiZt.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ List<StateAi> list = stateAiService.list();
|
|
|
+ Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(
|
|
|
+ StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
|
|
|
+
|
|
|
+// Map<String, Map<Double,Double>> fitMap = new HashMap<>();
|
|
|
+ int i = 0;
|
|
|
+ for (PointInfo ef : entityFs) {
|
|
|
+ String wtId = ef.getTurbineId();
|
|
|
+ PointInfo glInfo = glMap.get(wtId);
|
|
|
+ getSnapDataByEntity(ef, start, end, 60);
|
|
|
+ getSnapDataByEntity(glInfo, start, end, 60);
|
|
|
+ List<PointData> peek = ef.getPointDatas().stream().peek(pd -> pd.setDoubleValue(
|
|
|
+ NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
|
|
|
+ ef.setPointDatas(peek);
|
|
|
+
|
|
|
+ PointInfo turbineZt = calcTurbineDizt2(wtUcPis.get(wtId), latest, start, end, 60);
|
|
|
+ PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
|
|
|
+ Map<Double, Double> fit = new TreeMap<>();
|
|
|
+ double capacity = 2000;
|
|
|
+ if (turbineZt != null) {
|
|
|
+ capacity = map.get(turbineZt.getSpare()).getPowerProduction();
|
|
|
+ fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
|
|
|
+// fitMap.put(wtId, fit);
|
|
|
+ turbineZt.setPointDatas(null);
|
|
|
+ }
|
|
|
+ if (turbineAizt != null) {
|
|
|
+ capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
|
|
|
+ fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
|
|
|
+// fitMap.put(wtId, fit);
|
|
|
+ turbineAizt.setPointDatas(null);
|
|
|
+ }
|
|
|
+ ef.setPointDatas(null);
|
|
|
+ glInfo.setPointDatas(null);
|
|
|
+
|
|
|
+ //存redis
|
|
|
+// stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
|
|
|
|
|
|
- //功率曲线拟合,
|
|
|
- calcGlqxnh_edfs(timeBegin.toJdkDate(), timeNow.toJdkDate());
|
|
|
+
|
|
|
+ //符合条件的风速和
|
|
|
+ List<Double> listDouble = new ArrayList<>();
|
|
|
+ //遍历fit集合,取出值与capacity相等的key
|
|
|
+ if (!fit.isEmpty()) {
|
|
|
+ for (double key : fit.keySet()) {
|
|
|
+ Double v = fit.get(key);
|
|
|
+ //如果v-capacity的值小于10大于-10,则把key加入listDouble
|
|
|
+ if ((Math.abs(v - capacity) <= 10) && Math.abs(v - capacity) >= -10) {
|
|
|
+ listDouble.add(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //取出listDouble的值求平均值
|
|
|
+ double agValue = 0;
|
|
|
+ if (!listDouble.isEmpty()) {
|
|
|
+ for (Double aDouble : listDouble) {
|
|
|
+ agValue += aDouble;
|
|
|
+ }
|
|
|
+ agValue = agValue / listDouble.size();
|
|
|
+ }
|
|
|
+ System.out.println("wtId:" + wtId + "agValue平均额定风速:" + agValue);
|
|
|
+
|
|
|
+
|
|
|
+ //存入数据库
|
|
|
+ System.out.println(wtId + " " + start);
|
|
|
+ QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
|
|
|
+ turbineInfoDayQueryWrapper.eq("turbine_id", wtId);
|
|
|
+ turbineInfoDayQueryWrapper.eq("record_date", start);
|
|
|
+ TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
|
|
|
+ System.out.println(one);
|
|
|
+ if (one == null) {
|
|
|
+ TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
|
|
|
+ turbineInfoDay.setTurbineId(wtId);
|
|
|
+ turbineInfoDay.setRecordDate(start);
|
|
|
+ turbineInfoDay.setEdfs(agValue);
|
|
|
+ System.out.println(turbineInfoDay);
|
|
|
+ turbineInfoDayService.save(turbineInfoDay);
|
|
|
+ } else {
|
|
|
+ one.setEdfs(agValue);
|
|
|
+ System.out.println(one);
|
|
|
+ turbineInfoDayService.updateById(one);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+// stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|