diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java index 17b1c84ae..6ab013c87 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -179,6 +179,10 @@ public class CommonService { // 海南 result = haiNanChargeService.pushStationInfoV2(dto); } + // if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), dto.getThirdPartyType())) { + // // 青海平台 + // qingHaiPlatformService. + // } finalResult.append(result).append("\n"); } return finalResult.toString(); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java index e1becdadc..dac24284d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java @@ -760,7 +760,7 @@ public class HuaweiServiceV2 { orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo); // 回复华为消息 JSONObject jsonObject = new JSONObject(); - jsonObject.put("StartChargeSeq", "startChargeSeq"); + jsonObject.put("StartChargeSeq", startChargeSeq); jsonObject.put("SuccStat", 0); jsonObject.put("FailReason", 0); @@ -815,10 +815,17 @@ public class HuaweiServiceV2 { // 将交易记录中的交易标识 05 传入实时数据对象,用于结算订单后解锁 vin 状态 data.setTransactionIdentifier("05"); } + // 异步结算订单 + CompletableFuture.runAsync(() -> { + try { + String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId()); + AbstractProgramLogic orderLogic = ProgramLogicFactory.getProgramLogic(mode); + orderLogic.settleOrderForThirdParty(data, orderBasicInfo); + } catch (Exception e) { + log.error("异步结算华为订单 error", e); + } + }); - String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId()); - AbstractProgramLogic orderLogic = ProgramLogicFactory.getProgramLogic(mode); - orderLogic.settleOrderForThirdParty(data, orderBasicInfo); // orderBasicInfo.setChargeStartTime(DateUtils.parseDate(dto.getStartTime())); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index dd4d17ab3..fe42b4828 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -380,10 +380,11 @@ public class LianLianServiceImpl implements LianLianService { public static void main(String[] args) throws UnsupportedEncodingException { - String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB - String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT + String dataSecret = "NHsBDtTanA60vTIu"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB + String dataSecretIV = "2uyE2Cgu4nVf6egc"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA - String dataString = "iW1cm5Ktq70YeNayo1+R3UVzsqFK2AN9C7xDbKmdhrLQivIVtbR30Ct6VxpBrXSkDbgtyX7jxPxsnhrE+X2uxw=="; + String dataString = "R4Z4/rHpm2PgVGuP77+mIm9DZlTITfUjBZt4yrwd6AxKF2WbKv4BWaXc9CXd/pYWn0eC0U21ej28u/QUtGfH0Q7WFLvyojDdaIda6TpQ2etI16+MtUAu/1Eoj7Fr2pTK9GpYOxzx7uS+Ou5K3WI\n" + + "Y4gWdC6z0Hi12xEWYlBE4DfOxcJXbQ81//o7GbMAI73XeiOaewroA/VOrZ9e1WwMznWpR8rqywoIqM+51bMBFVo6K6M7WPpp5mY/2be62EgEJNoFiCBP0fCrsBLePpolACYn0lYPEq7C6AKI3Ggf1JilacE4oQ6BaleV3+5UKmcnOrwPb06h/u78FaalIU/kn2E9eWfTvAfa5h7D3bCW2OijPTzJzYTc18TewjNi/OOWE4mQDJ/R2LBDj0Uq1C72h2lYFC27xXVMl5Qqq8uI+M6pYNJn0hcm1Nrswuumv9rATFyAF4fVA2tae130IwRKtBh0zuMUbsD3Px2mc8zsw9gX59GFuZDH+n7uMLWpfg2DwWBgDF6MI0lq/KD4sJOlodEGBkqH2l4nQngYzPmGo7Ycqozi6wRljOOuXpWKDumb+Vu85byhyvfxUFGr32LacG7/s1khpEHrZWacnvBU4DYU="; // 解密data byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes()); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/ConnectorChargeStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/ConnectorChargeStatusInfo.java new file mode 100644 index 000000000..395104dd5 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/ConnectorChargeStatusInfo.java @@ -0,0 +1,120 @@ +package com.jsowell.thirdparty.platform.common; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * TODO + * + * @author Lemon + * @Date 2024/4/11 15:50:45 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ConnectorChargeStatusInfo { + /** + * 充电订单号 + */ + @JSONField(name = "StartChargeSeq") + private String startChargeSeq; + + /** + * 充电设接口编码 + */ + @JSONField(name = "ConnectorID") + private String connectorID; + + /** + * 充电订单状态 + * 1:启动中 + * 2:充电中 + * 3:停止中 + * 4:已结束 + * 5:订单挂起 + * 6:充电异常结束 + * 7:启动失败 + */ + @JSONField(name = "StartchargeSeqStatus") + private Integer startchargeSeqStatus; + + /** + * 充电接口状态 + * 1:空闲 + * 2:占用(未充电) + * 3:占用(充电中) + * 4:占用(预约锁定) + * 255:故障 + */ + @JSONField(name = "ConnectorStatus") + private Integer connectorStatus; + + /** + * A 相电流 + * 保留 1 位小数 + */ + @JSONField(name = "CurrentA") + private BigDecimal currentA; + + /** + * A 相电压 + * 保留 1 位小数 + */ + @JSONField(name = "VoltageA") + private BigDecimal voltageA; + + /** + * 电池剩余电量 + * 保留 1 位小数 + */ + @JSONField(name = "Soc") + private BigDecimal soc; + + /** + * 开始充电时间 + * 格式“yyyy-MM-dd HH:mm:ss” + */ + @JSONField(name = "StartTime") + private String startTime; + + /** + * 本次采样时间 + * 格式“yyyy-MM-dd HH:mm:ss” + */ + @JSONField(name = "EndTime") + private String endTime; + + /** + * 累计充电量 + * 保留 2 位小数 + */ + @JSONField(name = "TotalPower") + private BigDecimal totalPower; + + /** + * 累计电费 + * 保留 2 位小数 + */ + @JSONField(name = "ElecMoney") + private BigDecimal elecMoney; + + /** + * 累计服务费 + * 保留 2 位小数 + */ + @JSONField(name = "SeviceMoney") + private BigDecimal seviceMoney; + + /** + * 累计总金额 + * 保留 2 位小数 + */ + @JSONField(name = "TotalMoney") + private BigDecimal totalMoney; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/SupStationPowerInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/SupStationPowerInfo.java new file mode 100644 index 000000000..9fd883275 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/SupStationPowerInfo.java @@ -0,0 +1,139 @@ +package com.jsowell.thirdparty.platform.common; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 充换电站功率信息 + * + * @author Lemon + * @Date 2024/4/12 13:50:05 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SupStationPowerInfo { + /** + * 运营平台ID + */ + @JSONField(name = "OperatorID") + private String operatorID; + + /** + * 产权所属单位 ID + */ + @JSONField(name = "EquipmentOwnerID") + private String equipmentOwnerID; + + /** + * 充换电站ID + */ + @JSONField(name = "StationID") + private String stationID; + + /** + * 站点分类 + * 1:充电站 + * 2:换电站 + * 3:充换电一体站 + */ + @JSONField(name = "StationClassification") + private Integer stationClassification; + + /** + * 统计时间 + * 格式:‘yyyy-MM-dd HH:mm:ss’ + */ + @JSONField(name = "DataTime") + private String dataTime; + + /** + * 充换电站实时功率 + * 充电站整站的实时功率 保留一位小数 + */ + @JSONField(name = "StationRealTimePower") + private BigDecimal stationRealTimePower; + + /** + * 充电设备功率信息列表 + */ + @JSONField(name = "EquipmentPowerInfos") + private List equipmentPowerInfos; + + + @Data + public static class EquipmentPowerInfo{ + /** + * 设备编码 + */ + @JSONField(name = "EquipmentID") + private String equipmentID; + + /** + * 设备分类 + * 1:车辆充电设备 + * 2:换电站内的电池箱充电设备 + */ + @JSONField(name = "EquipmentClassification") + private Integer equipmentClassification; + + /** + * 统计时间 + * 格式:‘yyyy-MM-dd HH:mm:ss’ + */ + @JSONField(name = "DataTime") + private String dataTime; + + /** + * 充电设备实时功率 + * 保留一位小数 + */ + @JSONField(name = "EquipRealTimePower") + private BigDecimal equipRealTimePower; + + /** + * 充电设备接口实时功率列表 + */ + @JSONField(name = "ConnectorPowerInfos") + private List connectorPowerInfos; + + + @Data + public static class ConnectorPowerInfo{ + /** + * 充电设备接口编码 + */ + @JSONField(name = "ConnectorID") + private String connectorID; + + /** + * 设备分类 + * 1:车辆充电设备 + * 2:换电站内的电池箱充电设备 + */ + @JSONField(name = "EquipmentClassification") + private Integer equipmentClassification; + + /** + * 统计时间 + * 格式:‘yyyy-MM-dd HH:mm:ss’ + */ + @JSONField(name = "DataTime") + private String dataTime; + + /** + * 充电设备接口实时功率 + * 保留一位小数 + */ + @JSONField(name = "ConnectorRealTimePower") + private BigDecimal connectorRealTimePower; + } + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java index fc193bc73..1cc9dde52 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java @@ -1,27 +1,40 @@ 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.Maps; import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +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.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.dto.QueryEquipChargeStatusDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; -import com.jsowell.pile.service.PileBasicInfoService; -import com.jsowell.pile.service.PileStationInfoService; -import com.jsowell.pile.service.ThirdPartyPlatformConfigService; -import com.jsowell.pile.service.ThirdPartyStationRelationService; +import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; 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.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.hainan.domain.HNStationInfo; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.GBSignUtils; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,6 +43,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -54,6 +68,12 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { @Autowired private PileBasicInfoService pileBasicInfoService; + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + @Autowired private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; @@ -165,15 +185,130 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 设备状态变化推送(在0x13中调用统一推送接口) + * notification_stationStatus * @param pileConnectorCode 充电枪口编号 * @param status 枪口状态 * @return */ @Override public String notificationStationStatus(String pileConnectorCode, String status) { - return ThirdPartyPlatformService.super.notificationStationStatus(pileConnectorCode, status); + // 查出该桩所属哪个站点 + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileConnectorCode(pileConnectorCode); + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationVO.getId()); + 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 url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; } + /** + * 推送充电状态 notification_equip_charge_status + * + * @param orderCode + */ + @Override + 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) { + 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 url = urlAddress + "notification_connector_charge_status"; + + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 通过订单号查询实时数据 + List realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + ConnectorChargeStatusInfo info; + if (CollectionUtils.isEmpty(realTimeData)) { + info = new ConnectorChargeStatusInfo(); + }else { + RealTimeMonitorData data = realTimeData.get(0); + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { + // 充电中 + orderStatus = "2"; + } else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) { + // 充电完成 + orderStatus = "4"; + } else { + // 直接给 5-未知 + orderStatus = "5"; + } + String status = data.getConnectorStatus(); + int connectorStatus = 0; + if (StringUtils.isBlank(status)) { + // 查询当前枪口状态 + PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + connectorStatus = connectorInfoVO.getStatus(); + } else { + connectorStatus = Integer.parseInt(status); + } + BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); + BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); + + // 拼装对应平台数据 + info = ConnectorChargeStatusInfo.builder() + .startChargeSeq(orderCode) + .connectorID(orderInfo.getPileConnectorCode()) + .startchargeSeqStatus(Integer.parseInt(orderStatus)) + .connectorStatus(connectorStatus) + .currentA(new BigDecimal(data.getOutputCurrent()).setScale(1, BigDecimal.ROUND_HALF_UP)) + .voltageA(new BigDecimal(data.getOutputVoltage()).setScale(1, BigDecimal.ROUND_HALF_UP)) + .soc(new BigDecimal(data.getSOC()).setScale(1, BigDecimal.ROUND_DOWN)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(DateUtils.getDateTime()) // 本次采样时间 + .totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量 + .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费 + .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费 + .totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额 + .build(); + } + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("ConnectorChargeStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** * 将需要发送至对接平台的的返回参数加密返回 * @param jsonObject