|
@@ -7,19 +7,21 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gyee.gaia.meter.entity.MeterInfoBottomcode;
|
|
|
import com.gyee.gaia.meter.entity.MeterInfoCalculating;
|
|
|
import com.gyee.gaia.meter.entity.MeterInfoEquipment;
|
|
|
+import com.gyee.gaia.meter.entity.MeterPoint;
|
|
|
import com.gyee.gaia.meter.entity.vo.MeterInfoVo;
|
|
|
import com.gyee.gaia.meter.service.impl.MeterInfoBottomcodeServiceImpl;
|
|
|
import com.gyee.gaia.meter.service.impl.MeterInfoCalculatingServiceImpl;
|
|
|
import com.gyee.gaia.meter.service.impl.MeterInfoEquipmentServiceImpl;
|
|
|
+import com.gyee.gaia.meter.service.impl.MeterPointServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Author: malijun
|
|
@@ -34,23 +36,21 @@ public class GetMeterInfo {
|
|
|
MeterInfoEquipmentServiceImpl meterInfoEquipmentService;
|
|
|
@Resource
|
|
|
MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
|
|
|
+ @Resource
|
|
|
+ MeterPointServiceImpl meterPointService;
|
|
|
|
|
|
- //根据场站ID,开始时间,结束时间,查询获取场站下所有数据
|
|
|
public ArrayList<MeterInfoVo> getBottomInfoByWindId(String windId, long startTime, long endTime) {
|
|
|
|
|
|
- Date date1 = new Date(startTime);
|
|
|
- Date date2 = new Date(endTime);
|
|
|
-
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String format1 = simpleDateFormat.format(date1);
|
|
|
- String format2 = simpleDateFormat.format(date2);
|
|
|
+ String format1 = simpleDateFormat.format(new Date(startTime));
|
|
|
+ String format2 = simpleDateFormat.format(new Date(endTime));
|
|
|
|
|
|
//设置取值开始时间
|
|
|
- DateTime startDateTime = DateUtil.parse(format1);
|
|
|
-
|
|
|
- //设置取值结束时间
|
|
|
- DateTime endDateTime = DateUtil.parse(format2);
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.beginOfDay(endDateTime1);
|
|
|
|
|
|
//指定开始日期到结束日期的天数
|
|
|
LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
@@ -88,14 +88,18 @@ public class GetMeterInfo {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //根据场站ID,开始时间,结束时间,查询获取场站下所有数据
|
|
|
- public ArrayList<MeterInfoVo> getEquipmentInfoByWindId(String windId, String startTime, String endTime) {
|
|
|
+ public ArrayList<MeterInfoVo> getEquipmentInfoByWindId(String windId, 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 startDateTime = DateUtil.parse(startTime);
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
|
|
|
- //设置取值结束时间
|
|
|
- DateTime endDateTime = DateUtil.parse(endTime);
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.beginOfDay(endDateTime1);
|
|
|
|
|
|
//指定开始日期到结束日期的天数
|
|
|
LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
@@ -119,9 +123,18 @@ public class GetMeterInfo {
|
|
|
MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
meterInfoVo.setDate(dateTime1);
|
|
|
meterInfoVo.setName(meterInfoEquipment.getName());
|
|
|
- meterInfoVo.setRdl(meterInfoEquipment.getRfdl());
|
|
|
+ meterInfoVo.setRdl(meterInfoEquipment.getRfdl().divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
|
|
|
meterInfoVos.add(meterInfoVo);
|
|
|
}
|
|
|
+
|
|
|
+ MeterInfoCalculating meterInfoCalculating = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("windpowerstation_id", windId).eq("date", dateTime1).like("code", "%_FJFDL_P%"));
|
|
|
+ MeterInfoVo meterInfoVo1 = new MeterInfoVo();
|
|
|
+ meterInfoVo1.setDate(dateTime1);
|
|
|
+ meterInfoVo1.setName(meterInfoCalculating.getName());
|
|
|
+ meterInfoVo1.setRdl(meterInfoCalculating.getValue());
|
|
|
+ meterInfoVos.add(meterInfoVo1);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
System.out.println(meterInfoVos.size());
|
|
|
|
|
@@ -131,14 +144,18 @@ public class GetMeterInfo {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //根据场站ID,开始时间,结束时间,查询获取场站下所有数据
|
|
|
- public ArrayList<MeterInfoVo> getCalculatingInfoByWindId(String windId, String startTime, String endTime) {
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoByWindId(String windId, 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 startDateTime = DateUtil.parse(startTime);
|
|
|
+ DateTime startDateTime1 = DateUtil.parse(format1);
|
|
|
+ DateTime endDateTime1 = DateUtil.parse(format2);
|
|
|
|
|
|
- //设置取值结束时间
|
|
|
- DateTime endDateTime = DateUtil.parse(endTime);
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.beginOfDay(endDateTime1);
|
|
|
|
|
|
//指定开始日期到结束日期的天数
|
|
|
LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
@@ -173,4 +190,588 @@ public class GetMeterInfo {
|
|
|
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoMonthByWindId1(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.beginOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ //指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.offsetMonth(startDateTime, i + 1);
|
|
|
+
|
|
|
+ List<MeterInfoCalculating> meterInfoCalculatingList = meterInfoCalculatingService.list(new QueryWrapper<MeterInfoCalculating>().eq("windpowerstation_id", windId).eq("date", dateTime1).like("code", "%_MONTH"));
|
|
|
+ //遍历集合
|
|
|
+
|
|
|
+
|
|
|
+ for (MeterInfoCalculating meterInfoCalculating : meterInfoCalculatingList) {
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterInfoCalculating.getName());
|
|
|
+ meterInfoVo.setRdl(meterInfoCalculating.getValue());
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(meterInfoVos.size());
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改后
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoMonthByWindId(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ long betweenDays = ChronoUnit.DAYS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
+ .eq("windpowerstation_id", windId)
|
|
|
+ .like("property", "JSD%"));
|
|
|
+
|
|
|
+
|
|
|
+ // 批量查询MeterInfoCalculating数据
|
|
|
+ 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);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ System.out.println(meterPoint.getName());
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+
|
|
|
+ BigDecimal ydl = BigDecimal.valueOf(0);
|
|
|
+ System.out.println("ydl开始值" + ydl);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ System.out.println("J的值(第-1天)" + j);
|
|
|
+
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+// MeterInfoCalculating meterInfoCalculating = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", meterPoint.getNemCode()).eq("date", dateTime3));
|
|
|
+ MeterInfoCalculating meterInfoCalculating = findMeterInfoCalculating(meterInfoCalculatings, meterPoint.getNemCode(), dateTime3);
|
|
|
+
|
|
|
+ if (meterInfoCalculating != null) {
|
|
|
+ ydl = ydl.add(meterInfoCalculating.getValue());
|
|
|
+ System.out.println("当月每天累加" + ydl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getEquipmentInfoMonthByWindId1(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.beginOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ //指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.offsetMonth(startDateTime, i + 1);
|
|
|
+
|
|
|
+ List<MeterInfoCalculating> meterInfoCalculatingList = meterInfoCalculatingService.list(new QueryWrapper<MeterInfoCalculating>().eq("windpowerstation_id", windId).eq("date", dateTime1).like("code", "%_FJFDL_P%"));
|
|
|
+ //遍历集合
|
|
|
+
|
|
|
+ for (MeterInfoCalculating meterInfoCalculating : meterInfoCalculatingList) {
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterInfoCalculating.getName());
|
|
|
+ meterInfoVo.setRdl(meterInfoCalculating.getValue());
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ System.out.println(meterInfoVos.size());
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改后
|
|
|
+ public ArrayList<MeterInfoVo> getEquipmentInfoMonthByWindId(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>().eq("windpowerstation_id", windId).eq("meter_type", "风机发电量"));
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ System.out.println(meterPoint.getName());
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+
|
|
|
+ BigDecimal ydl = BigDecimal.valueOf(0);
|
|
|
+ System.out.println("ydl开始值" + ydl);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ System.out.println("J的值(第-1天)" + j);
|
|
|
+
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ MeterInfoCalculating meterInfoCalculating = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", meterPoint.getNemCode()).eq("date", dateTime3));
|
|
|
+
|
|
|
+ if (meterInfoCalculating != null) {
|
|
|
+ ydl = ydl.add(meterInfoCalculating.getValue());
|
|
|
+ System.out.println("当月每天累加" + ydl);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getBottomInfoMonthByWindId(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>().eq("windpowerstation_id", windId).eq("property", "CD"));
|
|
|
+
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ System.out.println(meterPoint.getName());
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+
|
|
|
+ BigDecimal ydl = BigDecimal.valueOf(0);
|
|
|
+ System.out.println("ydl开始值" + ydl);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ System.out.println("J的值(第-1天)" + j);
|
|
|
+
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ MeterInfoBottomcode meterInfoBottomcode = meterInfoBottomcodeService.getOne(new QueryWrapper<MeterInfoBottomcode>().eq("code", meterPoint.getNemCode()).eq("start_time", dateTime3));
|
|
|
+
|
|
|
+ if (meterInfoBottomcode != null) {
|
|
|
+ ydl = ydl.add(meterInfoBottomcode.getDayValue());
|
|
|
+ System.out.println("当月每天累加" + ydl);
|
|
|
+
|
|
|
+ if (j == 0) {
|
|
|
+ meterInfoVo.setStartCode(meterInfoBottomcode.getStartValue());
|
|
|
+ }
|
|
|
+ if (!(meterInfoBottomcode.getStartValue() == null)) {
|
|
|
+ meterInfoVo.setEndCode(meterInfoBottomcode.getEndValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //优化后,时间存可能不对
|
|
|
+ public ArrayList<MeterInfoVo> getBottomInfoMonthByWindId1(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>().eq("windpowerstation_id", windId).eq("property", "CD"));
|
|
|
+
|
|
|
+ // 提前生成需要查询的日期列表
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+ dateTimes.add(dateTime1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量查询指定日期范围内的数据
|
|
|
+ List<MeterInfoBottomcode> meterInfoBottomcodes = meterInfoBottomcodeService
|
|
|
+ .list(new QueryWrapper<MeterInfoBottomcode>().in("start_time", dateTimes));
|
|
|
+
|
|
|
+ Map<DateTime, MeterInfoBottomcode> meterInfoBottomcodeMap = new HashMap<>();
|
|
|
+ for (MeterInfoBottomcode meterInfoBottomcode : meterInfoBottomcodes) {
|
|
|
+ meterInfoBottomcodeMap.put(new DateTime(meterInfoBottomcode.getStartTime()), meterInfoBottomcode);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for (DateTime dateTime1 : dateTimes) {
|
|
|
+ DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这天相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ System.out.println(meterPoint.getName());
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+
|
|
|
+ BigDecimal ydl = BigDecimal.valueOf(0);
|
|
|
+ System.out.println("ydl开始值" + ydl);
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ System.out.println("J的值(第-1天)" + j);
|
|
|
+
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ MeterInfoBottomcode meterInfoBottomcode = meterInfoBottomcodeMap.get(dateTime3);
|
|
|
+
|
|
|
+ if (meterInfoBottomcode != null) {
|
|
|
+ ydl = ydl.add(meterInfoBottomcode.getDayValue());
|
|
|
+ System.out.println("当天累加" + ydl);
|
|
|
+
|
|
|
+ if (j == 0) {
|
|
|
+ meterInfoVo.setStartCode(meterInfoBottomcode.getStartValue());
|
|
|
+ }
|
|
|
+ if (meterInfoBottomcode.getEndValue() != null) {
|
|
|
+ meterInfoVo.setEndCode(meterInfoBottomcode.getEndValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ //没有按月累加
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoMonthByWindId3(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+
|
|
|
+ // 批量查询MeterPoint列表
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
+ .eq("windpowerstation_id", windId)
|
|
|
+ .like("property", "JSD%"));
|
|
|
+
|
|
|
+ // 批量查询MeterInfoCalculating数据
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ DateTime dateTime4 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+
|
|
|
+ dateTimes.add(dateTime4);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeterInfoCalculating> meterInfoCalculatings = meterInfoCalculatingService.list(new QueryWrapper<MeterInfoCalculating>()
|
|
|
+ .in("date", dateTimes));
|
|
|
+ System.out.println("先查询的集合大小" + meterInfoCalculatings.size());
|
|
|
+
|
|
|
+ // 处理查询结果,按月累加数据
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setRdl(BigDecimal.ZERO);
|
|
|
+ BigDecimal ydl = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ // 查找对应日期的MeterInfoCalculating对象
|
|
|
+ MeterInfoCalculating meterInfoCalculating = findMeterInfoCalculating(meterInfoCalculatings, meterPoint.getNemCode(), dateTime3);
|
|
|
+
|
|
|
+ if (meterInfoCalculating != null) {
|
|
|
+ ydl = ydl.add(meterInfoCalculating.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ meterInfoVos.add(meterInfoVo);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 辅助方法,根据日期和NemCode查找MeterInfoCalculating对象
|
|
|
+ private MeterInfoCalculating findMeterInfoCalculating(List<MeterInfoCalculating> meterInfoCalculatings, String nemCode, DateTime date) {
|
|
|
+ for (MeterInfoCalculating meterInfoCalculating : meterInfoCalculatings) {
|
|
|
+ if (meterInfoCalculating.getCode().equals(nemCode) && DateUtil.isSameDay(new DateTime(meterInfoCalculating.getDate()), date)) {
|
|
|
+ return meterInfoCalculating;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ArrayList<MeterInfoVo> getCalculatingInfoMonthByWindId4(String windId, 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.beginOfMonth(startDateTime1);
|
|
|
+ DateTime endDateTime = DateUtil.endOfMonth(endDateTime1);
|
|
|
+
|
|
|
+ // 指定开始日期到结束日期的天数
|
|
|
+ LocalDateTime day1 = LocalDateTimeUtil.of(startDateTime);
|
|
|
+ LocalDateTime day2 = LocalDateTimeUtil.of(endDateTime);
|
|
|
+ long between = ChronoUnit.MONTHS.between(day1, day2);
|
|
|
+ System.out.println("相差月数" + between);
|
|
|
+
|
|
|
+ ArrayList<MeterInfoVo> meterInfoVos = new ArrayList<>();
|
|
|
+ Map<String, MeterInfoVo> meterInfoMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 批量查询MeterPoint列表
|
|
|
+ List<MeterPoint> meterPoints = meterPointService.list(new QueryWrapper<MeterPoint>()
|
|
|
+ .eq("windpowerstation_id", windId)
|
|
|
+ .like("property", "JSD%"));
|
|
|
+
|
|
|
+ // 批量查询MeterInfoCalculating数据
|
|
|
+ List<DateTime> dateTimes = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ DateTime dateTime4 = DateUtil.offsetDay(startDateTime, i);
|
|
|
+
|
|
|
+ dateTimes.add(dateTime4);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeterInfoCalculating> meterInfoCalculatings = meterInfoCalculatingService.list(new QueryWrapper<MeterInfoCalculating>()
|
|
|
+ .in("date", dateTimes));
|
|
|
+ System.out.println("先查询的集合大小" + meterInfoCalculatings.size());
|
|
|
+
|
|
|
+ // 处理查询结果,按月累加数据
|
|
|
+ for (int i = 0; i <= between; i++) {
|
|
|
+ DateTime dateTime1 = DateUtil.offsetMonth(startDateTime, i);
|
|
|
+ DateTime dateTime2 = DateUtil.endOfMonth(dateTime1);
|
|
|
+
|
|
|
+ LocalDateTime day3 = LocalDateTimeUtil.of(dateTime1);
|
|
|
+ LocalDateTime day4 = LocalDateTimeUtil.of(dateTime2);
|
|
|
+ long betweenDay = ChronoUnit.DAYS.between(day3, day4);
|
|
|
+ System.out.println("这月相差天数:" + betweenDay);
|
|
|
+
|
|
|
+ for (MeterPoint meterPoint : meterPoints) {
|
|
|
+ String nemCode = meterPoint.getNemCode();
|
|
|
+
|
|
|
+ MeterInfoVo meterInfoVo = meterInfoMap.get(nemCode);
|
|
|
+ if (meterInfoVo == null) {
|
|
|
+ meterInfoVo = new MeterInfoVo();
|
|
|
+ meterInfoVo.setName(meterPoint.getName());
|
|
|
+ meterInfoVo.setDate(dateTime1);
|
|
|
+ meterInfoVo.setRdl(BigDecimal.ZERO);
|
|
|
+ meterInfoMap.put(nemCode, meterInfoVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal ydl = meterInfoVo.getRdl();
|
|
|
+
|
|
|
+ for (int j = 0; j <= betweenDay; j++) {
|
|
|
+ DateTime dateTime3 = DateUtil.offsetDay(dateTime1, j);
|
|
|
+
|
|
|
+ // 查找对应日期的MeterInfoCalculating对象
|
|
|
+ MeterInfoCalculating meterInfoCalculating = findMeterInfoCalculating(meterInfoCalculatings, nemCode, dateTime3);
|
|
|
+
|
|
|
+ if (meterInfoCalculating != null) {
|
|
|
+ ydl = ydl.add(meterInfoCalculating.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ meterInfoVo.setRdl(ydl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加所有MeterInfoVo对象到列表
|
|
|
+ meterInfoVos.addAll(meterInfoMap.values());
|
|
|
+
|
|
|
+ return meterInfoVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 辅助方法,根据日期和NemCode查找MeterInfoCalculating对象
|
|
|
+
|
|
|
+
|
|
|
+}
|