mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-20 23:29:48 +08:00
新增华为 接收设备请求状态变化推送、请求设备认证接口
This commit is contained in:
@@ -364,7 +364,7 @@ public class MemberService {
|
|||||||
}
|
}
|
||||||
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
||||||
}
|
}
|
||||||
log.info("查询用户余额信息 service方法 开始处理分页----");
|
// log.info("查询用户余额信息 service方法 开始处理分页----");
|
||||||
List<MemberWalletLogVO> collect = list.stream()
|
List<MemberWalletLogVO> collect = list.stream()
|
||||||
.skip((pageNum - 1) * pageSize)
|
.skip((pageNum - 1) * pageSize)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
@@ -381,7 +381,7 @@ public class MemberService {
|
|||||||
.total(total)
|
.total(total)
|
||||||
.build();
|
.build();
|
||||||
vo.setPageResponse(pageResponse);
|
vo.setPageResponse(pageResponse);
|
||||||
log.info("查询用户余额信息 service方法 end");
|
// log.info("查询用户余额信息 service方法 end");
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.jsowell.pile.vo.huawei;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求设备认证VO
|
||||||
|
*
|
||||||
|
* @author Lemon
|
||||||
|
* @Date 2024/1/22 15:53:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryEquipAuthVO {
|
||||||
|
|
||||||
|
@JSONField(name = "EquipAuthSeq")
|
||||||
|
private String equipAuthSeq;
|
||||||
|
|
||||||
|
@JSONField(name = "ConnectorID")
|
||||||
|
private String connectorID;
|
||||||
|
|
||||||
|
@JSONField(name = "SuccStat")
|
||||||
|
private Integer succStat;
|
||||||
|
|
||||||
|
@JSONField(name = "FailReason")
|
||||||
|
private Integer failReason;
|
||||||
|
}
|
||||||
@@ -3,20 +3,21 @@ package com.jsowell.thirdparty.huawei;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.jsowell.common.constant.Constants;
|
import com.jsowell.common.constant.Constants;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.pile.domain.PileBasicInfo;
|
import com.jsowell.pile.domain.PileBasicInfo;
|
||||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||||
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
||||||
import com.jsowell.pile.domain.huawei.HWStationInfo;
|
import com.jsowell.pile.domain.huawei.HWStationInfo;
|
||||||
import com.jsowell.pile.dto.PushStationInfoDTO;
|
import com.jsowell.pile.dto.PushStationInfoDTO;
|
||||||
import com.jsowell.pile.service.PileBasicInfoService;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
import com.jsowell.pile.vo.huawei.QueryEquipAuthVO;
|
||||||
import com.jsowell.pile.service.PileStationInfoService;
|
|
||||||
import com.jsowell.pile.service.ThirdPartySettingInfoService;
|
|
||||||
import com.jsowell.pile.vo.web.PileStationVO;
|
import com.jsowell.pile.vo.web.PileStationVO;
|
||||||
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;
|
||||||
@@ -57,6 +58,9 @@ public class HuaweiServiceV2 {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ThirdPartySettingInfoService thirdPartySettingInfoService;
|
private ThirdPartySettingInfoService thirdPartySettingInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@@ -179,11 +183,10 @@ public class HuaweiServiceV2 {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<StationStatusInfo> queryStationStatus(List<String> stationIds) {
|
public List<StationStatusInfo> queryStationStatus(List<String> stationIds) {
|
||||||
// 通过华为的type查询出密钥配置
|
ThirdPartySettingInfo settingInfo = getHuaWeiSettingInfo();
|
||||||
ThirdPartySettingInfo info = new ThirdPartySettingInfo();
|
if (settingInfo == null) {
|
||||||
info.setType(ThirdPlatformTypeEnum.HUA_WEI.getCode());
|
return null;
|
||||||
ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.selectSettingInfo(info);
|
}
|
||||||
|
|
||||||
String operatorSecret = settingInfo.getOperatorSecret();
|
String operatorSecret = settingInfo.getOperatorSecret();
|
||||||
String dataSecret = settingInfo.getDataSecret();
|
String dataSecret = settingInfo.getDataSecret();
|
||||||
String dataSecretIv = settingInfo.getDataSecretIv();
|
String dataSecretIv = settingInfo.getDataSecretIv();
|
||||||
@@ -220,12 +223,97 @@ public class HuaweiServiceV2 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收设备接口状态变化推送
|
||||||
|
* 需在Controller传入operatorId
|
||||||
|
*
|
||||||
|
* @param connectorStatusInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Map<String, String> receiveNotificationStationStatus(ConnectorStatusInfo connectorStatusInfo) {
|
public Map<String, String> receiveNotificationStationStatus(ConnectorStatusInfo connectorStatusInfo) {
|
||||||
|
String pileConnectorCode = connectorStatusInfo.getConnectorID();
|
||||||
|
Integer status = connectorStatusInfo.getStatus();
|
||||||
|
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(connectorStatusInfo.getOperatorId());
|
||||||
|
if (configInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// 将枪口状态改为对应的状态
|
||||||
|
pileConnectorInfoService.updateConnectorStatus(pileConnectorCode, String.valueOf(status));
|
||||||
|
// 构造返回参数
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("Status", 0);
|
||||||
|
// 加密
|
||||||
|
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||||
|
// 加密数据
|
||||||
|
byte[] encryptText = Cryptos.aesEncrypt(jsonObject.toJSONString().getBytes(),
|
||||||
|
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||||
|
String encryptData = Encodes.encodeBase64(encryptText);
|
||||||
|
|
||||||
|
resultMap.put("Data", encryptData);
|
||||||
|
// 生成sig
|
||||||
|
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||||
|
resultMap.put("Sig", resultSign);
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public QueryEquipAuthVO queryEquipAuth(String connectorId) {
|
||||||
|
ThirdPartySettingInfo settingInfo = getHuaWeiSettingInfo();
|
||||||
|
if (settingInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String operatorSecret = settingInfo.getOperatorSecret();
|
||||||
|
String dataSecret = settingInfo.getDataSecret();
|
||||||
|
String dataSecretIv = settingInfo.getDataSecretIv();
|
||||||
|
String signSecret = settingInfo.getSignSecret();
|
||||||
|
String urlAddress = settingInfo.getUrlAddress();
|
||||||
|
|
||||||
|
String requestUrl = urlAddress + "query_equip_auth";
|
||||||
|
|
||||||
|
// 生成设备认证流水号(格式“运营商ID + 唯一编号”(<=27字符))
|
||||||
|
// 生成唯一编号(用时间戳表示)
|
||||||
|
long currentTimeMillis = System.currentTimeMillis();
|
||||||
|
String equipAuthSeq = Constants.OPERATORID_JIANG_SU + currentTimeMillis;
|
||||||
|
// 拼装参数
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("EquipAuthSeq", equipAuthSeq);
|
||||||
|
jsonObject.put("ConnectorID", connectorId);
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
byte[] encryptText = Cryptos.aesEncrypt(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8),
|
||||||
|
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||||
|
String strData = Encodes.encodeBase64(encryptText);
|
||||||
|
|
||||||
|
// 向华为发送请求
|
||||||
|
String response = sendRequest2HuaWei(strData, signSecret, requestUrl);
|
||||||
|
|
||||||
|
CommonResult<?> commonResult = JSONObject.parseObject(response, CommonResult.class);
|
||||||
|
if (commonResult.getRet() != 0) {
|
||||||
|
log.error("查询华为设备接口状态 error:{}, ", commonResult.getMsg());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 解密data
|
||||||
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) commonResult.getData()),
|
||||||
|
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||||
|
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// 转换成 StationStatus 对象
|
||||||
|
QueryEquipAuthVO queryEquipAuthVO = JSON.parseObject(dataStr, QueryEquipAuthVO.class);
|
||||||
|
return queryEquipAuthVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取华为配置信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ThirdPartySettingInfo getHuaWeiSettingInfo() {
|
||||||
|
// 通过华为的type查询出密钥配置
|
||||||
|
ThirdPartySettingInfo info = new ThirdPartySettingInfo();
|
||||||
|
info.setType(ThirdPlatformTypeEnum.HUA_WEI.getCode());
|
||||||
|
ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.selectSettingInfo(info);
|
||||||
|
return settingInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向华为发送请求
|
* 向华为发送请求
|
||||||
@@ -250,8 +338,11 @@ public class HuaweiServiceV2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取桩列表
|
||||||
|
* @param stationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private List<HWStationInfo.EquipmentLogicInfo> getPileList(String stationId) {
|
private List<HWStationInfo.EquipmentLogicInfo> getPileList(String stationId) {
|
||||||
List<HWStationInfo
|
List<HWStationInfo
|
||||||
.EquipmentLogicInfo> equipmentLogicInfos = new ArrayList<>();
|
.EquipmentLogicInfo> equipmentLogicInfos = new ArrayList<>();
|
||||||
@@ -283,6 +374,11 @@ public class HuaweiServiceV2 {
|
|||||||
return equipmentLogicInfos;
|
return equipmentLogicInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枪口列表
|
||||||
|
* @param pileSn
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private List<HWStationInfo.EquipmentLogicInfo.ConnectorInfo> getConnectorInfoList(String pileSn) {
|
private List<HWStationInfo.EquipmentLogicInfo.ConnectorInfo> getConnectorInfoList(String pileSn) {
|
||||||
List<HWStationInfo.EquipmentLogicInfo
|
List<HWStationInfo.EquipmentLogicInfo
|
||||||
.ConnectorInfo> connectorInfoList = new ArrayList<>();
|
.ConnectorInfo> connectorInfoList = new ArrayList<>();
|
||||||
|
|||||||
@@ -42,4 +42,8 @@ public class ConnectorStatusInfo {
|
|||||||
* 地锁状态(0-未知;10-已解锁;50-占用) N
|
* 地锁状态(0-未知;10-已解锁;50-占用) N
|
||||||
*/
|
*/
|
||||||
private String LockStatus;
|
private String LockStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String operatorId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user