|
@@ -18,10 +18,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Author: malijun
|
|
@@ -49,7 +46,6 @@ class SaveMeterInfoHistoryTest {
|
|
|
MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
|
|
|
|
|
|
|
|
|
-
|
|
|
@Value("${start.time}")
|
|
|
private String startTimeString;
|
|
|
@Value("${end.time}")
|
|
@@ -63,8 +59,6 @@ class SaveMeterInfoHistoryTest {
|
|
|
//1,在testingpoint中根据 uniform_code=AI064 和code like "%_FJ_%" 取出所有风机的电量测点code
|
|
|
List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").like("code", "%_FJ_%"));
|
|
|
|
|
|
- //所有风机总共407个电量测点code
|
|
|
-
|
|
|
//2,遍历list,每次取出一个code
|
|
|
for (TestingPoint testingPoint : testingPointList) {
|
|
|
//获取测点code
|
|
@@ -87,30 +81,50 @@ class SaveMeterInfoHistoryTest {
|
|
|
|
|
|
for (int i = 0; i <= between; i++) {
|
|
|
|
|
|
-
|
|
|
//开始时间00:00:01
|
|
|
DateTime dateTime1 = DateUtil.offsetSecond(DateUtil.offsetDay(startDateTime, i), 1);
|
|
|
//结束时间第二天00:00:01
|
|
|
DateTime dateTime2 = DateUtil.offsetSecond(DateUtil.offsetDay(startDateTime, i + 1), 1);
|
|
|
|
|
|
- //6,根据code和日期开始时间00:00:00获取日期开始点发电量
|
|
|
- Map<String, PointData> historySection1 = adapter.getHistorySection(pointcode, dateTime1.getTime());
|
|
|
- double value1 = historySection1.get(pointcode).getValue();
|
|
|
+ //8,结束点发电量减去开始点发电量得到日发电量(单位Kwh)
|
|
|
+ List<PointData> historyRaw = adapter.getHistoryRaw(pointcode, dateTime1.getTime(), dateTime2.getTime());
|
|
|
|
|
|
- //7,根据code和日期结束时间23:59:59获取日期结束点发电量
|
|
|
- Map<String, PointData> historySection2 = adapter.getHistorySection(pointcode, dateTime2.getTime());
|
|
|
- double value2 = historySection2.get(pointcode).getValue();
|
|
|
+ BigDecimal rfdl = new BigDecimal(0);
|
|
|
|
|
|
- //8,结束点发电量减去开始点发电量得到日发电量(单位Kwh)
|
|
|
- BigDecimal bigDecimal1 = new BigDecimal(Double.toString(value1));
|
|
|
- BigDecimal bigDecimal2 = new BigDecimal(Double.toString(value2));
|
|
|
- BigDecimal rfdl = bigDecimal2.subtract(bigDecimal1);
|
|
|
+ if (historyRaw.size() > 0) {
|
|
|
+ BigDecimal bigDecimal1 = new BigDecimal(Double.toString(historyRaw.get(0).getValue()));
|
|
|
+ BigDecimal bigDecimal2 = new BigDecimal(Double.toString(historyRaw.get(historyRaw.size() - 1).getValue()));
|
|
|
+ rfdl = bigDecimal2.subtract(bigDecimal1);
|
|
|
|
|
|
+ if (rfdl.doubleValue() > 50000 || rfdl.doubleValue() < 0) {
|
|
|
|
|
|
+ ArrayList<Double> arrayList = new ArrayList<>();
|
|
|
+ for (PointData pointData : historyRaw) {
|
|
|
+ arrayList.add(pointData.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = -1;
|
|
|
+ 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 > 50000 || difference < 0) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//9,company_nem_code (powerstation_nem_code project_nem_code line_nem_code equipment_nem_code )都在basic equipment中叫project_id name date rfdl 存入meterInfo表中
|
|
|
Equipment thingId1 = equipmentService.getOne(new QueryWrapper<Equipment>().eq("nem_code", thingId));
|
|
|
|
|
|
-
|
|
|
MeterInfoEquipment meterInfoEquipment = new MeterInfoEquipment();
|
|
|
meterInfoEquipment.setPowerstationNemCode(thingId1.getWindpowerstationId());
|
|
|
meterInfoEquipment.setProjectNemCode(thingId1.getProjectId());
|
|
@@ -127,14 +141,10 @@ class SaveMeterInfoHistoryTest {
|
|
|
} else {
|
|
|
meterInfoEquipment.insert();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- //读取时间段内meter_point表中所有电计量测点数据存入pg数据库
|
|
|
@Test
|
|
|
void saveBottomCode() {
|
|
|
|
|
@@ -172,25 +182,46 @@ class SaveMeterInfoHistoryTest {
|
|
|
//结束时间第二天00:00:01
|
|
|
DateTime dateTime2 = DateUtil.offsetSecond(DateUtil.offsetDay(startDateTime, i + 1), 1);
|
|
|
|
|
|
- //6,根据测点code和日期开始时间00:00:01获取日期开始点发电量
|
|
|
- Map<String, PointData> historySection1 = adapter.getHistorySection(pointcode, dateTime1.getTime());
|
|
|
-
|
|
|
- //7,根据测点code和日期结束时间第二点00:00:01获取日期结束点发电量
|
|
|
- Map<String, PointData> historySection2 = adapter.getHistorySection(pointcode, dateTime2.getTime());
|
|
|
-
|
|
|
- BigDecimal bigDecimal1 = meterPoint.getInitialValue();
|
|
|
- BigDecimal bigDecimal2 = meterPoint.getInitialValue();
|
|
|
-
|
|
|
-
|
|
|
- if (historySection1.size() > 0 && historySection2.size() > 0) {
|
|
|
- double value1 = historySection1.get(pointcode).getValue();
|
|
|
- double value2 = historySection2.get(pointcode).getValue();
|
|
|
- bigDecimal1 = new BigDecimal(Double.toString(value1));
|
|
|
- bigDecimal2 = new BigDecimal(Double.toString(value2));
|
|
|
+ List<PointData> historyRaw = adapter.getHistoryRaw(pointcode, dateTime1.getTime(), dateTime2.getTime());
|
|
|
+ BigDecimal bigDecimal1 = new BigDecimal(0);
|
|
|
+ BigDecimal bigDecimal2 = new BigDecimal(0);
|
|
|
+ BigDecimal rfdl = new BigDecimal(0);
|
|
|
+
|
|
|
+ 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() > 5000000||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());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- bigDecimal1 = bigDecimal1.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- bigDecimal2 = bigDecimal2.divide(meterPoint.getXs(), 4, RoundingMode.HALF_EVEN);
|
|
|
- BigDecimal rfdl = bigDecimal2.subtract(bigDecimal1).multiply(meterPoint.getMagnification());
|
|
|
|
|
|
MeterInfoBottomcode meterInfoBottomcode = new MeterInfoBottomcode();
|
|
|
meterInfoBottomcode.setName(meterPoint.getName());
|
|
@@ -210,11 +241,14 @@ class SaveMeterInfoHistoryTest {
|
|
|
} else {
|
|
|
meterInfoBottomcode.insert();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//项目期期风机总发电量
|
|
@@ -343,7 +377,7 @@ class SaveMeterInfoHistoryTest {
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println("获取数据异常:"+e.getMessage());
|
|
|
+ System.out.println("获取数据异常:" + e.getMessage());
|
|
|
|
|
|
}
|
|
|
try {
|
|
@@ -363,14 +397,11 @@ class SaveMeterInfoHistoryTest {
|
|
|
} else {
|
|
|
meterInfoCalculating.insert();
|
|
|
}
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
System.out.println("存入异常 :" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -380,10 +411,9 @@ class SaveMeterInfoHistoryTest {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //调用所有
|
|
|
+ //调用上面4个,第四个需要3次
|
|
|
@Test
|
|
|
- void saveCalculating3(){
|
|
|
+ void saveCalculating3() {
|
|
|
this.saveEquipmentRfdl();
|
|
|
this.saveBottomCode();
|
|
|
this.saveCalculatingProjectFDL();
|
|
@@ -392,14 +422,9 @@ class SaveMeterInfoHistoryTest {
|
|
|
this.saveCalculating();
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|