mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update
This commit is contained in:
@@ -43,6 +43,8 @@ import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
||||
import com.jsowell.thirdparty.lianlian.util.HttpRequestUtil;
|
||||
import com.jsowell.thirdparty.lianlian.vo.*;
|
||||
import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO;
|
||||
import com.jsowell.thirdparty.yongchengboche.service.YCBCService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -88,6 +90,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Autowired
|
||||
private YCBCService ycbcService;
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@@ -856,14 +861,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relationInfo.getThirdPartyType();
|
||||
|
||||
String url = urlAddress + "notification_stationStatus";
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
|
||||
.connectorID(pileConnectorCode)
|
||||
.status(status)
|
||||
@@ -872,13 +872,24 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("ConnectorStatusInfo", info);
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
// 获取令牌
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
String token = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO dto = new YCBCGetTokenDTO();
|
||||
dto.setOperatorId(operatorId);
|
||||
dto.setDataSecret(dataSecret);
|
||||
dto.setSignSecret(signSecret);
|
||||
dto.setUrlAddress(urlAddress);
|
||||
dto.setDataSecretIv(dataSecretIv);
|
||||
dto.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(dto);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1036,14 +1047,11 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relation.getThirdPartyType();
|
||||
|
||||
// 推送启动充电结果(调用接口 notification_start_charge_result)
|
||||
String url = urlAddress + "notification_start_charge_result";
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String orderStatus = orderInfo.getOrderStatus();
|
||||
// 订单状态统一
|
||||
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
|
||||
@@ -1065,10 +1073,21 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO dto = new YCBCGetTokenDTO();
|
||||
dto.setOperatorId(operatorId);
|
||||
dto.setDataSecret(dataSecret);
|
||||
dto.setSignSecret(signSecret);
|
||||
dto.setUrlAddress(urlAddress);
|
||||
dto.setDataSecretIv(dataSecretIv);
|
||||
dto.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(dto);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
return result;
|
||||
@@ -1098,6 +1117,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relation.getThirdPartyType();
|
||||
|
||||
// 调用 查询充电状态方法
|
||||
QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO();
|
||||
@@ -1113,19 +1133,27 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转成对应的对象
|
||||
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String url = urlAddress + "notification_equip_charge_status";
|
||||
// 调用联联平台接口
|
||||
String jsonString = JSONObject.toJSONString(queryEquipChargeStatusDTO);
|
||||
|
||||
// 获取令牌
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO ycbcGetTokenDTO = new YCBCGetTokenDTO();
|
||||
ycbcGetTokenDTO.setOperatorId(operatorId);
|
||||
ycbcGetTokenDTO.setDataSecret(dataSecret);
|
||||
ycbcGetTokenDTO.setSignSecret(signSecret);
|
||||
ycbcGetTokenDTO.setUrlAddress(urlAddress);
|
||||
ycbcGetTokenDTO.setDataSecretIv(dataSecretIv);
|
||||
ycbcGetTokenDTO.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(ycbcGetTokenDTO);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
return result;
|
||||
@@ -1159,6 +1187,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relation.getThirdPartyType();
|
||||
|
||||
String url = urlAddress + "notification_stop_charge_result";
|
||||
|
||||
@@ -1174,11 +1203,6 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
} else {
|
||||
orderStatus = "5";
|
||||
}
|
||||
// 获取token
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 拼装联联平台参数
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -1190,11 +1214,22 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
|
||||
// 发送请求
|
||||
// 获取token
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO dto = new YCBCGetTokenDTO();
|
||||
dto.setOperatorId(operatorId);
|
||||
dto.setDataSecret(dataSecret);
|
||||
dto.setSignSecret(signSecret);
|
||||
dto.setUrlAddress(urlAddress);
|
||||
dto.setDataSecretIv(dataSecretIv);
|
||||
dto.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(dto);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
return result;
|
||||
@@ -1226,6 +1261,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relation.getThirdPartyType();
|
||||
|
||||
String url = urlAddress + "notification_charge_order_info";
|
||||
|
||||
@@ -1241,17 +1277,27 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
json.put("StopReason", 2); // 2:BMS 停止充电
|
||||
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (token == null) {
|
||||
return null;
|
||||
}
|
||||
// 发送请求
|
||||
// 获取令牌
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO dto = new YCBCGetTokenDTO();
|
||||
dto.setOperatorId(operatorId);
|
||||
dto.setDataSecret(dataSecret);
|
||||
dto.setSignSecret(signSecret);
|
||||
dto.setUrlAddress(urlAddress);
|
||||
dto.setDataSecretIv(dataSecretIv);
|
||||
dto.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(dto);
|
||||
// 发送请求
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
// 发送请求
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
package com.jsowell.thirdparty.yongchengboche.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
||||
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
|
||||
import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO;
|
||||
import com.jsowell.thirdparty.yongchengboche.service.YCBCService;
|
||||
import com.jsowell.thirdparty.zhongdianlian.service.ZDLService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -27,6 +40,8 @@ public class YCBCServiceImpl implements YCBCService {
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
@@ -35,7 +50,60 @@ public class YCBCServiceImpl implements YCBCService {
|
||||
*/
|
||||
@Override
|
||||
public String YCBCGetToken(YCBCGetTokenDTO dto) {
|
||||
return zdlService.ZDLGetToken(dto);
|
||||
String dataSecret = dto.getDataSecret();
|
||||
String dataSecretIv = dto.getDataSecretIv();
|
||||
String operatorId = dto.getOperatorId();
|
||||
String operatorSecret = dto.getOperatorSecret();
|
||||
String urlAddress = dto.getUrlAddress();
|
||||
String signSecret = dto.getSignSecret();
|
||||
|
||||
String token = "";
|
||||
try {
|
||||
// 请求地址
|
||||
String requestUrl = urlAddress + "query_token";
|
||||
|
||||
// 请求data
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("OperatorID", operatorId);
|
||||
data.put("OperatorSecret", operatorSecret);
|
||||
data.put("DataSecretIV", dataSecretIv);
|
||||
String dataJson = JSONUtil.toJsonStr(data);
|
||||
|
||||
// 加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
|
||||
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||
String strData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
Map<String, String> request = new LinkedHashMap<>();
|
||||
request.put("OperatorID", operatorId);
|
||||
request.put("Data", strData);
|
||||
request.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
|
||||
request.put("Seq", "0001");
|
||||
|
||||
// 生成签名
|
||||
String sig = GBSignUtils.sign(request, signSecret);
|
||||
request.put("Portname", "wcc-pro"); // 此处是与其他获取令牌方法唯一不同之处,甬城泊车获取令牌需要添加此字段
|
||||
request.put("Sig", sig);
|
||||
|
||||
String tokenRequest = JSONUtil.toJsonStr(request);
|
||||
|
||||
String response = HttpUtil.post(requestUrl, tokenRequest);
|
||||
LianLianResultVO result = JSON.parseObject(response, LianLianResultVO.class);
|
||||
logger.info("获取甬城泊车令牌 result:{}", result);
|
||||
|
||||
if (result.getRet() == 0) {
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()),
|
||||
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
|
||||
token = resultMap.get("AccessToken");
|
||||
logger.info("甬城泊车 token: {}", token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
||||
import com.jsowell.thirdparty.lianlian.util.HttpRequestUtil;
|
||||
import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO;
|
||||
import com.jsowell.thirdparty.yongchengboche.service.YCBCService;
|
||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLConnectorInfo;
|
||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLEquipmentInfo;
|
||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLStationInfo;
|
||||
@@ -48,6 +50,9 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
@Autowired
|
||||
private YCBCService ycbcService;
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@@ -109,6 +114,7 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
String dataSecret = relationInfo.getDataSecret();
|
||||
String dataSecretIv = relationInfo.getDataSecretIv();
|
||||
String urlAddress = relationInfo.getUrlAddress();
|
||||
String thirdPartyType = relation.getThirdPartyType();
|
||||
|
||||
// 组装中电联平台所需要的数据格式
|
||||
ZDLStationInfo info = ZDLStationInfo.builder()
|
||||
@@ -151,22 +157,31 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
System.out.println("jsonString : " + jsonString);
|
||||
|
||||
// 获取令牌
|
||||
ZDLGetTokenDTO tokenDTO = ZDLGetTokenDTO.builder()
|
||||
.urlAddress(urlAddress)
|
||||
.operatorId(operatorId)
|
||||
.operatorSecret(operatorSecret)
|
||||
.dataSecret(dataSecret)
|
||||
.dataSecretIv(dataSecretIv)
|
||||
.signSecret(signSecret)
|
||||
.build();
|
||||
String token = ZDLGetToken(tokenDTO);
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) {
|
||||
YCBCGetTokenDTO ycbcGetTokenDTO = new YCBCGetTokenDTO();
|
||||
ycbcGetTokenDTO.setOperatorId(operatorId);
|
||||
ycbcGetTokenDTO.setDataSecret(dataSecret);
|
||||
ycbcGetTokenDTO.setSignSecret(signSecret);
|
||||
ycbcGetTokenDTO.setUrlAddress(urlAddress);
|
||||
ycbcGetTokenDTO.setDataSecretIv(dataSecretIv);
|
||||
ycbcGetTokenDTO.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(ycbcGetTokenDTO);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
ZDLGetTokenDTO tokenDTO = ZDLGetTokenDTO.builder()
|
||||
.urlAddress(urlAddress)
|
||||
.operatorId(operatorId)
|
||||
.operatorSecret(operatorSecret)
|
||||
.dataSecret(dataSecret)
|
||||
.dataSecretIv(dataSecretIv)
|
||||
.signSecret(signSecret)
|
||||
.build();
|
||||
token = ZDLGetToken(tokenDTO);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
|
||||
// System.out.println(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user