List<Long> siteIdList = ttSiteMonitorMapper.selectAllNormalSite();
List<Long> siteIds = new ArrayList<Long>();
int i = 1;
int j = (int) Math.ceil(siteIdList.size()/50);
for (; i < siteIdList.size();) {
if(i>j){
break;
}
if(siteIdList.size() >= (i * 50)){
siteIds = siteIdList.subList((i - 1) * 50, i * 50);
enter.setSiteIdList(new ArrayList<Long>(siteIds));
List<TtSiteMonitorEnter> list = getSiteList4Base(enter);
try {
insertThreshold(siteIds, list);
} catch (Exception e) {
}
}else if(siteIdList.size() < (i * 50)){
siteIds = siteIdList.subList((i - 1) * 50, i * 50);
enter.setSiteIdList(new ArrayList<Long>(siteIds));
List<TtSiteMonitorEnter> list = getSiteList4Base(enter);
try {
insertThreshold(siteIds, list);
} catch (Exception e) {
}
}
i++;
}
------------------------------------
List<Long> siteIdList = ttSiteMonitorMapper.selectAllNormalSite();
List<Long> siteIds = new ArrayList<Long>();
int i = 0;
for (Long siteId : siteIdList) {
if (i % 50 == 0 && i >= 50) {
//因为后边要继续使用siteIds,故而在此新建一个副本值
enter.setSiteIdList(new ArrayList<Long>(siteIds));
List<TtSiteMonitorEnter> list = getSiteList4Base(enter);
if(list == null || list.size() == 0) {
siteIds.clear();
continue;
}
try {
insertThreshold(siteIds, list);
} catch (Exception e) {
}
siteIds.clear();
// 最后一批可能不够50个
} else if (i % 50 != 0 && i == (siteIdList.size() - 1)) {
//因为后边要继续使用siteIds,故而在此新建一个副本值
enter.setSiteIdList(new ArrayList<Long>(siteIds));
List<TtSiteMonitorEnter> list = getSiteList4Base(enter);
if(list == null || list.size() == 0) {
siteIds.clear();
continue;
}
try {
insertThreshold(siteIds, list);
} catch (Exception e) {
}
siteIds.clear();
}
siteIds.add(siteId);
i++;
}