update 第三方平台设备认证、请求启动充电接口

This commit is contained in:
Lemon
2023-11-07 14:08:36 +08:00
parent 10e1d7eeb6
commit abb49f392e
5 changed files with 53 additions and 32 deletions

View File

@@ -23,6 +23,7 @@ import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
import com.jsowell.pile.dto.*;
@@ -56,6 +57,7 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Service
@@ -223,10 +225,10 @@ public class LianLianServiceImpl implements LianLianService {
}
public static void main(String[] args) throws UnsupportedEncodingException {
String dataSecret = "SPBNJ1Z5EQNmpK08"; // SPBNJ1Z5EQNmpK08
String dataSecretIV = "peRoTcb2C7zqKeII"; // peRoTcb2C7zqKeII
String dataSecret = "VTAEKDPVN9CUS7WO"; // SPBNJ1Z5EQNmpK08
String dataSecretIV = "83UZFFRRZDYNF5CR"; // peRoTcb2C7zqKeII
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
String dataString = "DLYTJz/I1OkVfqHDPEyF6g==";
String dataString = "G1bRJULwSjloSpIrYO4fBIiNfQPxWKxtY3WZjdru78xkr6A2zggaIecRj4nxfGHyqbOx1mzmDR3nj4tTSfmlwFtdDTi38fdodI4AoPpf4naeOBvHzVzTapvnpGDU3txZxlyNx4axEWanyicO2y1EGSeP6d3oCdhK1N6ghfaEGPYVG2c/Y/cOqhrQ+xlwAB41";
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
@@ -544,45 +546,41 @@ public class LianLianServiceImpl implements LianLianService {
*/
@Override
public Map<String, String> query_equip_auth(QueryEquipmentDTO dto) {
Map<String, String> resultMap = Maps.newLinkedHashMap();
EquipmentAuthVO vo = new EquipmentAuthVO();
String equipAuthSeq = dto.getEquipAuthSeq();
String equipAuthSeq = dto.getEquipAuthSeq(); // MA1X78KH5202311071202015732
String pileConnectorCode = dto.getConnectorID();
// 通过运营商id + 枪口编码查询数据
String merchantId = StringUtils.substring(equipAuthSeq, 0, 9);
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
// 能查到为成功
vo.setSuccStat(1); // 1-失败 0-成功
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
if (pileBasicInfo == null) {
vo.setFailReason(2); // 设备检测失败
vo.setFailReasonMsg("未查到该桩的数据");
return null;
}
// 先查询配置密钥相关信息
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
if (configInfo == null) {
return null;
}
if (pileBasicInfo.getMerchantId() == Long.parseLong(merchantId)) {
vo.setSuccStat(0);
// 查询当前数据
// 根据桩编号查询数据
// String merchantId = StringUtils.substring(equipAuthSeq, 0, 9);
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
vo.setSuccStat(1); // 1-失败 0-成功 默认失败
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
if (pileBasicInfo != null) {
// 查询当前枪口数据
PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode);
if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), String.valueOf(connectorInfo.getStatus()))
|| StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorInfo.getStatus()))
|| StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_APPOINTMENT_LOCK.getValue(), String.valueOf(connectorInfo.getStatus()))
) {
vo.setSuccStat(0);
vo.setFailReason(0);
} else {
vo.setSuccStat(1);
vo.setFailReason(1); // 1- 此设备尚未插枪;
}
vo.setFailReasonMsg("");
vo.setEquipAuthSeq(equipAuthSeq);
vo.setConnectorID(pileConnectorCode);
} else {
vo.setFailReason(2); // 设备检测失败
vo.setFailReasonMsg("未查到该桩的数据");
}
vo.setEquipAuthSeq(equipAuthSeq);
vo.setConnectorID(pileConnectorCode);
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(vo).getBytes(),
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
@@ -604,7 +602,6 @@ public class LianLianServiceImpl implements LianLianService {
*/
public Map<String, String> query_start_charge(QueryStartChargeDTO dto) {
// 通过传过来的订单号和枪口号生成订单
// String orderCode = dto.getStartChargeSeq();
String pileConnectorCode = dto.getConnectorID();
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq());
if (orderInfo != null) {
@@ -615,6 +612,7 @@ public class LianLianServiceImpl implements LianLianService {
if (configInfo == null) {
return null;
}
// 生成订单
Map<String, Object> map = orderBasicInfoService.generateOrderForLianLian(dto);
String orderCode = (String) map.get("orderCode");
String transactionCode = (String) map.get("transactionCode");
@@ -640,8 +638,16 @@ public class LianLianServiceImpl implements LianLianService {
.FailReason(0)
.build();
// 推送启动充电结果
pushStartChargeResult(orderCode);
// 异步推送启动充电结果
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
pushStartChargeResult(orderCode);
});
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
@@ -1047,7 +1053,7 @@ public class LianLianServiceImpl implements LianLianService {
String dataSecret = relationInfo.getDataSecret();
String dataSecretIv = relationInfo.getDataSecretIv();
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relation.getThirdPartyType();
String thirdPartyType = relationInfo.getThirdPartyType();
// 推送启动充电结果(调用接口 notification_start_charge_result)
String url = urlAddress + "notification_start_charge_result";