mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-23 16:49:49 +08:00
update 对接lianlian平台
This commit is contained in:
137
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java
vendored
Normal file
137
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyBaseController.java
vendored
Normal file
@@ -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<String, String> 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> T parseDto(CommonParamsDTO dto, Class<T> 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<String, String> 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<String, String> 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<String, String> 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("查询充换电站状态信息发生异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.jsowell.pile.mapper;
|
package com.jsowell.pile.mapper;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
|
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -68,4 +69,6 @@ public interface ThirdPartyPlatformConfigMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId);
|
ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId);
|
||||||
|
|
||||||
|
ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.jsowell.pile.service;
|
package com.jsowell.pile.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方平台配置Service接口
|
* 第三方平台配置Service接口
|
||||||
*
|
*
|
||||||
@@ -67,18 +67,5 @@ public interface ThirdPartySettingInfoService {
|
|||||||
*/
|
*/
|
||||||
public int deleteThirdPartySettingInfoById(Long id);
|
public int deleteThirdPartySettingInfoById(Long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据站点id 查询配置列表
|
|
||||||
*
|
|
||||||
* @param stationId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ThirdPartySettingInfo getInfoByStationId(Long stationId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改站点互联互通配置
|
|
||||||
* @param info
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int updateStationSettingInfo(ThirdPartySettingInfo info);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jsowell.common.util.DateUtils;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.jsowell.pile.mapper.ThirdPartyPlatformConfigMapper;
|
|
||||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
import java.util.List;
|
||||||
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对接平台配置信息Service业务层处理
|
* 对接平台配置信息Service业务层处理
|
||||||
@@ -98,4 +99,12 @@ public class ThirdPartyPlatformConfigServiceImpl implements ThirdPartyPlatformCo
|
|||||||
public ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId) {
|
public ThirdPartyPlatformConfig getInfoByOperatorId(String operatorId) {
|
||||||
return thirdPartyPlatformConfigMapper.getInfoByOperatorId(operatorId);
|
return thirdPartyPlatformConfigMapper.getInfoByOperatorId(operatorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询第三方平台配置的密钥信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ThirdPartySecretInfoVO queryThirdPartySecretInfo(String operatorId) {
|
||||||
|
return thirdPartyPlatformConfigMapper.queryThirdPartySecretInfo(operatorId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jsowell.common.util.DateUtils;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper;
|
|
||||||
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
import java.util.List;
|
||||||
import com.jsowell.pile.service.ThirdPartySettingInfoService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方平台配置Service业务层处理
|
* 第三方平台配置Service业务层处理
|
||||||
@@ -98,33 +98,5 @@ public class ThirdPartySettingInfoServiceImpl implements ThirdPartySettingInfoSe
|
|||||||
return thirdPartySettingInfoMapper.deleteThirdPartySettingInfoById(id);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -110,4 +110,8 @@
|
|||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
and operator_id = #{operatorId,jdbcType=VARCHAR}
|
and operator_id = #{operatorId,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryThirdPartySecretInfo" resultType="com.jsowell.pile.vo.ThirdPartySecretInfoVO">
|
||||||
|
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="type" column="type" />
|
<result property="type" column="type" />
|
||||||
<result property="urlAddress" column="url_address" />
|
<result property="urlAddress" column="url_address" />
|
||||||
<result property="stationId" column="station_id" />
|
|
||||||
<result property="operatorId" column="operator_id" />
|
<result property="operatorId" column="operator_id" />
|
||||||
<result property="operatorSecret" column="operator_secret" />
|
<result property="operatorSecret" column="operator_secret" />
|
||||||
<result property="signSecret" column="sign_secret" />
|
<result property="signSecret" column="sign_secret" />
|
||||||
@@ -22,12 +21,12 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectThirdPartySettingInfoVo">
|
<sql id="selectThirdPartySettingInfoVo">
|
||||||
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
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
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
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectThirdPartySettingInfoList" parameterType="com.jsowell.pile.domain.ThirdPartySettingInfo" resultMap="ThirdPartySettingInfoResult">
|
<select id="selectThirdPartySettingInfoList" parameterType="com.jsowell.pile.domain.ThirdPartySettingInfo" resultMap="ThirdPartySettingInfoResult">
|
||||||
@@ -35,7 +34,6 @@
|
|||||||
<where>
|
<where>
|
||||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||||
<if test="urlAddress != null and type != ''"> and url_address = #{urlAddress}</if>
|
<if test="urlAddress != null and type != ''"> and url_address = #{urlAddress}</if>
|
||||||
<if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
|
|
||||||
<if test="operatorId != null and operatorId != ''"> and operator_id = #{operatorId}</if>
|
<if test="operatorId != null and operatorId != ''"> and operator_id = #{operatorId}</if>
|
||||||
<if test="operatorSecret != null and operatorSecret != ''"> and operator_secret = #{operatorSecret}</if>
|
<if test="operatorSecret != null and operatorSecret != ''"> and operator_secret = #{operatorSecret}</if>
|
||||||
<if test="signSecret != null and signSecret != ''"> and sign_secret = #{signSecret}</if>
|
<if test="signSecret != null and signSecret != ''"> and sign_secret = #{signSecret}</if>
|
||||||
@@ -54,7 +52,6 @@
|
|||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="type != null">type,</if>
|
<if test="type != null">type,</if>
|
||||||
<if test="urlAddress != null">url_address,</if>
|
<if test="urlAddress != null">url_address,</if>
|
||||||
<if test="stationId != null">station_id,</if>
|
|
||||||
<if test="operatorId != null">operator_id,</if>
|
<if test="operatorId != null">operator_id,</if>
|
||||||
<if test="operatorSecret != null">operator_secret,</if>
|
<if test="operatorSecret != null">operator_secret,</if>
|
||||||
<if test="signSecret != null">sign_secret,</if>
|
<if test="signSecret != null">sign_secret,</if>
|
||||||
@@ -88,7 +85,6 @@
|
|||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="type != null">type = #{type},</if>
|
<if test="type != null">type = #{type},</if>
|
||||||
<if test="urlAddress != null">url_address = #{urlAddress},</if>
|
<if test="urlAddress != null">url_address = #{urlAddress},</if>
|
||||||
<if test="stationId != null">station_id = #{stationId},</if>
|
|
||||||
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
||||||
<if test="operatorSecret != null">operator_secret = #{operatorSecret},</if>
|
<if test="operatorSecret != null">operator_secret = #{operatorSecret},</if>
|
||||||
<if test="signSecret != null">sign_secret = #{signSecret},</if>
|
<if test="signSecret != null">sign_secret = #{signSecret},</if>
|
||||||
@@ -114,19 +110,10 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="getInfoByStationId" resultMap="ThirdPartySettingInfoResult">
|
|
||||||
select <include refid="Base_Column_List"/>
|
|
||||||
from thirdparty_setting_info
|
|
||||||
where station_id = #{stationId,jdbcType=BIGINT}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectThirdInfo" resultMap="ThirdPartySettingInfoResult">
|
<select id="selectThirdInfo" resultMap="ThirdPartySettingInfoResult">
|
||||||
select <include refid="Base_Column_List"/>
|
select <include refid="Base_Column_List"/>
|
||||||
from thirdparty_setting_info
|
from thirdparty_setting_info
|
||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
<if test="stationId != null">
|
|
||||||
and station_id = #{stationId,jdbcType=BIGINT}
|
|
||||||
</if>
|
|
||||||
<if test="type != null and type != ''">
|
<if test="type != null and type != ''">
|
||||||
and type = #{type,jdbcType=VARCHAR}
|
and type = #{type,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class LianLianServiceImpl implements LianLianService {
|
|||||||
|
|
||||||
// 组装联联平台所需要的数据格式
|
// 组装联联平台所需要的数据格式
|
||||||
StationInfo info = StationInfo.builder()
|
StationInfo info = StationInfo.builder()
|
||||||
.stationID("LC" +dto.getStationId())
|
.stationID("LC" + dto.getStationId())
|
||||||
.operatorID(operatorId)
|
.operatorID(operatorId)
|
||||||
// .equipmentOwnerID(Constants.OPERATORID_LIANLIAN)
|
// .equipmentOwnerID(Constants.OPERATORID_LIANLIAN)
|
||||||
.stationName(pileStationInfo.getStationName())
|
.stationName(pileStationInfo.getStationName())
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import com.jsowell.common.util.StringUtils;
|
|||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
||||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
|
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
||||||
|
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
|
||||||
import com.jsowell.thirdparty.platform.util.Cryptos;
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||||
import com.jsowell.thirdparty.platform.util.Encodes;
|
import com.jsowell.thirdparty.platform.util.Encodes;
|
||||||
import com.jsowell.thirdparty.platform.util.GBSignUtils;
|
import com.jsowell.thirdparty.platform.util.GBSignUtils;
|
||||||
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
|
||||||
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
|||||||
.map(PileInfoVO::getSpeedType)
|
.map(PileInfoVO::getSpeedType)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
vo.setOperatorId(Constants.OPERATORID_LIANLIAN);
|
vo.setOperatorId(Constants.OPERATORID_LIANLIAN);
|
||||||
vo.setStationId(stationId);
|
vo.setStationId("LC" + stationId);
|
||||||
|
|
||||||
for (String equipmentType : equipmentTypeList) {
|
for (String equipmentType : equipmentTypeList) {
|
||||||
for (BillingPriceVO billingPriceVO : billingPriceVOList) {
|
for (BillingPriceVO billingPriceVO : billingPriceVOList) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
|||||||
import com.jsowell.common.enums.ykc.BillingTimeTypeEnum;
|
import com.jsowell.common.enums.ykc.BillingTimeTypeEnum;
|
||||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.JWTUtils;
|
|
||||||
import com.jsowell.common.util.PageUtils;
|
import com.jsowell.common.util.PageUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
@@ -25,7 +24,6 @@ import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
|
|||||||
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
|
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
|
||||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
|
||||||
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
||||||
import com.jsowell.pile.util.MerchantUtils;
|
import com.jsowell.pile.util.MerchantUtils;
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
@@ -37,7 +35,6 @@ import com.jsowell.pile.vo.web.PileStationVO;
|
|||||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
|
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
|
||||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
||||||
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
|
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
|
||||||
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
|
||||||
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
|
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
|
||||||
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
||||||
import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo;
|
import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo;
|
||||||
@@ -98,49 +95,49 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
// @Override
|
||||||
public Map<String, String> queryToken(CommonParamsDTO dto) {
|
// public Map<String, String> queryToken(CommonParamsDTO dto) {
|
||||||
AccessTokenVO vo = new AccessTokenVO();
|
// AccessTokenVO vo = new AccessTokenVO();
|
||||||
// 0:成功;1:失败
|
// // 0:成功;1:失败
|
||||||
int succStat = 0;
|
// int succStat = 0;
|
||||||
// 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义
|
// // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义
|
||||||
int failReason = 0;
|
// int failReason = 0;
|
||||||
|
//
|
||||||
String operatorId = dto.getPlatformID();
|
// String operatorId = dto.getPlatformID();
|
||||||
// 通过operatorId 查出 operatorSecret
|
// // 通过operatorId 查出 operatorSecret
|
||||||
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||||
if (platformConfig == null) {
|
// if (platformConfig == null) {
|
||||||
failReason = 1;
|
// failReason = 1;
|
||||||
succStat = 1;
|
// succStat = 1;
|
||||||
} else {
|
// } else {
|
||||||
String operatorSecret = platformConfig.getOperatorSecret();
|
// String operatorSecret = platformConfig.getOperatorSecret();
|
||||||
String dataSecret = platformConfig.getDataSecret();
|
// String dataSecret = platformConfig.getDataSecret();
|
||||||
String dataSecretIv = platformConfig.getDataSecretIv();
|
// String dataSecretIv = platformConfig.getDataSecretIv();
|
||||||
// 解密data 获取参数中的OperatorSecret
|
// // 解密data 获取参数中的OperatorSecret
|
||||||
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
// String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||||
String inputOperatorSecret = null;
|
// String inputOperatorSecret = null;
|
||||||
if (StringUtils.isNotBlank(decrypt)) {
|
// if (StringUtils.isNotBlank(decrypt)) {
|
||||||
inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
|
// inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
|
||||||
}
|
// }
|
||||||
// 对比密钥
|
// // 对比密钥
|
||||||
if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
|
// if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
|
||||||
failReason = 1;
|
// failReason = 1;
|
||||||
succStat = 1;
|
// succStat = 1;
|
||||||
} else {
|
// } else {
|
||||||
// 生成token
|
// // 生成token
|
||||||
String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
|
// String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
|
||||||
vo.setAccessToken(token);
|
// vo.setAccessToken(token);
|
||||||
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
|
// vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// 组装返回参数
|
// // 组装返回参数
|
||||||
vo.setPlatformId(operatorId);
|
// vo.setPlatformId(operatorId);
|
||||||
vo.setFailReason(failReason);
|
// vo.setFailReason(failReason);
|
||||||
vo.setSuccStat(succStat);
|
// vo.setSuccStat(succStat);
|
||||||
|
//
|
||||||
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
|
// Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
|
||||||
return resultMap;
|
// return resultMap;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询运营商信息 query_operator_info
|
* 查询运营商信息 query_operator_info
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package com.jsowell.thirdparty.platform.util;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ThirdPartyPlatformUtils {
|
public class ThirdPartyPlatformUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.jsowell.thirdparty.platform.zhongdianlian.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.jsowell.common.util.JWTUtils;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
|
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
||||||
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
|
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
||||||
|
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
||||||
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||||
|
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query_token 获取token,提供给第三方平台使用
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryToken(CommonParamsDTO dto) {
|
||||||
|
AccessTokenVO vo = new AccessTokenVO();
|
||||||
|
// 0:成功;1:失败
|
||||||
|
int succStat = 0;
|
||||||
|
// 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义
|
||||||
|
int failReason = 0;
|
||||||
|
|
||||||
|
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
||||||
|
// 通过operatorId 查出 operatorSecret
|
||||||
|
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||||
|
if (platformConfig == null) {
|
||||||
|
failReason = 1;
|
||||||
|
succStat = 1;
|
||||||
|
} else {
|
||||||
|
String operatorSecret = platformConfig.getOperatorSecret();
|
||||||
|
String dataSecret = platformConfig.getDataSecret();
|
||||||
|
String dataSecretIv = platformConfig.getDataSecretIv();
|
||||||
|
// 解密data 获取参数中的OperatorSecret
|
||||||
|
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||||
|
String inputOperatorSecret = null;
|
||||||
|
if (StringUtils.isNotBlank(decrypt)) {
|
||||||
|
inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
|
||||||
|
}
|
||||||
|
// 对比密钥
|
||||||
|
if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
|
||||||
|
failReason = 1;
|
||||||
|
succStat = 1;
|
||||||
|
} else {
|
||||||
|
// 生成token
|
||||||
|
String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
|
||||||
|
vo.setAccessToken(token);
|
||||||
|
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 组装返回参数
|
||||||
|
vo.setPlatformId(operatorId);
|
||||||
|
vo.setFailReason(failReason);
|
||||||
|
vo.setSuccStat(succStat);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user