|
|
@@ -2,10 +2,8 @@ package com.zsElectric.boot.charging.service.impl;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
import com.zsElectric.boot.charging.service.ChargingReceptionService;
|
|
|
-import com.zsElectric.boot.charging.vo.ChargeResponseVO;
|
|
|
-import com.zsElectric.boot.charging.vo.ChargingStatusResponseVO;
|
|
|
+import com.zsElectric.boot.charging.vo.*;
|
|
|
import com.zsElectric.boot.common.constant.ConnectivityConstants;
|
|
|
-import com.zsElectric.boot.common.util.AESCryptoUtils;
|
|
|
import com.zsElectric.boot.common.util.electric.ChargingUtil;
|
|
|
import com.zsElectric.boot.common.util.electric.RequestParmsEntity;
|
|
|
import com.zsElectric.boot.common.util.electric.ResponseParmsEntity;
|
|
|
@@ -17,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
|
import static com.zsElectric.boot.common.constant.ConnectivityConstants.FAIL_REASON_NONE;
|
|
|
import static com.zsElectric.boot.common.constant.ConnectivityConstants.STATUS_OK;
|
|
|
import static com.zsElectric.boot.common.util.HmacMD5Util.genSign;
|
|
|
+import static com.zsElectric.boot.common.util.HmacMD5Util.verify;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -34,17 +33,22 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
String encryptData;
|
|
|
String genSign;
|
|
|
try {
|
|
|
- String decryptData = chargingUtil.decryptData(requestDTO.getData());
|
|
|
- log.info("解密后的数据:{}", decryptData);
|
|
|
- chargingStatusResponseVO = new Gson().fromJson(decryptData, ChargingStatusResponseVO.class);
|
|
|
- //todo 业务代码待处理
|
|
|
+ if(verify(requestDTO.getData(), ConnectivityConstants.SIG_SECRET, requestDTO.getSig())){
|
|
|
+ String decryptData = chargingUtil.decryptData(requestDTO.getData());
|
|
|
+ log.info("解密后的数据:{}", decryptData);
|
|
|
+ chargingStatusResponseVO = new Gson().fromJson(decryptData, ChargingStatusResponseVO.class);
|
|
|
+ //todo 业务代码待处理
|
|
|
|
|
|
|
|
|
- chargeResponseVO.setStartChargeSeq(chargingStatusResponseVO.getStartChargeSeq());
|
|
|
- chargeResponseVO.setSuccStat(STATUS_OK);
|
|
|
- chargeResponseVO.setFailReason(FAIL_REASON_NONE);
|
|
|
- encryptData = chargingUtil.encryptData(new Gson().toJson(chargeResponseVO));
|
|
|
- genSign = genSign(STATUS_OK, "请求成功", encryptData, ConnectivityConstants.SIG_SECRET);
|
|
|
+ chargeResponseVO.setStartChargeSeq(chargingStatusResponseVO.getStartChargeSeq());
|
|
|
+ chargeResponseVO.setSuccStat(STATUS_OK);
|
|
|
+ chargeResponseVO.setFailReason(FAIL_REASON_NONE);
|
|
|
+ encryptData = chargingUtil.encryptData(new Gson().toJson(chargeResponseVO));
|
|
|
+ genSign = genSign(STATUS_OK, "请求成功", encryptData, ConnectivityConstants.SIG_SECRET);
|
|
|
+ }else {
|
|
|
+ log.error("数据验签失败");
|
|
|
+ throw new BusinessException("数据验签失败");
|
|
|
+ }
|
|
|
}catch (Exception e){
|
|
|
log.error("数据解密失败:{}", e.getMessage());
|
|
|
throw new BusinessException("数据解密失败:" + e.getMessage(), e);
|
|
|
@@ -59,19 +63,107 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
@Override
|
|
|
public ResponseParmsEntity chargeStatusResponse(RequestParmsEntity requestDTO) {
|
|
|
log.info("接收推送充电状态请求参数:{}", requestDTO);
|
|
|
- return null;
|
|
|
+ EquipChargeStatusResponseVO equipChargeStatusResponseVO;
|
|
|
+ ChargeResponseVO chargeResponseVO = new ChargeResponseVO();
|
|
|
+ String encryptData;
|
|
|
+ String genSign;
|
|
|
+ try {
|
|
|
+ if(verify(requestDTO.getData(), ConnectivityConstants.SIG_SECRET, requestDTO.getSig())){
|
|
|
+ String decryptData = chargingUtil.decryptData(requestDTO.getData());
|
|
|
+ log.info("解密后的数据:{}", decryptData);
|
|
|
+ equipChargeStatusResponseVO = new Gson().fromJson(decryptData, EquipChargeStatusResponseVO.class);
|
|
|
+ //todo 业务代码待处理
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ chargeResponseVO.setStartChargeSeq(equipChargeStatusResponseVO.getStartChargeSeq());
|
|
|
+ chargeResponseVO.setSuccStat(STATUS_OK);
|
|
|
+ chargeResponseVO.setFailReason(FAIL_REASON_NONE);
|
|
|
+ encryptData = chargingUtil.encryptData(new Gson().toJson(chargeResponseVO));
|
|
|
+ genSign = genSign(STATUS_OK, "请求成功", encryptData, ConnectivityConstants.SIG_SECRET);
|
|
|
+ }else {
|
|
|
+ log.error("数据验签失败");
|
|
|
+ throw new BusinessException("数据验签失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("数据解密失败:{}", e.getMessage());
|
|
|
+ throw new BusinessException("数据解密失败:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return new ResponseParmsEntity()
|
|
|
+ .setRet(STATUS_OK)
|
|
|
+ .setMsg("请求成功")
|
|
|
+ .setData(encryptData)
|
|
|
+ .setSig(genSign);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ResponseParmsEntity stopChargeResponse(RequestParmsEntity requestDTO) {
|
|
|
log.info("接收推送停止充电结果请求参数:{}", requestDTO);
|
|
|
- return null;
|
|
|
+ StopChargingResponseVO stopChargingResponseVO;
|
|
|
+ ChargeResponseVO chargeResponseVO = new ChargeResponseVO();
|
|
|
+ String encryptData;
|
|
|
+ String genSign;
|
|
|
+ try {
|
|
|
+ if(verify(requestDTO.getData(), ConnectivityConstants.SIG_SECRET, requestDTO.getSig())){
|
|
|
+ String decryptData = chargingUtil.decryptData(requestDTO.getData());
|
|
|
+ log.info("解密后的数据:{}", decryptData);
|
|
|
+ stopChargingResponseVO = new Gson().fromJson(decryptData, StopChargingResponseVO.class);
|
|
|
+ //todo 业务代码待处理
|
|
|
+
|
|
|
+
|
|
|
+ chargeResponseVO.setStartChargeSeq(stopChargingResponseVO.getStartChargeSeq());
|
|
|
+ chargeResponseVO.setSuccStat(STATUS_OK);
|
|
|
+ chargeResponseVO.setFailReason(FAIL_REASON_NONE);
|
|
|
+ encryptData = chargingUtil.encryptData(new Gson().toJson(chargeResponseVO));
|
|
|
+ genSign = genSign(STATUS_OK, "请求成功", encryptData, ConnectivityConstants.SIG_SECRET);
|
|
|
+ }else {
|
|
|
+ log.error("数据验签失败");
|
|
|
+ throw new BusinessException("数据验签失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("数据解密失败:{}", e.getMessage());
|
|
|
+ throw new BusinessException("数据解密失败:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return new ResponseParmsEntity()
|
|
|
+ .setRet(STATUS_OK)
|
|
|
+ .setMsg("请求成功")
|
|
|
+ .setData(encryptData)
|
|
|
+ .setSig(genSign);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ResponseParmsEntity chargeOrderResponse(RequestParmsEntity requestDTO) {
|
|
|
log.info("接收推送充电订单信息请求参数:{}", requestDTO);
|
|
|
- return null;
|
|
|
+ ChargingOrderVO chargingOrderVO;
|
|
|
+ ChargeResponseVO chargeResponseVO = new ChargeResponseVO();
|
|
|
+ String encryptData;
|
|
|
+ String genSign;
|
|
|
+ try {
|
|
|
+ if(verify(requestDTO.getData(), ConnectivityConstants.SIG_SECRET, requestDTO.getSig())){
|
|
|
+ String decryptData = chargingUtil.decryptData(requestDTO.getData());
|
|
|
+ log.info("解密后的数据:{}", decryptData);
|
|
|
+ chargingOrderVO = new Gson().fromJson(decryptData, ChargingOrderVO.class);
|
|
|
+ //todo 业务代码待处理
|
|
|
+
|
|
|
+
|
|
|
+ chargeResponseVO.setStartChargeSeq(chargingOrderVO.getStartChargeSeq());
|
|
|
+ chargeResponseVO.setSuccStat(STATUS_OK);
|
|
|
+ chargeResponseVO.setFailReason(FAIL_REASON_NONE);
|
|
|
+ encryptData = chargingUtil.encryptData(new Gson().toJson(chargeResponseVO));
|
|
|
+ genSign = genSign(STATUS_OK, "请求成功", encryptData, ConnectivityConstants.SIG_SECRET);
|
|
|
+ }else {
|
|
|
+ log.error("数据验签失败");
|
|
|
+ throw new BusinessException("数据验签失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("数据解密失败:{}", e.getMessage());
|
|
|
+ throw new BusinessException("数据解密失败:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return new ResponseParmsEntity()
|
|
|
+ .setRet(STATUS_OK)
|
|
|
+ .setMsg("请求成功")
|
|
|
+ .setData(encryptData)
|
|
|
+ .setSig(genSign);
|
|
|
}
|
|
|
|
|
|
}
|