From 7b2a3fe20e67e327fa2bb71a37616f2385f75d32 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 16 May 2023 15:04:08 +0800 Subject: [PATCH 1/5] =?UTF-8?q?add=20=20=E6=8E=A8=E9=80=81=E8=81=94?= =?UTF-8?q?=E8=81=94=E5=B9=B3=E5=8F=B0=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/SpringBootTestController.java | 36 +++++++------- .../impl/PileConnectorInfoServiceImpl.java | 8 ++++ .../domain/ConnectorStatusInfo.java | 7 ++- .../thirdparty/service/LianLianService.java | 10 +++- .../service/impl/LianLianServiceImpl.java | 47 +++++++++++++++++-- 5 files changed, 83 insertions(+), 25 deletions(-) diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 4ced984c4..2f427fa6e 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -160,24 +160,26 @@ public class SpringBootTestController { @Test public void testLianLian(){ - // 获取令牌 - LianLianGetTokenDTO dto = new LianLianGetTokenDTO(); - dto.setOperatorId("987654321"); - dto.setOperatorSecret("1234567890abcdef"); - String token = lianLianService.getToken(dto); - System.out.println("token:" + token); + // // 获取令牌 + // LianLianGetTokenDTO dto = new LianLianGetTokenDTO(); + // dto.setOperatorId("987654321"); + // dto.setOperatorSecret("1234567890abcdef"); + // String token = lianLianService.getToken(dto); + // System.out.println("token:" + token); + // + // + // LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder() + // .OperatorID("987654321") + // .DataSecret("1234567890abcdef") + // .DataSecretIV("1234567890abcdef") + // .SigSecret("1234567890abcdef") + // .token(token) + // .stationId(2L) + // + // .build(); + // lianLianService.pushStationInfo(dto1); - - LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder() - .OperatorID("987654321") - .DataSecret("1234567890abcdef") - .DataSecretIV("1234567890abcdef") - .SigSecret("1234567890abcdef") - .token(token) - .stationId(2L) - - .build(); - lianLianService.pushStationInfo(dto1); + lianLianService.pushConnectorStatus("8800000000000101", "1"); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index bda70444c..0ab5f6dd7 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -439,6 +439,11 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService { return response; } + @Override + public String pushConnectorStatus(String pileConnectorCode, String status) { + return null; + } + /** * 查询充电枪口的实时数据 */ @@ -527,6 +532,9 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService { num = pileConnectorInfoMapper.updateConnectorStatus(pileConnectorCode, status); deleteRedisByPileSn(pileSn); redisCache.setCacheObject(redisKey, status); + + // 推送联联平台 设备状态变化推送接口 ConnectorStatusInfo + } return num; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/domain/ConnectorStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/domain/ConnectorStatusInfo.java index c7a1eebfc..553c93b1b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/domain/ConnectorStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/domain/ConnectorStatusInfo.java @@ -1,5 +1,6 @@ package com.jsowell.thirdparty.domain; +import com.alibaba.fastjson2.annotation.JSONField; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -17,7 +18,8 @@ public class ConnectorStatusInfo { * 充电设备接口编码 Y * 充电设备接口编码,同一对接平台内唯一 */ - private String ConnectorID; + @JSONField(name = "ConnectorID") + private String connectorID; /** * 充电设备接口状态 Y @@ -28,7 +30,8 @@ public class ConnectorStatusInfo { * 4:占用(预约锁定) * 255:故障 */ - private String Status; + @JSONField(name = "Status") + private String status; /** * 车位状态(0-未知;10-空闲;50-占用) N diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/LianLianService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/LianLianService.java index 8af4b5414..73ac3b631 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/LianLianService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/LianLianService.java @@ -16,7 +16,7 @@ public interface LianLianService { /** * 根据充电站id,推送充电站信息 - * @param stationId + * @param dto */ void pushStationInfo(LianLianPushStationInfoDTO dto); @@ -78,4 +78,12 @@ public interface LianLianService { * @return */ String getToken(LianLianGetTokenDTO dto); + + /** + * 推送联联平台 设备状态变化推送 + * @param pileConnectorCode + * @param status + * @return + */ + String pushConnectorStatus(String pileConnectorCode, String status); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java index 809994022..0ffd168f9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java @@ -55,6 +55,12 @@ import java.util.stream.Collectors; @Service public class LianLianServiceImpl implements LianLianService { + private static final String TEST_URL = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/"; + private static final String OPERATOR_ID = "987654321"; + private static final String OPERATOR_SECRET = "1234567890abcdef"; + private static final String SIG_SECRET = "1234567890abcdef"; // 签名秘钥 + private static final String DATA_SECRET = "1234567890abcdef"; // 消息密钥 + private static final String DATA_SECRETIV = "1234567890abcdef"; // 消息密钥初始化向量 @Autowired private IPileMerchantInfoService pileMerchantInfoService; @@ -152,7 +158,7 @@ public class LianLianServiceImpl implements LianLianService { } // 调用联联平台接口 - String url = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/" + "notification_stationInfo"; + String url = TEST_URL + "notification_stationInfo"; String jsonStr = JSONObject.toJSONString(info); JSONObject data = new JSONObject(); @@ -169,8 +175,7 @@ public class LianLianServiceImpl implements LianLianService { } public static void main(String[] args){ - BigDecimal bigDecimal = new BigDecimal("7").setScale(1, BigDecimal.ROUND_HALF_UP); - System.out.println(bigDecimal); + } /** @@ -564,7 +569,7 @@ public class LianLianServiceImpl implements LianLianService { } /** - * 获取令牌 + * 从联联平台获取令牌 * @param dto * @return */ @@ -575,7 +580,7 @@ public class LianLianServiceImpl implements LianLianService { String token = ""; try { //测试用请求地址 - String requestUrl = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/query_token"; + String requestUrl = TEST_URL + "query_token"; //请求data Map data = new HashMap<>(); @@ -617,6 +622,38 @@ public class LianLianServiceImpl implements LianLianService { return token; } + /** + * 联联平台推送 设备状态变化推送 + * @param pileConnectorCode + * @param status + * @return + */ + @Override + public String pushConnectorStatus(String pileConnectorCode, String status) { + String url = TEST_URL + "notification_stationStatus"; + + // 获取令牌 + LianLianGetTokenDTO dto = new LianLianGetTokenDTO(); + dto.setOperatorId(OPERATOR_ID); + dto.setOperatorSecret(OPERATOR_SECRET); + String token = getToken(dto); + if (StringUtils.isBlank(token)) { + return null; + } + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(status) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSONObject.toJSONString(json); + + String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + + return result; + } + // TODO 推送停止充电结果 notification_stop_charge_result // TODO 推送充电订单信息 notification_charge_order_info From 4298e62ceda9572bbaf7f5ed621a65f1bd6e01fc Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Wed, 17 May 2023 09:40:00 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B1=87=E4=BB=98=20=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsowell/api/uniapp/PayController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java index 962e33ea6..3a39b335e 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java @@ -1,5 +1,6 @@ package com.jsowell.api.uniapp; +import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.google.common.collect.ImmutableMap; import com.jsowell.common.annotation.Anonymous; @@ -228,4 +229,33 @@ public class PayController extends BaseController { } return response; } + + /** + * 汇付支付回调 + * https://api.jsowellcloud.com/uniapp/pay/refund + */ + @PostMapping("/adapayCallback") + public void callback(HttpServletRequest request) { + try { + //验签请参data + String data = request.getParameter("data"); + //验签请参sign + String sign = request.getParameter("sign"); + //验签标记 + boolean checkSign; + //验签请参publicKey + String publicKey = AdapayCore.PUBLIC_KEY; + logger.info("汇付支付回调验签请参:data={}sign={}", data, sign); + //验签 + checkSign = AdapaySign.verifySign(data, sign, publicKey); + if (checkSign) { + //验签成功逻辑 + logger.info("汇付支付回调成功返回数据data:{}", data); + } else { + //验签失败逻辑 + } + } catch (Exception e) { + logger.error("汇付支付回调失败 request:{}", JSON.toJSONString(request)); + } + } } From 22a54aab7f5bbffbd13c294fc74af696a89877a8 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Wed, 17 May 2023 10:14:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B1=87=E4=BB=98?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsowell/api/uniapp/PayController.java | 2 ++ jsowell-pile/pom.xml | 10 ++++++++++ .../pile/service/IPileConnectorInfoService.java | 4 +++- pom.xml | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java index 3a39b335e..4203cb0b3 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java @@ -3,6 +3,8 @@ package com.jsowell.api.uniapp; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.google.common.collect.ImmutableMap; +import com.huifu.adapay.core.AdapayCore; +import com.huifu.adapay.core.util.AdapaySign; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.core.redis.RedisCache; diff --git a/jsowell-pile/pom.xml b/jsowell-pile/pom.xml index bc0cace92..1115d102b 100644 --- a/jsowell-pile/pom.xml +++ b/jsowell-pile/pom.xml @@ -82,6 +82,16 @@ com.alibaba.fastjson2 fastjson2 + + + com.huifu.adapay.core + adapay-core-sdk + + + + com.huifu.adapay + adapay-java-sdk + diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java index 798420031..5b100c5e3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java @@ -91,7 +91,9 @@ public interface IPileConnectorInfoService { */ int updateConnectorStatus(String connectorCode, String status); - /** + String pushConnectorStatus(String pileConnectorCode, String status); + + /** * 通过桩编号修改枪口状态 * 仅用于登录逻辑使用 * @param pileSn 桩编号 diff --git a/pom.xml b/pom.xml index 7b3ed0d34..2dd5dfc90 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ 20.0 2.5.14 4.1.75.Final + 1.2.10 @@ -280,6 +281,20 @@ 5.7.3 + + + com.huifu.adapay.core + adapay-core-sdk + ${huifu.version} + + + + + com.huifu.adapay + adapay-java-sdk + ${huifu.version} + + From 6ff244fa24bfda959770f0c0c2cef52c13cc6c68 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Wed, 17 May 2023 10:46:18 +0800 Subject: [PATCH 4/5] =?UTF-8?q?update=20=E6=B7=BB=E5=8A=A0=E6=B1=87?= =?UTF-8?q?=E4=BB=98=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/jsowell/api/uniapp/PayController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java index 4203cb0b3..17bb5d14b 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java @@ -1,6 +1,5 @@ package com.jsowell.api.uniapp; -import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.google.common.collect.ImmutableMap; import com.huifu.adapay.core.AdapayCore; @@ -234,7 +233,7 @@ public class PayController extends BaseController { /** * 汇付支付回调 - * https://api.jsowellcloud.com/uniapp/pay/refund + * https://api.jsowellcloud.com/uniapp/pay/adapayCallback */ @PostMapping("/adapayCallback") public void callback(HttpServletRequest request) { @@ -247,7 +246,7 @@ public class PayController extends BaseController { boolean checkSign; //验签请参publicKey String publicKey = AdapayCore.PUBLIC_KEY; - logger.info("汇付支付回调验签请参:data={}sign={}", data, sign); + logger.info("汇付支付回调验签请参data={}, sign={}", data, sign); //验签 checkSign = AdapaySign.verifySign(data, sign, publicKey); if (checkSign) { @@ -257,7 +256,7 @@ public class PayController extends BaseController { //验签失败逻辑 } } catch (Exception e) { - logger.error("汇付支付回调失败 request:{}", JSON.toJSONString(request)); + logger.error("汇付支付回调失败 error", e); } } } From 2bace785c1ff66de09a8bea46716d9c3478708e9 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Wed, 17 May 2023 16:25:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?update=20=E6=96=B0=E5=A2=9E=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/jsowell/api/uniapp/PayController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java index 17bb5d14b..3944ed2c4 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java @@ -237,6 +237,7 @@ public class PayController extends BaseController { */ @PostMapping("/adapayCallback") public void callback(HttpServletRequest request) { + logger.info("汇付支付回调 request:{}", JSONObject.toJSONString(request)); try { //验签请参data String data = request.getParameter("data");