list合并数据

 

String result="{\"appl_sum:120000:SP:fh:20170407\":\"10000\",\"appl_count:120000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:130000:SP:fh:20170407\":\"10000\",\"appl_count:130000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:140000:SP:fh:20170407\":\"10000\",\"appl_count:140000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:150000:SP:fh:20170407\":\"10000\",\"appl_count:150000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:150000:SP:fl:20170407\":\"10000\",\"appl_count:150000:SP:fl:20170407\":\"1\""
+ ","+"\"appl_sum:150000:SP:fl:20170407\":\"10000\",\"appl_count:150000:SP:fl:20170407\":\"1\""
+ ","+"\"appl_sum:160000:SP:fh:20170407\":\"10000\",\"appl_count:160000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:170000:SP:fh:20170407\":\"10000\",\"appl_count:170000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:180000:SP:fh:20170407\":\"10000\",\"appl_count:180000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:180000:SP:d:20170407\":\"10000\",\"appl_count:180000:SP:d:20170407\":\"1\""
+ ","+"\"appl_sum:190000:SP:fh:20170407\":\"10000\",\"appl_count:190000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:200000:SP:fh:20170407\":\"10000\",\"appl_count:200000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:200000:SP:d:20170407\":\"10000\",\"appl_count:200000:SP:d:20170407\":\"1\""
+ ","+"\"appl_sum:210000:SP:fh:20170407\":\"10000\",\"appl_count:210000:SP:fh:20170407\":\"1\""
+ ","+"\"appl_sum:220000:SP:fh:20170407\":\"10000\",\"appl_count:220000:SP:fh:20170407\":\"1\""
+ "}";



                                                                     

List<RealTimeHandlModel> arr=new ArrayList<>();
Map<String , RealTimeHandlModel> map=new HashMap();
for (RealTimeHandlModel model : list) {
RealTimeHandlModel mo =new RealTimeHandlModel();
if(map.containsKey(model.getBranchNo())){//有这个branchNo的时候
mo=map.get(model.getBranchNo());
mo.setPrem((new BigDecimal(mo.getPrem()).add(new BigDecimal(model.getPrem())).toPlainString()));
mo.setCount((new BigDecimal(mo.getCount()).add(new BigDecimal(model.getCount())).toPlainString()));
map.replace(model.getBranchNo(), mo);
}else{//没有这个branchNo 10.9128370120301011000123012310
map.put(model.getBranchNo(), model);
}
}
for (String entryKey : map.keySet()) {
arr.add(map.get(entryKey));
}

System.out.println(list.size());
System.out.println(arr.size());
System.out.println(arr);

 

转载于:https://www.cnblogs.com/yongyao/p/6745477.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值