|
@@ -21,6 +21,7 @@ import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.function.Function;
|
|
|
|
|
|
|
|
|
* Author: malijun
|
|
@@ -78,7 +79,7 @@ public class GetMeterInfo {
|
|
|
MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
meterInfoVo.setDate(dateTime1);
|
|
|
meterInfoVo.setName(meterInfoEquipment.getName());
|
|
|
- meterInfoVo.setRdl(meterInfoEquipment.getRfdl().divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
+ meterInfoVo.setRdl(meterInfoEquipment.getRfdl().divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_EVEN));
|
|
|
meterInfoVos.add(meterInfoVo);
|
|
|
}
|
|
|
}
|
|
@@ -247,7 +248,8 @@ public class GetMeterInfo {
|
|
|
|
|
|
List<MeterInfoEquipment> meterInfoEquipments = meterInfoEquipmentService.list(new QueryWrapper<MeterInfoEquipment>()
|
|
|
.in("date", dateTimes)
|
|
|
- .eq("equipment_nem_code", id)
|
|
|
+ .eq(StringUtil.isNotBlank(windId), "powerstation_nem_code", windId)
|
|
|
+ .eq(StringUtil.isNotBlank(id),"equipment_nem_code", id)
|
|
|
);
|
|
|
|
|
|
for (int i = 0; i <= between; i++) {
|
|
@@ -269,13 +271,14 @@ public class GetMeterInfo {
|
|
|
|
|
|
for (int j = 0; j <= betweenDay; j++) {
|
|
|
DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
- MeterInfoEquipment meterInfoEquipment = findMeterInfoEquipment(meterInfoEquipments, equipment.getNemCode(), dateTime3);
|
|
|
+
|
|
|
+ MeterInfoEquipment meterInfoEquipment = findObjectByCodeAndDate(meterInfoEquipments, equipment.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoEquipment::getEquipmentNemCode, MeterInfoEquipment::getDate);
|
|
|
if (meterInfoEquipment != null) {
|
|
|
ydl = ydl.add(meterInfoEquipment.getRfdl());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVo.setRdl(ydl.divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
meterInfoVos.add(meterInfoVo);
|
|
|
}
|
|
|
}
|
|
@@ -343,7 +346,8 @@ public class GetMeterInfo {
|
|
|
for (int j = 0; j <= betweenDay; j++) {
|
|
|
DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
|
|
|
- MeterInfoBottomcode meterInfoBottomcode = findMeterInfoBottomcode(meterInfoBottomcodes, meterPoint.getNemCode(), dateTime3);
|
|
|
+
|
|
|
+ MeterInfoBottomcode meterInfoBottomcode = findObjectByCodeAndDate(meterInfoBottomcodes, meterPoint.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoBottomcode::getCode, MeterInfoBottomcode::getStartTime);
|
|
|
if (meterInfoBottomcode != null) {
|
|
|
|
|
|
if (j == 0) {
|
|
@@ -420,7 +424,8 @@ public class GetMeterInfo {
|
|
|
BigDecimal ydl = BigDecimal.valueOf(0);
|
|
|
for (int j = 0; j <= betweenDay; j++) {
|
|
|
DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
- MeterInfoCalculating meterInfoCalculating = findMeterInfoCalculating(meterInfoCalculatings, meterPoint.getNemCode(), dateTime3);
|
|
|
+
|
|
|
+ MeterInfoCalculating meterInfoCalculating = findObjectByCodeAndDate(meterInfoCalculatings, meterPoint.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoCalculating::getCode, MeterInfoCalculating::getDate);
|
|
|
if (meterInfoCalculating != null) {
|
|
|
ydl = ydl.add(meterInfoCalculating.getValue());
|
|
|
}
|
|
@@ -434,6 +439,245 @@ public class GetMeterInfo {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getEquipmentInfoYearByWindId(String windId, String id, long startTime, long endTime) {
|
|
|
+
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format1 = simpleDateFormat.format(new Date(startTime));
|
|
|
+ String format2 = simpleDateFormat.format(new Date(endTime));
|
|
|
+
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
+
|
|
|
+ DateTime startDateTime = DateUtil.beginOfYear(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfYear(endDateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+
|
|
|
+ long between = ChronoUnit.YEARS.between(day1, day2);
|
|
|
+
|
|
|
+ long betweenDays = ChronoUnit.DAYS.between(day1, day2);
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ List<Equipment> equipments = equipmentService.list(new QueryWrapper<Equipment>()
|
|
|
+ .eq(StringUtil.isNotBlank(windId), "windpowerstation_id", windId)
|
|
|
+ .eq(StringUtil.isNotBlank(id), "nem_code", id)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= betweenDays; i++) {
|
|
|
+ DateTime dateTime4 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+ dateTimes.add(dateTime4);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeterInfoEquipment> meterInfoEquipments = meterInfoEquipmentService.list(new QueryWrapper<MeterInfoEquipment>()
|
|
|
+ .in("date", dateTimes)
|
|
|
+ .eq(StringUtil.isNotBlank(windId),"powerstation_nem_code", windId)
|
|
|
+ .eq(StringUtil.isNotBlank(id),"equipment_nem_code", id)
|
|
|
+ );
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i * 12);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfYear(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+
|
|
|
+ for (Equipment equipment : equipments) {
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(equipment.getName());
|
|
|
+
|
|
|
+ BigDecimal ndl = BigDecimal.valueOf(0);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ MeterInfoEquipment meterInfoEquipment = findObjectByCodeAndDate(meterInfoEquipments, equipment.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoEquipment::getEquipmentNemCode, MeterInfoEquipment::getDate);
|
|
|
+ if (meterInfoEquipment != null) {
|
|
|
+ ndl = ndl.add(meterInfoEquipment.getRfdl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ meterInfoVo.setRdl(ndl.divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getBottomInfoYearByWindId(String windId, String meterType, String meterClass, String name, long startTime, long endTime) {
|
|
|
+
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format1 = simpleDateFormat.format(new Date(startTime));
|
|
|
+ String format2 = simpleDateFormat.format(new Date(endTime));
|
|
|
+
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
+
|
|
|
+ DateTime startDateTime = DateUtil.beginOfYear(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfYear(endDateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+
|
|
|
+ long between = ChronoUnit.YEARS.between(day1, day2);
|
|
|
+
|
|
|
+ long betweenDays = ChronoUnit.DAYS.between(day1, day2);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
+ .eq("windpowerstation_id", windId)
|
|
|
+ .like("property", "CD")
|
|
|
+ .eq(StringUtil.isNotBlank(meterType), "meter_type", meterType)
|
|
|
+ .eq(StringUtil.isNotBlank(meterClass), "meter_class", meterClass)
|
|
|
+ .eq(StringUtil.isNotBlank(name), "name", name)
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= betweenDays; i++) {
|
|
|
+ DateTime dateTime4 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+ dateTimes.add(dateTime4);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeterInfoBottomcode> meterInfoBottomcodes = meterInfoBottomcodeService.list(new QueryWrapper<MeterInfoBottomcode>()
|
|
|
+ .in("start_time", dateTimes));
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i * 12);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfYear(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+
|
|
|
+ BigDecimal ndl = BigDecimal.valueOf(0);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+
|
|
|
+ MeterInfoBottomcode meterInfoBottomcode = findObjectByCodeAndDate(meterInfoBottomcodes, meterPoint.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoBottomcode::getCode, MeterInfoBottomcode::getStartTime);
|
|
|
+ if (meterInfoBottomcode != null) {
|
|
|
+
|
|
|
+ if (j == 0) {
|
|
|
+ meterInfoVo.setStartCode(meterInfoBottomcode.getStartValue());
|
|
|
+ }
|
|
|
+ ndl = ndl.add(meterInfoBottomcode.getDayValue());
|
|
|
+
|
|
|
+ meterInfoVo.setEndCode(meterInfoBottomcode.getEndValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ndl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoYearByWindId(String windId, String meterType, String meterClass, String name, long startTime, long endTime) {
|
|
|
+
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format1 = simpleDateFormat.format(new Date(startTime));
|
|
|
+ String format2 = simpleDateFormat.format(new Date(endTime));
|
|
|
+
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
+
|
|
|
+ DateTime startDateTime = DateUtil.beginOfYear(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfYear(endDateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+
|
|
|
+ long between = ChronoUnit.YEARS.between(day1, day2);
|
|
|
+
|
|
|
+ long betweenDays = ChronoUnit.DAYS.between(day1, day2);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
+ .eq("windpowerstation_id", windId)
|
|
|
+ .like("property", "JSD%")
|
|
|
+ .eq(StringUtil.isNotBlank(meterType), "meter_type", meterType)
|
|
|
+ .eq(StringUtil.isNotBlank(meterClass), "meter_class", meterClass)
|
|
|
+ .eq(StringUtil.isNotBlank(name), "name", name)
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= betweenDays; i++) {
|
|
|
+ DateTime dateTime4 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+ dateTimes.add(dateTime4);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeterInfoCalculating> meterInfoCalculatings = meterInfoCalculatingService.list(new QueryWrapper<MeterInfoCalculating>()
|
|
|
+ .in("date", dateTimes));
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i * 12);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfYear(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+ BigDecimal ndl = BigDecimal.valueOf(0);
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ MeterInfoCalculating meterInfoCalculating = findObjectByCodeAndDate(meterInfoCalculatings, meterPoint.getNemCode(), dateTime3.toLocalDateTime(), MeterInfoCalculating::getCode, MeterInfoCalculating::getDate);
|
|
|
+ if (meterInfoCalculating != null) {
|
|
|
+ ndl = ndl.add(meterInfoCalculating.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ndl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Nullable
|
|
|
+ private <T> T findObjectByCodeAndDate(@NotNull List<T> objects, String code, LocalDateTime date, Function<T, String> getCodeFunction, Function<T, LocalDateTime> getDateFunction) {
|
|
|
+ for (T object : objects) {
|
|
|
+ if (getCodeFunction.apply(object).equals(code) && getDateFunction.apply(object).toLocalDate().isEqual(date.toLocalDate())) {
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Nullable
|
|
|
private MeterInfoCalculating findMeterInfoCalculating(@NotNull List<MeterInfoCalculating> meterInfoCalculatings, String nemCode, DateTime date) {
|