一开始总是报错Integer.parseInt java.lang.NumberFormatException: For input string:,查询是转换的问题,list拿到的是Object类型,多次转换计算数值,中间出错
public Result collectionStatistics(AccountRechargeRequest request) { LoggerUtils.infoData("/collectionStatistics", request); var list = databaseDao.statementDao.collectionStatistics(request); var eid = "employee_id"; HashMapsumMap = new HashMap (); for (var e : list) { if (e.containsKey(eid)) { e.put("name", SystemConfigService.findEmployeeName(Integer.parseInt(e.get(eid).toString()))); } else { e.put("name", "其他"); } } var r = new Result(list); ArrayList > result = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { var map = new HashMap (); var e = list.get(i); map.put("sum", e.get("sum") == null ? e.get("sum") : BigDecimal.valueOf(Double.parseDouble(e.get("sum").toString())).divide(BigDecimal.valueOf(1))); result.add(map); } double sumSalesVolume = result.stream().mapToDouble(e -> Double.valueOf(e.get("sum") == null ? "0" : e.get("sum").toString())).sum(); DecimalFormat format = new DecimalFormat("0"); Object sum = format.format(sumSalesVolume); sumMap.put("sumMap", sum); r.setSumMap(sumMap); return r; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)