add 后管推送站点信息到联联平台

This commit is contained in:
Lemon
2023-05-26 08:58:42 +08:00
parent fd84575155
commit 7c53e44830
9 changed files with 235 additions and 106 deletions

View File

@@ -18,7 +18,7 @@ public interface LianLianService {
* 根据充电站id推送充电站信息
* @param dto
*/
void pushStationInfo(LianLianPushStationInfoDTO dto);
String pushStationInfo(LianLianPushStationInfoDTO dto);
/**
* 联联平台获取充电站信息
@@ -74,11 +74,12 @@ public interface LianLianService {
/**
* 联联平台获取令牌
* @param urlAddress
* @param operatorId
* @param operatorSecret
* @return
*/
String getToken(String operatorId, String operatorSecret);
String getToken(String urlAddress, String operatorId, String operatorSecret);
/**
* 推送联联平台 设备状态变化推送

View File

@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
@Service
public class LianLianServiceImpl implements LianLianService {
private static final String TEST_URL = "http://dataexchange.evchargeonline.com:81/shevcs/v1/"; // http://testdataexchange.evchargeonline.com:82/shevcs/v1/
// private static final String TEST_URL = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/"; // http://testdataexchange.evchargeonline.com:82/shevcs/v1/
// private static final String OPERATOR_ID = "MA1JLFUU8"; // MA1JLFUU8 987654321
// private static final String OPERATOR_SECRET = "fGwLsxW1HdzLw7jp"; // fGwLsxW1HdzLw7jp 1234567890abcdef
// private static final String SIG_SECRET = "TmsdVaFVTtjzZbLi"; // 签名秘钥 TmsdVaFVTtjzZbLi 1234567890abcdef
@@ -96,7 +96,7 @@ public class LianLianServiceImpl implements LianLianService {
* @param dto
*/
@Override
public void pushStationInfo(LianLianPushStationInfoDTO dto){
public String pushStationInfo(LianLianPushStationInfoDTO dto){
// String OperatorID = "987654321";
// String SigSecret = "1234567890abcdef"; // 签名秘钥
// String DataSecret = "1234567890abcdef"; // 消息密钥
@@ -108,13 +108,14 @@ public class LianLianServiceImpl implements LianLianService {
// 通过站点id查询相关配置信息
ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(dto.getStationId());
if (settingInfo == null) {
return;
throw new BusinessException("", "");
}
String operatorId = settingInfo.getOperatorId();
String operatorSecret = settingInfo.getOperatorSecret();
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
// 组装联联平台所需要的数据格式
StationInfo info = StationInfo.builder()
@@ -162,7 +163,7 @@ public class LianLianServiceImpl implements LianLianService {
}
// 调用联联平台接口
String url = TEST_URL + "notification_stationInfo";
String url = urlAddress + "notification_stationInfo";
String jsonStr = JSONObject.toJSONString(info);
JSONObject data = new JSONObject();
@@ -172,12 +173,12 @@ public class LianLianServiceImpl implements LianLianService {
System.out.println("jsonString : " + jsonString);
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret
, dataSecretIv, operatorId, signSecret);
System.out.println(result);
// System.out.println(result);
return result;
}
public static void main(String[] args){
@@ -591,13 +592,13 @@ public class LianLianServiceImpl implements LianLianService {
* @return
*/
@Override
public String getToken(String operatorId, String operatorSecret) {
public String getToken(String urlAddress, String operatorId, String operatorSecret) {
// String operatorId = dto.getOperatorId();
// String operatorSecret = dto.getOperatorSecret();
String token = "";
try {
//测试用请求地址
String requestUrl = TEST_URL + "query_token";
String requestUrl = urlAddress + "query_token";
//请求data
Map<String, String> data = new HashMap<>();
@@ -660,11 +661,12 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = TEST_URL + "notification_stationStatus";
String url = urlAddress + "notification_stationStatus";
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)) {
return null;
}
@@ -704,8 +706,9 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = TEST_URL + "notification_orderInfo";
String url = urlAddress + "notification_orderInfo";
// 拼装成联联平台所需格式对象
OrderInfo orderInfo = OrderInfo.builder()
@@ -790,7 +793,7 @@ public class LianLianServiceImpl implements LianLianService {
orderInfo.setChargeDetails(chargeDetails);
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)) {
return null;
}
@@ -826,11 +829,12 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
// 推送启动充电结果(调用接口 notification_start_charge_result)
String url = TEST_URL + "notification_start_charge_result";
String url = urlAddress + "notification_start_charge_result";
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)) {
return null;
}
@@ -879,15 +883,16 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
// 调用 查询充电状态方法
QueryChargingStatusVO vo = query_equip_charge_status(orderCode);
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)) {
return null;
}
String url = TEST_URL + "notification_equip_charge_status";
String url = urlAddress + "notification_equip_charge_status";
// 调用联联平台接口
String jsonString = JSONObject.toJSONString(vo);
@@ -903,7 +908,7 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public String pushStopChargeResult(String orderCode) {
String url = TEST_URL + "notification_stop_charge_result";
// 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
if (orderInfo == null) {
@@ -919,6 +924,9 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "notification_stop_charge_result";
String orderStatus = orderInfo.getOrderStatus();
String successFlag = "1";
@@ -933,7 +941,7 @@ public class LianLianServiceImpl implements LianLianService {
orderStatus = "5";
}
// 获取token
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)) {
return null;
}
@@ -961,7 +969,7 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public String pushChargeOrderInfo(String orderCode) {
String url = TEST_URL + "notification_charge_order_info";
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
@@ -975,6 +983,9 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "notification_charge_order_info";
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);
@@ -988,7 +999,7 @@ public class LianLianServiceImpl implements LianLianService {
json.put("StopReason", 2); // 2BMS 停止充电
String jsonString = JSONObject.toJSONString(json);
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (token == null) {
return null;
}
@@ -1036,7 +1047,7 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public String queryOrderSettlementInfo(String orderCode) {
String url = TEST_URL + "query_order_settlement_info";
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);
String jsonString = JSONObject.toJSONString(json);
@@ -1053,9 +1064,12 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "query_order_settlement_info";
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)){
return null;
}
@@ -1072,7 +1086,7 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public String pushOrderReconciliationInfo(String orderCode) {
String url = TEST_URL + "check_charge_orders";
List<ChargeOrder> list = new ArrayList<>();
// 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
@@ -1091,6 +1105,9 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "check_charge_orders";
JSONObject json = new JSONObject();
json.put("CheckOrderSeq", orderCode);
@@ -1109,7 +1126,7 @@ public class LianLianServiceImpl implements LianLianService {
json.put("ChargeOrders", list);
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)){
return null;
}
@@ -1127,7 +1144,7 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public String pushPileChargeStatusChange(String pileConnectorCode) {
String url = TEST_URL + "notification_connector_charge_status";
// 根据枪口号查询充电实时状态
OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode);
List<RealTimeMonitorData> list = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
@@ -1159,9 +1176,12 @@ public class LianLianServiceImpl implements LianLianService {
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "notification_connector_charge_status";
// 获取令牌
String token = getToken(operatorId, operatorSecret);
String token = getToken(urlAddress, operatorId, operatorSecret);
if (StringUtils.isBlank(token)){
return null;
}