From ee92864b1968b1bc95780264c7a1cddc3bd77f98 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 8 Apr 2025 09:27:25 +0800 Subject: [PATCH 01/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsowell/thirdparty/platform/util/HttpRequestUtil.java | 4 ++++ 1 file changed, 4 insertions(+) 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..48a40a5a9 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 @@ -144,6 +144,10 @@ public class HttpRequestUtil { if (ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode().equals(thirdPlatformType)) { params.put("Portname", "wcc-pro"); } + if (ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode().equals(thirdPlatformType)) { + // 内蒙古平台 + params.put("PlatformID", operatorId); + } String sign = GBSignUtils.sign(params, sigSecret); params.put("Sig", sign); From b641e5cb86db478d2c6f486d1704d1bae72205ae Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 8 Apr 2025 10:16:43 +0800 Subject: [PATCH 02/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/ThirdPlatformTypeEnum.java | 2 +- .../service/ThirdPartyPlatformService.java | 1 + .../impl/NeiMengGuPlatformServiceImpl.java | 79 +++++++++++++++++-- .../platform/util/HttpRequestUtil.java | 1 + 4 files changed, 77 insertions(+), 6 deletions(-) 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/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/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index 5ca48cccd..ee9d15700 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,13 +1,17 @@ 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; @@ -16,6 +20,7 @@ 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 +46,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 +64,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; /** @@ -545,10 +549,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 * 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 48a40a5a9..4e5d5bdf4 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 @@ -146,6 +146,7 @@ public class HttpRequestUtil { } if (ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode().equals(thirdPlatformType)) { // 内蒙古平台 + params.remove("OperatorID"); params.put("PlatformID", operatorId); } From 62e7badbddd596e22b7e3007b2a60c20f045b250 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 8 Apr 2025 15:52:32 +0800 Subject: [PATCH 03/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ChargeAlgorithmService.java | 2 +- .../impl/NeiMengGuPlatformServiceImpl.java | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) 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..94bff2fef 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 @@ -134,7 +134,7 @@ public class ChargeAlgorithmService { 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 ee9d15700..a76be4fbd 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 @@ -200,7 +200,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; } @@ -303,7 +304,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; } @@ -409,7 +411,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; } @@ -460,7 +463,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; } @@ -483,7 +487,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(); @@ -536,7 +540,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(); @@ -635,7 +639,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(); @@ -696,7 +700,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(); @@ -757,7 +761,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(); @@ -816,7 +820,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(); @@ -954,7 +958,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; } From f871234f8ec14acf502e371e6d2b7ec49ceb07ff Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 8 Apr 2025 16:06:57 +0800 Subject: [PATCH 04/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/platform/util/HttpRequestUtil.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 4e5d5bdf4..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"); @@ -144,11 +149,7 @@ public class HttpRequestUtil { if (ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode().equals(thirdPlatformType)) { params.put("Portname", "wcc-pro"); } - if (ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode().equals(thirdPlatformType)) { - // 内蒙古平台 - params.remove("OperatorID"); - params.put("PlatformID", operatorId); - } + String sign = GBSignUtils.sign(params, sigSecret); params.put("Sig", sign); From 2b12f9e80b579b3351986224e5f131e798c19c42 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 8 Apr 2025 16:14:51 +0800 Subject: [PATCH 05/11] =?UTF-8?q?update=20=20=E7=94=B5=E6=B1=A0=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E5=BA=94=E7=94=A8Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/domain/ChargeAlgorithmData.java | 50 +++++++++++++++++++ .../service/impl/ChargeAlgorithmService.java | 19 +++++++ 2 files changed, 69 insertions(+) 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/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index 94bff2fef..1e6567158 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; @@ -43,6 +45,9 @@ public class ChargeAlgorithmService { @Autowired private PileBasicInfoService pileBasicInfoService; + @Autowired + private PileStationInfoService pileStationInfoService; + @Autowired private RedisCache redisCache; @@ -58,6 +63,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,6 +133,17 @@ 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(); From 4e97b2a08331f03c043c58774fb265739ff0ad27 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 10:02:43 +0800 Subject: [PATCH 06/11] =?UTF-8?q?update=20=20=E7=94=B5=E6=B1=A0=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E5=BA=94=E7=94=A8Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsowell/thirdparty/common/NotificationService.java | 10 ++++++---- .../platform/service/impl/ChargeAlgorithmService.java | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) 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/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index 1e6567158..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 @@ -24,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; /** @@ -149,6 +146,10 @@ public class ChargeAlgorithmService { 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); From 8e8b091747676f1a6739e4ffbcb7665c709eb702 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 10:04:15 +0800 Subject: [PATCH 07/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/impl/NeiMengGuPlatformServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a76be4fbd..e16f4bfee 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 @@ -784,7 +784,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 转成对应的对象 QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); - String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); + String url = urlAddress + "supervise_notification_equip_charge_status"; // 调用联联平台接口 String jsonString = JSON.toJSONString(vo); From 04419a7180d7616a1c482b7cc37a356b713fe3c2 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 10:21:03 +0800 Subject: [PATCH 08/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/SupEquipChargeStatusInfo.java | 12 ++++ .../impl/NeiMengGuPlatformServiceImpl.java | 66 ++++++++++++++----- 2 files changed, 62 insertions(+), 16 deletions(-) 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/impl/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index e16f4bfee..1d352f4a0 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 @@ -16,6 +16,7 @@ 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; @@ -758,6 +759,33 @@ 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(); @@ -768,25 +796,31 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { 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("") + + .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); From 74c39bc2be4f52d49ad69f8721e93bf5a8d2f665 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 10:33:57 +0800 Subject: [PATCH 09/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/NeiMengGuPlatformServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 1d352f4a0..e0ce39cd2 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 @@ -506,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; } @@ -683,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; } @@ -744,7 +744,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; } @@ -824,7 +824,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 获取令牌 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; } @@ -890,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; } From e1d2f028e02bad3383893f087278984297300325 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 13:42:02 +0800 Subject: [PATCH 10/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/impl/NeiMengGuPlatformServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e0ce39cd2..595384db4 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 @@ -715,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); From eb09d9dbd99be76aebfe2538eb8681877a128d1e Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 9 Apr 2025 16:09:09 +0800 Subject: [PATCH 11/11] =?UTF-8?q?update=20=20=20=E5=86=85=E8=92=99?= =?UTF-8?q?=E5=8F=A4=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/impl/NeiMengGuPlatformServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 595384db4..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 @@ -741,9 +741,9 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用联联平台接口 - JSONObject json = new JSONObject(); - json.put("ChargeOrderInfo", orderInfo); - String jsonString = JSON.toJSONString(json); + // 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; }