@Test public void testConvertMap() throws Exception { }
private List<HashMap> convertMap(List<HashMap> statistics){ Map<String, HashMap> map = new HashMap<>(); List<HashMap> result = new ArrayList<>(); for(HashMap s: statistics){ String userName = s.get("name").toString(); String type = s.get("type").toString(); BigDecimal totalMoney = (BigDecimal) s.get("total_money"); if (!map.containsKey(userName)) { map.put(userName, new HashMap()); map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } else{ map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } } Iterator ite = map.entrySet().iterator(); int i = 0; while(ite.hasNext()){ Map.Entry string = (Map.Entry)ite.next(); result.add(i, (HashMap) string.getValue()); i++; } return result; }
DoctorStatisticsServiceImpl implements DoctorStatisticsService { private List<HashMap> convertMap(List<HashMap> statistics){ Map<String, HashMap> map = new HashMap<>(); List<HashMap> result = new ArrayList<>(); for(HashMap s: statistics){ String userName = s.get("name").toString(); String type = s.get("type").toString(); BigDecimal totalMoney = (BigDecimal) s.get("total_money"); if (!map.containsKey(userName)) { map.put(userName, new HashMap()); map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } else{ map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } } Iterator ite = map.entrySet().iterator(); int i = 0; while(ite.hasNext()){ Map.Entry string = (Map.Entry)ite.next(); result.add(i, (HashMap) string.getValue()); i++; } return result; } }
DoctorStatisticsServiceImpl implements DoctorStatisticsService { private List<HashMap> convertMap(List<HashMap> statistics){ Map<String, HashMap> map = new HashMap<>(); List<HashMap> result = new ArrayList<>(); for(HashMap s: statistics){ String userName = s.get("name").toString(); String type = s.get("type").toString(); BigDecimal totalMoney = (BigDecimal) s.get("total_money"); if (!map.containsKey(userName)) { map.put(userName, new HashMap()); map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } else{ map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } } Iterator ite = map.entrySet().iterator(); int i = 0; while(ite.hasNext()){ Map.Entry string = (Map.Entry)ite.next(); result.add(i, (HashMap) string.getValue()); i++; } return result; }  }
DoctorStatisticsServiceImpl implements DoctorStatisticsService { private List<HashMap> convertMap(List<HashMap> statistics){ Map<String, HashMap> map = new HashMap<>(); List<HashMap> result = new ArrayList<>(); for(HashMap s: statistics){ String userName = s.get("name").toString(); String type = s.get("type").toString(); BigDecimal totalMoney = (BigDecimal) s.get("total_money"); if (!map.containsKey(userName)) { map.put(userName, new HashMap()); map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } else{ map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } } Iterator ite = map.entrySet().iterator(); int i = 0; while(ite.hasNext()){ Map.Entry string = (Map.Entry)ite.next(); result.add(i, (HashMap) string.getValue()); i++; } return result; }  @Override CommonResult doctorStatistics(String beginDateStr, String endDateStr); @Override CommonResult doctorStatisticsByUserIdAndDate(String dateStr, Integer userId); }
DoctorStatisticsServiceImpl implements DoctorStatisticsService { private List<HashMap> convertMap(List<HashMap> statistics){ Map<String, HashMap> map = new HashMap<>(); List<HashMap> result = new ArrayList<>(); for(HashMap s: statistics){ String userName = s.get("name").toString(); String type = s.get("type").toString(); BigDecimal totalMoney = (BigDecimal) s.get("total_money"); if (!map.containsKey(userName)) { map.put(userName, new HashMap()); map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } else{ map.get(userName).put("userName", userName); map.get(userName).put(type, totalMoney); } } Iterator ite = map.entrySet().iterator(); int i = 0; while(ite.hasNext()){ Map.Entry string = (Map.Entry)ite.next(); result.add(i, (HashMap) string.getValue()); i++; } return result; }  @Override CommonResult doctorStatistics(String beginDateStr, String endDateStr); @Override CommonResult doctorStatisticsByUserIdAndDate(String dateStr, Integer userId);  }