| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | //此时保证两个集合都不为null |
| | | this.save2Db(info.ugTaskId, info.ugRtuStateList, cache.ugRtuStateList); |
| | | } |
| | | if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ |
| | | //此时保证两个集合都不为null |
| | | info.ugRtuStateList.stream().sorted(Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder())).collect(Collectors.toList()); |
| | | } |
| | | //cache赋值必须放在上面处理的后面,否则上面的比较不成功 |
| | | cache = info; |
| | | } |
| | |
| | | */ |
| | | private void save2Db(String taskId, List<UpgradeRtu> newList, List<UpgradeRtu> oldList){ |
| | | List<UpgradeRtu> newOverList = newList.stream().filter(vo -> vo.isOver).collect(Collectors.toList()) ; |
| | | List<UpgradeRtu> oldNoOverList = newList.stream().filter(vo -> !vo.isOver).collect(Collectors.toList()) ; |
| | | for(UpgradeRtu nvo : newOverList){ |
| | | if(nvo != null) { |
| | | if(oldList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr) && vo.isOver == false)){ |
| | | if(oldNoOverList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr))){ |
| | | //上次没有升级结束,而当前升级结束了 |
| | | this.sv.saveRtuUpgradeState(Long.parseLong(taskId), nvo); |
| | | } |