|  |  | 
 |  |  |  | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.concurrent.ExecutorService; | 
 |  |  | import java.util.concurrent.Executors; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public void updateList(Integer id, String guid) { | 
 |  |  |         ExecutorService executorService = Executors.newFixedThreadPool(2); | 
 |  |  |         QueryWrapper<GovMonitorPoint> wrapper_govMonitorPoint = new QueryWrapper<>(); | 
 |  |  |         wrapper_govMonitorPoint.eq("is_delete", Constants.NOT_DELETE); | 
 |  |  |         wrapper_govMonitorPoint.eq("id", id); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         GovMonitorPoint govMonitorPoint = govMonitorPoints.get(0); | 
 |  |  |         String oldGuid = govMonitorPoint.getGuid(); | 
 |  |  |         if(!oldGuid.equals(guid)){ | 
 |  |  |             govMonitorPoint.setGuid(guid); | 
 |  |  |             govMonitorPointMapper.updateById(govMonitorPoint); | 
 |  |  |             //删除redis | 
 |  |  |             delGovMonitorPointInfoFromRedis(id.toString()); | 
 |  |  |             //更新redis | 
 |  |  |             setGovMonitorPointInfoToRedis(id.toString(), selectGovMonitorPointInfoById(id)); | 
 |  |  |             //操作日志记录 | 
 |  |  |             HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
 |  |  |             StringBuilder content = new StringBuilder(); | 
 |  |  |             content.append("修改了政府站点:").append("id:").append(govMonitorPoint.getId() + ";"); | 
 |  |  |             if (!ObjectUtils.isEmpty(govMonitorPoint.getGuid())) { | 
 |  |  |                 content.append("guid:").append(oldGuid).append("->").append(guid).append(";"); | 
 |  |  |             } | 
 |  |  |             LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
 |  |  |             LambdaQueryChainWrapper<Device> wrapper = deviceService.lambdaQuery(); | 
 |  |  |             wrapper.eq(Device::getIsDelete,0); | 
 |  |  |             wrapper.eq(Device::getGuid,oldGuid); | 
 |  |  |             List<Device> list = wrapper.list(); | 
 |  |  |             list.forEach(it->it.setGuid(guid)); | 
 |  |  |             deviceService.updateBatchById(list); | 
 |  |  |             for(Device d : list){ | 
 |  |  |                 Map<String, Object> deviceInfo = deviceService.selectDeviceInfoById(d.getId()); | 
 |  |  |                 redisTemplate.opsForHash().delete(RedisConstants.DEVICE, d.getMac()); | 
 |  |  |                 redisTemplate.opsForHash().put(RedisConstants.DEVICE, d.getMac(), deviceInfo); | 
 |  |  |             } | 
 |  |  |         LambdaQueryChainWrapper<Device> wrapper = deviceService.lambdaQuery(); | 
 |  |  |         wrapper.eq(Device::getIsDelete,0); | 
 |  |  |         wrapper.eq(Device::getGuid,oldGuid); | 
 |  |  |         List<Device> list = wrapper.list(); | 
 |  |  |         list.forEach(it->it.setGuid(guid)); | 
 |  |  |  | 
 |  |  |         deviceService.updateBatchById(list); | 
 |  |  |  | 
 |  |  |         govMonitorPoint.setGuid(guid); | 
 |  |  |         govMonitorPointMapper.updateById(govMonitorPoint); | 
 |  |  |         //删除redis | 
 |  |  |         delGovMonitorPointInfoFromRedis(id.toString()); | 
 |  |  |         //更新redis | 
 |  |  |         setGovMonitorPointInfoToRedis(id.toString(), selectGovMonitorPointInfoById(id)); | 
 |  |  |         //操作日志记录 | 
 |  |  |         HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
 |  |  |         StringBuilder content = new StringBuilder(); | 
 |  |  |         content.append("修改了政府站点:").append("id:").append(govMonitorPoint.getId() + ";"); | 
 |  |  |         if (!ObjectUtils.isEmpty(govMonitorPoint.getGuid())) { | 
 |  |  |             content.append("guid:").append(oldGuid).append("->").append(guid).append(";"); | 
 |  |  |         } | 
 |  |  |         LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
 |  |  |         for(Device d : list){ | 
 |  |  |             executorService.submit(()->{ | 
 |  |  |                 redisTemplate.opsForHash().delete(RedisConstants.DEVICE, d.getMac()); | 
 |  |  |                 Map<String, Object> deviceInfo = deviceService.selectDeviceInfoById(d.getId()); | 
 |  |  |                 redisTemplate.opsForHash().put(RedisConstants.DEVICE, d.getMac(), deviceInfo); | 
 |  |  |  | 
 |  |  |             }); | 
 |  |  |         } | 
 |  |  |         // 关闭线程池 | 
 |  |  |         executorService.shutdown(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override |