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