mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
将推送第三方平台改为可推送多个平台
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user