mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
新增第三方吉林平台接口代码
This commit is contained in:
266
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/JiLinPlatformController.java
vendored
Normal file
266
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/JiLinPlatformController.java
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
package com.jsowell.api.thirdparty;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.QueryEquipmentDTO;
|
||||
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 吉林平台Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jilin")
|
||||
@Anonymous
|
||||
public class JiLinPlatformController extends ThirdPartyBaseController{
|
||||
private final String platformName = "吉林省平台";
|
||||
|
||||
|
||||
private final String platformType = ThirdPlatformTypeEnum.JI_LIN_PLATFORM.getTypeCode();
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("jiLinPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
|
||||
/**
|
||||
* getToken
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-请求令牌 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = platformLogic.queryToken(dto);
|
||||
logger.info("{}-请求令牌 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求令牌成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-请求令牌 error:" , platformName , e);
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询运营商信息
|
||||
* query_operator_info
|
||||
*/
|
||||
@PostMapping("/v1/query_operator_info")
|
||||
public CommonResult<?> query_operator_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询运营商信息 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryOperatorInfoDTO queryOperatorInfoDTO = parseParamsDTO(dto , QueryOperatorInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryOperatorInfo(queryOperatorInfoDTO);
|
||||
logger.info("{}-查询运营商信息 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "查询运营商信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询运营商信息 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询运营商信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息
|
||||
* query_stations_info
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询充电站信息 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
logger.info("{}-携带的token:{}",platformName, request.getHeader("Authorization"));
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
|
||||
logger.info("{}-查询充电站信息 result:{}" , platformName , JSON.toJSONString(map));
|
||||
return CommonResult.success(0 , "查询充电站信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询充电站信息 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设备接口状态查询 query_station_status
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_station_status(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-设备接口状态查询 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStationStatus(queryStationInfoDTO);
|
||||
logger.info("{}-设备接口状态查询 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "设备接口状态查询成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-设备接口状态查询 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("设备接口状态查询发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_auth")
|
||||
public CommonResult<?> query_equip_auth(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-请求设备认证 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
dto.setPlatformType(platformType);
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryEquipmentDTO queryEquipmentDTO = parseParamsDTO(dto , QueryEquipmentDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryEquipAuth(queryEquipmentDTO);
|
||||
logger.info("{}-请求设备认证 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求设备认证成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求设备认证 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求设备认证发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/start_charge")
|
||||
public CommonResult<?> start_charge(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-请求启动充电 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
dto.setPlatformType(platformType);
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class);
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStartCharge(queryStartChargeDTO);
|
||||
logger.info("{}-请求启动充电 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求启动充电成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求启动充电 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推送启动充电结果
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_start_charge_result/{orderCode}")
|
||||
public RestApiResponse<?> notification_start_charge_result(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("【{}】推送启动充电结果 params:{}" , this.getClass().getSimpleName() , orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStartChargeResult(orderCode);
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , result);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e.getCode() , e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -195,9 +195,17 @@ public class SiChuanController extends ThirdPartyBaseController {
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电站信息
|
||||
*/
|
||||
@PostMapping("/v1/supervise_push_stations_info/{stationId}")
|
||||
public CommonResult<?> supervise_push_stations_info(HttpServletRequest request , @PathVariable("stationId") String stationId) {
|
||||
logger.info("{}-推送充电站信息 params:{}" , platformName , JSON.toJSONString(stationId));
|
||||
|
||||
String s = platformLogic.notificationStationInfo(stationId);
|
||||
logger.info("{}-推送充电站信息 result:{}" , platformName , s);
|
||||
|
||||
|
||||
|
||||
return CommonResult.success(0 , "推送充电站信息成功!" , s , null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user