update 浙江省平台

This commit is contained in:
Lemon
2024-08-14 10:36:03 +08:00
parent c3c4859511
commit fb23c9c434
5 changed files with 118 additions and 39 deletions

View File

@@ -436,7 +436,10 @@ public class CommonService {
dto.setStatus(changedStatus);
dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType());
dto.setOrderCode(orderInfo.getOrderCode());
notificationService.notificationConnectorChargeStatus(dto);
notificationService.notificationStationStatus(dto);
}
}

View File

@@ -120,8 +120,10 @@ public class NotificationService {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO);
platformService.notificationEquipChargeStatus(orderCode);
} catch (Exception e) {
logger.error("设备充电中状态变化推送error:{}", e.getMessage());
logger.error("设备充电中状态变化推送error:", e);
}
}
}

View File

@@ -370,4 +370,21 @@ public class StationInfo extends BaseStationInfo {
@JSONField(name = "ParkingLockFlag")
private Integer parkingLockFlag;
/**
* 充电计费信息
*/
@JSONField(name = "PolicyInfos")
private List<PolicyInfo> policyInfos;
@Data
public static class PolicyInfo{
@JSONField(name = "StartTime")
private String startTime;
@JSONField(name = "ElecFee")
private BigDecimal elecFee;
@JSONField(name = "ServiceFee")
private BigDecimal serviceFee;
}
}

View File

@@ -102,6 +102,12 @@ public class SupEquipChargeStatusInfo {
@JSONField(name = "CurrentA")
private BigDecimal currentA;
/**
* A相电压
*/
@JSONField(name = "VoltageA")
private BigDecimal voltageA;
/**
* 电池剩余电量
* 小数点后1位
@@ -127,4 +133,22 @@ public class SupEquipChargeStatusInfo {
*/
@JSONField(name = "TotalPower")
private BigDecimal totalPower;
/**
* 上报时间
*/
@JSONField(name = "EventTime")
private String eventTime;
/**
* 输出电压
*/
@JSONField(name = "ChargeVoltage")
private BigDecimal chargeVoltage;
/**
* 输出电流
*/
@JSONField(name = "ChargeCurrent")
private BigDecimal chargeCurrent;
}

View File

@@ -20,6 +20,7 @@ import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
@@ -32,8 +33,11 @@ import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
import com.jsowell.thirdparty.platform.domain.*;
@@ -257,12 +261,35 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService {
stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag()));
stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag()));
stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag()));
// 根据桩号查询正在使用的计费模板
List<BillingPriceVO> billingPriceVOList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
if (CollectionUtils.isEmpty(billingPriceVOList)) {
return null;
}
SupStationInfo.PolicyInfo policyInfo = null;
// 获取计费模板
List<SupStationInfo.PolicyInfo> policyInfoList = new ArrayList<>();
for (BillingPriceVO billingPriceVO : billingPriceVOList) {
// 将时段开始时间、电费、服务费信息进行封装
policyInfo = new SupStationInfo.PolicyInfo();
String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式
// 需要将中间的冒号去掉,改为 000000 格式
String replace = StringUtils.replace(startTime, ":", "");
policyInfo.setStartTime(replace);
policyInfo.setElecFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
policyInfo.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
policyInfoList.add(policyInfo);
}
stationInfo.setPolicyInfos(policyInfoList);
List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(stationId);
if (CollectionUtils.isNotEmpty(pileList)) {
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
}
resultList.add(stationInfo);
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("PageNo", pageInfo.getPageNum());
map.put("PageCount", pageInfo.getPages());
@@ -292,10 +319,8 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService {
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId));
// 查询第三方平台配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
if (thirdPartySecretInfoVO == null) {
throw new BusinessException("", "无此平台配置信息");
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getZheJiangPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getOurOperatorId();
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
@@ -454,44 +479,52 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService {
public String notificationEquipChargeStatus(String orderCode) {
// 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
// 通过第三方平台类型查询相关配置信息
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
relation.setThirdPartyType(orderInfo.getThirdPartyType());
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation);
if (relationInfo == 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();
// 查询枪口状态
PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
// 调用 查询充电状态方法
QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO();
dto.setStartChargeSeq(orderCode);
// 根据type获取operatorId
String operatorIdByType = ThirdPartyOperatorIdEnum.getOperatorIdByType(thirdPartyType);
dto.setOperatorID(operatorIdByType);
Map<String, String> map = queryEquipChargeStatus(dto);
if (map == null) {
return null;
// 查询相关配置信息
ThirdPartySecretInfoVO zheJiangPlatformSecretInfo = getZheJiangPlatformSecretInfo();
String operatorId = zheJiangPlatformSecretInfo.getTheirOperatorId();
String operatorSecret = zheJiangPlatformSecretInfo.getTheirOperatorSecret();
String signSecret = zheJiangPlatformSecretInfo.getTheirSigSecret();
String dataSecret = zheJiangPlatformSecretInfo.getTheirDataSecret();
String dataSecretIv = zheJiangPlatformSecretInfo.getTheirDataSecretIv();
String urlAddress = zheJiangPlatformSecretInfo.getTheirUrlPrefix();
String dateTime = DateUtils.getDateTime();
SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
.operatorID(Constants.OPERATORID_JIANG_SU)
.equipmentOwnerID(Constants.OPERATORID_JIANG_SU)
.stationID(orderInfo.getStationId())
.equipmentID(orderInfo.getPileSn())
.connectorID(orderInfo.getPileConnectorCode())
.orderNo(orderInfo.getOrderCode())
.orderStatus(2)
.pushTimeStamp(dateTime)
.connectorStatus(info.getStatus()) // 3-充电中
.currentA(info.getCurrent().setScale(1, BigDecimal.ROUND_HALF_UP))
.voltageA(info.getVoltage().setScale(1, BigDecimal.ROUND_HALF_UP))
.soc(new BigDecimal(info.getSOC()))
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime()))
.endTime(dateTime)
.totalPower(info.getChargingDegree())
.eventTime(dateTime)
.chargeVoltage(info.getVoltage().setScale(1, BigDecimal.ROUND_HALF_UP))
.chargeCurrent(info.getCurrent().setScale(1, BigDecimal.ROUND_HALF_UP))
.build();
// 查询运营商信息
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId());
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId);
}
String data = map.get("Data");
// 解密data (此处解密需用 thirdparty_platform_config 的密钥配置)
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorIdByType);
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data),
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转成对应的对象
QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class);
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue();
// 调用联联平台接口
String jsonString = JSON.toJSONString(vo);
// 调用平台接口
String jsonString = JSON.toJSONString(supEquipChargeStatusInfo);
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);