diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java new file mode 100644 index 000000000..ba3270d61 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java @@ -0,0 +1,137 @@ +package com.jsowell.web.controller.thirdparty; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.service.ThirdPartyPlatformConfigService; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * 内蒙古接口 + */ +@Anonymous +@RestController +public class ThirdPartyBaseController extends BaseController { + @Autowired + @Qualifier("zhongDianLianPlatformServiceImpl") + private ThirdPartyPlatformService platformLogic; + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + /** + * 获取token接口 + * http://localhost:8080/query_token + */ + @PostMapping("/query_token") + public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { + logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto)); + try { + Map map = platformLogic.queryToken(dto); + logger.info("平台请求令牌 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("平台请求令牌接口 异常", e); + return CommonResult.failed("获取token发生异常"); + } + } + + // 解析DTO + private T parseDto(CommonParamsDTO dto, Class targetClass) { + // 解密 + String operatorId = dto.getOperatorID(); + // 通过operatorId 查出 operatorSecret + ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); + if (platformConfig == null) { + throw new BusinessException("1", "无此对接平台"); + } + + String operatorSecret = platformConfig.getOperatorSecret(); + String dataSecret = platformConfig.getDataSecret(); + String dataSecretIv = platformConfig.getDataSecretIv(); + String signSecret = platformConfig.getSignSecret(); + + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + return JSONObject.parseObject(decrypt, targetClass); + } + + /** + * 查询运营商信息 + * 接口名称:supervise_query_operator_info + * 使用方法:由数据提供方实现此接口,数据需求方调用 + * 接口频率:每天一次或多次 + * 超时时间:120秒 + */ + @PostMapping("/v1/supervise_query_operator_info") + public CommonResult queryOperatorInfo(@RequestBody CommonParamsDTO dto) { + logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + try { + QueryOperatorInfoDTO paramDTO = parseDto(dto, QueryOperatorInfoDTO.class); + Map map = platformLogic.queryOperatorInfo(paramDTO); + logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询运营商信息 异常", e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充换电站信息 + * 接口名称: supervise_query_stations_info + * 使用方法:由数据提供方实现此接口,数据需求方调用 + * 接口频率:每天一次或多次 + * 超时时间:120秒 + */ + @PostMapping("/v1/supervise_query_stations_info") + public CommonResult queryStationsInfo(@RequestBody CommonParamsDTO dto) { + logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + try { + QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); + Map map = platformLogic.queryStationsInfo(paramDTO); + logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询运营商信息 异常", e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充换电站状态信息 + * supervise_query_station_status + */ + @PostMapping("/v1/supervise_query_station_status") + public CommonResult queryStationStatus(@RequestBody CommonParamsDTO dto) { + logger.info("海南平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto)); + try { + QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); + Map map = platformLogic.queryStationStatus(paramDTO); + logger.info("海南平台查询充换电站状态信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询充换电站状态信息异常", e); + return CommonResult.failed("查询充换电站状态信息发生异常"); + } + } + + /** + * + */ +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java index 410501dbf..f9f4c7479 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyPlatformConfigMapper.java @@ -1,6 +1,7 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import org.springframework.stereotype.Repository; import java.util.List; @@ -68,4 +69,6 @@ public interface ThirdPartyPlatformConfigMapper { * @return */ ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId); + + ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java index 63a6476d4..1363382d5 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartySettingInfoService.java @@ -1,9 +1,9 @@ package com.jsowell.pile.service; -import java.util.List; - import com.jsowell.pile.domain.ThirdPartySettingInfo; +import java.util.List; + /** * 第三方平台配置Service接口 * @@ -67,18 +67,5 @@ public interface ThirdPartySettingInfoService { */ public int deleteThirdPartySettingInfoById(Long id); - /** - * 根据站点id 查询配置列表 - * - * @param stationId - * @return - */ - public ThirdPartySettingInfo getInfoByStationId(Long stationId); - /** - * 修改站点互联互通配置 - * @param info - * @return - */ - int updateStationSettingInfo(ThirdPartySettingInfo info); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java index f0dc96cd7..7fbb93f1b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyPlatformConfigServiceImpl.java @@ -1,13 +1,14 @@ package com.jsowell.pile.service.impl; -import java.util.List; - import com.jsowell.common.util.DateUtils; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.mapper.ThirdPartyPlatformConfigMapper; +import com.jsowell.pile.service.ThirdPartyPlatformConfigService; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.jsowell.pile.mapper.ThirdPartyPlatformConfigMapper; -import com.jsowell.pile.domain.ThirdPartyPlatformConfig; -import com.jsowell.pile.service.ThirdPartyPlatformConfigService; + +import java.util.List; /** * 对接平台配置信息Service业务层处理 @@ -98,4 +99,12 @@ public class ThirdPartyPlatformConfigServiceImpl implements ThirdPartyPlatformCo public ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId) { return thirdPartyPlatformConfigMapper.getInfoByOperatorId(operatorId); } + + /** + * 查询第三方平台配置的密钥信息 + * @return + */ + public ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId) { + return thirdPartyPlatformConfigMapper.queryThirdPartySecretInfo(operatorId); + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java index c1760973c..fc13ec364 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java @@ -1,13 +1,13 @@ package com.jsowell.pile.service.impl; -import java.util.List; - import com.jsowell.common.util.DateUtils; +import com.jsowell.pile.domain.ThirdPartySettingInfo; +import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper; +import com.jsowell.pile.service.ThirdPartySettingInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper; -import com.jsowell.pile.domain.ThirdPartySettingInfo; -import com.jsowell.pile.service.ThirdPartySettingInfoService; + +import java.util.List; /** * 第三方平台配置Service业务层处理 @@ -98,33 +98,5 @@ public class ThirdPartySettingInfoServiceImpl implements ThirdPartySettingInfoSe return thirdPartySettingInfoMapper.deleteThirdPartySettingInfoById(id); } - /** - * 根据站点id 查询配置列表 - * - * @param stationId - * @return - */ - @Override - public ThirdPartySettingInfo getInfoByStationId(Long stationId) { - return thirdPartySettingInfoMapper.getInfoByStationId(stationId); - } - /** - * 修改站点互联互通配置 - * @param info - * @return - */ - @Override - public int updateStationSettingInfo(ThirdPartySettingInfo info) { - Long stationId = info.getStationId(); - ThirdPartySettingInfo infoByStationId = getInfoByStationId(stationId); - if (infoByStationId == null) { - // 新增 - return insertThirdPartySettingInfo(info); - }else { - // 修改 - info.setId(infoByStationId.getId()); - return updateThirdPartySettingInfo(info); - } - } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java new file mode 100644 index 000000000..33e8e6ffe --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java @@ -0,0 +1,44 @@ +package com.jsowell.pile.vo; + +import lombok.Getter; +import lombok.Setter; + +/** + * 第三方平台配置的密钥信息 + */ +@Getter +@Setter +public class ThirdPartySecretInfoVO { + // 我方的组织机构代码 + private String ourOperatorId; + + // 我方生成的唯一识别密钥 + private String ourOperatorSecret; + + // 我方生成的消息密钥 + private String ourDataSecret; + + // 我方生成的初始化向量 + private String ourDataSecretIv; + + // 我方生成的签名密钥 + private String ourSigSecret; + + // 对接平台的组织机构代码 + private String theirOperatorId; + + // 对接平台生成的唯一识别密钥 + private String theirOperatorSecret; + + // 对接平台生成的消息密钥 + private String theirDataSecret; + + // 对接平台的初始化向量 + private String theirDataSecretIv; + + // 对接平台生成的签名密钥 + private String theirSigSecret; + + // 对接平台接口前缀 + private String theirUrlPrefix; +} diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml index efc7f6251..73a854726 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyPlatformConfigMapper.xml @@ -110,4 +110,8 @@ where del_flag = '0' and operator_id = #{operatorId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml index 7dbd71729..a3ccf2623 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml @@ -8,7 +8,6 @@ - @@ -22,12 +21,12 @@ - select id, type, url_address, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag from thirdparty_setting_info + select id, type, url_address, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag from thirdparty_setting_info - id, type, url_address, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag + id, type, url_address, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag - select - from thirdparty_setting_info - where station_id = #{stationId,jdbcType=BIGINT} - -