update 青海平台Service

This commit is contained in:
Lemon
2024-04-24 16:54:30 +08:00
parent 68ac106f65
commit 514ae10214
4 changed files with 42 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
@@ -53,7 +54,7 @@ public class QingHaiController extends BaseController {
// Map<String, String> map = lianLianService.generateToken(dto);
Map<String, String> map = qingHaiPlatformServiceImpl.queryToken(dto);
logger.info("青海平台请求令牌 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("获取token接口 异常");
return CommonResult.failed("获取token发生异常");
@@ -94,8 +95,9 @@ public class QingHaiController extends BaseController {
// 转换成相应对象
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
queryStationInfoDTO.setThirdPlatformType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode());
Map<String, String> map = qingHaiPlatformServiceImpl.queryStationsInfo(queryStationInfoDTO);
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("青海平台查询充电站信息 error", e);
}
@@ -136,7 +138,7 @@ public class QingHaiController extends BaseController {
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = qingHaiPlatformServiceImpl.queryEquipBusinessPolicy(queryStartChargeDTO);
return CommonResult.success(0, "查询业务策略信息成功!", map.get("Data"), map.get("Sig"));
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("青海平台查询业务策略信息 error", e);
}

View File

@@ -1109,6 +1109,9 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
String pileSn = pileBasicInfo.getSn();
equipmentInfo.setEquipmentId(pileSn);
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
if (modelInfo == null) {
continue;
}
equipmentInfo.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType()));
equipmentInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
equipmentInfo.setEquipmentClassification(Constants.one); // 1-车辆充电设备

View File

@@ -252,11 +252,10 @@ public class LianLianServiceImpl implements LianLianService {
public static void main(String[] args) throws UnsupportedEncodingException {
String dataSecret = "YPFVz1OvAS4nSwLW"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式NHsBDtTanA60vTIu pJahbxk8wG79CMDB
String dataSecretIV = "5tLoP60aR9QUB5Mx"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
String dataSecret = "1234567890abcdef"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式NHsBDtTanA60vTIu pJahbxk8wG79CMDB
String dataSecretIV = "1234567890abcdef"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
String dataString = "XGsQOWT30eM0JPCGRkT6DQrmXQyvH+0klPcXN+kQ2vK5/7m5dTELoDjiT7AY9h8dCrjcRf7kx07\n" +
"5MitXO8CzoHerSke1nYGjtvGcL/zUMbs=";
String dataString = "P1/F/NR6fTmwF0jBZ5zzSsuMBwkBgCaVRX1wnGuAtVDmbCJq5P4dAqw6hBh3l/c/nhYb+G32jZKwiWrfvAjY875/1wiGnygxHtUOniX9kXPwXmzRLVGVMAZ+YVnZOJmxX7TBN6Aq2rO6bKqRlRO+9brn0jXiFP7gtpKaaWjE14d/vc9xJoK2TP1rWTESLXyJvViIx5peI60c16c/93l7QZgAOZ5gUYeoL56UvQ9keiufBFHrgFmlTfDQdamlxD6S8QguDw7yV5/UoFvM3zMNcrIz68NdsagMaiKSU+jqGyfdLWa/iokmogbRqm12Cfi4CQClhv6rYii5o1fVyc0+TD3Fl2MDAESDJAUdzV9xr4M=";
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());

View File

@@ -24,6 +24,7 @@ import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.ZDLEquipmentInfo;
import com.jsowell.pile.thirdparty.ZDLStationInfo;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
@@ -38,10 +39,8 @@ import com.jsowell.thirdparty.platform.common.ChargeOrderInfo;
import com.jsowell.thirdparty.platform.common.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.platform.common.SupStationPowerInfo;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.platform.util.Encodes;
import com.jsowell.thirdparty.platform.util.GBSignUtils;
import com.jsowell.thirdparty.platform.util.HttpRequestUtil;
import com.jsowell.thirdparty.platform.util.*;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,6 +49,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -79,6 +79,9 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private PileConnectorInfoService pileConnectorInfoService;
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@Autowired
private PileBillingTemplateService pileBillingTemplateService;
@@ -149,14 +152,35 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), dataSecret, dataSecretIv);
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(),
dataSecret.getBytes(), dataSecretIv.getBytes());
String encryptData = Encodes.encodeBase64(encryptText); // data
resultMap.put("Ret", "0");
resultMap.put("Msg", "请求令牌成功!");
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, signSecret);
resultMap.put("Sig", resultSign);
return resultMap;
}
public static void main(String[] args) {
String data = "P1/F/NR6fTmwF0jBZ5zzSsuMBwkBgCaVRX1wnGuAtVDmbCJq5P4dAqw6hBh3l/c/nhYb+G32jZKwiWrfvAjY8/hUmOJHouHqfTfifQ2wMC5vZ+5OagGyU435iliW76oKx4O7jcmY9bLwFnHsuOoGRke6YuhhwVP5Q0hLXNuKu5vEGfVgMH8rccg4BOBe8WK0moV03pf9X+tWdNQC2kO/1IhiACDl/hst/doNLtyDI0plAekJHBYVFunAAWTUzKDzBdXBy4+r3rieOW/h5GHkPWbKiQOuptsjB1scURAFIQg5CtuQjhrRsSy/LoA8HkhWIlcvUhmf9MOYzgDDEjjeC3xwS/V2aroZ4KqVxyICH3E=";
String signSecret = "1234567890abcdef";
String sig = "E02F0364E6D842301C5093105BAF4BF4";
Map<String, String> map = Maps.newLinkedHashMap();
map.put("OperatorID", "MA1X78KH5");
map.put("Data", data);
map.put("TimeStamp", "1713925616685");
map.put("Seq", "1043");
String sign = GBSignUtils.sign(map, signSecret);
// 验证签名 得到请求方传过来的签名sig->自己拿到请求体后再按双方约定的协议生成一个sig->对比两个sig是否一致
System.out.println(StringUtils.equals(sign, sig));
}
/**
* 查询站点信息 query_stations_info
* @param dto 查询站点信息dto
@@ -647,7 +671,8 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
byte[] encryptText = Cryptos.aesEncrypt(jsonObject.toJSONString().getBytes(),
platformConfig.getDataSecret().getBytes(), platformConfig.getDataSecretIv().getBytes());
String encryptData = Encodes.encodeBase64(encryptText);
resultMap.put("Ret", "0");
resultMap.put("Msg", "请求令牌成功!");
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, platformConfig.getSignSecret());