2021与蓝度共同重构项目,服务端
liuhaonan
2022-09-19 03328152832ecc95572f75c03bd21934162d42d0
ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
@@ -4,10 +4,6 @@
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.security.SecurityUtils;
import com.sandu.ximon.admin.utils.*;
@@ -16,6 +12,7 @@
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.NovaAStateInfoVO;
import com.sandu.ximon.admin.vo.NovaPushResultVO;
import com.sandu.ximon.admin.vo.NovaScreenShorUrlVO;
import com.sandu.ximon.admin.vo.NovaWeatherVO;
@@ -508,8 +505,7 @@
        List<String> temp = new ArrayList<>();
        for (LedPlayerEntity item : ledList) {
            String playerId = item.getPlayerId();
            if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null
                    || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null) {
            if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null) {
                temp.add(item.getPlayerId());
            }
        }
@@ -609,19 +605,17 @@
        List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO> lines = new ArrayList<>();
        list.forEach(
                txt -> {
                    List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO> textAttributes = 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.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();
@@ -644,7 +638,12 @@
     * 更新诺瓦屏幕分辨率
     */
    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("更新诺瓦屏幕分辨率成功");
@@ -654,7 +653,75 @@
    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":
                    if ("CLOSE".equals(screenPowerStatus)) {
                        novaAStateInfoVO.setScreenPowerStatus("0");
                    } else {
                        novaAStateInfoVO.setScreenPowerStatus("1");
                    }
                    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);
                }
        );
    }
}