Java数据聚合问题
public class Demo {
public static void main(String[] args) throws IOException {
HashMap<Object, Object> m1 = new HashMap<>();
m1.put("month","2020-06");
m1.put("plan_working_hours",272.5);
m1.put("month_total_working_hours",120);
m1.put("project_code","ToB-APP");
m1.put("this_years_total_working_hours",287);
m1.put("project_name","B端APP框架");
m1.put("total_working_hours",307);
HashMap<Object, Object> m2 = new HashMap<>();
m2.put("month","2020-07");
m2.put("plan_working_hours",272.5);
m2.put("month_total_working_hours",93);
m2.put("project_code","ToB-APP");
m2.put("this_years_total_working_hours",287);
m2.put("project_name","B端APP框架");
m2.put("total_working_hours",307);
HashMap<Object, Object> m3 = new HashMap<>();
m3.put("month","2020-11");
m3.put("plan_working_hours",104);
m3.put("month_total_working_hours",16);
m3.put("project_code","1001");
m3.put("this_years_total_working_hours",67);
m3.put("project_name","C端底座");
m3.put("total_working_hours",150);
HashMap<Object, Object> m4 = new HashMap<>();
m4.put("month","2020-12");
m4.put("plan_working_hours",104);
m4.put("month_total_working_hours",51);
m4.put("project_code","1001");
m4.put("this_years_total_working_hours",67);
m4.put("project_name","C端底座");
m4.put("total_working_hours",150);
ArrayList<Map> maps = new ArrayList<>();
maps.add(m1);
maps.add(m2);
maps.add(m3);
maps.add(m4);
//todo 做数据聚合(
// 将project_name值相同的数据中的month和month_total_working_hours聚合到一个list中
// 每个project_name只有一个map数据)
/**
* 格式如下
*
* {
* "monthList": ["2020-06":120 ,"2020-07":93]
* "plan_working_hours": 272.5,
* "project_code": "ToB-APP",
* "this_years_total_working_hours": 287,
* "project_name": "B端APP框架",
* "total_working_hours": 307
* },
*/
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…