Merge remote-tracking branch 'origin/dev' into dev-zzx

This commit is contained in:
YAS\29473
2025-04-09 19:55:07 +08:00
8 changed files with 251 additions and 53 deletions

View File

@@ -18,7 +18,7 @@ public enum ThirdPlatformTypeEnum {
HAI_NAN_1_PLATFORM("7", "海南一张网(监管平台)", "578725200"), HAI_NAN_1_PLATFORM("7", "海南一张网(监管平台)", "578725200"),
HAI_NAN_2_PLATFORM("8", "海南一张网(充电平台)", "MAA9A0PP1"), HAI_NAN_2_PLATFORM("8", "海南一张网(充电平台)", "MAA9A0PP1"),
HUA_WEI("9", "华为平台", "MA5GTQ528"), HUA_WEI("9", "华为平台", "MA5GTQ528"),
NEI_MENG_GU_PLATFORM("10", "内蒙古平台", ""), NEI_MENG_GU_PLATFORM("10", "内蒙古平台", "MAB03NTXZ"),
QING_HAI_PLATFORM("11", "青海平台", "630000000"), QING_HAI_PLATFORM("11", "青海平台", "630000000"),
DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""), DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""),
NING_XIA_PLATFORM("13", "宁夏平台", "MA01H3BQ9"), NING_XIA_PLATFORM("13", "宁夏平台", "MA01H3BQ9"),

View File

@@ -131,10 +131,12 @@ public class NotificationService {
logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}", logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}",
secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage()); secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage());
} }
try { finally {
platformService.notificationEquipChargeStatus(orderCode); try {
}catch (Exception e){ platformService.notificationEquipChargeStatus(orderCode);
logger.error("notification_equip_charge_status error", e); }catch (Exception e){
logger.error("notification_equip_charge_status error", e);
}
} }
} }
} }

View File

@@ -24,6 +24,56 @@ public class ChargeAlgorithmData {
*/ */
private String orderCode; 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 * 初始SOC
*/ */

View File

@@ -187,6 +187,18 @@ public class SupEquipChargeStatusInfo {
@JSONField(name = "ServiceMoney") @JSONField(name = "ServiceMoney")
private String serviceMoney; private String serviceMoney;
/**
* 电池编码
*/
@JSONField(name = "BatteryPackID")
private String batteryPackId;
/**
* 当前电表读数
*/
@JSONField(name = "CurrentMeter")
private String currentMeter;
/** /**
* 时段数 * 时段数
* 参数范围0 32 * 参数范围0 32

View File

@@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.redis.RedisCache; 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.DateUtils;
import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;

View File

@@ -12,8 +12,10 @@ import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.OrderSplitRecord; import com.jsowell.pile.domain.OrderSplitRecord;
import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.OrderBasicInfoService;
import com.jsowell.pile.service.PileBasicInfoService; import com.jsowell.pile.service.PileBasicInfoService;
import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.thirdparty.ParameterConfigData; import com.jsowell.pile.thirdparty.ParameterConfigData;
import com.jsowell.pile.vo.uniapp.customer.OrderVO; import com.jsowell.pile.vo.uniapp.customer.OrderVO;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData; import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -22,10 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -43,6 +42,9 @@ public class ChargeAlgorithmService {
@Autowired @Autowired
private PileBasicInfoService pileBasicInfoService; private PileBasicInfoService pileBasicInfoService;
@Autowired
private PileStationInfoService pileStationInfoService;
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@@ -58,6 +60,9 @@ public class ChargeAlgorithmService {
if (orderVO == null) { if (orderVO == null) {
return "订单信息为空"; return "订单信息为空";
} }
// 查询站点信息
PileStationVO stationVO = pileStationInfoService.getStationInfo(orderVO.getStationId());
// 计算充电时长 // 计算充电时长
long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime()); long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime());
String transactionCode = orderVO.getTransactionCode(); String transactionCode = orderVO.getTransactionCode();
@@ -125,16 +130,31 @@ public class ChargeAlgorithmService {
// .gunTemp("0") // 充电枪温度 // .gunTemp("0") // 充电枪温度
.doorStatus(Constants.zero) // 舱门状态 .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(); .build();
List<ChargeAlgorithmData List<ChargeAlgorithmData
.ChargingDetailInfo> chargingDetailInfos = transformData(transactionCode, chargerOutputInfoList, parameterConfigData, transactionRecordsData); .ChargingDetailInfo> 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); data.setChargingDetailInfo(chargingDetailInfos);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("dataJason", data); jsonObject.put("dataJson", data);
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject)); log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject));

View File

@@ -1,21 +1,27 @@
package com.jsowell.thirdparty.platform.service.impl; 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.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; 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.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; 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.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.*; import com.jsowell.common.util.*;
import com.jsowell.common.util.bean.BeanUtils;
import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.domain.OrderDetail; import com.jsowell.pile.domain.OrderDetail;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig; 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.ConnectorStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; 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.lianlian.vo.QueryChargingStatusVO;
import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.domain.*;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.*;
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.service.ThirdpartySecretInfoService; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import com.yi.business.geo.GeoCodeInfo; import com.yi.business.geo.GeoCodeInfo;
import com.yi.business.geo.TermRelationTreeCoordinate; import com.yi.business.geo.TermRelationTreeCoordinate;
@@ -61,6 +65,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -196,7 +201,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
map.put("ItemSize", pageInfo.getTotal()); map.put("ItemSize", pageInfo.getTotal());
map.put("OperatorInfos", operatorInfos); map.put("OperatorInfos", operatorInfos);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap; return resultMap;
} }
@@ -299,7 +305,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
map.put("PageCount", pageInfo.getPages()); map.put("PageCount", pageInfo.getPages());
map.put("ItemSize", pageInfo.getTotal()); map.put("ItemSize", pageInfo.getTotal());
map.put("StationInfos", resultList); map.put("StationInfos", resultList);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap; return resultMap;
} }
@@ -405,7 +412,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// map.put("Total", total); // map.put("Total", total);
map.put("StationStatusInfos", collect); map.put("StationStatusInfos", collect);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap; return resultMap;
} }
@@ -456,7 +464,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// 结果集 // 结果集
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
map.put("StationStatusInfos", stationStatusInfos); map.put("StationStatusInfos", stationStatusInfos);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap; return resultMap;
} }
@@ -479,7 +488,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// 查询相关配置信息 // 查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
@@ -497,7 +506,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
String jsonString = JSON.toJSONString(json); String jsonString = JSON.toJSONString(json);
// 获取令牌 // 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); 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; return result;
} }
@@ -532,7 +541,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
.build(); .build();
// 调用联联平台接口 // 调用联联平台接口
String operatorId = secretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String operatorSecret = secretInfoVO.getTheirOperatorSecret();
String signSecret = secretInfoVO.getTheirSigSecret(); String signSecret = secretInfoVO.getTheirSigSecret();
String dataSecret = secretInfoVO.getTheirDataSecret(); String dataSecret = secretInfoVO.getTheirDataSecret();
@@ -545,10 +554,75 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
String jsonString = JSON.toJSONString(info); String jsonString = JSON.toJSONString(info);
// 获取令牌 // 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); 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; 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<String, String> 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<String, String> 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<String, Object> resultMap = (Map<String, Object>) 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 * 充电订单推送 notification_charge_order_info
* *
@@ -566,7 +640,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// 查询相关配置信息 // 查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
@@ -609,7 +683,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("ChargeOrderInfo", orderInfo); json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(json); 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; return result;
} }
@@ -627,7 +701,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// return null; // return null;
// } // }
String operatorId = secretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String operatorSecret = secretInfoVO.getTheirOperatorSecret();
String signSecret = secretInfoVO.getTheirSigSecret(); String signSecret = secretInfoVO.getTheirSigSecret();
String dataSecret = secretInfoVO.getTheirDataSecret(); 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); ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail);
@@ -667,10 +741,10 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
return null; return null;
} }
// 调用联联平台接口 // 调用联联平台接口
JSONObject json = new JSONObject(); // JSONObject json = new JSONObject();
json.put("ChargeOrderInfo", orderInfo); // json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(json); String jsonString = JSON.toJSONString(orderInfo);
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; return result;
} }
@@ -685,39 +759,72 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
public String notificationEquipChargeStatus(String orderCode) { public String notificationEquipChargeStatus(String orderCode) {
// 根据订单号查询订单信息 // 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
// OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
// 根据站点id查询运营商id
PileStationVO stationVO = pileStationInfoService.getStationInfo(orderInfo.getStationId());
// 查询枪口实时状态
List<RealTimeMonitorData> 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(); ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
// 调用 查询充电状态方法 SupEquipChargeStatusInfo equipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); .operatorID(operatorId)
dto.setStartChargeSeq(orderCode); .equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(stationVO.getOrganizationCode()))
dto.setOperatorID(thirdPartySecretInfoVO.getTheirOperatorId()); .stationID(orderInfo.getStationId())
Map<String, String> map = queryEquipChargeStatus(dto); .equipmentID(orderInfo.getPileSn())
if (map == null) { .orderNo(orderInfo.getOrderCode())
return null; .orderStatus(Integer.parseInt(orderStatus))
} .connectorID(orderInfo.getPileConnectorCode())
String data = map.get("Data"); .equipmentClassification(1) // 车辆充电设备接口
// 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) .pushTimeStamp(DateUtils.dateTimeNow())
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), .connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus()))
thirdPartySecretInfoVO.getOurDataSecret().getBytes(), thirdPartySecretInfoVO.getOurDataSecretIv().getBytes()); .currentA(current)
String dataStr = new String(plainText, StandardCharsets.UTF_8); .voltageA(voltage)
// 转成对应的对象 .soc(new BigDecimal(soc))
QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); .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 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; return result;
} }
@@ -747,7 +854,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// 查询相关配置信息 // 查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
@@ -783,7 +890,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("ChargeOrderInfo", orderInfo); json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(json); 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; return result;
} }
@@ -885,7 +992,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
if (thirdPartySecretInfoVO == null) { if (thirdPartySecretInfoVO == null) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
} }
thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_LIANLIAN);
return thirdPartySecretInfoVO; return thirdPartySecretInfoVO;
} }

View File

@@ -135,7 +135,12 @@ public class HttpRequestUtil {
String encryptData = Encodes.encodeBase64(encryptText); String encryptData = Encodes.encodeBase64(encryptText);
Map<String, String> params = Maps.newLinkedHashMap(); Map<String, String> 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("Data", encryptData);
params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date())); params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
params.put("Seq", "001"); params.put("Seq", "001");
@@ -145,6 +150,7 @@ public class HttpRequestUtil {
params.put("Portname", "wcc-pro"); params.put("Portname", "wcc-pro");
} }
String sign = GBSignUtils.sign(params, sigSecret); String sign = GBSignUtils.sign(params, sigSecret);
params.put("Sig", sign); params.put("Sig", sign);