mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
将推送第三方平台改为可推送多个平台
This commit is contained in:
37
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java
vendored
Normal file
37
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.jsowell.thirdparty.common;
|
||||
|
||||
import com.jsowell.pile.domain.ThirdPartyStationRelation;
|
||||
import com.jsowell.pile.dto.PushStationInfoDTO;
|
||||
import com.jsowell.pile.service.ThirdPartyStationRelationService;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/18 15:11:32
|
||||
*/
|
||||
@Service
|
||||
public class CommonService {
|
||||
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
/**
|
||||
* 将站点--第三方平台类型对应关系存入关系表
|
||||
* @param dto
|
||||
*/
|
||||
public void insertInfo2DataBase(PushStationInfoDTO dto) {
|
||||
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
|
||||
relation.setStationId(dto.getStationId());
|
||||
relation.setThirdPartyType(dto.getThirdPartyType());
|
||||
ThirdPartyStationRelationVO vo = thirdPartyStationRelationService.selectRelationInfo(relation);
|
||||
if (vo != null) {
|
||||
return;
|
||||
}
|
||||
// 新增数据库
|
||||
thirdPartyStationRelationService.insertThirdPartyStationRelation(relation);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public interface LianLianService {
|
||||
*/
|
||||
String pushStationInfo(PushStationInfoDTO dto);
|
||||
|
||||
String pushStationInfoV2(PushStationInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 联联平台获取充电站信息
|
||||
* @param dto
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import com.jsowell.thirdparty.lianlian.domain.*;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
@@ -107,6 +108,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
@Override
|
||||
public void pushMerchantInfo(Long merchantId) {
|
||||
// 通过id查询运营商信息
|
||||
@@ -251,6 +255,124 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) {
|
||||
// String OperatorID = "987654321";
|
||||
// String SigSecret = "1234567890abcdef"; // 签名秘钥
|
||||
// String DataSecret = "1234567890abcdef"; // 消息密钥
|
||||
// String DataSecretIV = "1234567890abcdef"; // 消息密钥初始化向量
|
||||
// String token = "c548f9276c1c4ea8b88b1f7b1eb7cf07"; //QueryToken类查询接口获取到的token
|
||||
|
||||
// 通过id查询站点相关信息
|
||||
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId());
|
||||
// 通过第三方配置类型查询相关配置信息
|
||||
ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo();
|
||||
settingInfo.setType(dto.getThirdPartyType());
|
||||
ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo);
|
||||
|
||||
String operatorId = thirdPartySettingInfo.getOperatorId();
|
||||
String operatorSecret = thirdPartySettingInfo.getOperatorSecret();
|
||||
String signSecret = thirdPartySettingInfo.getSignSecret();
|
||||
String dataSecret = thirdPartySettingInfo.getDataSecret();
|
||||
String dataSecretIv = thirdPartySettingInfo.getDataSecretIv();
|
||||
String urlAddress = thirdPartySettingInfo.getUrlAddress();
|
||||
|
||||
// 组装联联平台所需要的数据格式
|
||||
StationInfo info = StationInfo.builder()
|
||||
.stationID("LC" +dto.getStationId())
|
||||
.operatorID(operatorId)
|
||||
// .equipmentOwnerID(Constants.OPERATORID_LIANLIAN)
|
||||
.stationName(pileStationInfo.getStationName())
|
||||
.isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply()))
|
||||
.isPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking()))
|
||||
.countryCode(pileStationInfo.getCountryCode())
|
||||
// .areaCode(pileStationInfo.getAreaCode())
|
||||
.address(pileStationInfo.getAddress())
|
||||
.serviceTel(pileStationInfo.getStationTel())
|
||||
.stationType(Integer.valueOf(pileStationInfo.getStationType()))
|
||||
.stationStatus(Integer.valueOf(pileStationInfo.getStationStatus()))
|
||||
.parkNums(Integer.valueOf(pileStationInfo.getParkNums()))
|
||||
.stationLng(new BigDecimal(pileStationInfo.getStationLng()))
|
||||
.stationLat(new BigDecimal(pileStationInfo.getStationLat()))
|
||||
.construction(Integer.valueOf(pileStationInfo.getConstruction()))
|
||||
.openAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay()))
|
||||
.minElectricityPrice(new BigDecimal(Constants.ZERO))
|
||||
.electricityFee(Constants.ZERO)
|
||||
.serviceFee(Constants.ZERO)
|
||||
.parkFree(Integer.valueOf(pileStationInfo.getParkFree()))
|
||||
// .ParkFee("2")
|
||||
.supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder()))
|
||||
.parkFeeType(0)
|
||||
.toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag()))
|
||||
.storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag()))
|
||||
.restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag()))
|
||||
.loungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag()))
|
||||
.canopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag()))
|
||||
.printerFlag(Integer.valueOf(pileStationInfo.getPrinterFlag()))
|
||||
.barrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag()))
|
||||
.parkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag()))
|
||||
|
||||
.build();
|
||||
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
|
||||
// 根据逗号分组
|
||||
String[] split = StringUtils.split(areaCode, ",");
|
||||
// 只取最后一部分 330213
|
||||
String subAreaCode = split[split.length - 1];
|
||||
info.setAreaCode(subAreaCode);
|
||||
// 截取运营商组织机构代码(去除最后一位后的最后九位)
|
||||
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId()));
|
||||
String organizationCode = merchantInfo.getOrganizationCode();
|
||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
||||
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
||||
info.setEquipmentOwnerID(equipmentOwnerId);
|
||||
}
|
||||
if (StringUtils.equals("36", String.valueOf(pileStationInfo.getMerchantId()))) {
|
||||
// 远大
|
||||
info.setEquipmentOwnerID(Constants.OPERATORID_YUAN_DA);
|
||||
}
|
||||
if (StringUtils.equals("35", String.valueOf(pileStationInfo.getMerchantId()))) {
|
||||
// 如果是希晓运营商,则把equipmentOwnerID换成希晓
|
||||
info.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO);
|
||||
}
|
||||
String payment = StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment());
|
||||
info.setPayment(payment);
|
||||
if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) {
|
||||
info.setIsPublicParkingLot(1);
|
||||
info.setParkingLotNumber(pileStationInfo.getParkingNumber());
|
||||
}
|
||||
// 户号
|
||||
if (StringUtils.isNotBlank(pileStationInfo.getAccountNumber())) {
|
||||
info.setAccountNumber(pileStationInfo.getAccountNumber());
|
||||
}
|
||||
// 容量
|
||||
if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) {
|
||||
info.setCapacity(pileStationInfo.getCapacity().setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
List<EquipmentInfo> pileList = getPileList(pileStationInfo);
|
||||
if (CollectionUtils.isNotEmpty(pileList)) {
|
||||
info.setEquipmentInfos(pileList); // 充电设备信息列表
|
||||
}
|
||||
|
||||
// 调用联联平台接口
|
||||
String url = urlAddress + "notification_stationInfo";
|
||||
|
||||
String jsonStr = JSONObject.toJSONString(info);
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("StationInfo", jsonStr);
|
||||
|
||||
String jsonString = JSONObject.toJSONString(data);
|
||||
System.out.println("jsonString : " + jsonString);
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret
|
||||
, dataSecretIv, operatorId, signSecret);
|
||||
|
||||
// 新增数据库
|
||||
commonService.insertInfo2DataBase(dto);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
String dataSecret = "KnGhAb88GtUEPb0j"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO
|
||||
String dataSecretIV = "XZ4wURhuo2y8s4ZS"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR
|
||||
|
||||
@@ -54,6 +54,9 @@ public interface NRService {
|
||||
public String pushStationInfo(PushStationInfoDTO dto) throws ParseException;
|
||||
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) throws ParseException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取充电站信息
|
||||
* @param dto
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
@@ -86,9 +87,15 @@ public class NRServiceImpl implements NRService {
|
||||
@Autowired
|
||||
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartySettingInfoService thirdPartySettingInfoService;
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@@ -235,6 +242,110 @@ public class NRServiceImpl implements NRService {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) throws ParseException {
|
||||
PileStationVO stationInfoVO = pileStationInfoService.getStationInfo(String.valueOf(dto.getStationId()));
|
||||
if (stationInfoVO == null) {
|
||||
return null;
|
||||
}
|
||||
// 通过第三方配置类型查询相关配置信息
|
||||
ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo();
|
||||
settingInfo.setType(dto.getThirdPartyType());
|
||||
ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo);
|
||||
|
||||
String operatorId = thirdPartySettingInfo.getOperatorId();
|
||||
String operatorSecret = thirdPartySettingInfo.getOperatorSecret();
|
||||
String signSecret = thirdPartySettingInfo.getSignSecret();
|
||||
String dataSecret = thirdPartySettingInfo.getDataSecret();
|
||||
String dataSecretIv = thirdPartySettingInfo.getDataSecretIv();
|
||||
String urlAddress = thirdPartySettingInfo.getUrlAddress();
|
||||
|
||||
// 拼装南瑞平台所需参数
|
||||
NRStationInfo nrStationInfo = NRStationInfo.builder()
|
||||
.stationId(String.valueOf(stationInfoVO.getId()))
|
||||
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||
// .equipmentOwnerID(Constants.OPERATORID_JIANG_SU)
|
||||
.stationName(stationInfoVO.getStationName())
|
||||
.countryCode(stationInfoVO.getCountryCode())
|
||||
// .areaCode()
|
||||
.address(stationInfoVO.getAddress())
|
||||
.serviceTel(stationInfoVO.getStationTel())
|
||||
.stationStatus(stationInfoVO.getStationStatus())
|
||||
.parkNums(0)
|
||||
.stationLng(new BigDecimal(stationInfoVO.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP))
|
||||
.stationLat(new BigDecimal(stationInfoVO.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP))
|
||||
.openForBusinessDate(DateUtils.convertDateTimeToDate(stationInfoVO.getCreateTime()))
|
||||
.openAllDay(Integer.parseInt(stationInfoVO.getOpenAllDay()))
|
||||
.busineHours(stationInfoVO.getBusinessHours())
|
||||
.minElectricityPrice(stationInfoVO.getElectricityPrice().add(stationInfoVO.getServicePrice()))
|
||||
.loungeFlag(0)
|
||||
.isAloneApply(0)
|
||||
.printerFlag(0)
|
||||
.parkFree(0)
|
||||
.isPublicParkingLot(0)
|
||||
.payment(1)
|
||||
.restaurantFlag(0)
|
||||
.barrierFlag(0)
|
||||
.serviceFee(stationInfoVO.getServicePrice())
|
||||
.parkingLockFlag(0)
|
||||
.electricityFee(stationInfoVO.getElectricityPrice())
|
||||
.storeFlag(0)
|
||||
.canopyFlag(0)
|
||||
.toiletFlag(0)
|
||||
.supportOrder(0)
|
||||
.parkFeeType(1)
|
||||
|
||||
.build();
|
||||
// 截取运营商组织机构代码(去除最后一位后的最后九位)
|
||||
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(stationInfoVO.getMerchantId()));
|
||||
String organizationCode = merchantInfo.getOrganizationCode();
|
||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
||||
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
||||
nrStationInfo.setEquipmentOwnerID(equipmentOwnerId);
|
||||
}
|
||||
// 站点地址
|
||||
String areaCode = stationInfoVO.getAreaCode();
|
||||
// 截取最后一组数据,例如将 320000,320500,320583 截取为 320583
|
||||
String[] split = StringUtils.split(areaCode, ",");
|
||||
String s = split[split.length - 1];
|
||||
nrStationInfo.setAreaCode(s);
|
||||
// 站点图片
|
||||
if (CollectionUtils.isNotEmpty(stationInfoVO.getPictureList())) {
|
||||
nrStationInfo.setPictures(stationInfoVO.getPictureList());
|
||||
}
|
||||
String stationType = stationInfoVO.getStationType();
|
||||
if (!StringUtils.equals("1", stationType) && !StringUtils.equals("255", stationType)) {
|
||||
// 不为1-公共并且不为255-其他,都为专用
|
||||
stationType = "2";
|
||||
}
|
||||
nrStationInfo.setStationType(Integer.parseInt(stationType));
|
||||
// 获取建设场所
|
||||
int jsConstructionCode = JiangSuConstructionEnum.getJSCodeByDataBaseCode(Integer.parseInt(stationInfoVO.getConstruction()));
|
||||
nrStationInfo.setConstruction(jsConstructionCode);
|
||||
|
||||
List<NREquipmentInfo> nrEquipmentInfos = getEquipmentInfo(String.valueOf(dto.getStationId()));
|
||||
nrStationInfo.setEquipmentInfos(nrEquipmentInfos);
|
||||
|
||||
// 推送到平台
|
||||
String url = urlAddress + "notification_stationInfo";
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("StationInfo", nrStationInfo);
|
||||
|
||||
String jsonString = data.toString();
|
||||
System.out.println("jsonString : " + jsonString);
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
System.out.println(token);
|
||||
String result = HttpRequestUtil.nrSendPost(token, jsonString, url, dataSecret
|
||||
, dataSecretIv, operatorId, signSecret);
|
||||
|
||||
// 新增数据库
|
||||
commonService.insertInfo2DataBase(dto);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电站信息
|
||||
* @param dto
|
||||
|
||||
@@ -119,4 +119,6 @@ public interface XDTService {
|
||||
|
||||
|
||||
String pushStationInfo(PushStationInfoDTO dto);
|
||||
|
||||
String pushStationInfoV2(PushStationInfoDTO dto);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.service.ThirdPartyStationRelationService;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.xindiantu.service.XDTService;
|
||||
import com.jsowell.thirdparty.zhongdianlian.dto.ZDLGetTokenDTO;
|
||||
@@ -42,6 +43,9 @@ public class XDTServiceImpl implements XDTService {
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* @param dto
|
||||
@@ -213,4 +217,10 @@ public class XDTServiceImpl implements XDTService {
|
||||
}
|
||||
return "Error";
|
||||
}
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) {
|
||||
// 新增数据库
|
||||
commonService.insertInfo2DataBase(dto);
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,4 +112,6 @@ public interface YCBCService {
|
||||
* @return
|
||||
*/
|
||||
String pushStationInfo(PushStationInfoDTO dto);
|
||||
|
||||
String pushStationInfoV2(PushStationInfoDTO dto);
|
||||
}
|
||||
@@ -278,4 +278,8 @@ public class YCBCServiceImpl implements YCBCService {
|
||||
return zdlService.pushStationInfo(dto);
|
||||
}
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) {
|
||||
return zdlService.pushStationInfoV2(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public interface ZDLService {
|
||||
*/
|
||||
String pushStationInfo(PushStationInfoDTO dto);
|
||||
|
||||
String pushStationInfoV2(PushStationInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 查询站点信息
|
||||
* @param dto
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
@@ -79,6 +80,12 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
@Autowired
|
||||
private PileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartySettingInfoService thirdPartySettingInfoService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* @param dto
|
||||
@@ -190,6 +197,95 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String pushStationInfoV2(PushStationInfoDTO dto) {
|
||||
// 通过id查询站点相关信息
|
||||
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId());
|
||||
// 通过第三方配置类型查询相关配置信息
|
||||
ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo();
|
||||
settingInfo.setType(dto.getThirdPartyType());
|
||||
ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo);
|
||||
|
||||
String operatorId = thirdPartySettingInfo.getOperatorId();
|
||||
String operatorSecret = thirdPartySettingInfo.getOperatorSecret();
|
||||
String signSecret = thirdPartySettingInfo.getSignSecret();
|
||||
String dataSecret = thirdPartySettingInfo.getDataSecret();
|
||||
String dataSecretIv = thirdPartySettingInfo.getDataSecretIv();
|
||||
String urlAddress = thirdPartySettingInfo.getUrlAddress();
|
||||
|
||||
// 组装中电联平台所需要的数据格式
|
||||
ZDLStationInfo info = ZDLStationInfo.builder()
|
||||
.stationId(String.valueOf(dto.getStationId()))
|
||||
.operatorId(Constants.OPERATORID_JIANG_SU)
|
||||
// .equipmentOwnerId(Constants.OPERATORID_JIANG_SU)
|
||||
.stationName(pileStationInfo.getStationName())
|
||||
.countryCode(pileStationInfo.getCountryCode())
|
||||
.areaCode(pileStationInfo.getAreaCode())
|
||||
.address(pileStationInfo.getAddress())
|
||||
.serviceTel(pileStationInfo.getStationTel())
|
||||
.stationType(Integer.valueOf(pileStationInfo.getStationType()))
|
||||
.stationStatus(Integer.valueOf(pileStationInfo.getStationStatus()))
|
||||
.parkNums(Integer.valueOf(pileStationInfo.getParkNums()))
|
||||
.stationLng(new BigDecimal(pileStationInfo.getStationLng()))
|
||||
.stationLat(new BigDecimal(pileStationInfo.getStationLat()))
|
||||
.construction(Integer.valueOf(pileStationInfo.getConstruction()))
|
||||
|
||||
.build();
|
||||
// 截取运营商组织机构代码(去除最后一位后的最后九位)
|
||||
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId()));
|
||||
String organizationCode = merchantInfo.getOrganizationCode();
|
||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
||||
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
||||
info.setEquipmentOwnerId(equipmentOwnerId);
|
||||
}
|
||||
|
||||
List<ZDLEquipmentInfo> pileList = getPileList(pileStationInfo);
|
||||
if (CollectionUtils.isNotEmpty(pileList)) {
|
||||
info.setEquipmentInfos(pileList); // 充电设备信息列表
|
||||
}
|
||||
|
||||
// 调用中电联平台接口
|
||||
String url = urlAddress + "notification_stationInfo";
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("StationInfo", info);
|
||||
|
||||
String jsonString = JSONObject.toJSONString(data);
|
||||
System.out.println("jsonString : " + jsonString);
|
||||
|
||||
// 获取令牌
|
||||
String token = "";
|
||||
String result = "";
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), dto.getThirdPartyType())) {
|
||||
YCBCGetTokenDTO ycbcGetTokenDTO = new YCBCGetTokenDTO();
|
||||
ycbcGetTokenDTO.setOperatorId(operatorId);
|
||||
ycbcGetTokenDTO.setDataSecret(dataSecret);
|
||||
ycbcGetTokenDTO.setSignSecret(signSecret);
|
||||
ycbcGetTokenDTO.setUrlAddress(urlAddress);
|
||||
ycbcGetTokenDTO.setDataSecretIv(dataSecretIv);
|
||||
ycbcGetTokenDTO.setOperatorSecret(operatorSecret);
|
||||
|
||||
token = ycbcService.YCBCGetToken(ycbcGetTokenDTO);
|
||||
result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}else {
|
||||
ZDLGetTokenDTO tokenDTO = ZDLGetTokenDTO.builder()
|
||||
.urlAddress(urlAddress)
|
||||
.operatorId(operatorId)
|
||||
.operatorSecret(operatorSecret)
|
||||
.dataSecret(dataSecret)
|
||||
.dataSecretIv(dataSecretIv)
|
||||
.signSecret(signSecret)
|
||||
.build();
|
||||
token = ZDLGetToken(tokenDTO);
|
||||
result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
}
|
||||
// 新增数据库
|
||||
commonService.insertInfo2DataBase(dto);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String startTime = "00:00:00"; // 00:00:00 格式
|
||||
// 需要将中间的冒号去掉
|
||||
|
||||
Reference in New Issue
Block a user