|
@@ -0,0 +1,896 @@
|
|
|
+package com.gyee.gaia.meter.service.saveTDengine;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.gaia.meter.adapter.Adapter;
|
|
|
+import com.gyee.gaia.meter.entity.*;
|
|
|
+import com.gyee.gaia.meter.mapper.TDEquipmentMeterInfoMapper;
|
|
|
+import com.gyee.gaia.meter.service.impl.EquipmentServiceImpl;
|
|
|
+import com.gyee.gaia.meter.service.impl.ModelPowerDetailsServiceImpl;
|
|
|
+import com.gyee.gaia.meter.service.impl.TDEquipmentMeterInfoServiceImpl;
|
|
|
+import com.gyee.gaia.meter.service.impl.TestingPointServiceImpl;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Author: malijun
|
|
|
+ * Data : 2023: 04: 27
|
|
|
+ **/
|
|
|
+@SpringBootTest
|
|
|
+class TDSaveLLFDLTest {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ Adapter adapter;
|
|
|
+ @Resource
|
|
|
+ private EquipmentServiceImpl equipmentService;
|
|
|
+ @Resource
|
|
|
+ private ModelPowerDetailsServiceImpl modelPowerDetailsService;
|
|
|
+ @Resource
|
|
|
+ private TestingPointServiceImpl testingPointService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TDEquipmentMeterInfoMapper tdEquipmentMeterInfoMapper;
|
|
|
+ @Resource
|
|
|
+ private TDEquipmentMeterInfoServiceImpl tdEquipmentMeterInfoService;
|
|
|
+
|
|
|
+ @Value("${start.time}")
|
|
|
+ private String startTimeString;
|
|
|
+ @Value("${end.time}")
|
|
|
+ private String endTimeString;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 日理论发电量(每台风机,综合到每个场站,每个期次,每条线路)
|
|
|
+ * 1分钟平均风速乘model_power_details的理论功率
|
|
|
+ * w=pt,理论功率乘时间(kw/h)除以60为1分钟理论发电量
|
|
|
+ * pro_basic_equipment表中获取到所有风机,每台风机型号等
|
|
|
+ * uniFormCode AI022 从testing_point中获取到所有风速测点
|
|
|
+ * 从适配器中取1分钟平均风速,根据风速从model_power_details中取到理论功率
|
|
|
+ * 计算1分钟理论发电量
|
|
|
+ * 保存到taos数据库中
|
|
|
+ */
|
|
|
+
|
|
|
+ //理论发电量
|
|
|
+// @Test
|
|
|
+// public void llfdl_1Min() {
|
|
|
+//
|
|
|
+// //设置取值开始时间
|
|
|
+// String startString = startTimeString;
|
|
|
+// DateTime startDateTime = DateUtil.parse(startString);
|
|
|
+//
|
|
|
+// //设置取值结束时间
|
|
|
+// String endDateString = endTimeString;
|
|
|
+// DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
+// DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
+//
|
|
|
+// //从pro_basic_equipment(实体类为Equipment)表中获取到所有风机,每台风机型号等
|
|
|
+// List<Equipment> equipmentList = equipmentService.list(new QueryWrapper<Equipment>()
|
|
|
+// .eq("spare1", "WT")
|
|
|
+// );
|
|
|
+//
|
|
|
+// //model_power_details表中获取到所有型号各风速对应的理论功率
|
|
|
+// List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
|
|
|
+//
|
|
|
+// //遍历modelPowerDetailsList,放入map集合中,键为model_id,值为map集合,值的map集合的键为speed,值为theory_power
|
|
|
+// Map<String, Map<BigDecimal, Double>> map = new HashMap<>();
|
|
|
+// for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+// String modelId = modelPowerDetails.getModelId();
|
|
|
+// double speed0 = modelPowerDetails.getSpeed();
|
|
|
+// BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+// Double theoryPower = modelPowerDetails.getTheoryPower();
|
|
|
+//
|
|
|
+// // 检查是否已存在该modelId的映射关系
|
|
|
+// if (map.containsKey(modelId)) {
|
|
|
+// // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
|
|
|
+// Map<BigDecimal, Double> innerMap = map.get(modelId);
|
|
|
+// innerMap.put(speed, theoryPower);
|
|
|
+// } else {
|
|
|
+// // 如果不存在,创建新的内层HashMap,并添加映射关系
|
|
|
+// Map<BigDecimal, Double> innerMap = new HashMap<>();
|
|
|
+// innerMap.put(speed, theoryPower);
|
|
|
+// map.put(modelId, innerMap);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //根据uniform_code=AI130从testing_point表中获取到风机的实际功率测点
|
|
|
+// List<TestingPoint> testingPointList1 = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI022")
|
|
|
+// );
|
|
|
+// //遍历testingPointList1,把code取出放入一个string集合
|
|
|
+// List<String> codeList1 = new ArrayList<>();
|
|
|
+// for (TestingPoint testingPoint : testingPointList1) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// codeList1.add(code);
|
|
|
+// }
|
|
|
+// //遍历codeList作为适配器的参数,获取到1分钟实际平均功率
|
|
|
+// for (String code : codeList1) {
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// //根据uniform_code=AI022从testing_point表中获取到风机的风速测点
|
|
|
+// List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI022")
|
|
|
+// );
|
|
|
+// //遍历testingPointList,把code取出放入一个string集合
|
|
|
+// List<String> codeList = new ArrayList<>();
|
|
|
+// for (TestingPoint testingPoint : testingPointList) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// codeList.add(code);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //新建一个map,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
|
|
|
+// Map<String, Map<Long, BigDecimal>> map1 = new HashMap<>();
|
|
|
+//
|
|
|
+// //遍历codeList作为适配器的参数,获取到1分钟平均风速
|
|
|
+// for (String code : codeList) {
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// //遍历testingPointList,根据code取到风机编码thing_id
|
|
|
+// for (TestingPoint testingPoint : testingPointList) {
|
|
|
+// String code1 = testingPoint.getCode();
|
|
|
+// if (code.equals(code1)) {
|
|
|
+// String thingId = testingPoint.getThingId();
|
|
|
+// //根据thingId从equipmentList中取出型号
|
|
|
+// for (Equipment equipment : equipmentList) {
|
|
|
+// String nemCode = equipment.getNemCode();
|
|
|
+// if (thingId.equals(nemCode)) {
|
|
|
+// String modelId = equipment.getModelId();
|
|
|
+// //根据modelId从map中取出map集合,键为speed,值为theory_power
|
|
|
+// Map<BigDecimal, Double> map2 = map.get(modelId);
|
|
|
+// //遍历pointDataList,拿到风速,根据风速从map2中取到理论功率,计算1分钟理论发电量
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// //风速
|
|
|
+// double speed0 = pointData.getAvg().getValue();
|
|
|
+// BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+//
|
|
|
+// Double theoryPower = 0.0;
|
|
|
+// if (speed0 >= 3 && speed0 <= 25) {
|
|
|
+// //理论功率
|
|
|
+// theoryPower = map2.get(speed);
|
|
|
+// }
|
|
|
+// //时间
|
|
|
+// DateTime dateTime = DateTime.of(pointData.getAvg().getTs());
|
|
|
+//
|
|
|
+//
|
|
|
+// BigDecimal llfdl = BigDecimal.valueOf(0);
|
|
|
+// //1分钟理论发电量
|
|
|
+// if (theoryPower != null) {
|
|
|
+// llfdl = new BigDecimal(Double.toString(theoryPower))
|
|
|
+// .multiply(new BigDecimal(Double.toString(1)))
|
|
|
+// .divide(new BigDecimal(Double.toString(60)), 2, RoundingMode.HALF_UP);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //存入map1,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
|
|
|
+// if (map1.containsKey(nemCode)) {
|
|
|
+// // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
|
|
|
+// Map<Long, BigDecimal> innerMap = map1.get(nemCode);
|
|
|
+// innerMap.put(dateTime.getTime(), llfdl);
|
|
|
+// } else {
|
|
|
+// // 如果不存在,创建新的内层HashMap,并添加映射关系
|
|
|
+// Map<Long, BigDecimal> innerMap = new HashMap<>();
|
|
|
+// innerMap.put(dateTime.getTime(), llfdl);
|
|
|
+// map1.put(nemCode, innerMap);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// HashMap<String, BigDecimal> map2 = new HashMap<>();
|
|
|
+// for (String key : map1.keySet()) {
|
|
|
+// Map<Long, BigDecimal> mapValues = map1.get(key);
|
|
|
+// BigDecimal llfdl = BigDecimal.valueOf(0);
|
|
|
+// for (BigDecimal mapValue : mapValues.values()) {
|
|
|
+// llfdl = llfdl.add(mapValue);
|
|
|
+// }
|
|
|
+// map2.put(key, llfdl);
|
|
|
+// }
|
|
|
+//
|
|
|
+// BigDecimal mhsllfdl = BigDecimal.valueOf(0);
|
|
|
+// BigDecimal nssllfdl = BigDecimal.valueOf(0);
|
|
|
+// BigDecimal qsllfdl = BigDecimal.valueOf(0);
|
|
|
+// BigDecimal sbqllfdl = BigDecimal.valueOf(0);
|
|
|
+// BigDecimal xsllfdl = BigDecimal.valueOf(0);
|
|
|
+//
|
|
|
+// for (String key : map2.keySet()) {
|
|
|
+// if (key.contains("NX_GDDL_MHS_F_WT_")) {
|
|
|
+// mhsllfdl = mhsllfdl.add(map2.get(key));
|
|
|
+// }
|
|
|
+// if (key.contains("NX_GDDL_NSS_F_WT_")) {
|
|
|
+// nssllfdl = nssllfdl.add(map2.get(key));
|
|
|
+// }
|
|
|
+// if (key.contains("NX_GDDL_QS_F_WT_")) {
|
|
|
+// qsllfdl = qsllfdl.add(map2.get(key));
|
|
|
+// }
|
|
|
+// if (key.contains("NX_GDDL_SBQ_F_WT_")) {
|
|
|
+// sbqllfdl = sbqllfdl.add(map2.get(key));
|
|
|
+// }
|
|
|
+// if (key.contains("NX_GDDL_XS_F_WT_")) {
|
|
|
+// xsllfdl = xsllfdl.add(map2.get(key));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// System.out.println("麻黄山理论发电量:" + mhsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+// System.out.println("牛首山理论发电量:" + nssllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+// System.out.println("青山理论发电量:" + qsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+// System.out.println("石板泉理论发电量:" + sbqllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+// System.out.println("香山理论发电量:" + xsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 理论发电量,每台风机每分钟平均风速乘机型理论功率
|
|
|
+ * (如果理论功率小于实际功率,用实际功率)或者1分钟理论发电量小于1分钟实际发电量,用实际发电量
|
|
|
+ * 1分钟平均风速
|
|
|
+ */
|
|
|
+// @Test
|
|
|
+// public void llfdl_1Min1() {
|
|
|
+//
|
|
|
+// //设置取值开始时间
|
|
|
+// String startString = startTimeString;
|
|
|
+// DateTime startDateTime0 = DateUtil.parse(startString);
|
|
|
+// DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
|
|
|
+//
|
|
|
+// //设置取值结束时间
|
|
|
+// String endDateString = endTimeString;
|
|
|
+// DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
+// DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
+//// DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
|
|
|
+//
|
|
|
+// int a = 0;
|
|
|
+//
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
|
|
|
+//
|
|
|
+//
|
|
|
+// //model_power_details表中获取到所有型号各风速对应的理论功率
|
|
|
+// List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
|
|
|
+//// System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
|
|
|
+//
|
|
|
+// //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI022")
|
|
|
+// );
|
|
|
+//// System.out.println("testingPointList"+testingPointList);
|
|
|
+//
|
|
|
+// //遍历testingPointList拿到code作为适配器参数
|
|
|
+// for (TestingPoint testingPoint : testingPointList) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// System.out.println("风速返回数据:" + pointDataList.size());
|
|
|
+// //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// //1分钟平均风速
|
|
|
+// double speed0 = pointData.getAvg().getValue();
|
|
|
+// BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+//
|
|
|
+// //时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
|
|
|
+// tdEquiomentMeterInfo.setActualPower(0);
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(0);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+// tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//// System.out.println(tdEquiomentMeterInfoSpeed);
|
|
|
+//
|
|
|
+// //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI130")
|
|
|
+// .eq("thing_type", "windturbine")
|
|
|
+// );
|
|
|
+//
|
|
|
+// //遍历testingPointList拿到code作为适配器参数
|
|
|
+// for (TestingPoint testingPoint : testingPointList2) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// System.out.println("实际功率返回数据:" + pointDataList.size());
|
|
|
+// //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// //1分钟平均实际功率
|
|
|
+// double power = pointData.getAvg().getValue();
|
|
|
+//
|
|
|
+// //时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setActualPower(power);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+// tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
|
|
|
+//
|
|
|
+// System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
|
|
|
+// // 遍历 tdEquiomentMeterInfoSpeed 集合
|
|
|
+// for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// String tbName = speedInfo.getTbName();
|
|
|
+// long ts = speedInfo.getTs();
|
|
|
+// BigDecimal bigDecimal1 = new BigDecimal(ts);
|
|
|
+//
|
|
|
+// for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
|
|
|
+// BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
|
|
|
+// if (powerInfo.getTbName().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
|
|
|
+// a++;
|
|
|
+// speedInfo.setActualPower(powerInfo.getActualPower());
|
|
|
+// // 退出内部循环,继续查找下一个 speedInfo 对象
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+//
|
|
|
+// for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+// if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getEnsurePower());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+//// System.out.println("tdEquiomentMeterInfos"+tdEquiomentMeterInfos.size());
|
|
|
+// tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+//
|
|
|
+//
|
|
|
+// double c = 0;
|
|
|
+// double b = 0;
|
|
|
+//
|
|
|
+// for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
|
|
|
+// tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
|
|
|
+//
|
|
|
+// c = c + tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
|
|
|
+// b = b + tDEquiomentMeterInfo.getActualGeneration();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// System.out.println("理论发电量" + c);
|
|
|
+// System.out.println("实际发电量" + b);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ //理论功率
|
|
|
+// @Test
|
|
|
+// public void llfdl_1Min2() {
|
|
|
+//
|
|
|
+// //设置取值开始时间
|
|
|
+// String startString = startTimeString;
|
|
|
+// DateTime startDateTime0 = DateUtil.parse(startString);
|
|
|
+// DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
|
|
|
+//
|
|
|
+// //设置取值结束时间
|
|
|
+// String endDateString = endTimeString;
|
|
|
+// DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
+//// DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
+// DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
|
|
|
+//
|
|
|
+// int a = 0;
|
|
|
+//
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
|
|
|
+//
|
|
|
+//
|
|
|
+// //model_power_details表中获取到所有型号各风速对应的理论功率
|
|
|
+// List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
|
|
|
+//// System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
|
|
|
+//
|
|
|
+// //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI022")
|
|
|
+// );
|
|
|
+//// System.out.println("testingPointList"+testingPointList);
|
|
|
+//
|
|
|
+// //遍历testingPointList拿到code作为适配器参数
|
|
|
+// for (TestingPoint testingPoint : testingPointList) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// System.out.println("风速返回数据:" + pointDataList.size());
|
|
|
+// //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// //1分钟平均风速
|
|
|
+// double speed0 = pointData.getAvg().getValue();
|
|
|
+// BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+//
|
|
|
+// //时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
|
|
|
+// tdEquiomentMeterInfo.setActualPower(0);
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(0);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+// tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//// System.out.println(tdEquiomentMeterInfoSpeed);
|
|
|
+//
|
|
|
+// //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI130")
|
|
|
+// .eq("thing_type", "windturbine")
|
|
|
+// );
|
|
|
+//
|
|
|
+// //遍历testingPointList拿到code作为适配器参数
|
|
|
+// for (TestingPoint testingPoint : testingPointList2) {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// System.out.println("实际功率返回数据:" + pointDataList.size());
|
|
|
+// //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// //1分钟平均实际功率
|
|
|
+// double power = pointData.getAvg().getValue();
|
|
|
+//
|
|
|
+// //时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setActualPower(power);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+// tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
|
|
|
+//
|
|
|
+// System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
|
|
|
+// // 遍历 tdEquiomentMeterInfoSpeed 集合
|
|
|
+// for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// String tbName = speedInfo.getTbName();
|
|
|
+// long ts = speedInfo.getTs();
|
|
|
+// BigDecimal bigDecimal1 = new BigDecimal(ts);
|
|
|
+//
|
|
|
+// for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
|
|
|
+// BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
|
|
|
+// if (powerInfo.getTbName().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
|
|
|
+// a++;
|
|
|
+// speedInfo.setActualPower(powerInfo.getActualPower());
|
|
|
+// // 退出内部循环,继续查找下一个 speedInfo 对象
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+//
|
|
|
+// for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+// if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getTheoryPower());
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+// tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+//
|
|
|
+// //日理论发电量
|
|
|
+// //日实际发电量
|
|
|
+// double c = 0;
|
|
|
+//// double b = 0;
|
|
|
+// for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+//// tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
|
|
|
+// tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
|
|
|
+//
|
|
|
+// //选择功率大的
|
|
|
+// tDEquiomentMeterInfo.setTheoreticalPowerGeneration(Math.max(tDEquiomentMeterInfo.getTheoreticalPower(), tDEquiomentMeterInfo.getActualPower())/60);
|
|
|
+//
|
|
|
+//
|
|
|
+// c = c + tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
|
|
|
+//// b = b + tDEquiomentMeterInfo.getActualGeneration();
|
|
|
+//
|
|
|
+// //保存到taos
|
|
|
+// tdEquipmentMeterInfoMapper.insertTDEquiomentMeterInfo(tDEquiomentMeterInfo.getTbName(), tDEquiomentMeterInfo.getModel(), tDEquiomentMeterInfo.getStation(), tDEquiomentMeterInfo.getTs(), tDEquiomentMeterInfo.getSpeed(), tDEquiomentMeterInfo.getTheoreticalPower(), tDEquiomentMeterInfo.getActualPower(), tDEquiomentMeterInfo.getTheoreticalPowerGeneration(), tDEquiomentMeterInfo.getActualGeneration());
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//// System.out.println("理论发电量" + c);
|
|
|
+//// System.out.println("实际发电量" + b);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ //并行处理优化查询速度
|
|
|
+// @Test
|
|
|
+// public void llfdl_1Min3() {
|
|
|
+// // 设置取值开始时间
|
|
|
+// DateTime startDateTime = DateUtil.beginOfDay(DateUtil.parse(startTimeString));
|
|
|
+//
|
|
|
+// // 设置取值结束时间
|
|
|
+// DateTime endDateTime = DateUtil.endOfDay(DateUtil.parse(endTimeString));
|
|
|
+//
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
|
|
|
+// ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
|
|
|
+//
|
|
|
+// // 从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI022")
|
|
|
+// );
|
|
|
+//
|
|
|
+// // 并行获取风速数据
|
|
|
+// testingPointList.parallelStream().forEach(testingPoint -> {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// // 遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// // 1分钟平均风速
|
|
|
+// double speed0 = pointData.getAvg().getValue();
|
|
|
+// BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+//
|
|
|
+// // 时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
|
|
|
+// tdEquiomentMeterInfo.setActualPower(0);
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(0);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+//
|
|
|
+// synchronized (tdEquiomentMeterInfoSpeed) {
|
|
|
+// tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// // 从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+// List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+// .eq("uniform_code", "AI130")
|
|
|
+// .eq("thing_type", "windturbine")
|
|
|
+// );
|
|
|
+//
|
|
|
+// // 并行获取实际功率数据
|
|
|
+// testingPointList2.parallelStream().forEach(testingPoint -> {
|
|
|
+// String code = testingPoint.getCode();
|
|
|
+// List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+//
|
|
|
+// // 遍历pointDataList,取出1分钟平均实际功率,和时间
|
|
|
+// for (PointDatas pointData : pointDataList) {
|
|
|
+// // 1分钟平均实际功率
|
|
|
+// double power = pointData.getAvg().getValue();
|
|
|
+//
|
|
|
+// // 时间
|
|
|
+// long ts0 = pointData.getAvg().getTs();
|
|
|
+// long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
|
|
|
+//
|
|
|
+// TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+// tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
|
|
|
+// tdEquiomentMeterInfo.setTs(ts);
|
|
|
+// tdEquiomentMeterInfo.setActualPower(power);
|
|
|
+// tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+// tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+//
|
|
|
+// synchronized (tdEquiomentMeterInfoPower) {
|
|
|
+// tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+// // 创建HashMap用于加速查找
|
|
|
+// Map<String, TDEquipmentMeterInfo> powerInfoMap = new HashMap<>();
|
|
|
+// for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
|
|
|
+// powerInfoMap.put(powerInfo.getTbName() + "_" + powerInfo.getTs(), powerInfo);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 匹配风速和实际功率数据
|
|
|
+// for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// String tbName = speedInfo.getTbName();
|
|
|
+// long ts = speedInfo.getTs();
|
|
|
+// TDEquipmentMeterInfo powerInfo = powerInfoMap.get(tbName + "_" + ts);
|
|
|
+// if (powerInfo != null) {
|
|
|
+// speedInfo.setActualPower(powerInfo.getActualPower());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 获取所有型号对应的理论功率数据
|
|
|
+// List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
|
|
|
+//
|
|
|
+// // 使用HashSet提高查找速度
|
|
|
+// Set<String> modelSet = new HashSet<>();
|
|
|
+// for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+// modelSet.add(modelPowerDetails.getModelId());
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 匹配理论功率数据
|
|
|
+// for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// if (modelSet.contains(tdEquiomentMeterInfo.getModel())) {
|
|
|
+// for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+// if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
|
|
|
+// if (tdEquiomentMeterInfo.getSpeed() < 4.5) {
|
|
|
+// tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getEnsurePower());
|
|
|
+// }else {tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getTheoryPower());
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 根据tbName和ts排序
|
|
|
+//// tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+//// tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
|
|
|
+//
|
|
|
+// // 日理论发电量和日实际发电量
|
|
|
+// double c = 0;
|
|
|
+// double b = 0;
|
|
|
+// double d = 0;
|
|
|
+// for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+// tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
|
|
|
+// tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
|
|
|
+//
|
|
|
+//// c += tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
|
|
|
+//// b += tDEquiomentMeterInfo.getActualGeneration();
|
|
|
+// double c1 = tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
|
|
|
+//// double b1 = tDEquiomentMeterInfo.getActualGeneration();
|
|
|
+// c += c1;
|
|
|
+//// b += b1;
|
|
|
+//// d += Math.max(c1, b1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("理论功率功率理论发电量: " + c);
|
|
|
+// System.out.println("实际平均功率发电量: " + b);
|
|
|
+// System.out.println("优化理论发电量发电量: " + d);
|
|
|
+// }
|
|
|
+
|
|
|
+ //功率对比()taos
|
|
|
+ @Test
|
|
|
+ public void llfdl_1Min4() {
|
|
|
+
|
|
|
+ //设置取值开始时间
|
|
|
+ String startString = startTimeString;
|
|
|
+ DateTime startDateTime0 = DateUtil.parse(startString);
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
|
|
|
+
|
|
|
+ //设置取值结束时间
|
|
|
+ String endDateString = endTimeString;
|
|
|
+ DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
+ DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
+// DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
|
|
|
+
|
|
|
+ int a = 0;
|
|
|
+
|
|
|
+ ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
|
|
|
+ ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
|
|
|
+ ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ //model_power_details表中获取到所有型号各风速对应的理论功率
|
|
|
+ List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
|
|
|
+// System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
|
|
|
+
|
|
|
+ //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+ List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+ .eq("uniform_code", "AI022")
|
|
|
+ );
|
|
|
+// System.out.println("testingPointList"+testingPointList);
|
|
|
+
|
|
|
+ //遍历testingPointList拿到code作为适配器参数
|
|
|
+ for (TestingPoint testingPoint : testingPointList) {
|
|
|
+ String code = testingPoint.getCode();
|
|
|
+ List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+
|
|
|
+ System.out.println("风速返回数据:" + pointDataList.size());
|
|
|
+ //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+ for (PointDatas pointData : pointDataList) {
|
|
|
+ //1分钟平均风速
|
|
|
+ double speed0 = pointData.getAvg().getValue();
|
|
|
+ BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
+
|
|
|
+ //时间
|
|
|
+ long ts0 = pointData.getAvg().getTs();
|
|
|
+ long ts = DateUtil.offsetMinute(DateUtil.beginOfMinute(DateTime.of(ts0)), 1).getTime();
|
|
|
+
|
|
|
+ TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+ tdEquiomentMeterInfo.setTbname(testingPoint.getThingId());
|
|
|
+ tdEquiomentMeterInfo.setTs(ts);
|
|
|
+ tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
|
|
|
+ tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+ tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+ tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+// System.out.println(tdEquiomentMeterInfoSpeed);
|
|
|
+
|
|
|
+ //从testingPont表中根据uniform_code=AI022获取到设备风速测点
|
|
|
+ List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
+ .eq("uniform_code", "AI130")
|
|
|
+ .eq("thing_type", "windturbine")
|
|
|
+ );
|
|
|
+
|
|
|
+ //遍历testingPointList拿到code作为适配器参数
|
|
|
+ for (TestingPoint testingPoint : testingPointList2) {
|
|
|
+ String code = testingPoint.getCode();
|
|
|
+ List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
+
|
|
|
+ System.out.println("实际功率返回数据:" + pointDataList.size());
|
|
|
+ //遍历pointDataList,取出1分钟平均风速,和时间
|
|
|
+ for (PointDatas pointData : pointDataList) {
|
|
|
+ //1分钟平均实际功率
|
|
|
+ double power = pointData.getAvg().getValue();
|
|
|
+
|
|
|
+ //时间
|
|
|
+ long ts0 = pointData.getAvg().getTs();
|
|
|
+ long ts = DateUtil.offsetMinute(DateUtil.beginOfMinute(DateTime.of(ts0)), 1).getTime();
|
|
|
+
|
|
|
+ TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
|
|
|
+ tdEquiomentMeterInfo.setTbname(testingPoint.getThingId());
|
|
|
+ tdEquiomentMeterInfo.setTs(ts);
|
|
|
+ tdEquiomentMeterInfo.setShijigonglv(power);
|
|
|
+ tdEquiomentMeterInfo.setModel(testingPoint.getModel());
|
|
|
+ tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
|
|
|
+ tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
|
|
|
+
|
|
|
+ System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
|
|
|
+ // 遍历 tdEquiomentMeterInfoSpeed 集合
|
|
|
+ for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+ String tbName = speedInfo.getTbname();
|
|
|
+ long ts = speedInfo.getTs();
|
|
|
+ BigDecimal bigDecimal1 = new BigDecimal(ts);
|
|
|
+
|
|
|
+ for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
|
|
|
+ BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
|
|
|
+ if (powerInfo.getTbname().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
|
|
|
+ a++;
|
|
|
+ speedInfo.setShijigonglv(powerInfo.getShijigonglv());
|
|
|
+ // 退出内部循环,继续查找下一个 speedInfo 对象
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+
|
|
|
+ for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
+ if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
|
|
|
+ tdEquiomentMeterInfo.setLilungonglv(modelPowerDetails.getTheoryPower());
|
|
|
+ tdEquiomentMeterInfo.setBaozhenggonglv(modelPowerDetails.getEnsurePower());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
|
|
|
+
|
|
|
+ //实际理论选择大的
|
|
|
+ tDEquiomentMeterInfo.setShijililun(Math.max(tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getLilungonglv()));
|
|
|
+ //实际保证选择大的
|
|
|
+ tDEquiomentMeterInfo.setShijibaozhen(Math.max(tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getBaozhenggonglv()));
|
|
|
+
|
|
|
+
|
|
|
+// b = b + tDEquiomentMeterInfo.getActualGeneration();
|
|
|
+
|
|
|
+ //保存到taos
|
|
|
+ tdEquipmentMeterInfoMapper.insertTDEquiomentMeterInfo2(tDEquiomentMeterInfo.getTbname(), tDEquiomentMeterInfo.getModel(), tDEquiomentMeterInfo.getStation(), tDEquiomentMeterInfo.getTs(), tDEquiomentMeterInfo.getSpeed(), tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getLilungonglv(), tDEquiomentMeterInfo.getBaozhenggonglv(), tDEquiomentMeterInfo.getShijililun(), tDEquiomentMeterInfo.getShijibaozhen());
|
|
|
+ }
|
|
|
+
|
|
|
+// tdEquipmentMeterInfoService.saveBatch();
|
|
|
+// tdEquipmentMeterInfoService.saveOrUpdateBatch(tdEquiomentMeterInfoSpeed);
|
|
|
+
|
|
|
+
|
|
|
+// System.out.println("理论发电量" + c);
|
|
|
+// System.out.println("实际发电量" + b);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void cxllfdl() {
|
|
|
+ List<TDEquipmentMeterInfo> list = tdEquipmentMeterInfoService.list(new QueryWrapper<TDEquipmentMeterInfo>()
|
|
|
+// .eq("station", "NX_GDDL_QS_FDC_STA")
|
|
|
+// .eq("station", "NX_GDDL_SBQ_FDC_STA")
|
|
|
+ .eq("station", "NX_GDDL_XS_FDC_STA")
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ double shijigonglv = 0;
|
|
|
+ double lilungonglv = 0;
|
|
|
+ double baozhenggonglv = 0;
|
|
|
+ double shijililun = 0;
|
|
|
+ double baozhenlilun = 0;
|
|
|
+
|
|
|
+ //遍历list集合,累加
|
|
|
+ for (TDEquipmentMeterInfo tDEquipmentMeterInfo : list) {
|
|
|
+ shijigonglv += tDEquipmentMeterInfo.getShijigonglv()/60;
|
|
|
+ lilungonglv += tDEquipmentMeterInfo.getLilungonglv()/60;
|
|
|
+ baozhenggonglv += tDEquipmentMeterInfo.getBaozhenggonglv()/60;
|
|
|
+ shijililun += tDEquipmentMeterInfo.getShijililun()/60;
|
|
|
+ baozhenlilun += tDEquipmentMeterInfo.getShijibaozhen()/60;
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("实际功率" + new BigDecimal(shijigonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+ System.out.println("理论功率" + new BigDecimal(lilungonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+ System.out.println("保证功率" + new BigDecimal(baozhenggonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+ System.out.println("实际理论" + new BigDecimal(shijililun).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+ System.out.println("实保证证" + new BigDecimal(baozhenlilun).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|