将推送第三方平台改为可推送多个平台

This commit is contained in:
Lemon
2024-01-18 17:03:08 +08:00
parent 63ae3c8ab7
commit 0b09585bbc
21 changed files with 534 additions and 63 deletions

View File

@@ -28,6 +28,8 @@ public interface ZDLService {
*/
String pushStationInfo(PushStationInfoDTO dto);
String pushStationInfoV2(PushStationInfoDTO dto);
/**
* 查询站点信息
* @param dto

View File

@@ -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 格式
// 需要将中间的冒号去掉