diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java deleted file mode 100644 index 2db290775..000000000 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java +++ /dev/null @@ -1,533 +0,0 @@ -package com.jsowell.thirdparty.platform; - -import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson2.JSON; -import com.google.common.collect.Maps; -import com.jsowell.common.util.DateUtils; -import com.jsowell.common.util.JWTUtils; -import com.jsowell.common.util.StringUtils; -import com.jsowell.pile.domain.PileBasicInfo; -import com.jsowell.pile.domain.PileConnectorInfo; -import com.jsowell.pile.domain.PileStationInfo; -import com.jsowell.pile.domain.ThirdPartyPlatformConfig; -import com.jsowell.pile.dto.*; -import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; -import com.jsowell.pile.service.*; -import com.jsowell.pile.vo.web.PileModelInfoVO; -import com.jsowell.pile.thirdparty.CommonParamsDTO; -import com.jsowell.thirdparty.lianlian.util.Cryptos; -import com.jsowell.thirdparty.lianlian.util.Encodes; -import com.jsowell.thirdparty.lianlian.util.GBSignUtils; -import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; -import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; -import com.jsowell.pile.thirdparty.ZDLConnectorInfo; -import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; -import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; -import java.util.*; - -/** - * 对接第三方平台抽象类 - */ -public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean { - protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - protected PileMerchantInfoService pileMerchantInfoService; - - @Autowired - protected PileStationInfoService pileStationInfoService; - - @Autowired - protected ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; - - @Autowired - protected ThirdPartySettingInfoService thirdPartySettingInfoService; - - @Autowired - protected PileBillingTemplateService pileBillingTemplateService; - - @Autowired - protected PileBasicInfoService pileBasicInfoService; - - @Autowired - protected PileConnectorInfoService pileConnectorInfoService; - - @Autowired - protected PileModelInfoService pileModelInfoService; - - @Autowired - protected OrderBasicInfoService orderBasicInfoService; - - @Autowired - protected ThirdPartyStationRelationService thirdPartyStationRelationService; - - @Autowired - protected YKCPushCommandService ykcPushCommandService; - - @Autowired - protected PileRemoteService pileRemoteService; - - @Autowired - protected ZDLService zdlService; - - // =================================================================================== // - // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由我方平台实现此接口,对方平台调用的查询接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ // - // =================================================================================== // - - /** - * 查询运营商信息 query_operator_info - * supervise_query_operator_info - * @param dto 查询运营商信息DTO - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryOperatorInfo(QueryOperatorInfoDTO dto); - - /** - * 查询充电站信息 query_stations_info - * 此接口用于查询对接平台的充电站的信息 - * @param dto 查询站点信息dto - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryStationsInfo(QueryStationInfoDTO dto); - - /** - * 设备接口状态查询 query_station_status - * - * @param dto 查询站点信息dto - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryStationStatus(QueryStationInfoDTO dto); - - /** - * 查询统计信息 query_station_stats - * - * @param dto 查询站点信息dto - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryStationStats(QueryStationInfoDTO dto); - - /** - * 查询充电电量信息 query_order_info - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryOrderInfo(String orderCode); - - /** - * 请求设备认证 query_equip_auth - * 业务信息交换 - * @param dto 联联平台请求设备认证 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryEquipAuth(QueryEquipmentDTO dto); - - /** - * 请求启动充电 query_start_charge - * - * @param dto 请求启动充电DTO - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryStartCharge(QueryStartChargeDTO dto); - - /** - * 查询充电状态 query_equip_charge_status - * - * @param dto 查询充电状态DTO - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto); - - /** - * 请求停止充电 query_stop_charge - * - * @param dto 请求启动充电DTO - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryStopCharge(QueryStartChargeDTO dto); - - /** - * 充电站内充电桩空闲状态查询 query_free_pile_number - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryFreePileNumber(NXJTQueryStationInfoDTO dto); - - /** - * 某车牌号消费记录查询 query_orders_info_by_Plate_number - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryOrdersInfoByPlateNumber(NXJTQueryStationInfoDTO dto); - - /** - * 某段时间内消费记录查询 query_orders_info - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryOrdersInfo(NXJTQueryStationInfoDTO dto); - - /** - * 查询业务策略信息结果 - * 请求计费策略 request_equip_business_policy - * @param dto 请求启动充电DTO - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map queryEquipBusinessPolicy(QueryStartChargeDTO dto); - - /** - * 请求计费策略 request_equip_business_policy - * 华为平台 - * 合并到上面 查询业务策略信息结果 - */ - // public abstract Map requestEquipBusinessPolicy(QueryStationInfoDTO dto); - - /** - * VIN码充电 insert_start_charge - * 华为平台 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map insertStartCharge(QueryStationInfoDTO dto); - - /** - * 下发计费策略响应 notification_deliver_equip_business_policy_result - * 华为平台 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract Map notificationDeliverEquipBusinessPolicyResult(QueryStationInfoDTO dto); - - - // =================================================================================== // - // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由对方平台实现此接口,我方平台调用的通知接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ // - // =================================================================================== // - - /** - * 充电站信息变化推送 notification_stationInfo - * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 - * @param stationId 充电站id - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationStationInfo(String stationId); - - /** - * 设备状态变化推送 notification_stationStatus - * 推送充电设备接口状态信息 supervise_notification_station_status - * @param pileConnectorCode 充电枪口编号 - * @param status 枪口状态 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationStationStatus(String pileConnectorCode, String status); - - /** - * 设备充电中状态变化推送 notification_connector_charge_status - * @param pileConnectorCode 充电枪口编号 - * @param status 枪口状态 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationConnectorChargeStatus(String orderCode); - - /** - * 订单信息推送 notification_orderInfo - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationOrderInfo(String orderCode); - - /** - * 站点费率变化推送 notification_stationFee - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationStationFee(String stationId); - - /** - * 充电订单推送 notification_charge_order_info - * TODO 海南一张网文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 - * TODO 甬城泊车平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 - * TODO 华为平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 - * TODO 内蒙古平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 - * @param orderCode 订单编号 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationChargeOrderInfo(String orderCode); - - /** - * 告警信息推送 notification_alarmInfo - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationAlarmInfo(); - - /** - * 推送启动充电结果 notification_start_charge_result - * @param orderCode 订单编号 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationStartChargeResult(String orderCode); - - /** - * 推送充电状态 notification_equip_charge_status - * 推送充电状态信息 supervise_notification_equip_charge_status - * @param orderCode 订单编号 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationEquipChargeStatus(String orderCode) throws UnsupportedOperationException; - - /** - * 推送停止充电结果 notification_stop_charge_result - * @param orderCode 订单编号 - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationStopChargeResult(String orderCode); - - /** - * 华为平台 - * 平台充电设备编码同步 notification_operation_system_info - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationOperationSystemInfo(String orderCode); - - /** - * 推送充换电站用能统计信息 supervise_notification_operation_stats_info - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationOperationStatsInfo(String stationId); - - /** - * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history - * @exception UnsupportedOperationException 未实现异常 - */ - public abstract String notificationChargeOrderInfoHistory(String stationId); - - /** - * 推送充电订单对账信息 - */ - // public abstract Map checkChargeOrders(); - - // -------------------------------------- 以下是公用方法 --------------------------------------- // - /** - * 从联联平台获取令牌 - * - * @param operatorId 运营商id - * @param operatorSecret - * @return - */ - protected String getToken(String urlAddress, String operatorId, String operatorSecret, - String dataSecretIv, String signSecret, String dataSecret) { - String token = ""; - try { - // 请求地址 - String requestUrl = urlAddress + "query_token"; - - // 请求data - Map data = new HashMap<>(); - data.put("OperatorID", 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("OperatorID", 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 = resultMap.get("AccessToken"); - // logger.info("token: {}", token); - } - logger.info("获取令牌 result:{}, token: {}", result, token); - } catch (Exception e) { - return token; - } - return token; - } - - /** - * 身份认证 - */ - public Map generateToken(CommonParamsDTO dto) { - String operatorID = dto.getOperatorID(); - // 通过operatorID 查出 operatorSecret - ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorID); - if (platformConfig == null) { - return null; - } - String operatorSecret = platformConfig.getOperatorSecret(); - String dataSecret = platformConfig.getDataSecret(); - String dataSecretIv = platformConfig.getDataSecretIv(); - String signSecret = platformConfig.getSignSecret(); - // 校验签名 - Map checkResultMap = checkoutSign(dto); - if (checkResultMap == null) { - // 校验失败 - return null; - } - String dataString = checkResultMap.get("Data"); - // 解密data - byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIv.getBytes()); - String dataStr = new String(plainText, StandardCharsets.UTF_8); - Map resMap = (Map) JSON.parse(dataStr); - String secret = resMap.get("OperatorSecret"); - - // 对比解出来的密钥是否和数据库中保存的一致 - if (!StringUtils.equals(operatorSecret, secret)) { - // System.out.println("密钥不一致"); - return null; - } - System.out.println("密钥校验通过!! 密钥为: " + operatorSecret); - - // 生成token返回 eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MjUwMTA3NjUiLCJpYXQiOjE2ODUwOTcxMTYsInN1YiI6IjEyMzEyMzEyMzEyM2FhYWEiLCJleHAiOjY4NjkwOTcxMTZ9.NyxOUIZmgsqtfex7oiMRR2LaWePTA56WHVMXIkWWt2w - long ttlMillis = 60 * 60 * 24 * 1000; - String token = JWTUtils.createToken(operatorID, operatorSecret, ttlMillis); - - // 组装返回参数 - AccessTokenVO vo = new AccessTokenVO(); - vo.setAccessToken(token); - vo.setOperatorID(operatorID); - vo.setTokenAvailableTime((int) (ttlMillis / 1000)); - vo.setFailReason(0); - vo.setSuccStat(0); - - Map resultMap = Maps.newLinkedHashMap(); - // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - dataSecret.getBytes(), dataSecretIv.getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - - resultMap.put("Data", encryptData); - // 生成sig - String resultSign = GBSignUtils.sign(resultMap, signSecret); - resultMap.put("Sig", resultSign); - - return resultMap; - } - - public Map checkoutSign(CommonParamsDTO dto) { - String operatorID = dto.getOperatorID(); - // 通过operatorID 查出 operatorSecret - ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorID); - if (platformConfig == null) { - return null; - } - String operatorSecret = platformConfig.getOperatorSecret(); - String signSecret = platformConfig.getSignSecret(); - - Map map = Maps.newLinkedHashMap(); - map.put("OperatorID", dto.getOperatorID()); - map.put("Data", dto.getData()); - map.put("TimeStamp", dto.getTimeStamp()); - map.put("Seq", dto.getSeq()); - String sign = GBSignUtils.sign(map, signSecret); - // System.out.println(sign); - - // 验证签名 得到请求方传过来的签名sig->自己拿到请求体后,再按双方约定的协议生成一个sig->对比两个sig是否一致 - if (!StringUtils.equals(dto.getSig(), sign)) { - System.out.println("签名校验==失败"); - return null; - } - // System.out.println("签名校验通过!!!"); - - // 解密data - // byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dto.getData()), operatorSecret.getBytes(), operatorSecret.getBytes()); - // String dataStr = new String(plainText, "UTF-8"); - // Map resMap = (Map) JSON.parse(dataStr); - // return resMap; - Map resultMap = new LinkedHashMap<>(); - resultMap.put("Data", dto.getData()); - resultMap.put("OperatorSecret", operatorSecret); - resultMap.put("DataSecret", platformConfig.getDataSecret()); - resultMap.put("DataSecretIV", platformConfig.getDataSecretIv()); - return resultMap; - } - - /** - * 获取桩列表信息 - * - * @param pileStationInfo - * @return - */ - protected List getPileList(PileStationInfo pileStationInfo) { - List resultList = new ArrayList<>(); - // 通过站点id查询桩基本信息 - List list = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId())); - // 封装成中电联平台对象 - for (PileBasicInfo pileBasicInfo : list) { - ZDLEquipmentInfo equipmentInfo = new ZDLEquipmentInfo(); - String pileSn = pileBasicInfo.getSn(); - - equipmentInfo.setEquipmentId(pileSn); - - PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); - equipmentInfo.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType())); - equipmentInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); - - List connectorList = getConnectorList(pileBasicInfo); - equipmentInfo.setConnectorInfos(connectorList); - - resultList.add(equipmentInfo); - } - return resultList; - } - - /** - * 获取枪口列表 - * - * @param pileBasicInfo - * @return - */ - protected List getConnectorList(PileBasicInfo pileBasicInfo) { - List resultList = new ArrayList<>(); - - List list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn()); - for (PileConnectorInfo pileConnectorInfo : list) { - ZDLConnectorInfo connectorInfo = new ZDLConnectorInfo(); - - connectorInfo.setConnectorId(pileConnectorInfo.getPileConnectorCode()); - String pileSn = pileConnectorInfo.getPileSn(); - PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); - int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3; - - connectorInfo.setConnectorType(connectorType); - // 车位号 - if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) { - connectorInfo.setParkNo(pileConnectorInfo.getParkNo()); - } - connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage())); - connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage())); - connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); - connectorInfo.setNationalStandard(2); - // if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) { - // // 如果不是单枪,则枪口功率需要除以枪口数量 - // String ratedPowerStr = modelInfo.getRatedPower(); - // BigDecimal ratedPower = new BigDecimal(ratedPowerStr); - // connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP)); - // }else { - // } - connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); - - resultList.add(connectorInfo); - } - return resultList; - } -} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java deleted file mode 100644 index 8eb834bea..000000000 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jsowell.thirdparty.platform; - -import com.google.common.collect.Maps; -import com.jsowell.common.util.StringUtils; - -import java.util.Map; -import java.util.Objects; - -/** - * 工厂设计模式 - * 对接第三方平台逻辑工厂类 - */ -public class InterfaceWithPlatformLogicFactory { - - private static final Map platformMap = Maps.newHashMap(); - - /** - * 注册 - * @param code 平台code {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} - * @param handler 处理逻辑类 - */ - public static void register(String code, AbsInterfaceWithPlatformLogic handler) { - if (StringUtils.isBlank(code) || Objects.isNull(handler)) { - return; - } - platformMap.put(code, handler); - } - - /** - * 获取 - * @param code 平台code {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} - * @return 处理逻辑类 - */ - public static AbsInterfaceWithPlatformLogic getPlatformLogic(String code) { - return platformMap.get(code); - } -} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java index 6207335a9..8f6736ac0 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java @@ -208,13 +208,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { map.put("ItemSize", resultList.size()); map.put("StationInfos", resultList); - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); @@ -437,18 +433,13 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { map.put("Total", total); map.put("StationStatusInfos", collect); - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); resultMap.put("Sig", resultSign); - return resultMap; } @@ -536,14 +527,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { Map map = new LinkedHashMap<>(); map.put("StationStats", stationStatsInfo); - // 拼装结果集 - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); @@ -558,7 +544,7 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public Map queryEquipAuth(QueryEquipmentDTO dto) { - Map resultMap = Maps.newLinkedHashMap(); + EquipmentAuthVO vo = new EquipmentAuthVO(); String equipAuthSeq = dto.getEquipAuthSeq(); // MA1X78KH5202311071202015732 @@ -593,16 +579,13 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { vo.setFailReason(2); // 设备检测失败 vo.setFailReasonMsg("未查到该桩的数据"); } + Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); resultMap.put("Sig", resultSign); - return resultMap; } @@ -651,21 +634,15 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { .failReason(0) .sumPeriod(policyInfoList.size()) .policyInfos(policyInfoList) - .build(); - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); resultMap.put("Sig", resultSign); - return resultMap; } @@ -778,13 +755,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { vo.setStartChargeSeqStat(1); } - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); @@ -861,13 +834,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { .build(); } - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); @@ -967,13 +936,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { // 如果是新电途平台,则将 startChargeSeqStat 改为 3-停止中 vo.setStartChargeSeqStat(3); } - // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); - + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), configInfo.getDataSecret(), configInfo.getDataSecretIv()); resultMap.put("Data", encryptData); // 生成sig String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java index ed6fc4d70..7563e09e8 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java @@ -1,320 +1,15 @@ package com.jsowell.thirdparty.platform.neimenggu.service; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; -import com.jsowell.pile.dto.*; -import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; -import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformLogic; -import com.jsowell.thirdparty.platform.InterfaceWithPlatformLogicFactory; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; import org.springframework.stereotype.Service; -import java.util.Map; - /** * 内蒙古监测平台逻辑 */ @Service -public class NeiMengGuPlatformServiceImpl extends AbsInterfaceWithPlatformLogic { +public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 平台类型 private final String platformType = ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode(); - @Override - public void afterPropertiesSet() throws Exception { - InterfaceWithPlatformLogicFactory.register(platformType, this); - } - - /** - * 查询运营商信息 - * - * @param dto 查询运营商信息DTO - */ - @Override - public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 6.2 查询充电站信息 - * - * @param dto - */ - @Override - public Map queryStationsInfo(QueryStationInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 6.3 设备状态变化推送 - * - * @param pileConnectorCode - * @param status - */ - @Override - public String notificationStationStatus(String pileConnectorCode, String status) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 设备充电中状态变化推送 notification_connector_charge_status - * - * @param orderCode 订单号 - */ - @Override - public String notificationConnectorChargeStatus(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 订单信息推送 notification_orderInfo - * - * @param orderCode - */ - @Override - public String notificationOrderInfo(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 站点费率变化推送 notification_stationFee - * - * @param stationId - */ - @Override - public String notificationStationFee(String stationId) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 6.4 充电订单推送 - * - * @param orderCode - */ - @Override - public String notificationChargeOrderInfo(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 告警信息推送 notification_alarmInfo - */ - @Override - public String notificationAlarmInfo() { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 6.5 设备接口状态查询 - * - * @param dto - */ - @Override - public Map queryStationStatus(QueryStationInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 查询统计信息 query_station_stats - * - * @param dto - */ - @Override - public Map queryStationStats(QueryStationInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 查询充电电量信息 query_order_info - * - * @param orderCode - */ - @Override - public Map queryOrderInfo(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 请求设备认证 - * 业务信息交换 - * - * @param dto - */ - @Override - public Map queryEquipAuth(QueryEquipmentDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 查询业务策略信息结果 - * - * @param dto - */ - @Override - public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * VIN码充电 insert_start_charge - * 华为平台 - * - * @param dto - */ - @Override - public Map insertStartCharge(QueryStationInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 下发计费策略响应 notification_deliver_equip_business_policy_result - * 华为平台 - * - * @param dto - */ - @Override - public Map notificationDeliverEquipBusinessPolicyResult(QueryStationInfoDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 充电站信息变化推送 notification_stationInfo - * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 - * - * @param stationId 充电站id - */ - @Override - public String notificationStationInfo(String stationId) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 请求启动充电 - * - * @param dto - */ - @Override - public Map queryStartCharge(QueryStartChargeDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 推送启动充电结果 - * - * @param orderCode - */ - @Override - public String notificationStartChargeResult(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 推送充电状态 notification_equip_charge_status - * 推送充电状态信息 supervise_notification_equip_charge_status - * - * @param orderCode 订单编号 - */ - @Override - public String notificationEquipChargeStatus(String orderCode) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 查询充电状态 - * - * @param dto - */ - @Override - public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - - - /** - * 请求停止充电 - * - * @param dto - */ - @Override - public Map queryStopCharge(QueryStartChargeDTO dto) { - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 充电站内充电桩空闲状态查询 query_free_pile_number - * - * @param dto - */ - @Override - public Map queryFreePileNumber(NXJTQueryStationInfoDTO dto) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 某车牌号消费记录查询 query_orders_info_by_Plate_number - * - * @param dto - */ - @Override - public Map queryOrdersInfoByPlateNumber(NXJTQueryStationInfoDTO dto) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 某段时间内消费记录查询 query_orders_info - * - * @param dto - */ - @Override - public Map queryOrdersInfo(NXJTQueryStationInfoDTO dto) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 推送停止充电结果 - * - * @param orderCode - */ - @Override - public String notificationStopChargeResult(String orderCode) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 华为平台 - * 平台充电设备编码同步 notification_operation_system_info - * - * @param orderCode - */ - @Override - public String notificationOperationSystemInfo(String orderCode) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 推送充换电站用能统计信息 supervise_notification_operation_stats_info - * - * @param stationId - */ - @Override - public String notificationOperationStatsInfo(String stationId) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - /** - * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history - * - * @param stationId - */ - @Override - public String notificationChargeOrderInfoHistory(String stationId) { - //方法未实现,抛出异常 - throw new UnsupportedOperationException("This method is not yet implemented"); - } - - }