diff --git a/jsowell-admin/src/main/java/com/jsowell/lianlian/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/lianlian/LianLianController.java index 1ed426552..e92f685f4 100644 --- a/jsowell-admin/src/main/java/com/jsowell/lianlian/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/lianlian/LianLianController.java @@ -47,7 +47,7 @@ public class LianLianController extends BaseController { * @return */ @PostMapping("/pushStationInfo") - public RestApiResponse pushStationInfo(@RequestBody LianLianPushStationInfoDTO dto) { + public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { logger.info("推送联联平台充电站信息 params:{}", JSONObject.toJSONString(dto)); RestApiResponse response = null; try { diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java index 31a20339b..e3c892192 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java @@ -18,7 +18,7 @@ import com.jsowell.pile.domain.ThirdPartyStationRelation; import com.jsowell.pile.domain.ThirdPartySettingInfo; import com.jsowell.pile.domain.ThirdpartyParkingConfig; import com.jsowell.pile.dto.FastCreateStationDTO; -import com.jsowell.pile.dto.LianLianPushStationInfoDTO; +import com.jsowell.pile.dto.PushStationInfoDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.amap.EditAmapFlagDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; @@ -29,6 +29,7 @@ import com.jsowell.pile.service.IThirdPartySettingInfoService; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.service.PileService; import com.jsowell.thirdparty.lianlian.service.LianLianService; +import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -57,6 +58,9 @@ public class PileStationInfoController extends BaseController { @Autowired private LianLianService lianLianService; + @Autowired + private ZDLService zdlService; + @Autowired private IThirdPartyStationRelationService thirdPartyStationRelationService; @@ -258,24 +262,27 @@ public class PileStationInfoController extends BaseController { * @return */ @PostMapping("/pushStationInfo") - public RestApiResponse pushStationInfo(@RequestBody LianLianPushStationInfoDTO dto) { - logger.info("推送联联平台充电站信息 params:{}", JSONObject.toJSONString(dto)); + public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { + logger.info("推送第三方平台充电站信息 params:{}", JSONObject.toJSONString(dto)); RestApiResponse response = null; try { if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - + String result = ""; // 推送联联 if (StringUtils.equals("1", dto.getThirdPartyType())) { - String result = lianLianService.pushStationInfo(dto); - response = new RestApiResponse<>(result); + result = lianLianService.pushStationInfo(dto); + } else if (StringUtils.equals("2", dto.getThirdPartyType())) { + // 中电联 + result = zdlService.pushStationInfo(dto); } + response = new RestApiResponse<>(result); }catch (BusinessException e) { - logger.error("推送联联平台充电站信息 error",e); + logger.error("推送第三方平台充电站信息 error",e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); }catch (Exception e) { - logger.error("推送联联平台充电站信息 error", e); + logger.error("推送第三方平台充电站信息 error", e); response = new RestApiResponse<>("推送失败,请联系管理员"); // 删除对应配置信息 ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); @@ -283,7 +290,7 @@ public class PileStationInfoController extends BaseController { relation.setDelFlag(DelFlagEnum.DELETE.getValue()); thirdPartyStationRelationService.updateThirdPartyStationRelation(relation); } - logger.info("推送联联平台充电站信息 result:{}", response); + logger.info("推送第三方平台充电站信息 result:{}", response); return response; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/LianLianPushStationInfoDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushStationInfoDTO.java similarity index 94% rename from jsowell-pile/src/main/java/com/jsowell/pile/dto/LianLianPushStationInfoDTO.java rename to jsowell-pile/src/main/java/com/jsowell/pile/dto/PushStationInfoDTO.java index f722c9896..8f80fa4cb 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/LianLianPushStationInfoDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushStationInfoDTO.java @@ -15,7 +15,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor @Builder -public class LianLianPushStationInfoDTO { +public class PushStationInfoDTO { private String thirdPartyType; /** diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java index ab04a0349..07e78548b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java @@ -1,12 +1,9 @@ package com.jsowell.thirdparty.lianlian.service; import com.jsowell.pile.dto.*; -import com.jsowell.thirdparty.lianlian.domain.StationStatsInfo; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; -import com.jsowell.thirdparty.lianlian.vo.*; import java.io.UnsupportedEncodingException; -import java.util.List; import java.util.Map; public interface LianLianService { @@ -21,7 +18,7 @@ public interface LianLianService { * 根据充电站id,推送充电站信息 * @param dto */ - String pushStationInfo(LianLianPushStationInfoDTO dto); + String pushStationInfo(PushStationInfoDTO dto); /** * 联联平台获取充电站信息 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index e8ebab271..5358ef663 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -116,7 +116,7 @@ public class LianLianServiceImpl implements LianLianService { * @param dto */ @Override - public String pushStationInfo(LianLianPushStationInfoDTO dto) { + public String pushStationInfo(PushStationInfoDTO dto) { // String OperatorID = "987654321"; // String SigSecret = "1234567890abcdef"; // 签名秘钥 // String DataSecret = "1234567890abcdef"; // 消息密钥 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/domain/ZDLStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/domain/ZDLStationInfo.java index b720e84ec..c6513a73a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/domain/ZDLStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/domain/ZDLStationInfo.java @@ -1,7 +1,10 @@ package com.jsowell.thirdparty.zhongdianlian.domain; import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.math.BigDecimal; import java.util.List; @@ -13,6 +16,9 @@ import java.util.List; * @Date 2023/9/5 14:10 */ @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class ZDLStationInfo { @JSONField(name = "StationID") private String stationId; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/dto/ZDLGetTokenDTO.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/dto/ZDLGetTokenDTO.java index 7cca7fde7..0241796d7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/dto/ZDLGetTokenDTO.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/dto/ZDLGetTokenDTO.java @@ -1,6 +1,9 @@ package com.jsowell.thirdparty.zhongdianlian.dto; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; /** * 中电联获取token DTO @@ -9,6 +12,9 @@ import lombok.Data; * @Date 2023/9/5 8:42 */ @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class ZDLGetTokenDTO { /** * 对接平台url地址 (不加api名称) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java index bc3b028a5..2d2acad85 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java @@ -1,5 +1,6 @@ package com.jsowell.thirdparty.zhongdianlian.service; +import com.jsowell.pile.dto.PushStationInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.thirdparty.zhongdianlian.dto.ZDLGetTokenDTO; @@ -20,6 +21,12 @@ public interface ZDLService { */ public String ZDLGetToken(ZDLGetTokenDTO dto); + /** + * 根据充电站id,推送充电站信息 + * @param dto + */ + String pushStationInfo(PushStationInfoDTO dto); + /** * 查询站点信息 * @param dto diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java index 0a40064aa..f16c3ebaf 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java @@ -6,16 +6,16 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum; +import com.jsowell.common.enums.lianlian.StationPaymentEnum; import com.jsowell.common.enums.ykc.PileStatusEnum; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.PageUtils; 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.domain.*; +import com.jsowell.pile.dto.PushStationInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.*; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorInfo; import com.jsowell.thirdparty.lianlian.domain.EquipmentInfo; @@ -24,6 +24,7 @@ import com.jsowell.thirdparty.lianlian.service.LianLianService; 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.util.HttpRequestUtil; import com.jsowell.thirdparty.zhongdianlian.domain.ZDLConnectorInfo; import com.jsowell.thirdparty.zhongdianlian.domain.ZDLEquipmentInfo; import com.jsowell.thirdparty.zhongdianlian.domain.ZDLStationInfo; @@ -66,6 +67,9 @@ public class ZDLServiceImpl implements ZDLService { @Autowired private IPileConnectorInfoService pileConnectorInfoService; + @Autowired + private IThirdPartyStationRelationService thirdPartyStationRelationService; + /** * 获取令牌 * @param dto @@ -80,6 +84,83 @@ public class ZDLServiceImpl implements ZDLService { dto.getOperatorSecret(), dto.getDataSecretIv(), dto.getSignSecret(), dto.getDataSecret()); } + /** + * 根据充电站id,推送充电站信息 + * @param dto + */ + @Override + public String pushStationInfo(PushStationInfoDTO dto) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId()); + // 通过站点id查询相关配置信息 + ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + relation.setStationId(dto.getStationId()); + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + // ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(dto.getStationId()); + if (relationInfo == null) { + // 新增 + relation.setThirdPartyType(dto.getThirdPartyType()); + thirdPartyStationRelationService.insertThirdPartyStationRelation(relation); + + relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + // 组装联联平台所需要的数据格式 + ZDLStationInfo info = ZDLStationInfo.builder() + .stationId("ZDL" +dto.getStationId()) + .operatorId(operatorId) + .equipmentOwnerId(Constants.OPERATORID_LIANLIAN) + .stationName(pileStationInfo.getStationName()) + .countryCode(pileStationInfo.getCountryCode()) + .areaCode(pileStationInfo.getAreaCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + + .build(); + List pileList = getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // 调用中电联平台接口 + String url = urlAddress + "notification_stationInfo"; + + String jsonStr = JSONObject.toJSONString(info); + JSONObject data = new JSONObject(); + data.put("StationInfo", jsonStr); + + String jsonString = JSONObject.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + ZDLGetTokenDTO tokenDTO = ZDLGetTokenDTO.builder() + .urlAddress(urlAddress) + .operatorId(operatorId) + .operatorSecret(operatorSecret) + .dataSecret(dataSecret) + .dataSecretIv(dataSecretIv) + .signSecret(signSecret) + .build(); + String token = ZDLGetToken(tokenDTO); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret + , dataSecretIv, operatorId, signSecret); + + // System.out.println(result); + return result; + } + /** * 查询站点信息 * @return diff --git a/jsowell-ui/src/views/pile/station/detail.vue b/jsowell-ui/src/views/pile/station/detail.vue index 57423ddfb..4692b42b9 100644 --- a/jsowell-ui/src/views/pile/station/detail.vue +++ b/jsowell-ui/src/views/pile/station/detail.vue @@ -467,7 +467,7 @@ export default { getSettingParams() { const param = { // stationId: this.stationId, - thirdPartyType: this.stationSettingInfo.type, + type: this.stationSettingInfo.type, }; console.log("param", param); getSettingInfo(param).then((res) => {