puzhibing
2025-02-06 86e943f5e159dbb97d58cf8194e09d0b1d46406b
修改bug
4个文件已修改
27 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Operator.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/TCECUtil.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/BaseModel.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/enu/InterfaceUrlEnum.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Operator.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@@ -71,8 +72,7 @@
     * token过期时间(秒)
     */
    @TableField("tokenAvailableTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime tokenAvailableTime;
    private Long tokenAvailableTime;
    /**
     * 我方运营商唯一码
     */
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/TCECUtil.java
@@ -56,31 +56,30 @@
        baseRequest.setOperator(operator);
        baseRequest.setSig(buildSign(baseRequest));
        String request_json = JacksonUtils.toJson(baseRequest);
        log.info("获取授权token请求地址:" + post.getUrl());
        log.info("获取授权token请求参数:" + request_json);
        log.info("获取授权token请求Data:" + jsonString);
        log.info("获取三方平台授权token请求地址:" + post.getUrl());
        log.info("获取三方平台授权token请求参数:" + request_json);
        log.info("获取三方平台授权token请求Data:" + jsonString);
        post.body(request_json);
        HttpResponse execute = post.execute();
        if(200 != execute.getStatus()){
            log.error("获取三方token失败:" + execute.body());
            log.error("获取三方平台授权token失败:" + execute.body());
            return null;
        }
        log.info("获取授权token响应:" + execute.body());
        log.info("获取三方平台授权token响应参数:" + execute.body());
        BaseResult baseResult = JSON.parseObject(execute.body(), BaseResult.class);
        Integer Ret = baseResult.getRet();
        if(0 != Ret){
            log.error("获取三方token失败:" + baseResult.getMsg());
            log.error("获取三方平台授权token失败:" + baseResult.getMsg());
            return null;
        }
        //解密参数
        String decrypt = AESUtil.decrypt(baseResult.getData(), operator.getDataSecret(), operator.getDataSecretIv());
        log.info("获取授权token请求Data:" + decrypt);
        log.info("获取三方平台授权token响应Data:" + decrypt);
        QueryTokenResult queryTokenResult = JSON.parseObject(decrypt, QueryTokenResult.class);
        String token = queryTokenResult.getAccessToken();
        Long tokenAvailableTime = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) + queryTokenResult.getTokenAvailableTime();
        LocalDateTime localDateTime = Instant.ofEpochSecond(tokenAvailableTime).atOffset(ZoneOffset.UTC).toLocalDateTime();
        operator.setAccessToken(token);
        operator.setTokenAvailableTime(localDateTime);
        operator.setTokenAvailableTime(tokenAvailableTime);
        operatorClient.editOperator(operator);
        return token;
    }
@@ -91,7 +90,7 @@
     * @return
     */
    public static String getToken(Operator operator){
        if(null != operator.getTokenAvailableTime() && operator.getTokenAvailableTime().isBefore(LocalDateTime.now())){
        if(null != operator.getTokenAvailableTime() && operator.getTokenAvailableTime() > LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)){
            return operator.getAccessToken();
        }else{
            return queryToken(operator);
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/BaseModel.java
@@ -1,6 +1,7 @@
package com.ruoyi.integration.drainage.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ruoyi.other.api.domain.Operator;
import lombok.Data;
@@ -42,5 +43,6 @@
    /**
     * 运营商对象
     */
    @JsonIgnore
    private Operator operator;
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/enu/InterfaceUrlEnum.java
@@ -7,7 +7,7 @@
 */
public enum InterfaceUrlEnum {
    QUERY_TOKEN("/query_token", "获取权限token"),
    NOTIFICATION_STATION_STATUS("/notification_station_status", "设备状态变化推送"),
    NOTIFICATION_STATION_STATUS("/notification_stationStatus", "设备状态变化推送"),
    NOTIFICATION_STATION_CHANGE("/notification_station_change", "站点计费策略变更推送"),
    NOTIFICATION_START_CHARGE_RESULT("/notification_start_charge_result", "推送启动充电结果"),
    NOTIFICATION_EQUIP_CHARGE_STATUS("/notification_equip_charge_status", "推送充电状态"),