info.parallelStream().filter(it -> counts.parallelStream().noneMatch(subIt -> { String s1 = subIt.getSceniccode(); if (s1 == null) { return false; } String s = it.getSceniccode(); boolean result = s1.equals(s); if (result) { ScenicRegionInfo.setEntityByBasicInfo(subIt, it); subIt.setState(1); } return result; })).map(Collectors.toList()).forEach(it -> { final ScenicHourCount temp = new ScenicHourCount(); ScenicRegionInfo.setEntityByBasicInfo(temp, it); temp.setHourcount(0); temp.setCurrenttotal(0); temp.setUpdatetime(current); temp.setHourtime(yyyyMMddHH); temp.setCountycode(it.getRegion()); temp.setCitycode(temp.getCountycode().substring(4) + "00"); counts.add(temp); });
注意: 如果在 .map 中 调用 .add ,这会使 方法 重新 回到 .filter 中,使 .filter 再执行 一次!!!!!!