新增 对接青海平台 推送充换电站实时功率 接口

This commit is contained in:
Lemon
2024-04-15 13:57:09 +08:00
parent b73a34a75a
commit b961ec7e73
7 changed files with 197 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ package com.jsowell.pile.mapper;
import com.jsowell.pile.domain.PileMerchantInfo;
import com.jsowell.pile.dto.QueryMerchantInfoDTO;
import com.jsowell.pile.vo.web.MerchantSettleInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -119,4 +120,11 @@ public interface PileMerchantInfoMapper {
* @return
*/
List<PileMerchantInfo> selectListByFirstMerchant(@Param("firstMerchantId") String firstMerchantId);
/**
* 根据站点id查询运营商基本信息
* @param stationId
* @return
*/
PileMerchantInfoVO queryMerchantInfoByStationId(String stationId);
}

View File

@@ -5,6 +5,7 @@ import com.jsowell.pile.dto.CreateMerchantDTO;
import com.jsowell.pile.dto.QueryMerchantInfoDTO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.web.MerchantSettleInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import java.util.List;
@@ -140,4 +141,11 @@ public interface PileMerchantInfoService {
// 查询一级运营商下属的二级运营商
List<MerchantInfoVO> selectListByFirstMerchant(String firstMerchantId);
/**
* 通过站点id查询运营商基本信息
* @param stationId
* @return
*/
PileMerchantInfoVO queryMerchantInfoByStationId(String stationId);
}

View File

@@ -18,6 +18,7 @@ import com.jsowell.pile.service.PileMerchantInfoService;
import com.jsowell.pile.util.UserUtils;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.web.MerchantSettleInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import com.jsowell.system.service.SysDeptService;
import com.jsowell.system.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
@@ -545,4 +546,14 @@ public class PileMerchantInfoServiceImpl implements PileMerchantInfoService {
return resultList;
}
/**
* 通过站点id查询运营商基本信息
* @param stationId
* @return
*/
@Override
public PileMerchantInfoVO queryMerchantInfoByStationId(String stationId) {
return pileMerchantInfoMapper.queryMerchantInfoByStationId(stationId);
}
}

View File

@@ -0,0 +1,18 @@
package com.jsowell.pile.vo.web;
import lombok.Data;
/**
* TODO
*
* @author Lemon
* @Date 2024/4/15 10:58:58
*/
@Data
public class PileMerchantInfoVO {
private String stationId;
private String merchantId;
private String merchantName;
private String organizationCode;
}

View File

@@ -414,4 +414,18 @@
where del_flag = '0'
and (parent_id = #{firstMerchantId,jdbcType=VARCHAR} or id = #{firstMerchantId,jdbcType=VARCHAR})
</select>
<select id="queryMerchantInfoByStationId" resultType="com.jsowell.pile.vo.web.PileMerchantInfoVO">
SELECT
t1.id AS stationId,
t1.merchant_id AS merchantId,
t2.merchant_name AS merchantName,
t2.organization_code AS organizationCode
FROM
pile_station_info t1
JOIN pile_merchant_info t2 ON t1.merchant_id = t2.id
WHERE
t1.del_flag = '0'
AND t1.id = #{stationId,jdbcType=VARCHAR}
</select>
</mapper>

View File

@@ -36,7 +36,7 @@ public class SupStationPowerInfo {
* 充换电站ID
*/
@JSONField(name = "StationID")
private String stationID;
private String stationId;
/**
* 站点分类

View File

@@ -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;
}
/**
* 将需要发送至对接平台的的返回参数加密返回