|
@@ -28,10 +28,11 @@ public class NetCardInfoLogServiceImpl implements NetCardInfoLogService {
|
|
String[] split = nowDate.split("-");
|
|
String[] split = nowDate.split("-");
|
|
String year = split[0];
|
|
String year = split[0];
|
|
String month = split[1];
|
|
String month = split[1];
|
|
|
|
+ String monthStr = year + "-" + month;
|
|
if (netCardLogVO.getDataType() == 1) {
|
|
if (netCardLogVO.getDataType() == 1) {
|
|
return getNetCardLogListByLampIdAndYear(netCardLogVO.getLampId(), year, month);
|
|
return getNetCardLogListByLampIdAndYear(netCardLogVO.getLampId(), year, month);
|
|
}
|
|
}
|
|
- return getNetCardLogListByLampIdAndMonth(netCardLogVO.getLampId(), year, month);
|
|
|
|
|
|
+ return getNetCardLogListByLampIdAndMonth(netCardLogVO.getLampId(), year, monthStr);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -50,7 +51,7 @@ public class NetCardInfoLogServiceImpl implements NetCardInfoLogService {
|
|
List<Object> dataList = new ArrayList<>();
|
|
List<Object> dataList = new ArrayList<>();
|
|
List<Object> dateList = new ArrayList<>();
|
|
List<Object> dateList = new ArrayList<>();
|
|
|
|
|
|
- LocalDate firstDayOfMonth = LocalDate.parse(year + "-" + month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
|
+ LocalDate firstDayOfMonth = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
LocalDate lastDayOfMonth = firstDayOfMonth.withDayOfMonth(firstDayOfMonth.lengthOfMonth());
|
|
LocalDate lastDayOfMonth = firstDayOfMonth.withDayOfMonth(firstDayOfMonth.lengthOfMonth());
|
|
|
|
|
|
DecimalFormat df = new DecimalFormat("0.##");
|
|
DecimalFormat df = new DecimalFormat("0.##");
|
|
@@ -86,7 +87,7 @@ public class NetCardInfoLogServiceImpl implements NetCardInfoLogService {
|
|
allMonths.add(String.format("%s-%02d", year, i));
|
|
allMonths.add(String.format("%s-%02d", year, i));
|
|
}
|
|
}
|
|
|
|
|
|
- // 按月份分组,取每个月的最后一笔记录
|
|
|
|
|
|
+ // 将 logs 转换为 Map,键为月份,值为 NetCardInfoLogDTO
|
|
Map<String, NetCardInfoLogDTO> monthlyLogs = logs.stream()
|
|
Map<String, NetCardInfoLogDTO> monthlyLogs = logs.stream()
|
|
.collect(Collectors.toMap(
|
|
.collect(Collectors.toMap(
|
|
log -> log.getUpdateTime().substring(0, 7), // 取前7个字符,即 "YYYY-MM"
|
|
log -> log.getUpdateTime().substring(0, 7), // 取前7个字符,即 "YYYY-MM"
|
|
@@ -101,7 +102,7 @@ public class NetCardInfoLogServiceImpl implements NetCardInfoLogService {
|
|
DecimalFormat df = new DecimalFormat("0.##");
|
|
DecimalFormat df = new DecimalFormat("0.##");
|
|
// 遍历所有月份,填充 dataList 和 dateList
|
|
// 遍历所有月份,填充 dataList 和 dateList
|
|
for (String months : allMonths) {
|
|
for (String months : allMonths) {
|
|
- NetCardInfoLogDTO log = monthlyLogs.get(month);
|
|
|
|
|
|
+ NetCardInfoLogDTO log = monthlyLogs.get(months);
|
|
double usage = log != null ? log.getUseGprs() : 0.0;
|
|
double usage = log != null ? log.getUseGprs() : 0.0;
|
|
dataList.add(df.format(usage));
|
|
dataList.add(df.format(usage));
|
|
dateList.add(months);
|
|
dateList.add(months);
|