简体   繁体   English

如何从DAO迭代多个数据

[英]How to iterate multiple data from DAO

My code is like 我的代码就像

for (Integer catId: catIds) {
        List<Object[]> objectList = invoiceDAO.periodWiseSalesRepoByRetailOrServices(ids, catId, startDate, endDate);
    }

By using the code above, I get data when catId = 0 from table like: 通过使用上面的代码,我从表中获取catId = 0时的数据:

在此输入图像描述

similarly when catId = 1, I got data like: 同样,当catId = 1时,我得到的数据如下:

在此输入图像描述

What I want is, if date and shopid is the same, I just want to calculate both sums. 我想要的是,如果dateshopid相同,我只想计算两个总和。 Sum means for date 20-12-2016 i get 6440 when catId=1 ,similarly in next image sum is 1809 for same shopId i want 8249 as total . 对于日期20-12-2016的总和意味着当catId = 1时我获得6440,类似地在下一图像中,对于相同的商店,总和为1809,我想要8249作为总数。 like 喜欢

在此输入图像描述

What is the relevant approach? 相关方法是什么?

I fixed this issue as below: 我修正了这个问题如下:

if (map != null && map.containsKey(objects2[3].toString())) {
    map.put(objects2[3].toString(), map.get(objects2[3].toString()) + Double.parseDouble(objects2[2].toString()));
} else {
    map.put(objects2[3].toString(), Double.parseDouble(objects2[2].toString()));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM