java110
2021-10-19 3c821b3c5469ac5fc4660d33c3b998fb9005e889
service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java
old mode 100644 new mode 100755
@@ -35,14 +35,15 @@
    @Java110Synchronized(value = "hc_get_token")
    public static String get(RestTemplate restTemplate) {
    public static String get(RestTemplate restTemplate,boolean refreshAccessToken) {
        String token = CommonCache.getValue(IotConstant.HC_TOKEN);
        if (!StringUtil.isEmpty(token)) {
        if (!StringUtil.isEmpty(token) && !refreshAccessToken) {
            return token;
        }
        HttpHeaders headers = new HttpHeaders();
        HttpEntity httpEntity = new HttpEntity(headers);
        ResponseEntity<String> tokenRes = restTemplate.exchange(IotConstant.GET_TOKEN_URL, HttpMethod.GET, httpEntity, String.class);
        String url = IotConstant.getUrl(IotConstant.GET_TOKEN_URL.replace("APP_ID", IotConstant.getAppId()).replace("APP_SECRET", IotConstant.getAppSecret()));
        ResponseEntity<String> tokenRes = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class);
        if (tokenRes.getStatusCode() != HttpStatus.OK) {
            throw new IllegalArgumentException("获取token失败" + tokenRes.getBody());