mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
add 推送联联平台设备状态变更接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.thirdparty.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -17,7 +18,8 @@ public class ConnectorStatusInfo {
|
||||
* 充电设备接口编码 Y
|
||||
* 充电设备接口编码,同一对接平台内唯一
|
||||
*/
|
||||
private String ConnectorID;
|
||||
@JSONField(name = "ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
/**
|
||||
* 充电设备接口状态 Y
|
||||
@@ -28,7 +30,8 @@ public class ConnectorStatusInfo {
|
||||
* 4:占用(预约锁定)
|
||||
* 255:故障
|
||||
*/
|
||||
private String Status;
|
||||
@JSONField(name = "Status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 车位状态(0-未知;10-空闲;50-占用) N
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface LianLianService {
|
||||
|
||||
/**
|
||||
* 根据充电站id,推送充电站信息
|
||||
* @param stationId
|
||||
* @param dto
|
||||
*/
|
||||
void pushStationInfo(LianLianPushStationInfoDTO dto);
|
||||
|
||||
@@ -78,4 +78,12 @@ public interface LianLianService {
|
||||
* @return
|
||||
*/
|
||||
String getToken(LianLianGetTokenDTO dto);
|
||||
|
||||
/**
|
||||
* 推送联联平台 设备状态变化推送
|
||||
* @param pileConnectorCode
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
String pushConnectorStatus(String pileConnectorCode, String status);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class LianLianServiceImpl implements LianLianService {
|
||||
private static final String TEST_URL = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/";
|
||||
private static final String OPERATOR_ID = "987654321";
|
||||
private static final String OPERATOR_SECRET = "1234567890abcdef";
|
||||
private static final String SIG_SECRET = "1234567890abcdef"; // 签名秘钥
|
||||
private static final String DATA_SECRET = "1234567890abcdef"; // 消息密钥
|
||||
private static final String DATA_SECRETIV = "1234567890abcdef"; // 消息密钥初始化向量
|
||||
|
||||
@Autowired
|
||||
private IPileMerchantInfoService pileMerchantInfoService;
|
||||
@@ -152,7 +158,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
|
||||
// 调用联联平台接口
|
||||
String url = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/" + "notification_stationInfo";
|
||||
String url = TEST_URL + "notification_stationInfo";
|
||||
|
||||
String jsonStr = JSONObject.toJSONString(info);
|
||||
JSONObject data = new JSONObject();
|
||||
@@ -169,8 +175,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
BigDecimal bigDecimal = new BigDecimal("7").setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||
System.out.println(bigDecimal);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,7 +569,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* 从联联平台获取令牌
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -575,7 +580,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String token = "";
|
||||
try {
|
||||
//测试用请求地址
|
||||
String requestUrl = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/query_token";
|
||||
String requestUrl = TEST_URL + "query_token";
|
||||
|
||||
//请求data
|
||||
Map<String, String> data = new HashMap<>();
|
||||
@@ -617,6 +622,38 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台推送 设备状态变化推送
|
||||
* @param pileConnectorCode
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String pushConnectorStatus(String pileConnectorCode, String status) {
|
||||
String url = TEST_URL + "notification_stationStatus";
|
||||
|
||||
// 获取令牌
|
||||
LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||
dto.setOperatorId(OPERATOR_ID);
|
||||
dto.setOperatorSecret(OPERATOR_SECRET);
|
||||
String token = getToken(dto);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
|
||||
.connectorID(pileConnectorCode)
|
||||
.status(status)
|
||||
.build();
|
||||
// 调用联联平台接口
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("ConnectorStatusInfo", info);
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO 推送停止充电结果 notification_stop_charge_result
|
||||
|
||||
// TODO 推送充电订单信息 notification_charge_order_info
|
||||
|
||||
Reference in New Issue
Block a user