| | |
| | | package com.sandu.ximon.admin.utils; |
| | | |
| | | 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.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.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component("VnnoxAPIUtil") |
| | | @AllArgsConstructor |
| | |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | |
| | | //TODO |
| | | System.out.println("result+ " + result); |
| | | // result+ {"logid":1660889486514,"status":2,"errmsg":"playerIds must be array and is not empty"} |
| | | // {"logid":1660889534521,"status":0,"data":{"success":["f788af56421f3e8e8da39a63238fd212"],"fail":[]}} |
| | | |
| | | if (result.startsWith("{") && result.endsWith("}")) { |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | if (response.getStatus() == 0) { |
| | |
| | | return response.getData(); |
| | | } |
| | | |
| | | |
| | | public List<LedPlayerEntity> saveCurrentInfo(List<LedPlayerEntity> list) { |
| | | List<String> playerIds = new ArrayList<>(); |
| | | if (list.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | for (LedPlayerEntity playerEntity : list) { |
| | | playerIds.add(playerEntity.getPlayerId()); |
| | | } |
| | | |
| | | VnnoxSyncCurrentInfoRequest vnnoxSyncCurrentInfoRequest = new VnnoxSyncCurrentInfoRequest(); |
| | | vnnoxSyncCurrentInfoRequest.setPlayerIds(playerIds); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SYNC_CURRENT_INFO), |
| | | vnnoxSyncCurrentInfoRequest.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | |
| | | VnnoxSyncCurrentInfoResponse response = JSON.parseObject(result, VnnoxSyncCurrentInfoResponse.class); |
| | | |
| | | for (LedPlayerEntity playerEntity : list) { |
| | | for (VnnoxPlayerInfoResponse res : response.getData()) { |
| | | if (res.getPlayerId().equals(playerEntity.getPlayerId())) { |
| | | playerEntity.setResolution(res.getWidth() + " * " + res.getHeight()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | } |