add 推送联联平台设备状态变更接口

This commit is contained in:
Lemon
2023-05-16 15:04:08 +08:00
parent d465afbc1e
commit 7b2a3fe20e
5 changed files with 83 additions and 25 deletions

View File

@@ -160,24 +160,26 @@ public class SpringBootTestController {
@Test
public void testLianLian(){
// 获取令牌
LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
dto.setOperatorId("987654321");
dto.setOperatorSecret("1234567890abcdef");
String token = lianLianService.getToken(dto);
System.out.println("token:" + token);
// // 获取令牌
// LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
// dto.setOperatorId("987654321");
// dto.setOperatorSecret("1234567890abcdef");
// String token = lianLianService.getToken(dto);
// System.out.println("token:" + token);
//
//
// LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
// .OperatorID("987654321")
// .DataSecret("1234567890abcdef")
// .DataSecretIV("1234567890abcdef")
// .SigSecret("1234567890abcdef")
// .token(token)
// .stationId(2L)
//
// .build();
// lianLianService.pushStationInfo(dto1);
LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
.OperatorID("987654321")
.DataSecret("1234567890abcdef")
.DataSecretIV("1234567890abcdef")
.SigSecret("1234567890abcdef")
.token(token)
.stationId(2L)
.build();
lianLianService.pushStationInfo(dto1);
lianLianService.pushConnectorStatus("8800000000000101", "1");
}

View File

@@ -439,6 +439,11 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
return response;
}
@Override
public String pushConnectorStatus(String pileConnectorCode, String status) {
return null;
}
/**
* 查询充电枪口的实时数据
*/
@@ -527,6 +532,9 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
num = pileConnectorInfoMapper.updateConnectorStatus(pileConnectorCode, status);
deleteRedisByPileSn(pileSn);
redisCache.setCacheObject(redisKey, status);
// 推送联联平台 设备状态变化推送接口 ConnectorStatusInfo
}
return num;
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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