diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index 1ba6534a7..a304c6a4c 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -18,7 +18,7 @@ public enum ThirdPlatformTypeEnum { HAI_NAN_1_PLATFORM("7", "海南一张网(监管平台)", "578725200"), HAI_NAN_2_PLATFORM("8", "海南一张网(充电平台)", "MAA9A0PP1"), HUA_WEI("9", "华为平台", "MA5GTQ528"), - NEI_MENG_GU_PLATFORM("10", "内蒙古平台", ""), + NEI_MENG_GU_PLATFORM("10", "内蒙古平台", "MAB03NTXZ"), QING_HAI_PLATFORM("11", "青海平台", "630000000"), DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""), NING_XIA_PLATFORM("13", "宁夏平台", "MA01H3BQ9"), diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 262f531f6..2c97c5e80 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -131,10 +131,12 @@ public class NotificationService { logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}", secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage()); } - try { - platformService.notificationEquipChargeStatus(orderCode); - }catch (Exception e){ - logger.error("notification_equip_charge_status error", e); + finally { + try { + platformService.notificationEquipChargeStatus(orderCode); + }catch (Exception e){ + logger.error("notification_equip_charge_status error", e); + } } } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java index 6b4ef6778..06efcfaec 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java @@ -24,6 +24,56 @@ public class ChargeAlgorithmData { */ private String orderCode; + /** + * 站点详细地址 + */ + private String siteAddress; + + /** + * 站点编号 + */ + private String siteCode; + + /** + * 桩编号 + */ + private String pileCode; + + /** + * 枪编号 + */ + private String gunNo; + + /** + * 车主年龄段 + */ + private String age; + + /** + * 车主性别 + */ + private String gender; + + /** + * 用车场景 + */ + private String scene; + + /** + * 车辆使用年限 + */ + private String serviceLife; + + /** + * 车辆累计里程 + */ + private String odometer; + + /** + * 站点名称 + */ + private String siteName; + /** * 初始SOC */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java index 3e454c554..b857bd1d0 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java @@ -187,6 +187,18 @@ public class SupEquipChargeStatusInfo { @JSONField(name = "ServiceMoney") private String serviceMoney; + /** + * 电池编码 + */ + @JSONField(name = "BatteryPackID") + private String batteryPackId; + + /** + * 当前电表读数 + */ + @JSONField(name = "CurrentMeter") + private String currentMeter; + /** * 时段数 * 参数范围:0~ 32 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 8b1551d17..09517a058 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -7,6 +7,7 @@ import com.google.common.collect.Maps; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.redis.RedisCache; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.StringUtils; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index 46d281730..59fe2f367 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java @@ -12,8 +12,10 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.OrderSplitRecord; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileBasicInfoService; +import com.jsowell.pile.service.PileStationInfoService; import com.jsowell.pile.thirdparty.ParameterConfigData; import com.jsowell.pile.vo.uniapp.customer.OrderVO; +import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,10 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -43,6 +42,9 @@ public class ChargeAlgorithmService { @Autowired private PileBasicInfoService pileBasicInfoService; + @Autowired + private PileStationInfoService pileStationInfoService; + @Autowired private RedisCache redisCache; @@ -58,6 +60,9 @@ public class ChargeAlgorithmService { if (orderVO == null) { return "订单信息为空"; } + // 查询站点信息 + PileStationVO stationVO = pileStationInfoService.getStationInfo(orderVO.getStationId()); + // 计算充电时长 long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime()); String transactionCode = orderVO.getTransactionCode(); @@ -125,16 +130,31 @@ public class ChargeAlgorithmService { // .gunTemp("0") // 充电枪温度 .doorStatus(Constants.zero) // 舱门状态 + .siteAddress(stationVO.getAddress()) + .siteCode(stationVO.getId()) + .pileCode(orderVO.getPileSn()) + .gunNo(orderVO.getPileConnectorCode()) + .age("0") + .gender("0") + .scene("0") + .serviceLife("0") + .odometer("0") + .siteName(stationVO.getStationName()) + .build(); List chargingDetailInfos = transformData(transactionCode, chargerOutputInfoList, parameterConfigData, transactionRecordsData); + chargingDetailInfos.stream() + .filter(info -> info.getCurrentSoc() > 100) // 只处理 currentSoc > 100 的元素 + .forEach(info -> info.setCurrentSoc(100)); + Collections.reverse(chargingDetailInfos); data.setChargingDetailInfo(chargingDetailInfos); JSONObject jsonObject = new JSONObject(); - jsonObject.put("dataJason", data); + jsonObject.put("dataJson", data); log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject)); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index 5ca48cccd..e98e7b901 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java @@ -1,21 +1,27 @@ package com.jsowell.thirdparty.platform.service.impl; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.core.redis.RedisCache; 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.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.OrderStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; +import com.jsowell.common.util.bean.BeanUtils; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.OrderDetail; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; @@ -41,15 +47,13 @@ import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; -import com.jsowell.thirdparty.platform.util.Cryptos; -import com.jsowell.thirdparty.platform.util.Encodes; -import com.jsowell.thirdparty.platform.util.HttpRequestUtil; -import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.platform.util.*; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import com.yi.business.geo.GeoCodeInfo; import com.yi.business.geo.TermRelationTreeCoordinate; @@ -61,6 +65,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -196,7 +201,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { map.put("ItemSize", pageInfo.getTotal()); map.put("OperatorInfos", operatorInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -299,7 +305,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { map.put("PageCount", pageInfo.getPages()); map.put("ItemSize", pageInfo.getTotal()); map.put("StationInfos", resultList); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -405,7 +412,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // map.put("Total", total); map.put("StationStatusInfos", collect); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -456,7 +464,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 结果集 Map map = Maps.newHashMap(); map.put("StationStatusInfos", stationStatusInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -479,7 +488,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -497,7 +506,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { 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); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -532,7 +541,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { .build(); // 调用联联平台接口 - String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String signSecret = secretInfoVO.getTheirSigSecret(); String dataSecret = secretInfoVO.getTheirDataSecret(); @@ -545,10 +554,75 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { String jsonString = JSON.toJSONString(info); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, secretInfoVO.getPlatformType()); return result; } + @Override + public String getToken(String urlAddress, String operatorId, String operatorSecret, String dataSecretIv, String signSecret, String dataSecret) { + String token = ""; + // 先查询缓存有没有token + String tokenKey = CacheConstants.THIRD_PARTY_TOKEN_BY_OPERATOR_SECRET + operatorSecret; + RedisCache redisCache = BeanUtils.getBean(RedisCache.class); + String cacheToken = redisCache.getCacheObject(tokenKey); + if (StringUtils.isNotBlank(cacheToken)) { + token = cacheToken; + return token; + } + + try { + // 请求地址 + String requestUrl = urlAddress + "query_token"; + + // 请求data + Map data = new HashMap<>(); + data.put("PlatformID", operatorId); + data.put("OperatorSecret", operatorSecret); + data.put("DataSecretIV", dataSecretIv); + String dataJson = JSONUtil.toJsonStr(data); + + // 加密 + byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8), + dataSecret.getBytes(), dataSecretIv.getBytes()); + String strData = Encodes.encodeBase64(encryptText); + + Map request = new LinkedHashMap<>(); + request.put("PlatformID", operatorId); + request.put("Data", strData); + request.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date())); + request.put("Seq", "0001"); + + // 生成签名 + String sig = GBSignUtils.sign(request, signSecret); + request.put("Sig", sig); + + String tokenRequest = JSONUtil.toJsonStr(request); + + String response = HttpUtil.post(requestUrl, tokenRequest); + LianLianResultVO result = JSON.parseObject(response, LianLianResultVO.class); +// logger.info("获取令牌 result:{}", result); + + if (result.getRet() == 0) { + // 解密data + byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()), + dataSecret.getBytes(), dataSecretIv.getBytes()); + String dataStr = new String(plainText, StandardCharsets.UTF_8); + Map resultMap = (Map) JSON.parse(dataStr); + token = String.valueOf(resultMap.get("AccessToken")); + if (resultMap.get("TokenAvailableTime") != null) { + int tokenAvailableTime = Integer.parseInt(String.valueOf(resultMap.get("TokenAvailableTime"))); + // 将token存入缓存 + redisCache.setCacheObject(tokenKey, token, tokenAvailableTime, TimeUnit.SECONDS); + } + // logger.info("token: {}", token); + } + // logger.info("获取令牌 result:{}, token: {}", result, token); + } catch (Exception e) { + return token; + } + return token; + } + /** * 充电订单推送 notification_charge_order_info * @@ -566,7 +640,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -609,7 +683,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { JSONObject json = new JSONObject(); json.put("ChargeOrderInfo", orderInfo); String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -627,7 +701,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // return null; // } - String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String signSecret = secretInfoVO.getTheirSigSecret(); String dataSecret = secretInfoVO.getTheirDataSecret(); @@ -641,7 +715,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { } // 推送地址 - String url = urlAddress + "notification_orderInfo"; + String url = urlAddress + "supervise_notification_charge_order_info"; // 拼装成内蒙古平台所需格式对象 ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); @@ -667,10 +741,10 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用联联平台接口 - JSONObject json = new JSONObject(); - json.put("ChargeOrderInfo", orderInfo); - String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + // JSONObject json = new JSONObject(); + // json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -685,39 +759,72 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { public String notificationEquipChargeStatus(String orderCode) { // 根据订单号查询订单信息 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 根据站点id查询运营商id + PileStationVO stationVO = pileStationInfoService.getStationInfo(orderInfo.getStationId()); + + // 查询枪口实时状态 + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + RealTimeMonitorData realTimeMonitorData; + if (CollectionUtils.isEmpty(chargingRealTimeData)) { + realTimeMonitorData = RealTimeMonitorData.builder() + .chargingDegree(Constants.ZERO) + .connectorStatus("3") + .build(); + chargingRealTimeData.add(realTimeMonitorData); + } else { + realTimeMonitorData = chargingRealTimeData.get(0); + } + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) { + // 充电中 + orderStatus = "2"; + } else if (StringUtils.equals(OrderStatusEnum.ORDER_COMPLETE.getValue(), orderStatus)) { + // 充电完成 + orderStatus = "4"; + } + BigDecimal current = realTimeMonitorData.getOutputCurrent() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputCurrent()); + BigDecimal voltage = realTimeMonitorData.getOutputVoltage() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputVoltage()); + String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : realTimeMonitorData.getSOC(); // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); - // 调用 查询充电状态方法 - QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); - dto.setStartChargeSeq(orderCode); - dto.setOperatorID(thirdPartySecretInfoVO.getTheirOperatorId()); - Map map = queryEquipChargeStatus(dto); - if (map == null) { - return null; - } - String data = map.get("Data"); - // 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) - byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), - thirdPartySecretInfoVO.getOurDataSecret().getBytes(), thirdPartySecretInfoVO.getOurDataSecretIv().getBytes()); - String dataStr = new String(plainText, StandardCharsets.UTF_8); - // 转成对应的对象 - QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); + SupEquipChargeStatusInfo equipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(operatorId) + .equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(stationVO.getOrganizationCode())) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(Integer.parseInt(orderStatus)) + .connectorID(orderInfo.getPileConnectorCode()) + .equipmentClassification(1) // 车辆充电设备接口 + .pushTimeStamp(DateUtils.dateTimeNow()) + .connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) + .currentA(current) + .voltageA(voltage) + .soc(new BigDecimal(soc)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(DateUtils.getDateTime()) + .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) + .batteryPackId("") + .currentMeter("") - String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); + .build(); + + String url = urlAddress + "supervise_notification_equip_charge_status"; // 调用联联平台接口 - String jsonString = JSON.toJSONString(vo); + String jsonString = JSON.toJSONString(equipChargeStatusInfo); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -747,7 +854,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -783,7 +890,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { JSONObject json = new JSONObject(); json.put("ChargeOrderInfo", orderInfo); String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -885,7 +992,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { if (thirdPartySecretInfoVO == null) { throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); } - thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_LIANLIAN); return thirdPartySecretInfoVO; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java index 8c03f2f5e..f84621db6 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java @@ -135,7 +135,12 @@ public class HttpRequestUtil { String encryptData = Encodes.encodeBase64(encryptText); Map params = Maps.newLinkedHashMap(); - params.put("OperatorID", operatorId); + if (ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode().equals(thirdPlatformType)) { + // 内蒙古平台 + params.put("PlatformID", operatorId); + }else { + params.put("OperatorID", operatorId); + } params.put("Data", encryptData); params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date())); params.put("Seq", "001"); @@ -145,6 +150,7 @@ public class HttpRequestUtil { params.put("Portname", "wcc-pro"); } + String sign = GBSignUtils.sign(params, sigSecret); params.put("Sig", sign);