| | |
| | | */ |
| | | @Slf4j |
| | | public class TCECUtil { |
| | | /** |
| | | * 运营商标识 |
| | | */ |
| | | private static final String OperatorID = ""; |
| | | |
| | | private static OperatorClient operatorClient = SpringUtils.getBean(OperatorClient.class); |
| | | // private static OperatorClient operatorClient = SpringUtils.getBean(OperatorClient.class); |
| | | |
| | | public static Map<Long, Integer> map = new HashMap<>(); |
| | | |
| | |
| | | LocalDateTime localDateTime = Instant.ofEpochSecond(tokenAvailableTime).atOffset(ZoneOffset.UTC).toLocalDateTime(); |
| | | operator.setAccessToken(token); |
| | | operator.setTokenAvailableTime(localDateTime); |
| | | operatorClient.editOperator(operator); |
| | | // operatorClient.editOperator(operator); |
| | | return token; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 站点变更通知 |
| | | * @param operator |
| | | * @param type |
| | | * @param siteIds |
| | | * @return |
| | | */ |
| | | public static NotificationStationChangeResult notificationStationChange(Operator operator, Integer type, List<Integer> siteIds) { |
| | | StationChange stationChange = new StationChange(); |
| | | stationChange.setOperatorId(OperatorID); |
| | | stationChange.setType(type); |
| | | List<String> collect = siteIds.stream().map(String::valueOf).collect(Collectors.toList()); |
| | | stationChange.setStationIds(collect); |
| | | HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_STATION_CHANGE.getUrl()); |
| | | buildBody(post, stationChange, operator); |
| | | HttpResponse execute = post.execute(); |
| | | if(200 != execute.getStatus()){ |
| | | log.error("推送站点变更通知失败:" + execute.body()); |
| | | return null; |
| | | } |
| | | return JSON.parseObject(execute.body(), NotificationStationChangeResult.class); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | BaseModel model = new BaseModel(); |
| | | model.setOperatorID("MA25CNM38"); |
| | | model.setData("lkQUXmphG3h5Wf0UIxSfzNoCdqDLYkmDGceCbofJuWFqKBwCYulTUHSn9bJpVMVFNji/4xtSq3o1U5jSZZwIhA=="); |
| | | model.setTimeStamp(20250205120800L); |
| | | model.setSeq("0001"); |
| | | Operator operator = new Operator(); |
| | | operator.setName("XinDianTu"); |
| | | operator.setSigSecret("S94xUpTpOIlLJBk8"); |
| | | model.setOperator(operator); |
| | | String key = operator.getSigSecret(); |
| | | |
| | | String m = new StringBuilder(model.getOperatorID()).append(model.getData()).append(model.getTimeStamp()).append(model.getSeq()).toString(); |
| | | byte[] hmacMd5 = SignUtil.getHMacMD5Bytes(key.getBytes(), m.getBytes()); |
| | | // 打印计算得到的签名Sig |
| | | String s = SignUtil.bytesToHexString(hmacMd5); |
| | | System.err.println(s); |
| | | } |
| | | } |