|
@@ -2,17 +2,22 @@ package com.gyee.gaia.meter.service;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.gyee.gaia.meter.adapter.Adapter;
|
|
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.MeterInfoEquipment;
|
|
import com.gyee.gaia.meter.entity.PointData;
|
|
import com.gyee.gaia.meter.entity.PointData;
|
|
import com.gyee.gaia.meter.entity.TestingPoint;
|
|
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.service.impl.TestingPointServiceImpl;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -29,6 +34,9 @@ class AdapterServiceTest {
|
|
@Resource
|
|
@Resource
|
|
TestingPointServiceImpl testingPointService;
|
|
TestingPointServiceImpl testingPointService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ EquipmentServiceImpl equipmentService;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -49,62 +57,174 @@ class AdapterServiceTest {
|
|
@Test
|
|
@Test
|
|
void saveEquipmentRfdl() {
|
|
void saveEquipmentRfdl() {
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-
|
|
|
|
List<TestingPoint> list = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").like("code", "%_FJ_%"));
|
|
List<TestingPoint> list = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").like("code", "%_FJ_%"));
|
|
|
|
|
|
|
|
|
|
System.out.println(list.size());
|
|
System.out.println(list.size());
|
|
- String pointcode = list.get(0).getCode();
|
|
|
|
-
|
|
|
|
|
|
|
|
-
|
|
+
|
|
- String strsss = "2023-04-1";
|
|
+ for (TestingPoint testingPoint : list) {
|
|
- DateTime dateTime = DateUtil.parse(strsss);
|
|
+
|
|
- System.out.println(dateTime);
|
|
+ String pointcode = testingPoint.getCode();
|
|
- long time = dateTime.getTime();
|
|
+
|
|
- System.out.println(time);
|
|
+ String thingId = testingPoint.getThingId();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<String, PointData> historySection1 = adapter.getHistorySection(pointcode, dateTime1.getTime());
|
|
|
|
+ double value1 = historySection1.get(pointcode).getValue();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<String, PointData> historySection2 = adapter.getHistorySection(pointcode, dateTime2.getTime());
|
|
|
|
+ double value2 = historySection2.get(pointcode).getValue();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BigDecimal bigDecimal1 = new BigDecimal(Double.toString(value1));
|
|
|
|
+ BigDecimal bigDecimal2 = new BigDecimal(Double.toString(value2));
|
|
|
|
+ BigDecimal rfdl = bigDecimal2.subtract(bigDecimal1);
|
|
|
|
+ System.out.println(rfdl + "Kwh");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Equipment thingId1 = equipmentService.getOne(new QueryWrapper<Equipment>().eq("nem_code", thingId));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ MeterInfoEquipment meterInfoEquipment = new MeterInfoEquipment();
|
|
|
|
+ meterInfoEquipment.setCompanyNemCode("NX_GDDL_ZGS");
|
|
|
|
+ meterInfoEquipment.setPowerstationNemCode(thingId1.getWindpowerstationId());
|
|
|
|
+ meterInfoEquipment.setProjectNemCode(thingId1.getProjectId());
|
|
|
|
+ meterInfoEquipment.setLineNemCode(thingId1.getLineId());
|
|
|
|
+ meterInfoEquipment.setEquipmentNemCode(thingId1.getNemCode());
|
|
|
|
+ meterInfoEquipment.setName(thingId1.getName());
|
|
|
|
+ meterInfoEquipment.setDate(DateUtil.format(dateTime2, "yyyy-MM-dd"));
|
|
|
|
+ meterInfoEquipment.setRfdl(rfdl);
|
|
|
|
+ meterInfoEquipment.insert();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- DateTime dateTime1 = DateUtil.beginOfDay(dateTime);
|
|
|
|
- System.out.println("第一天开始" + dateTime1);
|
|
|
|
|
|
|
|
- DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
|
|
+ }
|
|
- System.out.println("第一天结束" + dateTime2);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<PointData> historySection1 = adapter.getHistorySnap(pointcode, dateTime1.getTime(),DateUtil.offsetSecond(dateTime1, 1).getTime());
|
|
|
|
- System.out.println(historySection1);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<PointData> historySection2 = adapter.getHistorySnap(pointcode, dateTime2.getTime(),DateUtil.offsetSecond(dateTime2, 1).getTime());
|
|
|
|
- System.out.println(historySection2);
|
|
|
|
|
|
|
|
|
|
|
|
- dateTime1 = DateUtil.offsetSecond(dateTime2, 1);
|
|
+
|
|
- System.out.println("第二天开始" + dateTime1);
|
|
+
|
|
|
|
|
|
- dateTime2 = DateUtil.endOfDay(dateTime1);
|
|
+
|
|
- System.out.println("第二天结束" + dateTime2);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
-
|
|
+
|
|
|
|
|
|
-
|
|
+
|
|
|
|
+ */
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- }
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|