| | |
| | | package com.sandu.ximon.admin.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.config.VnnoxConstant; |
| | | import com.sandu.ximon.admin.config.VnnoxUrl; |
| | | import com.sandu.ximon.admin.service.LedPlayerEntityService; |
| | | import com.sandu.ximon.admin.utils.request.*; |
| | | import com.sandu.ximon.admin.utils.response.*; |
| | | import com.sandu.ximon.dao.domain.LedPlayerEntity; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.URISyntaxException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | List<String> commands = new ArrayList<>(); |
| | | commands.add("volumeValue"); |
| | | commands.add("brightnessValue"); |
| | | commands.add("screenPowerStatus"); |
| | | VnnoxBaseRequest request = new VnnoxBaseRequest(); |
| | | request.setPlayerIds(playerId); |
| | | request.setCommands(commands); |
| | | request.setNoticeUrl(VnnoxConstant.STATUS_NOTIFY_URL); |
| | | |
| | | System.out.println(LocalDateTime.now() + "请求前"); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.ASYNCURRENTSTATUS), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | System.out.println(LocalDateTime.now() + "请求后"); |
| | | System.out.println(response.toString()); |
| | | int size = response.getData().getSuccess().size(); |
| | | CountDownLatch countDownLatch = new CountDownLatch(size * 2); |
| | | countDownLatchUtil.push(response.getLogid(), countDownLatch); |
| | | try { |
| | | countDownLatch.await(20, TimeUnit.SECONDS); |
| | | countDownLatch.await(3000, TimeUnit.MILLISECONDS); |
| | | countDownLatchUtil.remove(response.getLogid()); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | System.out.println(LocalDateTime.now() + "返回前"); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 获取屏幕信息 |
| | | */ |
| | | public VnnoxResultResponse getAsyncStatus(List<String> playerId, String statusValue) { |
| | | List<String> commands = new ArrayList<>(); |
| | | if ("all".equals(statusValue)) { |
| | | commands.add("volumeValue"); |
| | | commands.add("brightnessValue"); |
| | | commands.add("videoSourceValue"); |
| | | commands.add("timeValue"); |
| | | commands.add("screenPowerStatus"); |
| | | commands.add("syncPlayStatus"); |
| | | } else { |
| | | commands.add(statusValue); |
| | | } |
| | | VnnoxBaseRequest request = new VnnoxBaseRequest(); |
| | | request.setPlayerIds(playerId); |
| | | request.setCommands(commands); |
| | | request.setNoticeUrl(VnnoxConstant.STATUS_NOTIFY_URL); |
| | | System.out.println(LocalDateTime.now() + "请求前"); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.ASYNCURRENTSTATUS), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | System.out.println(LocalDateTime.now() + "请求后"); |
| | | System.out.println(response.toString()); |
| | | int size = response.getData().getSuccess().size(); |
| | | CountDownLatch countDownLatch = new CountDownLatch(size * commands.size()); |
| | | countDownLatchUtil.push(response.getLogid(), countDownLatch); |
| | | try { |
| | | countDownLatch.await(10000, TimeUnit.MILLISECONDS); |
| | | countDownLatchUtil.remove(response.getLogid()); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | System.out.println(LocalDateTime.now() + "返回前"); |
| | | return response; |
| | | } |
| | | } |