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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user