| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.exception.BusinessException; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.GovMonitorPointMapper; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.RegionCodeUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Resource |
| | | private OrganizationService organizationService; |
| | | |
| | | @Resource |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired(required = false) |
| | | private DeviceMapper deviceMapper; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void updateList(Integer id, String guid) { |
| | | QueryWrapper<GovMonitorPoint> wrapper_govMonitorPoint = new QueryWrapper<>(); |
| | | wrapper_govMonitorPoint.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper_govMonitorPoint.eq("id", id); |
| | | List<GovMonitorPoint> govMonitorPoints = govMonitorPointMapper.selectList(wrapper_govMonitorPoint); |
| | | if (govMonitorPoints.size() == 0) { |
| | | throw new BusinessException("站点不存在!"); |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Integer id) { |
| | | UpdateWrapper<GovMonitorPoint> wrapper_delete = new UpdateWrapper<>(); |
| | | wrapper_delete.eq("id", id).set("is_delete", Constants.DELETE); |