|
@@ -17,8 +17,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 【风-光-火-储能 实时明细表】Controller
|
|
@@ -70,11 +72,19 @@ public class MengxiVppRealTimePlanDataController extends BaseController {
|
|
|
});
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- List<String> times = new ArrayList<>();
|
|
|
+ Set<String> settime = new HashSet<>();
|
|
|
List<String> plan = new ArrayList<>();
|
|
|
for (MengxiVppRealTimePlanData m : list) {
|
|
|
- times.add(simpleDateFormat.format(new Date(m.getTime().getTime())));
|
|
|
- plan.add(String.valueOf(m.getPlan()));
|
|
|
+ settime.add(simpleDateFormat.format(new Date(m.getTime().getTime())));
|
|
|
+ }
|
|
|
+ List<String> times = new ArrayList<>(settime);
|
|
|
+ // 对List进行排序
|
|
|
+ Collections.sort(times);
|
|
|
+ for (String t : times) {
|
|
|
+ // 求和
|
|
|
+ List<MengxiVppRealTimePlanData> filterList = list.stream().filter(n -> simpleDateFormat.format(n.getTime()).equals(t)).collect(Collectors.toList());
|
|
|
+ BigDecimal sum = filterList.stream().map(s->new BigDecimal(s.getPlan().longValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ plan.add(sum.toString());
|
|
|
}
|
|
|
map.put("times", times);
|
|
|
map.put("plan", plan);
|