| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.config.VnnoxConstant; |
| | | import com.sandu.ximon.admin.dto.nova.AirDataProgram; |
| | | import com.sandu.ximon.admin.dto.nova.PlayerLayout; |
| | | import com.sandu.ximon.admin.dto.nova.PlayerPage; |
| | | import com.sandu.ximon.admin.dto.nova.PlayerWidget; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.redis.DeviceRedisKey; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.*; |
| | | import com.sandu.ximon.admin.utils.request.VnnoxScreenStatusType; |
| | |
| | | import com.sandu.ximon.admin.utils.response.VnnoxPlayerResponse; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResult; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResultResponse; |
| | | import com.sandu.ximon.admin.vo.NovaPushResultVO; |
| | | import com.sandu.ximon.admin.vo.NovaScreenShorUrlVO; |
| | | import com.sandu.ximon.admin.vo.*; |
| | | import com.sandu.ximon.dao.domain.LedPlayerEntity; |
| | | import com.sandu.ximon.dao.domain.LedPlayerInfoEntity; |
| | | import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity; |
| | |
| | | VnnoxResult vnnoxResult = vnnoxAPIUtil.volChange(playerList.stream().map(item -> item.getPlayerId()).collect(Collectors.toList()), vol); |
| | | // 根据音量调整REDIS标识位 |
| | | for (String playerId : vnnoxResult.getSuccess()) { |
| | | redisUtils.set(VnnoxConstant.REDIS_VOL + playerId, vol,VnnoxConstant.STATUS_TIME); |
| | | redisUtils.set(VnnoxConstant.REDIS_VOL + playerId, vol, VnnoxConstant.STATUS_TIME); |
| | | } |
| | | List<String> success = vnnoxResult.getSuccess(); |
| | | List<String> fail = vnnoxResult.getFail(); |
| | |
| | | for (LedPlayerEntity item : ledList) { |
| | | String playerId = item.getPlayerId(); |
| | | if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null |
| | | || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null) { |
| | | || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null |
| | | || redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId) == null) { |
| | | temp.add(item.getPlayerId()); |
| | | } |
| | | } |
| | |
| | | for (LedPlayerEntity playerEntity : list) { |
| | | String playerId = playerEntity.getPlayerId(); |
| | | LedPlayerInfoEntity cache = new LedPlayerInfoEntity(); |
| | | // 设置屏幕状态 |
| | | // 设置屏幕状态 更新状态之后还拿不到数据说明设备有问题或不在线 设置默认为黑屏 |
| | | String result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId); |
| | | Integer screenStatus = 1; |
| | | Integer screenStatus = 0; |
| | | if (null != result) { |
| | | screenStatus = Integer.parseInt(result); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public VnnoxResult publishWaterData(String playerId, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) { |
| | | public VnnoxResult WaterData(String playerId, Long duration, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) { |
| | | List<String> playerIds = new ArrayList<>(); |
| | | playerIds.add(playerId); |
| | | AirDataProgram playerProgram = new AirDataProgram(); |
| | | NovaWeatherVO playerProgram = new NovaWeatherVO(); |
| | | playerProgram.setPlayerIds(playerIds); |
| | | PlayerPage playerPage = new PlayerPage(); |
| | | playerPage.setName("AirData page"); |
| | | List<PlayerWidget> widgetList = generateWaterAndSensorWidget(poleSensorEntity); |
| | | playerPage.setWidgets(widgetList); |
| | | List<PlayerPage> list = new ArrayList<>(); |
| | | list.add(playerPage); |
| | | playerProgram.setPages(list); |
| | | playerProgram.setNoticeUrl(VnnoxConstant.NOTIFY_URL); |
| | | /** |
| | | * 诺瓦推送大气数据 日志记录开始 |
| | | //// */ |
| | | // String content = "{诺瓦playerId:" + playerId + ",节目内容:" + JSON.toJSONString(playerProgram) + " }"; |
| | | // StoreOperationRecordsUtils.storeOperationData(null, null, "大气数据推送到诺瓦", content); |
| | | /** |
| | | * 诺瓦推送大气数据 日志记录结束 |
| | | */ |
| | | |
| | | return vnnoxProgramAPIUtil.normalProgram(playerProgram).getData(); |
| | | NovaWeatherVO.AttributeDTO attributeDTO = new NovaWeatherVO.AttributeDTO(); |
| | | attributeDTO.setDuration(duration); |
| | | playerProgram.setAttribute(attributeDTO); |
| | | List<NovaWeatherVO.PageDTO.WidgetsDTO> widgets = setWeather(duration, poleSensorEntity); |
| | | NovaWeatherVO.PageDTO page = new NovaWeatherVO.PageDTO(); |
| | | page.setWidgets(widgets); |
| | | playerProgram.setPage(page); |
| | | |
| | | return vnnoxProgramAPIUtil.emergencyProgram(playerProgram).getData(); |
| | | } |
| | | |
| | | |
| | | private List<PlayerWidget> generateWaterAndSensorWidget(A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) { |
| | | private List<NovaWeatherVO.PageDTO.WidgetsDTO> setWeather(Long duration, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) { |
| | | |
| | | List widgetList = new ArrayList<>(); |
| | | List<NovaWeatherVO.PageDTO.WidgetsDTO> widgets = new ArrayList<>(); |
| | | List<String> list = new ArrayList<>(); |
| | | if (Objects.nonNull(poleSensorEntity)) { |
| | | list.add("环境监测:"); |
| | |
| | | list.add("pm10:" + poleSensorEntity.getPm10() + "μg/m³"); |
| | | list.add("甲醛:" + poleSensorEntity.getEch2o() + "μg/m³"); |
| | | list.add("CO2:" + poleSensorEntity.getCo2() + "ppm"); |
| | | } else { |
| | | list.add("大气设备不在线"); |
| | | list.add("目前是固定数据:"); |
| | | list.add("环境监测:"); |
| | | list.add("温度: 40°"); |
| | | list.add("湿度: 60%"); |
| | | list.add("pm25:0.58 μg/m³"); |
| | | list.add("pm10:0.58 μg/m³"); |
| | | list.add("甲醛:99.9 μg/m³"); |
| | | list.add("CO2:200 ppm"); |
| | | } |
| | | |
| | | widgetList.add(new PlayerWidget().generateScrollUpTextWidget("weather", 1, 100000L, list, "#FFFFFF", 15, new PlayerLayout("0%", "5%", "100%", "100%"))); |
| | | |
| | | return widgetList; |
| | | List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO> lines = new ArrayList<>(); |
| | | |
| | | list.forEach(txt -> { |
| | | List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO> textAttributes = new ArrayList<>(); |
| | | |
| | | NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO linesDTO = new NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO(); |
| | | NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO textAttributesDTO = new NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO(); |
| | | textAttributesDTO.setContent(txt); |
| | | textAttributes.add(textAttributesDTO); |
| | | System.out.println(txt + "文本内容"); |
| | | linesDTO.setTextAttributes(textAttributes); |
| | | lines.add(linesDTO); |
| | | }); |
| | | |
| | | NovaWeatherVO.PageDTO.WidgetsDTO widgetsDTO = new NovaWeatherVO.PageDTO.WidgetsDTO(); |
| | | NovaWeatherVO.PageDTO.WidgetsDTO.ScrollAttributeDTO scrollAttribute = new NovaWeatherVO.PageDTO.WidgetsDTO.ScrollAttributeDTO(); |
| | | |
| | | NovaWeatherVO.PageDTO.WidgetsDTO.LayoutDTO layout = new NovaWeatherVO.PageDTO.WidgetsDTO.LayoutDTO(); |
| | | |
| | | widgetsDTO.setScrollAttribute(scrollAttribute); |
| | | widgetsDTO.setLayout(layout); |
| | | widgetsDTO.setLines(lines); |
| | | |
| | | widgetsDTO.setDuration(duration); |
| | | widgets.add(widgetsDTO); |
| | | System.out.println(lines + "播放内容"); |
| | | |
| | | return widgets; |
| | | } |
| | | |
| | | |
| | |
| | | * 更新诺瓦屏幕分辨率 |
| | | */ |
| | | public void saveInfo() { |
| | | List<LedPlayerEntity> list = vnnoxAPIUtil.saveCurrentInfo(ledPlayerEntityService.list()); |
| | | List<LedPlayerEntity> all = ledPlayerEntityService.list(); |
| | | List<List<LedPlayerEntity>> split = CollectionUtil.split(all, 100); |
| | | List<LedPlayerEntity> list = new ArrayList<>(); |
| | | for (List<LedPlayerEntity> ledList : split) { |
| | | list.addAll(vnnoxAPIUtil.saveCurrentInfo(ledList)); |
| | | } |
| | | boolean b = SpringContextHolder.getBean(LedPlayerEntityService.class).updateBatchById(list); |
| | | if (b) { |
| | | LogUtils.error("更新诺瓦屏幕分辨率成功"); |
| | |
| | | |
| | | public void asyncStatus(List<String> playerIds) { |
| | | VnnoxResultResponse vnnoxResultResponse = vnnoxAPIUtil.asyncStatus(playerIds); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取诺瓦屏幕信息 |
| | | * |
| | | * @param stateValue |
| | | * @param playIdList |
| | | * @return |
| | | */ |
| | | public List<NovaAStateInfoVO> getInfo(String stateValue, List<String> playIdList) { |
| | | List<NovaAStateInfoVO> list = new ArrayList<>(); |
| | | NovaAStateInfoVO novaAStateInfoVO; |
| | | for (String playId : playIdList) { |
| | | String volumeValue = RedisUtils.getBean().get(VnnoxConstant.REDIS_VOL + playId); |
| | | String brightnessValue = RedisUtils.getBean().get(VnnoxConstant.REDIS_BRIGHTNESS + playId); |
| | | String videoSourceValue = RedisUtils.getBean().get(VnnoxConstant.VIDEO_SOURCE_VALUE + playId); |
| | | String timezoneValue = RedisUtils.getBean().get(VnnoxConstant.TIME_VALUE_TIMEZONE + playId); |
| | | String timeValue = RedisUtils.getBean().get(VnnoxConstant.TIME_VALUE_TIME + playId); |
| | | String screenPowerStatus = RedisUtils.getBean().get(VnnoxConstant.REDIS_SCREEN_STATUS + playId); |
| | | String syncPlayStatus = RedisUtils.getBean().get(VnnoxConstant.SYNC_PLAY_STATUS + playId); |
| | | novaAStateInfoVO = new NovaAStateInfoVO(); |
| | | novaAStateInfoVO.setPlayerId(playId); |
| | | switch (stateValue) { |
| | | case "all": |
| | | novaAStateInfoVO.setVolumeValue(volumeValue); |
| | | novaAStateInfoVO.setBrightnessValue(brightnessValue); |
| | | novaAStateInfoVO.setVideoSourceValue(videoSourceValue); |
| | | novaAStateInfoVO.setTimezoneValue(timezoneValue); |
| | | novaAStateInfoVO.setTimeValue(timeValue); |
| | | novaAStateInfoVO.setScreenPowerStatus(screenPowerStatus); |
| | | novaAStateInfoVO.setSyncPlayStatus(syncPlayStatus); |
| | | break; |
| | | case "volumeValue": |
| | | novaAStateInfoVO.setVolumeValue(volumeValue); |
| | | break; |
| | | case "brightnessValue": |
| | | novaAStateInfoVO.setBrightnessValue(brightnessValue); |
| | | break; |
| | | case "videoSourceValue": |
| | | novaAStateInfoVO.setVideoSourceValue(videoSourceValue); |
| | | break; |
| | | case "timeValue": |
| | | novaAStateInfoVO.setTimezoneValue(timezoneValue); |
| | | novaAStateInfoVO.setTimeValue(timeValue); |
| | | break; |
| | | case "screenPowerStatus": |
| | | novaAStateInfoVO.setScreenPowerStatus(screenPowerStatus); |
| | | break; |
| | | case "syncPlayStatus": |
| | | novaAStateInfoVO.setSyncPlayStatus(syncPlayStatus); |
| | | break; |
| | | default: |
| | | } |
| | | list.add(novaAStateInfoVO); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public void getAsyncStatus(List<String> playerIdList, String stateValue) { |
| | | List<List<String>> split = CollectionUtil.split(playerIdList, 100); |
| | | split.forEach( |
| | | playerIds -> { |
| | | vnnoxAPIUtil.getAsyncStatus(playerIdList, stateValue); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 向Redis中存入设备状态 |
| | | */ |
| | | public void setCacheData() { |
| | | |
| | | List<List<LedPlayerEntity>> split = CollectionUtil.split(ledPlayerEntityService.list(), 100); |
| | | List<LedPlayerEntity> ledList = new ArrayList<>(); |
| | | split.forEach( |
| | | list -> { |
| | | List<LedPlayerEntity> ledPlayerEntities = vnnoxAPIUtil.syncCurrentInfo(list); |
| | | ledList.addAll(ledPlayerEntities); |
| | | } |
| | | ); |
| | | |
| | | ledList.forEach( |
| | | device -> { |
| | | RedisDeviceStatus deviceStatus = new RedisDeviceStatus(); |
| | | deviceStatus.setDeviceId(device.getPlayerId()); |
| | | if (device.getOnlineStatus() == 0) { |
| | | deviceStatus.setStatus(1); |
| | | } else if (device.getOnlineStatus() == 1) { |
| | | deviceStatus.setStatus(0); |
| | | } else { |
| | | deviceStatus.setStatus(1); |
| | | } |
| | | redisUtils.set(DeviceRedisKey.NOVA + device.getPlayerId(), JSON.toJSONString(deviceStatus)); |
| | | // redisUtils.delete(DeviceRedisKey.IP_BROADCAST + device.getId()); |
| | | } |
| | | ); |
| | | |
| | | } |
| | | } |