| | |
| | | @Hidden //不公开接口,其只有通信中间件调用 |
| | | @PostMapping(path = "/receive") |
| | | public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo info, HttpServletRequest req, HttpServletResponse rep){ |
| | | /* |
| | | log.info("接收到的RTU远程升级状态数据为:{}", info.toString("532328000214")); |
| | | //进行排序 |
| | | //Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder()); |
| | | //info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList()); |
| | | |
| | | //通信中间件传过来的机构tag,以用于查找数据源 |
| | | String token = req.getHeader(Constant.UserTokenKeyInHeader); |
| | | DataSourceContext.set(token); |
| | | |
| | | if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ |
| | | if(info.ugRtuStateList.size() < 10){ |
| | | for (UpgradeRtu rtuVo : info.ugRtuStateList) { |
| | |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | |
| | | //进行排序 |
| | | Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder()); |
| | | info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList()); |
| | | |
| | | //通信中间件传过来的机构tag,以用于查找数据源 |
| | | String token = req.getHeader(Constant.UserTokenKeyInHeader); |
| | | DataSourceContext.set(token); |
| | | |
| | | if(cache == null){ |
| | | cache = info; |
| | | //此时不做任务操作,只保障cache不为空, 等待下次发来数据 |
| | |
| | | //此时保证两个集合都不为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; |
| | | if(info.ugOverallState != null && info.ugOverallState.allOver){ |
| | | this.saveTaskOver(info.ugTaskId) ; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存升级任务已经执行完成 |
| | | * @param taskId |
| | | */ |
| | | private void saveTaskOver(String taskId){ |
| | | this.sv.updateTaskOver(taskId) ; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | ///////////////////////////////////////////////////// |
| | | // |
| | | // 以下模拟数据 |