|
@@ -1,517 +0,0 @@
|
|
|
-package com.gyee.gaia.meter.service.saveTDengine;
|
|
|
-
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
-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.TDLineFDL15MinMapper;
|
|
|
-import com.gyee.gaia.meter.service.impl.*;
|
|
|
-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.sql.SQLOutput;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-/**
|
|
|
- * Author: malijun
|
|
|
- * Data : 2023: 04: 27
|
|
|
- **/
|
|
|
-@SpringBootTest
|
|
|
-class TDLLFDLTest {
|
|
|
-
|
|
|
- @Resource
|
|
|
- TDLineFDL15MinServiceImpl tdLineFDL15MinService;
|
|
|
- @Resource
|
|
|
- TDLineFDL15MinMapper tdLineFDL15MinMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- Adapter adapter;
|
|
|
- @Resource
|
|
|
- PowerStationServiceImpl powerStationService;
|
|
|
- @Resource
|
|
|
- MeterPointServiceImpl meterPointService;
|
|
|
- @Resource
|
|
|
- ProMeterLineFDL15MinServiceImpl proMeterLineFDL15MinService;
|
|
|
-
|
|
|
-
|
|
|
- @Value("${start.time}")
|
|
|
- private String startTimeString;
|
|
|
- @Value("${end.time}")
|
|
|
- private String endTimeString;
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存taos(根据超级表自动创建子表)
|
|
|
- */
|
|
|
- @Test
|
|
|
- void saveSaveLineFDL15Min() {
|
|
|
-
|
|
|
- //1,查询所有风电场
|
|
|
- List<PowerStation> powerStationList = powerStationService.list(new QueryWrapper<PowerStation>()
|
|
|
- .like("nem_code", "_FDC_"));
|
|
|
-
|
|
|
- for (PowerStation powerStation : powerStationList) {
|
|
|
- //2,根据场站ID,测点类型得到集电线路发电量的测点
|
|
|
- List<MeterPoint> meterPointList = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
- .eq("windpowerstation_id", powerStation.getId())
|
|
|
- .eq("property", "CD")
|
|
|
- .eq("meter_type", "线路")
|
|
|
- .like("meter_class", "集电线路")
|
|
|
- );
|
|
|
-
|
|
|
- //3,遍历测点,拿到每个测点的nem_code
|
|
|
- for (MeterPoint meterPoint : meterPointList) {
|
|
|
- System.out.println(meterPoint);
|
|
|
- //获取测点code
|
|
|
- String pointcode = meterPoint.getNemCode();
|
|
|
- String pointcode2 = pointcode.replace(".NX_", "_NX_");
|
|
|
-
|
|
|
- //设置取值开始时间
|
|
|
- String startString = startTimeString;
|
|
|
- DateTime startDateTime = DateUtil.parse(startString);
|
|
|
-
|
|
|
- //设置取值结束时间
|
|
|
- String endDateString = endTimeString;
|
|
|
- DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
- DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
-
|
|
|
- //指定开始日期到结束日期的间隔
|
|
|
- LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
- LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
- long between0 = ChronoUnit.MINUTES.between(day1, day2);
|
|
|
- int between = (int) (between0 / 15);
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i <= between; i++) {
|
|
|
-
|
|
|
- //开始时间00:00:01
|
|
|
- DateTime dateTime1 = DateUtil.offsetMinute(startDateTime, (i - 1) * 15);
|
|
|
- DateTime dateTime2 = DateUtil.offsetMinute(startDateTime, i * 15);
|
|
|
- BigDecimal bigDecimal1 = new BigDecimal(0);
|
|
|
- BigDecimal bigDecimal2 = new BigDecimal(0);
|
|
|
- BigDecimal rfdl = new BigDecimal(0);
|
|
|
-
|
|
|
-
|
|
|
- List<PointData> historyRaw = adapter.getHistoryRaw(pointcode, dateTime1.getTime(), dateTime2.getTime());
|
|
|
-
|
|
|
- if (historyRaw.size() > 0) {
|
|
|
- bigDecimal1 = new BigDecimal(Double.toString(historyRaw.get(0).getValue()));
|
|
|
- bigDecimal1 = bigDecimal1.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- bigDecimal2 = new BigDecimal(Double.toString(historyRaw.get(historyRaw.size() - 1).getValue()));
|
|
|
- bigDecimal2 = bigDecimal2.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- rfdl = bigDecimal2.subtract(bigDecimal1).multiply(meterPoint.getMagnification());
|
|
|
-
|
|
|
- if (rfdl.doubleValue() > 50000 || rfdl.doubleValue() < 0) {
|
|
|
-
|
|
|
- ArrayList<Double> arrayList = new ArrayList<>();
|
|
|
- for (PointData pointData : historyRaw) {
|
|
|
- arrayList.add(pointData.getValue());
|
|
|
- }
|
|
|
- int index = -1;
|
|
|
- // 定义增长阈值
|
|
|
- double threshold = 50000.0;
|
|
|
-
|
|
|
- for (int j = 1; j < arrayList.size(); j++) {
|
|
|
- double current = arrayList.get(j);
|
|
|
- double previous = arrayList.get(j - 1);
|
|
|
- double difference = current - previous;
|
|
|
- if (difference > threshold) {
|
|
|
- index = j;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (index != -1) {
|
|
|
- double valueGrow2 = arrayList.get(index);
|
|
|
- BigDecimal bigDecimalGrow2 = new BigDecimal(Double.toString(valueGrow2));
|
|
|
- double valueGrow1 = arrayList.get(index - 1);
|
|
|
- BigDecimal bigDecimalGrow1 = new BigDecimal(Double.toString(valueGrow1));
|
|
|
- rfdl = (bigDecimal2.subtract(bigDecimalGrow2).add(bigDecimalGrow1).subtract(bigDecimal1)).multiply(meterPoint.getMagnification());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- tdLineFDL15MinMapper.insertLineFDL15Min(
|
|
|
- pointcode2,
|
|
|
- meterPoint.getWindpowerstationId(),
|
|
|
- meterPoint.getProjectId(),
|
|
|
- meterPoint.getDescription(),
|
|
|
- dateTime2.getTime(),
|
|
|
- bigDecimal2.doubleValue(),
|
|
|
- rfdl.doubleValue()
|
|
|
- );
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量保存到taos(不会自动建表)
|
|
|
- */
|
|
|
- @Test
|
|
|
- void saveSaveLineFDL15Min_batchInsert() {
|
|
|
-
|
|
|
- //1,查询所有风电场
|
|
|
- List<PowerStation> powerStationList = powerStationService.list(new QueryWrapper<PowerStation>()
|
|
|
- .like("nem_code", "_FDC_"));
|
|
|
-
|
|
|
- for (PowerStation powerStation : powerStationList) {
|
|
|
- //2,根据场站ID,测点类型得到集电线路发电量的测点
|
|
|
- List<MeterPoint> meterPointList = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
- .eq("windpowerstation_id", powerStation.getId())
|
|
|
- .eq("property", "CD")
|
|
|
- .eq("meter_type", "线路")
|
|
|
- .like("meter_class", "集电线路")
|
|
|
- );
|
|
|
-
|
|
|
- //3,遍历测点,拿到每个测点的nem_code
|
|
|
- for (MeterPoint meterPoint : meterPointList) {
|
|
|
- System.out.println(meterPoint);
|
|
|
- //获取测点code
|
|
|
- String pointcode = meterPoint.getNemCode();
|
|
|
- String pointcode2 = pointcode.replace(".NX_", "_NX_");
|
|
|
-
|
|
|
- //设置取值开始时间
|
|
|
- String startString = startTimeString;
|
|
|
- DateTime startDateTime = DateUtil.parse(startString);
|
|
|
-
|
|
|
- //设置取值结束时间
|
|
|
- String endDateString = endTimeString;
|
|
|
- DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
- DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
-
|
|
|
- //指定开始日期到结束日期的间隔
|
|
|
- LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
- LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
- long between0 = ChronoUnit.MINUTES.between(day1, day2);
|
|
|
- int between = (int) (between0 / 15);
|
|
|
-
|
|
|
- ArrayList<TDLineFDL15Min> tdLineFDL15Mins = new ArrayList<>();
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i <= between; i++) {
|
|
|
-
|
|
|
- //开始时间00:00:01
|
|
|
- DateTime dateTime1 = DateUtil.offsetMinute(startDateTime, (i - 1) * 15);
|
|
|
- DateTime dateTime2 = DateUtil.offsetMinute(startDateTime, i * 15);
|
|
|
- BigDecimal bigDecimal1 = new BigDecimal(0);
|
|
|
- BigDecimal bigDecimal2 = new BigDecimal(0);
|
|
|
- BigDecimal rfdl = new BigDecimal(0);
|
|
|
-
|
|
|
-
|
|
|
- List<PointData> historyRaw = adapter.getHistoryRaw(pointcode, dateTime1.getTime(), dateTime2.getTime());
|
|
|
-
|
|
|
- if (historyRaw.size() > 0) {
|
|
|
- bigDecimal1 = new BigDecimal(Double.toString(historyRaw.get(0).getValue()));
|
|
|
- bigDecimal1 = bigDecimal1.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- bigDecimal2 = new BigDecimal(Double.toString(historyRaw.get(historyRaw.size() - 1).getValue()));
|
|
|
- bigDecimal2 = bigDecimal2.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- rfdl = bigDecimal2.subtract(bigDecimal1).multiply(meterPoint.getMagnification());
|
|
|
-
|
|
|
- if (rfdl.doubleValue() > 50000 || rfdl.doubleValue() < 0) {
|
|
|
-
|
|
|
- ArrayList<Double> arrayList = new ArrayList<>();
|
|
|
- for (PointData pointData : historyRaw) {
|
|
|
- arrayList.add(pointData.getValue());
|
|
|
- }
|
|
|
- int index = -1;
|
|
|
- // 定义增长阈值
|
|
|
- double threshold = 50000.0;
|
|
|
-
|
|
|
- for (int j = 1; j < arrayList.size(); j++) {
|
|
|
- double current = arrayList.get(j);
|
|
|
- double previous = arrayList.get(j - 1);
|
|
|
- double difference = current - previous;
|
|
|
- if (difference > threshold) {
|
|
|
- index = j;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (index != -1) {
|
|
|
- double valueGrow2 = arrayList.get(index);
|
|
|
- BigDecimal bigDecimalGrow2 = new BigDecimal(Double.toString(valueGrow2));
|
|
|
- double valueGrow1 = arrayList.get(index - 1);
|
|
|
- BigDecimal bigDecimalGrow1 = new BigDecimal(Double.toString(valueGrow1));
|
|
|
- rfdl = (bigDecimal2.subtract(bigDecimalGrow2).add(bigDecimalGrow1).subtract(bigDecimal1)).multiply(meterPoint.getMagnification());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- TDLineFDL15Min tdLineFDL15Min = new TDLineFDL15Min();
|
|
|
- tdLineFDL15Min.setTbName(pointcode2);
|
|
|
- tdLineFDL15Min.setTs(dateTime2.getTime());
|
|
|
- tdLineFDL15Min.setBottom(bigDecimal2.doubleValue());
|
|
|
- tdLineFDL15Min.setMeter(rfdl.doubleValue());
|
|
|
- tdLineFDL15Min.setPowerstation(meterPoint.getWindpowerstationId());
|
|
|
- tdLineFDL15Min.setProject(meterPoint.getProjectId());
|
|
|
- tdLineFDL15Min.setName(meterPoint.getDescription());
|
|
|
-
|
|
|
- tdLineFDL15Mins.add(tdLineFDL15Min);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- List<List<TDLineFDL15Min>> split = ListUtil.split(tdLineFDL15Mins, 1000);
|
|
|
- int count = 0;
|
|
|
- for (List<TDLineFDL15Min> targets : split) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- for (TDLineFDL15Min target : targets) {
|
|
|
- sb.append(target.getTbName())
|
|
|
- .append(" values(")
|
|
|
- .append(target.getTs()).append(",").append(target.getBottom()).append(",").append(target.getMeter())
|
|
|
- .append(") ");
|
|
|
- }
|
|
|
- count += tdLineFDL15MinMapper.insert(sb.toString());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /*
|
|
|
- * 日理论发电量(每台风机,综合到每个场站,每个期次,每条线路)
|
|
|
- * 1分钟平均风速乘model_power_details的理论功率
|
|
|
- * w=pt,理论功率乘时间(kw/h)除以60为1分钟理论发电量
|
|
|
- * pro_basic_equipment表中获取到所有风机,每台风机型号等
|
|
|
- * uniFormCode AI022 从testing_point中获取到所有风速测点
|
|
|
- * 从适配器中取1分钟平均风速,根据风速从model_power_details中取到理论功率
|
|
|
- * 计算1分钟理论发电量
|
|
|
- * 保存到taos数据库中
|
|
|
- */
|
|
|
-
|
|
|
- @Resource
|
|
|
- private EquipmentServiceImpl equipmentService;
|
|
|
- @Resource
|
|
|
- private ModelPowerDetailsServiceImpl modelPowerDetailsService;
|
|
|
- @Resource
|
|
|
- private TestingPointServiceImpl testingPointService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void llfdl_1Min_0() {
|
|
|
-
|
|
|
- //设置取值开始时间
|
|
|
- String startString = startTimeString;
|
|
|
- DateTime startDateTime = DateUtil.parse(startString);
|
|
|
-
|
|
|
- //设置取值结束时间
|
|
|
- String endDateString = endTimeString;
|
|
|
- DateTime endDateTime0 = DateUtil.parse(endDateString);
|
|
|
- DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
|
|
|
-
|
|
|
- //指定开始日期到结束日期的间隔
|
|
|
- LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
- LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
- long between0 = ChronoUnit.MINUTES.between(day1, day2);
|
|
|
- int between = (int) (between0 / 15);
|
|
|
-
|
|
|
-
|
|
|
- //从pro_basic_equipment(实体类为Equipment)表中获取到所有风机,每台风机型号等
|
|
|
- List<Equipment> equipmentList = equipmentService.list(new QueryWrapper<Equipment>()
|
|
|
- .eq("spare1", "WT")
|
|
|
- );
|
|
|
-
|
|
|
- //遍历equipmentList拿到每台风机的型号(model_id)
|
|
|
- for (Equipment equipment : equipmentList) {
|
|
|
- String modelId = equipment.getModelId();
|
|
|
- //根据model_id从model_power_details表中获取到理论功率
|
|
|
- List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list(new QueryWrapper<ModelPowerDetails>()
|
|
|
- .eq("model_id", modelId)
|
|
|
- );
|
|
|
-// System.out.println(modelPowerDetailsList);
|
|
|
-
|
|
|
- //遍历modelPowerDetailsList,取出风速speed和理论功率theory_power放入map集合中,键为speed,值为theory_power
|
|
|
- Map<BigDecimal, Double> map = new HashMap<>();
|
|
|
- for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
|
|
|
- Double speed0 = modelPowerDetails.getSpeed();
|
|
|
- BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
- Double theoryPower = modelPowerDetails.getTheoryPower();
|
|
|
- map.put(speed, theoryPower);
|
|
|
- }
|
|
|
-
|
|
|
- //根据每台风机的编码和uniform_code=AI022从testing_point表中获取到每台风机的风速测点
|
|
|
- List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
|
|
|
- .eq("thing_id", equipment.getNemCode())
|
|
|
- .eq("uniform_code", "AI022")
|
|
|
- );
|
|
|
- //遍历testingPointList拿到每台风机的风速测点
|
|
|
- for (TestingPoint testingPoint : testingPointList) {
|
|
|
- String pointcode = testingPoint.getCode();
|
|
|
- //适配器获取到1分钟平均风速
|
|
|
- List<PointData> pointDataList = adapter.getHistorySnap(pointcode, startDateTime.getTime(), endDateTime.getTime(), 60);
|
|
|
- //遍历pointDataList拿到每台风机的1分钟平均风速,根据风速从map集合中取到理论功率,计算1分钟理论发电量
|
|
|
- for (PointData pointData : pointDataList) {
|
|
|
- //风速
|
|
|
- double speed0 = pointData.getValue();
|
|
|
- BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
-
|
|
|
- Double theoryPower = 0.0;
|
|
|
- if (speed0 >= 3) {
|
|
|
- //理论功率
|
|
|
- theoryPower = map.get(speed);
|
|
|
- }
|
|
|
- //时间
|
|
|
- DateTime dateTime = DateTime.of(pointData.getTs());
|
|
|
- //1分钟理论发电量
|
|
|
- BigDecimal llfdl = new BigDecimal(Double.toString(theoryPower))
|
|
|
- .multiply(new BigDecimal(Double.toString(1)))
|
|
|
- .divide(new BigDecimal(Double.toString(60)), 2, RoundingMode.HALF_UP);
|
|
|
-
|
|
|
- //输出
|
|
|
- System.out.println("风机编码:" + equipment.getNemCode() + "风速测点:" + pointcode + "时间:" + dateTime + "1分钟理论发电量:" + llfdl);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //优化查询
|
|
|
- @Test
|
|
|
- public void llfdl_1Min_1() {
|
|
|
-
|
|
|
- //设置取值开始时间
|
|
|
- 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=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<PointData> pointDataList = adapter.getHistorySnap(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 (PointData pointData : pointDataList) {
|
|
|
- //风速
|
|
|
- double speed0 = pointData.getValue();
|
|
|
- BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
|
|
|
-
|
|
|
- Double theoryPower = 0.0;
|
|
|
- if (speed0 >= 3) {
|
|
|
- //理论功率
|
|
|
- theoryPower = map2.get(speed);
|
|
|
- }
|
|
|
- //时间
|
|
|
- DateTime dateTime = DateTime.of(pointData.getTs());
|
|
|
- //1分钟理论发电量
|
|
|
- BigDecimal 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);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|