mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-12 14:00:12 +08:00
add 推送联联平台设备状态变更接口
This commit is contained in:
@@ -160,24 +160,26 @@ public class SpringBootTestController {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLianLian(){
|
public void testLianLian(){
|
||||||
// 获取令牌
|
// // 获取令牌
|
||||||
LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
// LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||||
dto.setOperatorId("987654321");
|
// dto.setOperatorId("987654321");
|
||||||
dto.setOperatorSecret("1234567890abcdef");
|
// dto.setOperatorSecret("1234567890abcdef");
|
||||||
String token = lianLianService.getToken(dto);
|
// String token = lianLianService.getToken(dto);
|
||||||
System.out.println("token:" + token);
|
// 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);
|
||||||
|
|
||||||
|
lianLianService.pushConnectorStatus("8800000000000101", "1");
|
||||||
LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
|
|
||||||
.OperatorID("987654321")
|
|
||||||
.DataSecret("1234567890abcdef")
|
|
||||||
.DataSecretIV("1234567890abcdef")
|
|
||||||
.SigSecret("1234567890abcdef")
|
|
||||||
.token(token)
|
|
||||||
.stationId(2L)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
lianLianService.pushStationInfo(dto1);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -439,6 +439,11 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
|||||||
return response;
|
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);
|
num = pileConnectorInfoMapper.updateConnectorStatus(pileConnectorCode, status);
|
||||||
deleteRedisByPileSn(pileSn);
|
deleteRedisByPileSn(pileSn);
|
||||||
redisCache.setCacheObject(redisKey, status);
|
redisCache.setCacheObject(redisKey, status);
|
||||||
|
|
||||||
|
// 推送联联平台 设备状态变化推送接口 ConnectorStatusInfo
|
||||||
|
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.thirdparty.domain;
|
package com.jsowell.thirdparty.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -17,7 +18,8 @@ public class ConnectorStatusInfo {
|
|||||||
* 充电设备接口编码 Y
|
* 充电设备接口编码 Y
|
||||||
* 充电设备接口编码,同一对接平台内唯一
|
* 充电设备接口编码,同一对接平台内唯一
|
||||||
*/
|
*/
|
||||||
private String ConnectorID;
|
@JSONField(name = "ConnectorID")
|
||||||
|
private String connectorID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电设备接口状态 Y
|
* 充电设备接口状态 Y
|
||||||
@@ -28,7 +30,8 @@ public class ConnectorStatusInfo {
|
|||||||
* 4:占用(预约锁定)
|
* 4:占用(预约锁定)
|
||||||
* 255:故障
|
* 255:故障
|
||||||
*/
|
*/
|
||||||
private String Status;
|
@JSONField(name = "Status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车位状态(0-未知;10-空闲;50-占用) N
|
* 车位状态(0-未知;10-空闲;50-占用) N
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface LianLianService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据充电站id,推送充电站信息
|
* 根据充电站id,推送充电站信息
|
||||||
* @param stationId
|
* @param dto
|
||||||
*/
|
*/
|
||||||
void pushStationInfo(LianLianPushStationInfoDTO dto);
|
void pushStationInfo(LianLianPushStationInfoDTO dto);
|
||||||
|
|
||||||
@@ -78,4 +78,12 @@ public interface LianLianService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getToken(LianLianGetTokenDTO dto);
|
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
|
@Service
|
||||||
public class LianLianServiceImpl implements LianLianService {
|
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
|
@Autowired
|
||||||
private IPileMerchantInfoService pileMerchantInfoService;
|
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);
|
String jsonStr = JSONObject.toJSONString(info);
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
@@ -169,8 +175,7 @@ public class LianLianServiceImpl implements LianLianService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args){
|
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
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -575,7 +580,7 @@ public class LianLianServiceImpl implements LianLianService {
|
|||||||
String token = "";
|
String token = "";
|
||||||
try {
|
try {
|
||||||
//测试用请求地址
|
//测试用请求地址
|
||||||
String requestUrl = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/query_token";
|
String requestUrl = TEST_URL + "query_token";
|
||||||
|
|
||||||
//请求data
|
//请求data
|
||||||
Map<String, String> data = new HashMap<>();
|
Map<String, String> data = new HashMap<>();
|
||||||
@@ -617,6 +622,38 @@ public class LianLianServiceImpl implements LianLianService {
|
|||||||
return token;
|
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_stop_charge_result
|
||||||
|
|
||||||
// TODO 推送充电订单信息 notification_charge_order_info
|
// TODO 推送充电订单信息 notification_charge_order_info
|
||||||
|
|||||||
Reference in New Issue
Block a user