|
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 能效情况工厂
|
|
@@ -190,12 +191,33 @@ public class EnergyEfficiencyFactory {
|
|
|
* 获取月内每日能效
|
|
|
*
|
|
|
* @param dailyEnergyEfficiency 每日能效列表
|
|
|
+ * @param reportMonth 报告月
|
|
|
* @return 月内每日能效
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/7/23 11:09 上午
|
|
|
*/
|
|
|
public AttrValueVO getDailyData(
|
|
|
- List<EnergyEfficiencyDataVO> dailyEnergyEfficiency) {
|
|
|
+ List<EnergyEfficiencyDataVO> dailyEnergyEfficiency, Date reportMonth) {
|
|
|
+ /* 每日能效列表中不一定包含报告月所有时间的数据,如果不包含某天的数据,将这天的数据设置为空,添加到每日能效列表中 */
|
|
|
+ // 获取当前能效列表中包含的日期
|
|
|
+ if (dailyEnergyEfficiency == null) {
|
|
|
+ dailyEnergyEfficiency = new ArrayList<>();
|
|
|
+ }
|
|
|
+ Set<String> timeSet = dailyEnergyEfficiency.stream().
|
|
|
+ map(EnergyEfficiencyDataVO::getTime).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 遍历报告月日期,补全数据
|
|
|
+ List<String> dayListOfMonth = DateUtils.getDayListOfMonth(reportMonth, DateUtils.SDF_SECOND);
|
|
|
+ if (CollectionUtils.isEmpty(dayListOfMonth)) {
|
|
|
+ throw new IllegalArgumentException("获取指定月份日期列表失败:" + reportMonth);
|
|
|
+ }
|
|
|
+ for (String day : dayListOfMonth) {
|
|
|
+ if (!timeSet.contains(day)) {
|
|
|
+ EnergyEfficiencyDataVO energyEfficiencyDataVO = new EnergyEfficiencyDataVO(day, null);
|
|
|
+ dailyEnergyEfficiency.add(energyEfficiencyDataVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Gson gson = new Gson();
|
|
|
return new AttrValueVO(ProjectEnergyEfficiencyContentCodes.dailyData.name(),
|
|
|
gson.toJson(dailyEnergyEfficiency), AttrValueTypeEnum.list);
|
|
@@ -330,7 +352,7 @@ public class EnergyEfficiencyFactory {
|
|
|
AttrValueVO minDays = getMinDays(dailyEnergyEfficiency);
|
|
|
attrValues.add(minDays);
|
|
|
// 每日能效
|
|
|
- AttrValueVO dailyData = getDailyData(dailyEnergyEfficiency);
|
|
|
+ AttrValueVO dailyData = getDailyData(dailyEnergyEfficiency, reportMonth);
|
|
|
attrValues.add(dailyData);
|
|
|
|
|
|
// 合格标准
|