|
|
|
|
@@ -3,6 +3,7 @@ package com.jsowell.thirdparty.platform.qinghai.service;
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import com.jsowell.common.constant.Constants;
|
|
|
|
|
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
|
|
|
|
@@ -10,13 +11,13 @@ import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
|
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
|
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
|
|
|
|
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
|
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
|
|
|
|
import com.jsowell.common.util.DateUtils;
|
|
|
|
|
import com.jsowell.common.util.PageUtils;
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
|
|
|
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
|
|
|
|
import com.jsowell.pile.domain.OrderDetail;
|
|
|
|
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
|
|
|
|
import com.jsowell.pile.domain.ThirdPartyStationRelation;
|
|
|
|
|
import com.jsowell.pile.domain.*;
|
|
|
|
|
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
|
|
|
|
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
|
|
|
|
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
|
|
|
|
import com.jsowell.pile.service.*;
|
|
|
|
|
@@ -25,11 +26,13 @@ import com.jsowell.pile.thirdparty.ZDLStationInfo;
|
|
|
|
|
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
|
|
|
|
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
|
|
|
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
|
|
|
|
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
|
|
|
|
|
import com.jsowell.pile.vo.web.PileStationVO;
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
|
|
|
|
|
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
|
|
|
|
import com.jsowell.thirdparty.platform.common.ConnectorChargeStatusInfo;
|
|
|
|
|
import com.jsowell.thirdparty.platform.common.SupStationPowerInfo;
|
|
|
|
|
import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo;
|
|
|
|
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
|
|
|
|
import com.jsowell.thirdparty.platform.util.Encodes;
|
|
|
|
|
@@ -74,6 +77,9 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private PileConnectorInfoService pileConnectorInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PileMerchantInfoService pileMerchantInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
|
|
|
|
|
|
|
|
|
@@ -192,19 +198,16 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String notificationStationStatus(String pileConnectorCode, String status) {
|
|
|
|
|
// 查出该桩所属哪个站点
|
|
|
|
|
PileStationVO stationVO = pileStationInfoService.getStationInfoByPileConnectorCode(pileConnectorCode);
|
|
|
|
|
// 通过站点id查询相关配置信息
|
|
|
|
|
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationVO.getId());
|
|
|
|
|
if (relationInfo == null) {
|
|
|
|
|
ThirdPartyStationRelationVO settingInfo = getQingHaiSettingInfo();
|
|
|
|
|
if (settingInfo == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String operatorId = relationInfo.getOperatorId();
|
|
|
|
|
String operatorSecret = relationInfo.getOperatorSecret();
|
|
|
|
|
String signSecret = relationInfo.getSignSecret();
|
|
|
|
|
String dataSecret = relationInfo.getDataSecret();
|
|
|
|
|
String dataSecretIv = relationInfo.getDataSecretIv();
|
|
|
|
|
String urlAddress = relationInfo.getUrlAddress();
|
|
|
|
|
String operatorId = settingInfo.getOperatorId();
|
|
|
|
|
String operatorSecret = settingInfo.getOperatorSecret();
|
|
|
|
|
String signSecret = settingInfo.getSignSecret();
|
|
|
|
|
String dataSecret = settingInfo.getDataSecret();
|
|
|
|
|
String dataSecretIv = settingInfo.getDataSecretIv();
|
|
|
|
|
String urlAddress = settingInfo.getUrlAddress();
|
|
|
|
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
|
|
|
|
|
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
|
|
|
|
|
.connectorID(pileConnectorCode)
|
|
|
|
|
@@ -229,21 +232,16 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
|
|
|
|
|
public String notificationEquipChargeStatus(String orderCode) {
|
|
|
|
|
// 根据订单号查询订单信息
|
|
|
|
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
|
|
|
|
// 通过站点id查询相关配置信息
|
|
|
|
|
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
|
|
|
|
|
relation.setStationId(Long.parseLong(orderInfo.getStationId()));
|
|
|
|
|
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation);
|
|
|
|
|
// ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId()));
|
|
|
|
|
if (relationInfo == null) {
|
|
|
|
|
ThirdPartyStationRelationVO settingInfo = getQingHaiSettingInfo();
|
|
|
|
|
if (settingInfo == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String operatorId = relationInfo.getOperatorId();
|
|
|
|
|
String operatorSecret = relationInfo.getOperatorSecret();
|
|
|
|
|
String signSecret = relationInfo.getSignSecret();
|
|
|
|
|
String dataSecret = relationInfo.getDataSecret();
|
|
|
|
|
String dataSecretIv = relationInfo.getDataSecretIv();
|
|
|
|
|
String urlAddress = relationInfo.getUrlAddress();
|
|
|
|
|
String thirdPartyType = relationInfo.getThirdPartyType();
|
|
|
|
|
String operatorId = settingInfo.getOperatorId();
|
|
|
|
|
String operatorSecret = settingInfo.getOperatorSecret();
|
|
|
|
|
String signSecret = settingInfo.getSignSecret();
|
|
|
|
|
String dataSecret = settingInfo.getDataSecret();
|
|
|
|
|
String dataSecretIv = settingInfo.getDataSecretIv();
|
|
|
|
|
String urlAddress = settingInfo.getUrlAddress();
|
|
|
|
|
|
|
|
|
|
String url = urlAddress + "notification_connector_charge_status";
|
|
|
|
|
|
|
|
|
|
@@ -308,6 +306,117 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 推送充换电站实时功率 supervise_notification_realtime_power_info
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String notificationPowerInfo(List<String> stationIds) {
|
|
|
|
|
SupStationPowerInfo supStationPowerInfo = null;
|
|
|
|
|
List<SupStationPowerInfo> list = new ArrayList<>();
|
|
|
|
|
SupStationPowerInfo
|
|
|
|
|
.EquipmentPowerInfo supPileInfo = null;
|
|
|
|
|
SupStationPowerInfo
|
|
|
|
|
.EquipmentPowerInfo
|
|
|
|
|
.ConnectorPowerInfo connectorPowerInfo = null;
|
|
|
|
|
for (String stationId : stationIds) {
|
|
|
|
|
BigDecimal stationPower = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
supStationPowerInfo.setOperatorID(Constants.OPERATORID_JIANG_SU);
|
|
|
|
|
supStationPowerInfo.setStationId(stationId);
|
|
|
|
|
supStationPowerInfo.setStationClassification(Constants.one);
|
|
|
|
|
// 查询运营商基本信息
|
|
|
|
|
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId);
|
|
|
|
|
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
|
|
|
|
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
|
|
|
|
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
|
|
|
|
supStationPowerInfo.setEquipmentOwnerID(equipmentOwnerId);
|
|
|
|
|
}else {
|
|
|
|
|
supStationPowerInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据站点id查询桩信息
|
|
|
|
|
List<PileBasicInfo> pileList = pileBasicInfoService.getPileListByStationId(stationId);
|
|
|
|
|
if (CollectionUtils.isEmpty(pileList)) {
|
|
|
|
|
logger.error("推送充换电站实时功率 error, 查询桩列表信息为空");
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
|
|
|
|
}
|
|
|
|
|
// 将桩id筛选出来用于批量查询枪口数据
|
|
|
|
|
List<Long> pileIds = pileList.stream()
|
|
|
|
|
.map(PileBasicInfo::getId)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
QueryConnectorListDTO dto = new QueryConnectorListDTO();
|
|
|
|
|
dto.setPileIds(pileIds);
|
|
|
|
|
List<PileConnectorInfoVO> connectorList = pileConnectorInfoService.getConnectorInfoListByParams(dto);
|
|
|
|
|
if (CollectionUtils.isEmpty(connectorList)) {
|
|
|
|
|
logger.error("推送充换电站实时功率 error, 查询枪口列表信息为空");
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
|
|
|
|
}
|
|
|
|
|
String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS);
|
|
|
|
|
for (PileBasicInfo pileBasicInfo : pileList) {
|
|
|
|
|
supPileInfo = new SupStationPowerInfo.EquipmentPowerInfo();
|
|
|
|
|
supPileInfo.setEquipmentID(pileBasicInfo.getSn());
|
|
|
|
|
supPileInfo.setEquipmentClassification(Constants.one);
|
|
|
|
|
supPileInfo.setDataTime(dateTimeNow);
|
|
|
|
|
BigDecimal pileInstantPower = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
for (PileConnectorInfoVO pileConnectorInfoVO : connectorList) {
|
|
|
|
|
if (StringUtils.equals(pileBasicInfo.getSn(), pileConnectorInfoVO.getPileSn())) {
|
|
|
|
|
connectorPowerInfo = new SupStationPowerInfo
|
|
|
|
|
.EquipmentPowerInfo
|
|
|
|
|
.ConnectorPowerInfo();
|
|
|
|
|
connectorPowerInfo.setConnectorID(pileConnectorInfoVO.getPileConnectorCode());
|
|
|
|
|
connectorPowerInfo.setEquipmentClassification(Constants.one);
|
|
|
|
|
connectorPowerInfo.setDataTime(dateTimeNow);
|
|
|
|
|
BigDecimal InstantPower = pileConnectorInfoVO.getInstantPower().setScale(1, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
connectorPowerInfo.setConnectorRealTimePower(InstantPower);
|
|
|
|
|
// 计算桩此时实时功率
|
|
|
|
|
pileInstantPower = pileInstantPower.add(InstantPower);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 桩实时功率
|
|
|
|
|
supPileInfo.setEquipRealTimePower(pileInstantPower);
|
|
|
|
|
stationPower = stationPower.add(pileInstantPower);
|
|
|
|
|
}
|
|
|
|
|
supStationPowerInfo.setStationRealTimePower(stationPower);
|
|
|
|
|
list.add(supStationPowerInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取推送配置密钥信息
|
|
|
|
|
ThirdPartyStationRelationVO settingInfo = getQingHaiSettingInfo();
|
|
|
|
|
if (settingInfo == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String operatorId = settingInfo.getOperatorId();
|
|
|
|
|
String operatorSecret = settingInfo.getOperatorSecret();
|
|
|
|
|
String signSecret = settingInfo.getSignSecret();
|
|
|
|
|
String dataSecret = settingInfo.getDataSecret();
|
|
|
|
|
String dataSecretIv = settingInfo.getDataSecretIv();
|
|
|
|
|
String urlAddress = settingInfo.getUrlAddress();
|
|
|
|
|
|
|
|
|
|
String url = urlAddress + "supervise_notification_realtime_power_info";
|
|
|
|
|
// 获取令牌
|
|
|
|
|
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
|
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("SupStationPowerInfos", list);
|
|
|
|
|
String jsonString = JSON.toJSONString(json);
|
|
|
|
|
// 发送请求
|
|
|
|
|
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取青海平台配置密钥信息
|
|
|
|
|
private ThirdPartyStationRelationVO getQingHaiSettingInfo() {
|
|
|
|
|
// 通过站点id查询相关配置信息
|
|
|
|
|
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
|
|
|
|
|
relation.setThirdPartyType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode());
|
|
|
|
|
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation);
|
|
|
|
|
return relationInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将需要发送至对接平台的的返回参数加密返回
|
|
|
|
|
|