update 设备状态变化推送联联平台接口

This commit is contained in:
Lemon
2023-05-26 09:40:24 +08:00
parent 0362095a10
commit 742b4a1b02
6 changed files with 55 additions and 12 deletions

View File

@@ -7,10 +7,7 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.LianLianPushStationInfoDTO;
import com.jsowell.pile.dto.QueryEquipmentDTO;
import com.jsowell.pile.dto.QueryStartChargeDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.*;
import com.jsowell.thirdparty.domain.StationStatsInfo;
import com.jsowell.thirdparty.service.LianLianService;
import com.jsowell.thirdparty.vo.*;
@@ -62,6 +59,35 @@ public class LianLianController extends BaseController {
return response;
}
/**
* 联联平台设备状态变化推送
* http://localhost:8080/LianLian/pushStationStatus
* @param dto
* @return
*/
@PostMapping("/pushStationStatus")
public RestApiResponse<?> pushStationStatus(@RequestBody PushInfoParamDTO dto) {
logger.info("联联平台设备状态变化推送 params:{}", JSONObject.toJSONString(dto));
RestApiResponse<?> response = null;
try {
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
String result = lianLianService.pushConnectorStatus(dto.getPileConnectorCode(), dto.getStatus());
response = new RestApiResponse<>(result);
}catch (BusinessException e) {
logger.error("联联平台设备状态变化推送 error",e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) {
logger.error("联联平台设备状态变化推送 error", e);
response = new RestApiResponse<>(e);
}
logger.info("联联平台设备状态变化推送 result:{}", response);
return response;
}
/**
* 联联平台查询充电站信息
* http://localhost:8080/LianLian/query_stations_info

View File

@@ -227,8 +227,8 @@ public class PileStationInfoController extends BaseController {
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
lianLianService.pushStationInfo(dto);
response = new RestApiResponse<>();
String result = lianLianService.pushStationInfo(dto);
response = new RestApiResponse<>(result);
}catch (BusinessException e) {
logger.error("推送联联平台充电站信息 error",e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());

View File

@@ -126,6 +126,7 @@ public class HttpRequestUtil {
Map<String, String> map = (Map<String, String>) JSON.parse(hutoolRequest);
String rData = map.get("Data");
String resultMsg = map.get("Msg");
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(rData),
dataSecret.getBytes(), dataSecretIV.getBytes());
@@ -137,6 +138,6 @@ public class HttpRequestUtil {
}
System.out.println("解密数据:" + plainData);
return plainData;
return resultMsg;
}
}

View File

@@ -19,22 +19,22 @@ public class LianLianPushStationInfoDTO {
/**
* 运营商id
*/
private String OperatorID;
private String operatorID;
/**
* 签名秘钥
*/
private String SigSecret;
private String signSecret;
/**
* 消息密钥
*/
private String DataSecret;
private String dataSecret;
/**
* 消息密钥初始化向量
*/
private String DataSecretIV;
private String dataSecretIv;
/**
* 令牌

View File

@@ -0,0 +1,16 @@
package com.jsowell.pile.dto;
import lombok.Data;
/**
* 练练平台推送信息参数DTO
*
* @author JS-ZZA
* @date 2023/5/26 9:26
*/
@Data
public class PushInfoParamDTO {
private String pileConnectorCode;
private String status;
}

View File

@@ -649,7 +649,7 @@ public class LianLianServiceImpl implements LianLianService {
@Override
public String pushConnectorStatus(String pileConnectorCode, String status) {
// 查出该桩所属哪个站点
String pileSn = StringUtils.substring(pileConnectorCode, 0, 16);
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn);
// 通过站点id查询相关配置信息
ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(stationVO.getId()));