|
@@ -5,12 +5,8 @@ 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.Equipment;
|
|
|
-import com.gyee.gaia.meter.entity.MeterInfoEquipment;
|
|
|
-import com.gyee.gaia.meter.entity.PointData;
|
|
|
-import com.gyee.gaia.meter.entity.TestingPoint;
|
|
|
-import com.gyee.gaia.meter.service.impl.EquipmentServiceImpl;
|
|
|
-import com.gyee.gaia.meter.service.impl.TestingPointServiceImpl;
|
|
|
+import com.gyee.gaia.meter.entity.*;
|
|
|
+import com.gyee.gaia.meter.service.impl.*;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
@@ -31,12 +27,6 @@ class AdapterServiceTest {
|
|
|
@Resource
|
|
|
Adapter adapter;
|
|
|
|
|
|
- @Resource
|
|
|
- TestingPointServiceImpl testingPointService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- EquipmentServiceImpl equipmentService;
|
|
|
-
|
|
|
|
|
|
//测试获取和保存数据
|
|
|
@Test
|
|
@@ -53,6 +43,13 @@ class AdapterServiceTest {
|
|
|
meterInfoEquipment.insert();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TestingPointServiceImpl testingPointService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ EquipmentServiceImpl equipmentService;
|
|
|
+
|
|
|
//测试读取设备发电量,并写入pg数据库
|
|
|
@Test
|
|
|
void saveEquipmentRfdl() {
|
|
@@ -128,5 +125,96 @@ class AdapterServiceTest {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ PowerStationServiceImpl powerStationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ MeterPointServiceImpl meterPointService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //读取底码数据存入pg数据库
|
|
|
+ @Test
|
|
|
+ void saveBottomCode() {
|
|
|
+
|
|
|
+ //1,查询所有风电场
|
|
|
+ List<PowerStation> powerStationList = powerStationService.list(new QueryWrapper<PowerStation>().like("nem_code", "_FDC_"));
|
|
|
+
|
|
|
+ for (PowerStation powerStation : powerStationList) {
|
|
|
+
|
|
|
+ //2,根据场站ID,meter_code='111'或者meter_code='121'或者meter_code='151',uniform_code='ZXYG',得到出线测点
|
|
|
+ List<MeterPoint> meterPointList = meterPointService.list(new QueryWrapper<MeterPoint>().eq("windpowerstation_id", powerStation.getId()).eq("uniform_code", "ZXYG").in("meter_code", "111", "121", "151"));
|
|
|
+ System.out.println(meterPointList.size());
|
|
|
+
|
|
|
+ //3,遍历出线测点,拿到每个测点的nem_code
|
|
|
+ for (MeterPoint meterPoint : meterPointList) {
|
|
|
+ System.out.println(meterPoint);
|
|
|
+ //获取测点code
|
|
|
+ String pointcode = meterPoint.getNemCode();
|
|
|
+
|
|
|
+ //6,设置取值开始日期前一天
|
|
|
+ String str = "2023-04-30";
|
|
|
+
|
|
|
+ DateTime dateTime = DateUtil.parse(str);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfDay(dateTime);
|
|
|
+ System.out.println("前一天天结束时间" + dateTime2);
|
|
|
+
|
|
|
+ //指定日期到现在天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(dateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTime.now();
|
|
|
+ System.out.println(day2);
|
|
|
+ long between = ChronoUnit.DAYS.between(day1, day2);
|
|
|
+ System.out.println(between);
|
|
|
+
|
|
|
+ for (int i = 1; i < between; i++) {
|
|
|
+
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMillisecond(dateTime2, 1);
|
|
|
+ System.out.println("第一天开始" + dateTime1);
|
|
|
+
|
|
|
+ dateTime2 = DateUtil.endOfDay(dateTime1);
|
|
|
+ System.out.println("第一天结束" + dateTime2);
|
|
|
+
|
|
|
+ //6,根据code和日期开始时间00:00:00获取日期开始点发电量
|
|
|
+ Map<String, PointData> historySection1 = adapter.getHistorySection(pointcode, dateTime1.getTime());
|
|
|
+ double value1 = historySection1.get(pointcode).getValue();
|
|
|
+
|
|
|
+ //7,根据code和日期结束时间23:59:59获取日期结束点发电量
|
|
|
+ Map<String, PointData> historySection2 = adapter.getHistorySection(pointcode, dateTime2.getTime());
|
|
|
+ double value2 = historySection2.get(pointcode).getValue();
|
|
|
+
|
|
|
+ //8,结束点发电量减去开始点发电量得到日发电量(单位Kwh)
|
|
|
+ BigDecimal bigDecimal1 = new BigDecimal(Double.toString(value1));
|
|
|
+ BigDecimal bigDecimal2 = new BigDecimal(Double.toString(value2));
|
|
|
+ BigDecimal rfdl = bigDecimal2.subtract(bigDecimal1);
|
|
|
+ System.out.println(rfdl + "Kwh");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ MeterInfoBottomcode meterInfoBottomcode = new MeterInfoBottomcode();
|
|
|
+ meterInfoBottomcode.setNameCode("110SCDL");
|
|
|
+ meterInfoBottomcode.setName("110KV送出电量");
|
|
|
+ meterInfoBottomcode.setType(meterPoint.getProjectId());
|
|
|
+// meterInfoBottomcode.setSubStation("");
|
|
|
+ meterInfoBottomcode.setStartTime(String.valueOf(dateTime1));
|
|
|
+ meterInfoBottomcode.setStartValue(BigDecimal.valueOf(value1));
|
|
|
+ meterInfoBottomcode.setEndTime(String.valueOf(dateTime2));
|
|
|
+ meterInfoBottomcode.setEndValue(BigDecimal.valueOf(value2));
|
|
|
+ meterInfoBottomcode.setDayValue(rfdl);
|
|
|
+ meterInfoBottomcode.setCode(pointcode);
|
|
|
+ meterInfoBottomcode.setMultiplyingPower(BigDecimal.valueOf(110000));
|
|
|
+ meterInfoBottomcode.insert();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|