mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 03:39:55 +08:00
update 华为Service
This commit is contained in:
@@ -4,12 +4,15 @@ import com.alibaba.fastjson2.JSON;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.jsowell.common.annotation.Anonymous;
|
import com.jsowell.common.annotation.Anonymous;
|
||||||
import com.jsowell.common.core.controller.BaseController;
|
import com.jsowell.common.core.controller.BaseController;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.response.RestApiResponse;
|
import com.jsowell.common.response.RestApiResponse;
|
||||||
import com.jsowell.common.util.JWTUtils;
|
import com.jsowell.common.util.JWTUtils;
|
||||||
|
import com.jsowell.pile.dto.ThirdPartyCommonStartChargeDTO;
|
||||||
import com.jsowell.pile.dto.huawei.*;
|
import com.jsowell.pile.dto.huawei.*;
|
||||||
import com.jsowell.pile.vo.huawei.QueryChargeStatusVO;
|
import com.jsowell.pile.vo.huawei.QueryChargeStatusVO;
|
||||||
import com.jsowell.pile.vo.huawei.QueryEquipAuthVO;
|
import com.jsowell.pile.vo.huawei.QueryEquipAuthVO;
|
||||||
import com.jsowell.pile.vo.huawei.QueryStartChargeVO;
|
import com.jsowell.pile.vo.huawei.QueryStartChargeVO;
|
||||||
|
import com.jsowell.thirdparty.common.CommonService;
|
||||||
import com.jsowell.thirdparty.huawei.HuaweiServiceV2;
|
import com.jsowell.thirdparty.huawei.HuaweiServiceV2;
|
||||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
||||||
@@ -40,6 +43,9 @@ public class HuaWeiControllerV2 extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private HuaweiServiceV2 huaweiServiceV2;
|
private HuaweiServiceV2 huaweiServiceV2;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommonService commonService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取token接口
|
* 获取token接口
|
||||||
* http://localhost:8080/huawei/v1/query_token
|
* http://localhost:8080/huawei/v1/query_token
|
||||||
@@ -184,12 +190,12 @@ public class HuaWeiControllerV2 extends BaseController {
|
|||||||
Map<String, String> resultMap = null;
|
Map<String, String> resultMap = null;
|
||||||
try {
|
try {
|
||||||
resultMap = huaweiServiceV2.vinStartCharge(vinStartChargeDTO);
|
resultMap = huaweiServiceV2.vinStartCharge(vinStartChargeDTO);
|
||||||
logger.info("华为vin启动充电 result:{}", resultMap);
|
} catch (Exception e) {
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("华为vin启动充电 error", e);
|
logger.error("华为vin启动充电 error", e);
|
||||||
}
|
}
|
||||||
|
logger.info("华为vin启动充电 resultMap:{}", resultMap);
|
||||||
if (resultMap != null) {
|
if (resultMap != null) {
|
||||||
return CommonResult.success(0, "vin启动充电成功!", resultMap.get("Data"), resultMap.get("Sig"));
|
return CommonResult.success(0, "vin启动充电结果", resultMap.get("Data"), resultMap.get("Sig"));
|
||||||
}else {
|
}else {
|
||||||
return CommonResult.failed("vin启动充电 error");
|
return CommonResult.failed("vin启动充电 error");
|
||||||
}
|
}
|
||||||
@@ -342,6 +348,21 @@ public class HuaWeiControllerV2 extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/commonStartCharge")
|
||||||
|
public RestApiResponse<?> commonStartCharge(@RequestBody ThirdPartyCommonStartChargeDTO dto) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String result = commonService.commonQueryStartCharge(dto);
|
||||||
|
response = new RestApiResponse<>(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("统一启动充电接口 error", e);
|
||||||
|
}
|
||||||
|
logger.info("统一启动充电接口 params:{}, result:{}", JSON.toJSONString(dto), response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -817,6 +817,9 @@ public class HuaweiServiceV2 {
|
|||||||
if (configInfo == null) {
|
if (configInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
int succStat = Constants.one; // 操作结果
|
||||||
|
int failReason = Constants.one; // 失败原因
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
|
||||||
String vinCode = dto.getVin();
|
String vinCode = dto.getVin();
|
||||||
String pileConnectorCode = dto.getConnectorID();
|
String pileConnectorCode = dto.getConnectorID();
|
||||||
@@ -827,32 +830,35 @@ public class HuaweiServiceV2 {
|
|||||||
MemberPlateNumberRelation basicInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
MemberPlateNumberRelation basicInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
||||||
if (basicInfo == null) {
|
if (basicInfo == null) {
|
||||||
// 该用户未注册
|
// 该用户未注册
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_GENERATE_ORDER_ERROR);
|
jsonObject.put("SuccStat", succStat);
|
||||||
|
jsonObject.put("FailReason", failReason);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = getResultMap(jsonObject);
|
||||||
|
return resultMap;
|
||||||
|
}else {
|
||||||
|
// 生成订单,并启动充电
|
||||||
|
GenerateOrderDTO generateOrderDTO = new GenerateOrderDTO();
|
||||||
|
generateOrderDTO.setMemberPlateNumberRelation(basicInfo);
|
||||||
|
generateOrderDTO.setPileSn(pileSn);
|
||||||
|
generateOrderDTO.setConnectorCode(connectorCode);
|
||||||
|
generateOrderDTO.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
||||||
|
generateOrderDTO.setMemberId(basicInfo.getMemberId());
|
||||||
|
generateOrderDTO.setStartSoc(String.valueOf(dto.getSoc()));
|
||||||
|
|
||||||
|
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(generateOrderDTO);
|
||||||
|
if (map != null) {
|
||||||
|
// 鉴权成功
|
||||||
|
succStat = Constants.zero;
|
||||||
|
failReason = Constants.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject.put("SuccStat", succStat);
|
||||||
|
jsonObject.put("FailReason", failReason);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = getResultMap(jsonObject);
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成订单,并启动充电
|
|
||||||
GenerateOrderDTO generateOrderDTO = new GenerateOrderDTO();
|
|
||||||
generateOrderDTO.setMemberPlateNumberRelation(basicInfo);
|
|
||||||
generateOrderDTO.setPileSn(pileSn);
|
|
||||||
generateOrderDTO.setConnectorCode(connectorCode);
|
|
||||||
generateOrderDTO.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
|
||||||
generateOrderDTO.setMemberId(basicInfo.getMemberId());
|
|
||||||
generateOrderDTO.setStartSoc(String.valueOf(dto.getSoc()));
|
|
||||||
|
|
||||||
int succStat = Constants.one; // 操作结果
|
|
||||||
int failReason = Constants.one; // 失败原因
|
|
||||||
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(generateOrderDTO);
|
|
||||||
if (map != null) {
|
|
||||||
// 鉴权成功
|
|
||||||
succStat = Constants.zero;
|
|
||||||
failReason = Constants.zero;
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.put("SuccStat", succStat);
|
|
||||||
jsonObject.put("FailReason", failReason);
|
|
||||||
|
|
||||||
Map<String, String> resultMap = getResultMap(jsonObject);
|
|
||||||
return resultMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ public class LianLianServiceImpl implements LianLianService {
|
|||||||
String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR
|
String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR
|
||||||
String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm
|
String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm
|
||||||
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
|
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
|
||||||
String dataString = "o1tqVesDkPUXBNdUmE10Z7FWjAf/KFO3Iq4NWNCcFeq0h8wBcdWcZwojkdv2TNFpS0Qftv1HWDTdm+8Pjj0AIw==";
|
String dataString = "GZlmSIZOVzT+Yvpc2PmvNmwKXhaqSnsNdCUS61pq9BxES7v9FWNrUvqk3OsAUMPvjCwmYeskIglHXw0OFfYGZ1bXxAzHymzsqfehZ10WoNs=";
|
||||||
|
|
||||||
// 解密data
|
// 解密data
|
||||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||||
|
|||||||
Reference in New Issue
Block a user