update 对接内蒙古平台

This commit is contained in:
2024-04-08 15:26:18 +08:00
parent ce3c1c0e66
commit dce696e402
10 changed files with 256 additions and 85 deletions

View File

@@ -102,7 +102,7 @@ public class HaiNanPlatformController extends BaseController {
// 转换成相应对象
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
queryStationInfoDTO.setThirdPlatformType(ThirdPlatformTypeEnum.HAI_NAN_1.getTypeCode());
queryStationInfoDTO.setThirdPlatformType(ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode());
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
logger.info("海南平台查询充电站信息 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));

View File

@@ -15,8 +15,8 @@ public enum ThirdPlatformTypeEnum {
YONG_CHENG_BO_CHE("4", "甬城泊车平台", "330205020"),
NING_XIA_JIAO_TOU("5", "宁夏交投", "MA771QENX"),
XIN_DIAN_TU("6", "新电途平台", "MA25CNM38"),
HAI_NAN_1("7", "海南一张网(监管平台)", "578725200"),
HAI_NAN_2("8", "海南一张网(充电平台)", "MAA9A0PP1"),
HAI_NAN_1_PLATFORM("7", "海南一张网(监管平台)", "578725200"),
HAI_NAN_2_PLATFORM("8", "海南一张网(充电平台)", "MAA9A0PP1"),
HUA_WEI("9", "华为平台", "MA5GTQ528"),
NEI_MENG_GU_PLATFORM("10", "内蒙古平台", ""),
;

View File

@@ -6,4 +6,13 @@ import lombok.Setter;
@Getter
@Setter
public class QueryOperatorInfoDTO {
/**
* 查询页码 默认为1
*/
private int PageNo = 1;
/**
* 每页数量 默认为50
*/
private int PageSize = 50;
}

View File

@@ -10,6 +10,12 @@ public class CommonParamsDTO {
@JsonProperty(value = "OperatorID")
private String operatorID;
/**
* 数据请求方的标识 请求方组织机构代码九位
*/
@JsonProperty(value = "PlatformID")
private String platformID;
@JsonProperty(value = "Data")
private String data;

View File

@@ -3,32 +3,53 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jsowell.pile.mapper.ThirdPartyStationRelationMapper">
<resultMap type="com.jsowell.pile.domain.ThirdPartyStationRelation" id="ThirdPartyStationRelationResult">
<result property="id" column="id" />
<result property="stationId" column="station_id" />
<result property="thirdPartyType" column="third_party_type" />
<result property="startMode" column="start_mode" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<result property="id" column="id"/>
<result property="stationId" column="station_id"/>
<result property="thirdPartyType" column="third_party_type"/>
<result property="startMode" column="start_mode"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectThirdPartyStationRelationVo">
select id, station_id, third_party_type, start_mode, create_time, create_by, update_time, update_by, del_flag from thirdparty_station_relation
select id,
station_id,
third_party_type,
start_mode,
create_time,
create_by,
update_time,
update_by,
del_flag
from thirdparty_station_relation
</sql>
<sql id="Base_Column_List" >
id, station_id, third_party_type, start_mode, create_time, create_by, update_time, update_by, del_flag
<sql id="Base_Column_List">
id,
station_id,
third_party_type,
start_mode,
create_time,
create_by,
update_time,
update_by,
del_flag
</sql>
<select id="selectThirdPartyStationRelationList" parameterType="com.jsowell.pile.domain.ThirdPartyStationRelation" resultMap="ThirdPartyStationRelationResult">
<select id="selectThirdPartyStationRelationList" parameterType="com.jsowell.pile.domain.ThirdPartyStationRelation"
resultMap="ThirdPartyStationRelationResult">
<include refid="selectThirdPartyStationRelationVo"/>
where del_flag = '0'
<if test="stationId != null "> and station_id = #{stationId}</if>
<if test="thirdPartyType != null and thirdPartyType != ''"> and third_party_type = #{thirdPartyType}</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="thirdPartyType != null and thirdPartyType != ''">
and third_party_type = #{thirdPartyType}
</if>
</select>
<select id="selectThirdPartyStationRelationById" parameterType="Long" resultMap="ThirdPartyStationRelationResult">
@@ -36,68 +57,120 @@
where id = #{id}
</select>
<insert id="insertThirdPartyStationRelation" parameterType="com.jsowell.pile.domain.ThirdPartyStationRelation" useGeneratedKeys="true" keyProperty="id">
<insert id="insertThirdPartyStationRelation" parameterType="com.jsowell.pile.domain.ThirdPartyStationRelation"
useGeneratedKeys="true" keyProperty="id">
insert into thirdparty_station_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="thirdPartyType != null">third_party_type,</if>
<if test="startMode != null">start_mode,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
<if test="stationId != null">
station_id,
</if>
<if test="thirdPartyType != null">
third_party_type,
</if>
<if test="startMode != null">
start_mode,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="thirdPartyType != null">#{thirdPartyType},</if>
<if test="startMode != null">#{startMode},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="stationId != null">
#{stationId},
</if>
<if test="thirdPartyType != null">
#{thirdPartyType},
</if>
<if test="startMode != null">
#{startMode},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="createBy != null">
#{createBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="updateBy != null">
#{updateBy},
</if>
<if test="delFlag != null">
#{delFlag},
</if>
</trim>
</insert>
<update id="updateThirdPartyStationRelation" parameterType="com.jsowell.pile.domain.ThirdPartyStationRelation">
update thirdparty_station_relation
<trim prefix="SET" suffixOverrides=",">
<if test="stationId != null">station_id = #{stationId},</if>
<if test="thirdPartyType != null">third_party_type = #{thirdPartyType},</if>
<if test="startMode != null">start_mode = #{startMode},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="stationId != null">
station_id = #{stationId},
</if>
<if test="thirdPartyType != null">
third_party_type = #{thirdPartyType},
</if>
<if test="startMode != null">
start_mode = #{startMode},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
</trim>
where station_id = #{stationId,jdbcType=BIGINT}
</update>
<delete id="deleteThirdPartyStationRelationById" parameterType="Long">
delete from thirdparty_station_relation where id = #{id}
delete
from thirdparty_station_relation
where id = #{id}
</delete>
<delete id="deleteThirdPartyStationRelationByIds" parameterType="String">
delete from thirdparty_station_relation where id in
delete
from thirdparty_station_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectRelationInfo" resultType="com.jsowell.pile.vo.base.ThirdPartyStationRelationVO">
select
t1.station_id as stationId,
t1.third_party_type as thirdPartyType,
t1.start_mode as startMode,
t2.url_address as urlAddress,
t2.operator_id as operatorId,
t2.operator_secret as operatorSecret,
t2.sign_secret as signSecret,
t2.data_secret as dataSecret,
t2.data_secret_IV as dataSecretIv
from thirdparty_station_relation t1 join thirdparty_setting_info t2 on t1.third_party_type = t2.type
select t1.station_id as stationId,
t1.third_party_type as thirdPartyType,
t1.start_mode as startMode,
t2.url_address as urlAddress,
t2.operator_id as operatorId,
t2.operator_secret as operatorSecret,
t2.sign_secret as signSecret,
t2.data_secret as dataSecret,
t2.data_secret_IV as dataSecretIv
from thirdparty_station_relation t1
join thirdparty_setting_info t2 on t1.third_party_type = t2.type
where t1.del_flag = '0'
<if test="stationId != null">
and t1.station_id = #{stationId,jdbcType=BIGINT}
@@ -109,17 +182,17 @@
</select>
<select id="getRelationInfoList" resultType="com.jsowell.pile.vo.base.ThirdPartyStationRelationVO">
select
t1.station_id as stationId,
t1.third_party_type as thirdPartyType,
t1.start_mode as startMode,
t2.url_address as urlAddress,
t2.operator_id as operatorId,
t2.operator_secret as operatorSecret,
t2.sign_secret as signSecret,
t2.data_secret as dataSecret,
t2.data_secret_IV as dataSecretIv
from thirdparty_station_relation t1 join thirdparty_setting_info t2 on t1.third_party_type = t2.type
select t1.station_id as stationId,
t1.third_party_type as thirdPartyType,
t1.start_mode as startMode,
t2.url_address as urlAddress,
t2.operator_id as operatorId,
t2.operator_secret as operatorSecret,
t2.sign_secret as signSecret,
t2.data_secret as dataSecret,
t2.data_secret_IV as dataSecretIv
from thirdparty_station_relation t1
join thirdparty_setting_info t2 on t1.third_party_type = t2.type
where t1.del_flag = '0'
<if test="stationId != null">
and t1.station_id = #{stationId,jdbcType=BIGINT}
@@ -129,11 +202,9 @@
<update id="updateRelationDelFlag">
update
thirdparty_station_relation
set
del_flag = '1'
where
station_id = #{stationId,jdbcType=VARCHAR}
and third_party_type in
set del_flag = '1'
where station_id = #{stationId,jdbcType=VARCHAR}
and third_party_type in
<foreach collection="types" open="(" item="type" close=")" separator=",">
#{type,jdbcType=VARCHAR}
</foreach>

View File

@@ -171,7 +171,7 @@ public class CommonService {
// // 华为
// result = huaWeiService.notificationOperationSystemInfo(dto);
// }
if(StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1.getTypeCode(), dto.getThirdPartyType())) {
if(StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode(), dto.getThirdPartyType())) {
// 海南
result = haiNanChargeService.pushStationInfoV2(dto);
}
@@ -287,7 +287,7 @@ public class CommonService {
// }
// huaWeiService.notificationEquipChargeStatus(orderInfo.getOrderCode());
// }
if (StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1.getTypeCode(), thirdPartyType)) {
if (StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode(), thirdPartyType)) {
// 海南平台
haiNanChargeService.notificationStationStatus(pileConnectorCode, changedStatus);
}
@@ -363,7 +363,7 @@ public class CommonService {
// // 推送订单信息
// result = huaWeiService.pushChargeOrderInfo(orderBasicInfo.getOrderCode());
// }
if (StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1.getTypeCode(), thirdPartyType)) {
if (StringUtils.equals(ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode(), thirdPartyType)) {
// 海南平台
haiNanChargeService.notificationChargeOrderInfo(orderBasicInfo.getOrderCode());
}

View File

@@ -13,6 +13,9 @@ public class AccessTokenVO {
@JsonProperty(value = "OperatorID")
private String operatorID;
@JsonProperty(value = "PlatformID")
private String platformId;
/**
* 整型
* 0:成功;

View File

@@ -38,9 +38,9 @@ public interface ThirdPartyPlatformService {
throw new UnsupportedOperationException("This method is not yet implemented");
}
default Map<String, String> queryToken(String operatorId, String operatorSecret) {
throw new UnsupportedOperationException("This method is not yet implemented");
}
// default Map<String, String> queryToken(String operatorId, String operatorSecret) {
// throw new UnsupportedOperationException("This method is not yet implemented");
// }
// =================================================================================== //
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由我方平台实现此接口,对方平台调用的查询接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ //

View File

@@ -70,7 +70,7 @@ import java.util.stream.Collectors;
public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
Logger logger = LoggerFactory.getLogger(HaiNanPlatformServiceImpl.class);
// 平台类型
private final String platformType = ThirdPlatformTypeEnum.HAI_NAN_1.getTypeCode();
private final String platformType = ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode();
@Autowired
private PileMerchantInfoService pileMerchantInfoService;

View File

@@ -1,10 +1,26 @@
package com.jsowell.thirdparty.platform.neimenggu.service;
import com.alibaba.fastjson2.JSON;
import com.google.common.collect.Maps;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
import com.jsowell.pile.domain.ThirdPartyStationRelation;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
import com.jsowell.pile.service.ThirdPartyStationRelationService;
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.GBSignUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@@ -12,6 +28,71 @@ import java.util.Map;
*/
@Service
public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
// 平台类型
private final String thirdPlatformType = ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode();
@Autowired
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
@Autowired
private ThirdPartyStationRelationService thirdPartyStationRelationService;
/**
* query_token 获取token提供给第三方平台使用
*
* @param dto
* @return
*/
@Override
public Map<String, String> queryToken(CommonParamsDTO dto) {
String operatorId = dto.getPlatformID();
// 通过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
try {
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)) {
throw new RuntimeException("密钥不一致");
}
} catch (RuntimeException e) {
throw new BusinessException("2", "密钥错误");
}
// 生成token
String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
// 组装返回参数
AccessTokenVO vo = new AccessTokenVO();
vo.setAccessToken(token);
// vo.setOperatorID(operatorId);
vo.setPlatformId(operatorId);
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
vo.setFailReason(0);
vo.setSuccStat(0);
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(vo), dataSecret, dataSecretIv);
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, signSecret);
resultMap.put("Sig", resultSign);
return resultMap;
}
/**
* 查询运营商信息 query_operator_info
* supervise_query_operator_info
@@ -21,7 +102,12 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
*/
@Override
public Map<String, String> queryOperatorInfo(QueryOperatorInfoDTO dto) {
return ThirdPartyPlatformService.super.queryOperatorInfo(dto);
Map<String, String> resultMap = Maps.newHashMap();
// TODO 查询接入内蒙古平台的站点信息
List<ThirdPartyStationRelation> thirdPartyStationRelations =
thirdPartyStationRelationService.selectThirdPartyStationRelationList(thirdPlatformType);
return resultMap;
}
/**
@@ -62,10 +148,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
/**
* 充电订单推送 notification_charge_order_info
* TODO 海南一张网文档中的接口检查一下是否和订单信息推送notification_orderInfo一致
* TODO 甬城泊车平台文档中的接口检查一下是否和订单信息推送notification_orderInfo一致
* TODO 华为平台文档中的接口检查一下是否和订单信息推送notification_orderInfo一致
* TODO 内蒙古平台文档中的接口检查一下是否和订单信息推送notification_orderInfo一致
*
* @param orderCode 订单编号
* @throws UnsupportedOperationException 未实现异常