| | |
| | | import com.sandu.ximon.admin.param.PoleBindingParam; |
| | | import com.sandu.ximon.admin.param.PoleParam; |
| | | import com.sandu.ximon.admin.param.PoleStatesParam; |
| | | import com.sandu.ximon.admin.param.PushAirDataToNovaParam; |
| | | import com.sandu.ximon.admin.redis.LightKey; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | |
| | | 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("设备不在线或设备未存在于服务器"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 推送大气监测数据到novaLED |
| | | */ |
| | | public VnnoxResult pushAirDataToNova(Long poleId) { |
| | | public VnnoxResult pushAirDataToNova(PushAirDataToNovaParam param) { |
| | | Long poleId=param.getPoleId(); |
| | | Pole pole = getById(poleId); |
| | | PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3)); |
| | | PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1)); |
| | |
| | | //获取大气监测数据 |
| | | A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId); |
| | | //推送数据 |
| | | return SpringContextHolder.getBean(VnnoxService.class).publishWaterData(LED.getPlayerId(), data); |
| | | // return SpringContextHolder.getBean(VnnoxService.class).publishWaterData(LED.getPlayerId(),param.getDuration(), data); |
| | | return SpringContextHolder.getBean(VnnoxService.class).WaterData(LED.getPlayerId(),param.getDuration(), data); |
| | | } |
| | | |
| | | |