| | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.dto.DeviceStatus; |
| | | import com.sandu.ximon.admin.dto.WaterQualityDataDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A1Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; |
| | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.DeviceStateEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.param.*; |
| | | 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; |
| | | import com.sandu.ximon.admin.utils.ListPagingUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResult; |
| | | import com.sandu.ximon.admin.vo.PoleBindVO; |
| | |
| | | BeanUtils.copyProperties(param, pole); |
| | | pole.setPoleCode(generatePoleCode()); |
| | | pole.setDeviceType(-1); |
| | | pole.setCentre(1); |
| | | boolean save = save(pole); |
| | | |
| | | /** |
| | |
| | | Pole update = new Pole(); |
| | | BeanUtils.copyProperties(param, update); |
| | | update.setId(poleId); |
| | | if (param.getIsCenter() != null) { |
| | | update.setCentre(param.getIsCenter()); |
| | | } |
| | | /** |
| | | * 修改灯杆日志记录开始 |
| | | */ |
| | |
| | | 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(), orderBy); |
| | | param.getBingStates(), param.getGroupid(), param.getKeyword(), center, orderBy); |
| | | } else { |
| | | poleList = poleMapper.queryPoleOnLineStatesList(SecurityUtils.getUserId(), |
| | | param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword(), orderBy); |
| | | param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword(), center, orderBy); |
| | | } |
| | | |
| | | poleList.forEach( |
| | | centre -> { |
| | | if (centre.getCentre() == 0) { |
| | | centre.setCenter(true); |
| | | } |
| | | } |
| | | ); |
| | | List<Pole> PoleResult = isOnLine(poleList, param); |
| | | setCount(PoleResult); |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | |