|
@@ -202,26 +202,12 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
@Override
|
|
|
public Map<String, List> fpvTimeElectricity(String modelId) {
|
|
|
Map<String, List> res = new HashMap<>();
|
|
|
-
|
|
|
- List<Map<String,String>> tops = new ArrayList<>();
|
|
|
- List<Map<String,String>> peaks = new ArrayList<>();
|
|
|
- List<Map<String,String>> flat = new ArrayList<>();
|
|
|
- List<Map<String,String>> valleys = new ArrayList<>();
|
|
|
// 根据模型ID查询模型编码
|
|
|
String leanModelCode = queryLeanModelCodeById(modelId);
|
|
|
-
|
|
|
- if (oConvertUtils.isEmpty(leanModelCode)){
|
|
|
- res.put("tops",tops);
|
|
|
- res.put("peaks",peaks);
|
|
|
- res.put("flat",flat);
|
|
|
- res.put("valleys",valleys);
|
|
|
- return res;
|
|
|
- }
|
|
|
if (leanModelCode.equals(ModelCodeContant.LARGE_SCREEN_RUN_REALTIME)){
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
-
|
|
|
- // 获取当前日期 尖峰平谷 时长、用电、占比
|
|
|
+ // 获取当前日期
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -229,43 +215,20 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
String formattedDate = currentDate.format(formatter);
|
|
|
String queryDateParam = "";
|
|
|
queryDateParam = formattedDate;
|
|
|
-
|
|
|
query.addCriteria(Criteria.where("dates").is(queryDateParam));
|
|
|
-
|
|
|
// 执行查询
|
|
|
List<DeviceStatiscsModelMongodb> deviceStatiscsModelMongodbList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "leanmodel_large_screen_run_realtime");
|
|
|
if (oConvertUtils.listIsEmpty(deviceStatiscsModelMongodbList)){
|
|
|
- res.put("tops",tops);
|
|
|
- res.put("peaks",peaks);
|
|
|
- res.put("flat",flat);
|
|
|
- res.put("valleys",valleys);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
deviceStatiscsModelMongodbList.forEach(x -> {
|
|
|
if (x != null) {
|
|
|
- // 判空处理,确保 `getDatestr` 和其他方法返回的值不为 null
|
|
|
- if (x.getDatestr() != null && x.getTopsPower() != null) {
|
|
|
- tops.add(getMap(parseDate(x.getDatestr()), x.getTopsPower().toString()));
|
|
|
- }
|
|
|
- if (x.getDatestr() != null && x.getPeaksPower() != null) {
|
|
|
- peaks.add(getMap(parseDate(x.getDatestr()), x.getPeaksPower().toString()));
|
|
|
- }
|
|
|
- if (x.getDatestr() != null && x.getFlatPower() != null) {
|
|
|
- flat.add(getMap(parseDate(x.getDatestr()), x.getFlatPower().toString()));
|
|
|
- }
|
|
|
- if (x.getDatestr() != null && x.getValleysPower() != null) {
|
|
|
- valleys.add(getMap(parseDate(x.getDatestr()), x.getValleysPower().toString()));
|
|
|
- }
|
|
|
+ Map<String, String> map = getMap(parseDate(x.getDatestr()), x.getPower().toString(), x.getDeviceRegionId());
|
|
|
+ String time = map.get("regionId");
|
|
|
+ res.computeIfAbsent(time, k -> new ArrayList<>()).add(map);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- // 合并相同时间的值并更新到结果中
|
|
|
- res.put("tops", mergeListByTime(tops));
|
|
|
- res.put("peaks", mergeListByTime(peaks));
|
|
|
- res.put("flat", mergeListByTime(flat));
|
|
|
- res.put("valleys", mergeListByTime(valleys));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -405,9 +368,10 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
|
|
|
|
|
|
|
|
|
- private Map<String, String> getMap(Date date, String value) {
|
|
|
+ private Map<String, String> getMap(Date date, String value, String regionId) {
|
|
|
Map<String, String> res = new HashMap<>();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
|
|
|
+ res.put("regionId", regionId);
|
|
|
if (date != null) {
|
|
|
res.put("time", simpleDateFormat.format(date));
|
|
|
} else {
|