|
|
@@ -1,8 +1,9 @@
|
|
|
package com.zsElectric.boot.charging.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.zsElectric.boot.charging.dto.StartChargingRequestDTO;
|
|
|
import com.zsElectric.boot.charging.dto.StartChargingResponseVO;
|
|
|
import com.zsElectric.boot.charging.service.ChargingBusinessService;
|
|
|
@@ -30,6 +31,8 @@ public class ChargingBusinessServiceImpl implements ChargingBusinessService {
|
|
|
|
|
|
private final ChargingUtil chargingUtil;
|
|
|
|
|
|
+ private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+
|
|
|
@Override
|
|
|
public ApiToken queryToken() {
|
|
|
try {
|
|
|
@@ -38,8 +41,8 @@ public class ChargingBusinessServiceImpl implements ChargingBusinessService {
|
|
|
.setOperatorID(ConnectivityConstants.OPERATOR_ID)
|
|
|
.setOperatorSecret(ConnectivityConstants.PLATFORM_OPERATOR_SECRET);
|
|
|
|
|
|
- JsonObject response = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_TOKEN, BeanUtil.beanToMap(queryTokenParms), false);
|
|
|
- ResponseParmsEntity responseParms = new Gson().fromJson(response, ResponseParmsEntity.class);
|
|
|
+ JsonNode response = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_TOKEN, BeanUtil.beanToMap(queryTokenParms), false);
|
|
|
+ ResponseParmsEntity responseParms = objectMapper.readValue(response.toString(), ResponseParmsEntity.class);
|
|
|
String data = responseParms.getRet() + responseParms.getMsg() + responseParms.getData();
|
|
|
boolean verify = HmacMD5Util.verify(data, ConnectivityConstants.PLATFORM_SIG_SECRET, responseParms.getSig());
|
|
|
if (!verify) {
|
|
|
@@ -65,7 +68,7 @@ public class ChargingBusinessServiceImpl implements ChargingBusinessService {
|
|
|
String decodeData = AESCryptoUtils.decrypt(responseParms.getData(), ConnectivityConstants.PLATFORM_DATA_SECRET,
|
|
|
ConnectivityConstants.PLATFORM_DATA_SECRET_IV);
|
|
|
|
|
|
- QueryTokenResponseData responseData = new Gson().fromJson(decodeData, QueryTokenResponseData.class);
|
|
|
+ QueryTokenResponseData responseData = objectMapper.readValue(decodeData, QueryTokenResponseData.class);
|
|
|
|
|
|
if (responseData.getSuccStat() == 1) {
|
|
|
//0-无,1-OperatorID无效
|
|
|
@@ -92,94 +95,94 @@ public class ChargingBusinessServiceImpl implements ChargingBusinessService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ChargingPricePolicyVO queryEquipBusinessPolicy(String equipBizSeq, String connectorID) {
|
|
|
+ public ChargingPricePolicyVO queryEquipBusinessPolicy(String equipBizSeq, String connectorID) throws JsonProcessingException {
|
|
|
Map<String, Object> queryTokenParms = new HashMap<>();
|
|
|
// 注意:第三方接口要求大驼峰命名
|
|
|
queryTokenParms.put("EquipBizSeq", equipBizSeq);
|
|
|
queryTokenParms.put("ConnectorID", connectorID);
|
|
|
log.info("查询设备价格策略请求参数:{}", queryTokenParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_BUSINESS_POLICY, queryTokenParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_BUSINESS_POLICY, queryTokenParms, true);
|
|
|
log.info("查询设备价格策略返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("查询设备价格策略返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, ChargingPricePolicyVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), ChargingPricePolicyVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public EquipmentAuthResponseVO queryEquipAuth(String EquipAuthSeq, String ConnectorID) {
|
|
|
+ public EquipmentAuthResponseVO queryEquipAuth(String EquipAuthSeq, String ConnectorID) throws JsonProcessingException {
|
|
|
Map<String, Object> queryTokenParms = new HashMap<>();
|
|
|
queryTokenParms.put("EquipAuthSeq", EquipAuthSeq);
|
|
|
queryTokenParms.put("ConnectorID", ConnectorID);
|
|
|
log.info("查询设备认证请求参数:{}", queryTokenParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_AUTH, queryTokenParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_AUTH, queryTokenParms, true);
|
|
|
log.info("查询设备认证返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("查询设备认证返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, EquipmentAuthResponseVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), EquipmentAuthResponseVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public QueryStationsInfoVO queryStationsInfo(String LastQueryTime, Integer PageNo, Integer PageSize) {
|
|
|
+ public QueryStationsInfoVO queryStationsInfo(String LastQueryTime, Integer PageNo, Integer PageSize) throws JsonProcessingException {
|
|
|
Map<String, Object> queryParms = new HashMap<>();
|
|
|
queryParms.put("LastQueryTime", LastQueryTime);
|
|
|
queryParms.put("PageNo", PageNo);
|
|
|
queryParms.put("PageSize", PageSize);
|
|
|
log.info("查询充电站信息请求参数:{}", queryParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATIONS_INFO, queryParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATIONS_INFO, queryParms, true);
|
|
|
log.info("查询充电站信息返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("查询充电站信息返回结果解密后:{}", responseDecode);
|
|
|
if (responseDecode == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- return new Gson().fromJson(responseDecode, QueryStationsInfoVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), QueryStationsInfoVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public QueryStationStatusVO queryStationStatus(List<String> stationIDs) {
|
|
|
+ public QueryStationStatusVO queryStationStatus(List<String> stationIDs) throws JsonProcessingException {
|
|
|
Map<String, Object> queryParms = new HashMap<>();
|
|
|
queryParms.put("StationIDs", stationIDs);
|
|
|
log.info("设备接口状态查询请求参数:{}", queryParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATION_STATUS, queryParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATION_STATUS, queryParms, true);
|
|
|
log.info("设备接口状态查询返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("设备接口状态查询返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, QueryStationStatusVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), QueryStationStatusVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StartChargingResponseVO startCharging(StartChargingRequestDTO requestDTO){
|
|
|
+ public StartChargingResponseVO startCharging(StartChargingRequestDTO requestDTO) throws JsonProcessingException {
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(requestDTO);
|
|
|
log.info("设备接口状态查询请求参数:{}", stringObjectMap);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_START_CHARGE, stringObjectMap, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_START_CHARGE, stringObjectMap, true);
|
|
|
log.info("设备接口状态查询返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("设备接口状态查询返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, StartChargingResponseVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), StartChargingResponseVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ChargingStatusQueryResponseVO queryChargingStatus(String StartChargeSeq) {
|
|
|
+ public ChargingStatusQueryResponseVO queryChargingStatus(String StartChargeSeq) throws JsonProcessingException {
|
|
|
Map<String, Object> queryParms = new HashMap<>();
|
|
|
queryParms.put("StartChargeSeq", StartChargeSeq);
|
|
|
log.info("查询充电订单状态请求参数:{}", queryParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_CHARGE_STATUS, queryParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_CHARGE_STATUS, queryParms, true);
|
|
|
log.info("查询充电订单状态返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("查询充电订单状态返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, ChargingStatusQueryResponseVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), ChargingStatusQueryResponseVO.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StopChargingOperationResponseVO stopCharging(String StartChargeSeq, String ConnectorID) {
|
|
|
+ public StopChargingOperationResponseVO stopCharging(String StartChargeSeq, String ConnectorID) throws JsonProcessingException {
|
|
|
Map<String, Object> queryTokenParms = new HashMap<>();
|
|
|
queryTokenParms.put("StartChargeSeq", StartChargeSeq);
|
|
|
queryTokenParms.put("ConnectorID", ConnectorID);
|
|
|
log.info("停止充电请求参数:{}", queryTokenParms);
|
|
|
- JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STOP_CHARGE, queryTokenParms, true);
|
|
|
+ JsonNode jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STOP_CHARGE, queryTokenParms, true);
|
|
|
log.info("停止充电返回结果:{}", jsonObject);
|
|
|
- JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
+ JsonNode responseDecode = chargingUtil.responseDecode(jsonObject);
|
|
|
log.info("停止充电返回结果解密后:{}", responseDecode);
|
|
|
- return new Gson().fromJson(responseDecode, StopChargingOperationResponseVO.class);
|
|
|
+ return objectMapper.readValue(responseDecode.toString(), StopChargingOperationResponseVO.class);
|
|
|
}
|
|
|
}
|