|
@@ -21,12 +21,11 @@ import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static net.sf.jsqlparser.parser.feature.Feature.limit;
|
|
|
-
|
|
|
/**
|
|
|
* @Description: 区域管理信息表
|
|
|
* @Author: jeecg-boot
|
|
@@ -50,6 +49,8 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
|
|
|
List<Map<String, Object>> arrayList = new ArrayList<>();
|
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
// 获取当天的开始和结束时间
|
|
|
LocalDate today = LocalDate.now();
|
|
|
String startOfDayString = today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00";
|
|
@@ -152,7 +153,13 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
|
|
|
String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
|
|
|
String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
|
|
|
- Map peaksAndValleysTimeMap = fpgGatherDataMapper.getFpgTheLeftSideOneData(deviceRegion.getId(), startDate, endDate);
|
|
|
+
|
|
|
+ LocalDateTime start_time = adjustCrossDay(LocalDateTime.parse(startDate, formatter), LocalDateTime.parse(endDate, formatter));
|
|
|
+
|
|
|
+ // 转换为字符串
|
|
|
+ String formattedStartTime = start_time.format(formatter);
|
|
|
+
|
|
|
+ Map peaksAndValleysTimeMap = fpgGatherDataMapper.getFpgTheLeftSideOneData(deviceRegion.getId(), formattedStartTime, endDate);
|
|
|
if (peaksAndValleysTimeMap != null) {
|
|
|
if ("tops".equals(peaksAndValleysTime.getType())) { // 尖值处理
|
|
|
BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
@@ -233,11 +240,6 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
powerMap.put(deviceRegion.getRegionTitle() + "谷时段总功率占比", "0%");
|
|
|
}
|
|
|
|
|
|
-// deviceInformationWrapper.eq(DeviceInformation::getDeviceRegionId, deviceRegion.getId())
|
|
|
-// .orderByAsc(DeviceInformation::getDeviceType);
|
|
|
-// ;
|
|
|
-// List<DeviceInformation> deviceInformations = deviceInformationMapper.selectList(deviceInformationWrapper);
|
|
|
-
|
|
|
List<String> stringList = new ArrayList<>();
|
|
|
stringList.add("1");
|
|
|
stringList.add("2");
|
|
@@ -269,7 +271,13 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
for (PeaksAndValleysTimeConfig peaksAndValleysTimeConfig : peaksAndValleysTimeConfiglist) {
|
|
|
String startDate = dayDate + " " + peaksAndValleysTimeConfig.getStartTime();
|
|
|
String endDate = dayDate + " " + peaksAndValleysTimeConfig.getEndTime();
|
|
|
- Map peaksAndValleysTimeMap = fpgGatherDataMapper.getDeviceTypeData(deviceIds, startDate, endDate);
|
|
|
+
|
|
|
+ LocalDateTime start_time = adjustCrossDay(LocalDateTime.parse(startDate, formatter), LocalDateTime.parse(endDate, formatter));
|
|
|
+
|
|
|
+ // 转换为字符串
|
|
|
+ String formattedStartTime = start_time.format(formatter);
|
|
|
+
|
|
|
+ Map peaksAndValleysTimeMap = fpgGatherDataMapper.getDeviceTypeData(deviceIds, formattedStartTime, endDate);
|
|
|
if (peaksAndValleysTimeMap != null) {
|
|
|
if ("tops".equals(peaksAndValleysTimeConfig.getType())) { // 尖值处理
|
|
|
BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
@@ -364,7 +372,6 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
powerMap.put("公司平时段总功率", companyFlatPower);
|
|
|
powerMap.put("公司谷时段总功率", companyValleysPower);
|
|
|
|
|
|
-
|
|
|
// // 假设 powerMap 里已经包含了公司相关的总功率
|
|
|
// BigDecimal companyTotalPower = companyAccumulatedTotalPower != null ? companyAccumulatedTotalPower : BigDecimal.ZERO; // 公司累计总功率
|
|
|
|
|
@@ -424,4 +431,12 @@ public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, Dev
|
|
|
BigDecimal percentage = ratio.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
|
|
|
return percentage.stripTrailingZeros().toPlainString() + "%";
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private LocalDateTime adjustCrossDay(LocalDateTime start, LocalDateTime end) {
|
|
|
+ if (end.isBefore(start)) {
|
|
|
+ return start.minusDays(1);
|
|
|
+ }
|
|
|
+ return start;
|
|
|
+ }
|
|
|
}
|