| | |
| | | String orderBy = "t1." + orderByResult + " " + orderBySeq; |
| | | |
| | | List<Pole> poleList; |
| | | Integer center = param.getCenter(); |
| | | if (SecurityUtils.getClientId() == null) { |
| | | poleList = poleMapper.queryPoleOnLineStatesList(null, param.getIsTrue(), |
| | | param.getBingStates(), param.getGroupid(), param.getKeyword(), param.getCenter(), orderBy); |
| | | param.getBingStates(), param.getGroupid(), param.getKeyword(), center, orderBy); |
| | | } else { |
| | | poleList = poleMapper.queryPoleOnLineStatesList(SecurityUtils.getUserId(), |
| | | param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword(), param.getCenter(), orderBy); |
| | | param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword(), center, orderBy); |
| | | } |
| | | |
| | | poleList.forEach( |
| | |
| | | boolean result = saveOrUpdate(pole); |
| | | |
| | | if (result) { |
| | | Light light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | Light light = SpringContextHolder.getBean(LightService.class).getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1")); |
| | | if (light == null) { |
| | | light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if (pole == null) { |
| | | throw new BusinessException("灯杆不存在"); |
| | | } |
| | | pole.setUserId(clientId); |
| | | if (!clientService.findClientId(clientId)) { |
| | | pole.setClientId(clientService.getClientId(clientId)); |
| | | pole.setClientId(clientId); |
| | | if (clientService.findClientId(clientId)) { |
| | | pole.setUserId(clientService.getClientId(clientId)); |
| | | |
| | | } |
| | | r = updateById(pole); |
| | | |
| | | if (!r) { |
| | | throw new BusinessException("灯杆ID为" + poleId + "设置失败,自动停止"); |
| | | } |
| | | |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * 用户解绑灯杆 |
| | | * |
| | | * @param clientId |
| | | * @param poleIds |
| | | * @return |
| | | */ |
| | | public boolean ClientUnBindingPole(long clientId, int[] poleIds) { |
| | | boolean r = false; |
| | | for (int poleId : poleIds) { |
| | | Pole pole = getById(poleId); |
| | | if (pole == null) { |
| | | throw new BusinessException("灯杆不存在"); |
| | | } |
| | | pole.setClientId(-1L); |
| | | r = updateById(pole); |
| | | |
| | | if (!r) { |
| | |
| | | throw new BusinessException("设备不存在"); |
| | | } |
| | | //关闭推送 |
| | | SpringContextHolder.getBean(LightemitUtils.class).clear(xixun.getDeviceCode()); |
| | | |
| | | String clear = SpringContextHolder.getBean(LightemitUtils.class).clear(xixun.getDeviceCode()); |
| | | if (clear.contains("is not") || clear.contains("does not")) { |
| | | throw new BusinessException("设备不在线或设备未存在于服务器"); |
| | | } |
| | | } |
| | | |
| | | /** |