|
@@ -10,6 +10,7 @@ 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;
|
|
@@ -23,36 +24,45 @@ import java.util.Map;
|
|
|
* Data : 2023: 04: 27
|
|
|
**/
|
|
|
@SpringBootTest
|
|
|
-class AdapterServiceTest {
|
|
|
+class SaveMeterInfoHistoryTest {
|
|
|
+
|
|
|
|
|
|
@Resource
|
|
|
Adapter adapter;
|
|
|
-
|
|
|
@Resource
|
|
|
TestingPointServiceImpl testingPointService;
|
|
|
-
|
|
|
@Resource
|
|
|
EquipmentServiceImpl equipmentService;
|
|
|
+ @Resource
|
|
|
+ PowerStationServiceImpl powerStationService;
|
|
|
+ @Resource
|
|
|
+ MeterPointServiceImpl meterPointService;
|
|
|
+ @Resource
|
|
|
+ MeterInfoBottomcodeServiceImpl meterInfoBottomcodeService;
|
|
|
+ @Resource
|
|
|
+ MeterInfoEquipmentServiceImpl meterInfoEquipmentService;
|
|
|
+ @Resource
|
|
|
+ MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
|
|
|
+
|
|
|
|
|
|
@Value("${start.time}")
|
|
|
private String startTimeString;
|
|
|
-
|
|
|
@Value("${end.time}")
|
|
|
private String endTimeString;
|
|
|
|
|
|
- //测试读取设备发电量,并写入pg数据库
|
|
|
+ //读取时间段内设备发电量计算肉发电量写入pg数据库
|
|
|
@Test
|
|
|
void saveEquipmentRfdl() {
|
|
|
|
|
|
|
|
|
//1,在testingpoint中根据 uniform_code=AI064 和code like "%_FJ_%" 取出所有风机的电量测点code
|
|
|
- List<TestingPoint> list = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").like("code", "%_FJ_%"));
|
|
|
+ List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").like("code", "%_FJ_%"));
|
|
|
|
|
|
//所有风机总共407个电量测点code
|
|
|
- System.out.println(list.size());
|
|
|
+ System.out.println(testingPointList.size());
|
|
|
|
|
|
//2,遍历list,每次取出一个code
|
|
|
- for (TestingPoint testingPoint : list) {
|
|
|
+ for (TestingPoint testingPoint : testingPointList) {
|
|
|
//获取测点code
|
|
|
String pointcode = testingPoint.getCode();
|
|
|
//获取设备ID
|
|
@@ -70,9 +80,9 @@ class AdapterServiceTest {
|
|
|
LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
long between = ChronoUnit.DAYS.between(day1, day2);
|
|
|
- System.out.println(between);
|
|
|
+ System.out.println("相差天数"+between);
|
|
|
|
|
|
- for (int i = 1; i < between; i++) {
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
|
|
|
|
|
|
//开始时间00:00:01
|
|
@@ -106,9 +116,18 @@ class AdapterServiceTest {
|
|
|
meterInfoEquipment.setLineNemCode(thingId1.getLineId());
|
|
|
meterInfoEquipment.setEquipmentNemCode(thingId1.getNemCode());
|
|
|
meterInfoEquipment.setName(thingId1.getName());
|
|
|
- meterInfoEquipment.setDate(DateUtil.format(dateTime2, "yyyy-MM-dd"));
|
|
|
+ meterInfoEquipment.setDate(dateTime1.toLocalDateTime());
|
|
|
meterInfoEquipment.setRfdl(rfdl);
|
|
|
- meterInfoEquipment.insert();
|
|
|
+// meterInfoEquipment.insert();
|
|
|
+ QueryWrapper<MeterInfoEquipment> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("equipment_nem_code", thingId1.getNemCode()).eq("date",dateTime1.toLocalDateTime());
|
|
|
+ List<MeterInfoEquipment> list = meterInfoEquipmentService.list(queryWrapper);
|
|
|
+ System.out.println("有无数据集合数"+list.size());
|
|
|
+ if (list.size() > 0) {
|
|
|
+ meterInfoEquipment.update(queryWrapper);
|
|
|
+ } else {
|
|
|
+ meterInfoEquipment.insert();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|
|
@@ -116,14 +135,7 @@ class AdapterServiceTest {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Resource
|
|
|
- PowerStationServiceImpl powerStationService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MeterPointServiceImpl meterPointService;
|
|
|
-
|
|
|
- //读取底码数据存入pg数据库,设置开始时间,结束时间
|
|
|
+ //读取时间段内meter_point表中所有电计量测点数据存入pg数据库
|
|
|
@Test
|
|
|
void saveBottomCode() {
|
|
|
|
|
@@ -154,16 +166,14 @@ class AdapterServiceTest {
|
|
|
LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
long between = ChronoUnit.DAYS.between(day1, day2);
|
|
|
- System.out.println(between);
|
|
|
-
|
|
|
+ System.out.println("相差天数"+between);
|
|
|
|
|
|
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);
|
|
|
-
|
|
|
+ DateTime dateTime2 = DateUtil.offsetSecond(DateUtil.offsetDay(startDateTime, i + 1), 1);
|
|
|
|
|
|
//没有测点code的字段
|
|
|
if (null == pointcode) {
|
|
@@ -178,15 +188,22 @@ class AdapterServiceTest {
|
|
|
meterInfoBottomcode.setName(meterPoint.getName());
|
|
|
meterInfoBottomcode.setStartTime(dateTime1.toLocalDateTime());
|
|
|
meterInfoBottomcode.setStartValue(bigDecimal1);
|
|
|
- meterInfoBottomcode.setEndTime(dateTime1.toLocalDateTime());
|
|
|
+ meterInfoBottomcode.setEndTime(dateTime2.toLocalDateTime());
|
|
|
meterInfoBottomcode.setEndValue(bigDecimal2);
|
|
|
meterInfoBottomcode.setDayValue(rfdl);
|
|
|
meterInfoBottomcode.setCode(pointcode);
|
|
|
meterInfoBottomcode.setWindpowerstationId(meterPoint.getWindpowerstationId());
|
|
|
- meterInfoBottomcode.insert();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+// meterInfoBottomcode.insert();
|
|
|
+
|
|
|
+ QueryWrapper<MeterInfoBottomcode> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("start_time", dateTime1.toLocalDateTime()).eq("name", meterPoint.getName()).eq("end_time",dateTime2.toLocalDateTime()).eq("windpowerstation_id", meterPoint.getWindpowerstationId());
|
|
|
+ List<MeterInfoBottomcode> list = meterInfoBottomcodeService.list(queryWrapper);
|
|
|
+ System.out.println(list.size());
|
|
|
+ if (list.size() > 0) {
|
|
|
+ meterInfoBottomcode.update(queryWrapper);
|
|
|
+ } else {
|
|
|
+ meterInfoBottomcode.insert();
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
//6,根据测点code和日期开始时间00:00:01获取日期开始点发电量
|
|
@@ -211,12 +228,22 @@ class AdapterServiceTest {
|
|
|
meterInfoBottomcode.setName(meterPoint.getName());
|
|
|
meterInfoBottomcode.setStartTime(dateTime1.toLocalDateTime());
|
|
|
meterInfoBottomcode.setStartValue(bigDecimal1);
|
|
|
- meterInfoBottomcode.setEndTime(dateTime1.toLocalDateTime());
|
|
|
+ meterInfoBottomcode.setEndTime(dateTime2.toLocalDateTime());
|
|
|
meterInfoBottomcode.setEndValue(bigDecimal2);
|
|
|
meterInfoBottomcode.setDayValue(rfdl);
|
|
|
meterInfoBottomcode.setCode(pointcode);
|
|
|
meterInfoBottomcode.setWindpowerstationId(meterPoint.getWindpowerstationId());
|
|
|
- meterInfoBottomcode.insert();
|
|
|
+// meterInfoBottomcode.insert();
|
|
|
+
|
|
|
+ QueryWrapper<MeterInfoBottomcode> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("start_time", dateTime1.toLocalDateTime()).eq("code", meterPoint.getNemCode());
|
|
|
+ List<MeterInfoBottomcode> list = meterInfoBottomcodeService.list(queryWrapper);
|
|
|
+ System.out.println(list.size());
|
|
|
+ if (list.size() > 0) {
|
|
|
+ meterInfoBottomcode.update(queryWrapper);
|
|
|
+ } else {
|
|
|
+ meterInfoBottomcode.insert();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -224,14 +251,6 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Resource
|
|
|
- MeterInfoBottomcodeServiceImpl meterInfoBottomcodeService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MeterInfoEquipmentServiceImpl meterInfoEquipmentService;
|
|
|
-
|
|
|
-
|
|
|
//发电量,上网电量,购网电量
|
|
|
@Test
|
|
|
void saveCalculating() {
|
|
@@ -463,11 +482,6 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Resource
|
|
|
- MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
|
|
|
-
|
|
|
-
|
|
|
//综合厂用电量
|
|
|
@Test
|
|
|
void saveCalculating1() {
|
|
@@ -838,7 +852,6 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//发电厂用电量
|
|
|
@Test
|
|
|
void saveCalculating3() {
|
|
@@ -934,7 +947,6 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//发电厂用电率(%)
|
|
|
@Test
|
|
|
void saveCalculating4() {
|
|
@@ -1034,7 +1046,6 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//利用小时
|
|
|
@Test
|
|
|
void saveCalculating5() {
|