mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-06 02:50:13 +08:00
466 lines
19 KiB
Java
466 lines
19 KiB
Java
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.*;
|
|
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
|
|
*/
|
|
@Anonymous
|
|
@RestController
|
|
@RequestMapping("/weiwangkuaidian")
|
|
public class WeiWangKuaiDianController extends ThirdPartyBaseController {
|
|
private final String platformName = "微网快电";
|
|
|
|
|
|
private final String platformType = ThirdPlatformTypeEnum.WEI_WANG_XIN_DIAN.getTypeCode();
|
|
|
|
|
|
@Autowired
|
|
@Qualifier("weiWangKuaiDianPlatformServiceImpl")
|
|
private ThirdPartyPlatformService platformLogic;
|
|
|
|
|
|
|
|
/**
|
|
* getToken
|
|
*/
|
|
@PostMapping("/v1/query_token")
|
|
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
|
logger.info("微网快电请求令牌 params:{}", JSON.toJSONString(dto));
|
|
try {
|
|
// Map<String, String> map = zdlService.generateToken(dto);
|
|
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("微网快电请求令牌接口 异常");
|
|
return CommonResult.failed("获取token发生异常");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 查询充电站信息
|
|
* 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 {
|
|
// 校验令牌
|
|
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("查询充电站信息发生异常");
|
|
}
|
|
|
|
|
|
/**
|
|
* 设备状态推送
|
|
* notification_stationStatus
|
|
* @param request
|
|
|
|
* @return
|
|
*/
|
|
@PostMapping("/v1/notification_stationStatus")
|
|
public RestApiResponse<?> notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO, HttpServletRequest request) {
|
|
RestApiResponse<?> response = null;
|
|
try {
|
|
String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO);
|
|
logger.info("【{}】推送设备状态 result:{}", this.getClass().getSimpleName(), result);
|
|
response = new RestApiResponse<>(result);
|
|
}catch (BusinessException e) {
|
|
logger.error("【{}】推送设备状态 error:{}", this.getClass().getSimpleName(), e.getMessage());
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
}catch (Exception e) {
|
|
logger.error("【{}】推送设备状态 error:{}", this.getClass().getSimpleName(), e);
|
|
response = new RestApiResponse<>(e);
|
|
}
|
|
logger.info("【{}】推送设备状态 response:{}", this.getClass().getSimpleName(), response);
|
|
return response;
|
|
|
|
}
|
|
|
|
/**
|
|
* 设备接口状态查询 query_station_status
|
|
* @param request
|
|
* @param dto
|
|
* @return
|
|
*/
|
|
@PostMapping("/v1/query_station_status")
|
|
public CommonResult<?> query_stations_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("设备接口状态查询发生异常");
|
|
}
|
|
|
|
/**
|
|
* 统计信息查询 query_station_stats
|
|
* @param request
|
|
* @param dto
|
|
* @return
|
|
*/
|
|
@PostMapping("/v1/query_station_stats")
|
|
public CommonResult<?> query_station_stats(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.queryStationStats(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(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
|
|
} catch (Exception e) {
|
|
logger.error("{}-请求设备认证 error:", platformName, e);
|
|
}
|
|
return CommonResult.failed("请求设备认证发生异常");
|
|
}
|
|
|
|
/**
|
|
* 查询业务策略信息
|
|
* @param dto
|
|
*/
|
|
@RequestMapping("/v1/query_equip_business_policy")
|
|
public CommonResult<?> query_equip_business_policy(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);
|
|
}
|
|
|
|
// 解析入参
|
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
|
|
|
// 执行逻辑
|
|
Map<String, String> map = platformLogic.queryEquipBusinessPolicy(queryStartChargeDTO);
|
|
logger.info("{}-查询业务策略信息 result:{}", platformName, map);
|
|
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), 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_start_charge")
|
|
public CommonResult<?> query_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(Integer.parseInt(map.get("Ret")), map.get("Msg"), 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;
|
|
}
|
|
|
|
/**
|
|
* 查询充电状态
|
|
* http://localhost:8080/xindiantu/query_equip_charge_status/{startChargeSeq}
|
|
* @param dto
|
|
* @return
|
|
*/
|
|
@PostMapping("/v1/query_equip_charge_status")
|
|
public CommonResult<?> query_equip_charge_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);
|
|
}
|
|
dto.setPlatformType(platformType);
|
|
|
|
// 校验签名
|
|
if (!verifySignature(dto)) {
|
|
// 签名错误
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
}
|
|
|
|
// 解析入参
|
|
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto, QueryEquipChargeStatusDTO.class);
|
|
|
|
// 执行逻辑
|
|
Map<String, String> map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
|
logger.info("{}-查询充电状态 result:{}", platformName, map);
|
|
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
|
|
} catch (Exception e) {
|
|
logger.error("{}-查询充电状态 error:", platformName, e);
|
|
}
|
|
return CommonResult.failed("查询充电状态发生异常");
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 推送充电状态
|
|
* http://localhost:8080/hainan/notificationEquipChargeStatus
|
|
* @param orderCode
|
|
* @return
|
|
*/
|
|
@GetMapping("/v1/notification_equip_charge_status/{orderCode}")
|
|
public RestApiResponse<?> notification_equip_charge_status(@PathVariable("orderCode") String orderCode) {
|
|
logger.info("推送充电状态 params:{}", orderCode);
|
|
RestApiResponse<?> response = null;
|
|
try {
|
|
String result = platformLogic.notificationEquipChargeStatus(orderCode);
|
|
logger.info("推送充电状态 result:{}", result);
|
|
response = new RestApiResponse<>(result);
|
|
}catch (BusinessException e) {
|
|
logger.error("推送充电状态 error",e);
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
}catch (Exception e) {
|
|
logger.error("推送充电状态 error", e);
|
|
response = new RestApiResponse<>(e);
|
|
}
|
|
logger.info("推送充电状态 result:{}", response);
|
|
return response;
|
|
}
|
|
|
|
|
|
/**
|
|
* 请求停止充电
|
|
*
|
|
* @param request
|
|
* @param dto
|
|
* @return
|
|
*/
|
|
@PostMapping("/v1/query_stop_charge")
|
|
public CommonResult<?> query_stop_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);
|
|
}
|
|
|
|
// 校验签名
|
|
if (!verifySignature(dto)) {
|
|
// 签名错误
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
}
|
|
|
|
// 解析入参
|
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
|
logger.info("{}-请求停止充电 params :{}", platformName, JSON.toJSONString(queryStartChargeDTO));
|
|
// 执行逻辑
|
|
Map<String, String> map = platformLogic.queryStopCharge(queryStartChargeDTO);
|
|
|
|
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
|
} catch (Exception e) {
|
|
logger.error("{}-请求停止充电 error", platformName, e);
|
|
}
|
|
return CommonResult.failed("{}-请求停止充电发生异常");
|
|
}
|
|
|
|
|
|
/**
|
|
* 推送停止充电结果
|
|
* http://localhost:8080/hainan/notificationStopChargeResult
|
|
* @param orderCode
|
|
* @return
|
|
*/
|
|
@GetMapping("/v1/notification_stop_charge_result/{orderCode}")
|
|
public RestApiResponse<?> notification_stop_charge_result(@PathVariable("orderCode") String orderCode) {
|
|
logger.info("推送停止充电结果 params:{}", orderCode);
|
|
RestApiResponse<?> response = null;
|
|
try {
|
|
String result = platformLogic.notificationStopChargeResult(orderCode);
|
|
logger.info("推送停止充电结果 result:{}", result);
|
|
response = new RestApiResponse<>(result);
|
|
}catch (BusinessException e) {
|
|
logger.error("推送停止充电结果 error",e);
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
}catch (Exception e) {
|
|
logger.error("推送停止充电结果 error", e);
|
|
response = new RestApiResponse<>(e);
|
|
}
|
|
logger.info("推送停止充电结果 result:{}", response);
|
|
return response;
|
|
}
|
|
|
|
/**
|
|
* 充电订单信息推送
|
|
*/
|
|
@PostMapping("/v1/notification_charge_order_info")
|
|
public RestApiResponse<?> notification_charge_order_info(@RequestBody QueryOrderDTO dto) {
|
|
RestApiResponse<?> response = null;
|
|
try {
|
|
String result = platformLogic.pushOrderInfo(dto);
|
|
response = new RestApiResponse<>(result);
|
|
}catch (BusinessException e){
|
|
logger.error("推送充电订单信息 error",e);
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
}catch (Exception e) {
|
|
logger.error("推送充电订单信息 error", e);
|
|
response = new RestApiResponse<>(e);
|
|
}
|
|
logger.info("推送充电订单信息 result:{}", response);
|
|
return response;
|
|
}
|
|
|
|
|
|
|
|
}
|