2024-05-10 15:30:20 +08:00
|
|
|
package com.jsowell.api.thirdparty;
|
2024-04-19 11:15:48 +08:00
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
2025-02-25 10:48:15 +08:00
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
2024-04-24 16:54:30 +08:00
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
2024-05-30 09:38:29 +08:00
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2024-04-19 11:15:48 +08:00
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
|
|
|
|
import com.jsowell.common.util.JWTUtils;
|
|
|
|
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
2024-04-25 15:01:44 +08:00
|
|
|
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
|
2024-04-19 11:15:48 +08:00
|
|
|
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
|
|
|
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
2025-02-25 10:48:15 +08:00
|
|
|
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
2024-04-19 11:15:48 +08:00
|
|
|
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
|
|
|
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
2025-07-04 14:41:20 +08:00
|
|
|
import com.jsowell.thirdparty.platform.dto.PushOrderDTO;
|
|
|
|
|
import com.jsowell.thirdparty.platform.dto.QueryOrderDTO;
|
2024-05-10 15:46:01 +08:00
|
|
|
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
2024-04-19 11:15:48 +08:00
|
|
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
|
|
|
|
import com.jsowell.thirdparty.platform.util.Encodes;
|
|
|
|
|
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.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 青海平台Controller
|
|
|
|
|
*
|
|
|
|
|
* @author Lemon
|
|
|
|
|
* @Date 2024/4/18 13:46:26
|
|
|
|
|
*/
|
|
|
|
|
@Anonymous
|
|
|
|
|
@RestController
|
2024-04-22 11:29:28 +08:00
|
|
|
@RequestMapping("/qinghai/evcs")
|
2024-08-08 10:56:02 +08:00
|
|
|
public class QingHaiController extends ThirdPartyBaseController {
|
2024-04-19 11:15:48 +08:00
|
|
|
|
2025-02-25 10:48:15 +08:00
|
|
|
private final String platformName = "青海省平台";
|
|
|
|
|
|
|
|
|
|
private final String platformType = ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode();
|
2024-04-19 11:15:48 +08:00
|
|
|
|
|
|
|
|
@Autowired
|
2025-02-25 10:48:15 +08:00
|
|
|
@Qualifier("qingHaiPlatformServiceImpl")
|
|
|
|
|
private ThirdPartyPlatformService platformLogic;
|
2024-04-19 11:15:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取token接口
|
2025-02-25 10:48:15 +08:00
|
|
|
* http://localhost:8080/qinghai/evcs/v1/query_token
|
2024-04-19 11:15:48 +08:00
|
|
|
*/
|
|
|
|
|
@PostMapping("/v1/query_token")
|
|
|
|
|
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
|
|
|
|
try {
|
2025-02-25 10:48:15 +08:00
|
|
|
Map<String, String> map = platformLogic.queryToken(dto);
|
|
|
|
|
logger.info("{}-请求令牌, params:{}, result:{}", platformName, JSON.toJSONString(dto), JSON.toJSONString(map));
|
2024-04-24 16:54:30 +08:00
|
|
|
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
|
2024-04-19 11:15:48 +08:00
|
|
|
} catch (Exception e) {
|
2025-02-25 10:48:15 +08:00
|
|
|
logger.error("{}-获取token接口, 异常, params:{}", platformName, JSON.toJSONString(dto), e);
|
2024-04-19 11:15:48 +08:00
|
|
|
return CommonResult.failed("获取token发生异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询充电站信息
|
|
|
|
|
* @param dto
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/v1/query_stations_info")
|
|
|
|
|
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2025-02-25 10:48:15 +08:00
|
|
|
logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto));
|
2024-04-19 11:15:48 +08:00
|
|
|
try {
|
|
|
|
|
// 校验令牌
|
2025-02-25 10:48:15 +08:00
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-04-19 11:15:48 +08:00
|
|
|
// 校验失败
|
2025-02-25 10:48:15 +08:00
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
2024-04-22 11:29:28 +08:00
|
|
|
|
|
|
|
|
// 校验签名
|
2025-02-25 10:48:15 +08:00
|
|
|
if (!verifySignature(dto)) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
2024-04-22 11:29:28 +08:00
|
|
|
}
|
2025-02-25 10:48:15 +08:00
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
|
|
|
|
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
|
|
|
|
|
|
2024-04-24 16:54:30 +08:00
|
|
|
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
|
2024-04-19 11:15:48 +08:00
|
|
|
} catch (Exception e) {
|
2025-02-25 10:48:15 +08:00
|
|
|
logger.info("{}-查询充电站信息 error:", platformName, e);
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
2025-02-25 10:48:15 +08:00
|
|
|
return CommonResult.failed("查询充电站信息发生异常");
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询业务策略信息
|
|
|
|
|
* @param dto
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/v1/query_equip_business_policy")
|
|
|
|
|
public CommonResult<?> query_equip_business_policy(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2025-02-25 10:48:15 +08:00
|
|
|
logger.info("{}-查询业务策略信息 params:{}", platformName, JSON.toJSONString(dto));
|
2024-04-19 11:15:48 +08:00
|
|
|
try {
|
|
|
|
|
// 校验令牌
|
2025-02-25 10:48:15 +08:00
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-04-19 11:15:48 +08:00
|
|
|
// 校验失败
|
2025-02-25 10:48:15 +08:00
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
|
|
|
|
|
2024-04-22 11:29:28 +08:00
|
|
|
// 校验签名
|
2025-02-25 10:48:15 +08:00
|
|
|
if (!verifySignature(dto)) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
2024-04-22 11:29:28 +08:00
|
|
|
}
|
2025-02-25 10:48:15 +08:00
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
|
|
|
|
Map<String, String> map = platformLogic.queryEquipBusinessPolicy(queryStartChargeDTO);
|
|
|
|
|
|
2024-04-24 16:54:30 +08:00
|
|
|
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
|
2024-04-19 11:15:48 +08:00
|
|
|
} catch (Exception e) {
|
2025-02-25 10:48:15 +08:00
|
|
|
logger.info("{}-查询业务策略信息 error:", platformName, e);
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
2025-02-25 10:48:15 +08:00
|
|
|
return CommonResult.failed("查询业务策略信息发生异常");
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 推送站点功率
|
|
|
|
|
* @param stationIds
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2025-02-25 10:48:15 +08:00
|
|
|
// @PostMapping("/pushStationPower")
|
|
|
|
|
// public RestApiResponse<?> pushStationPower(@RequestBody List<String> stationIds) {
|
|
|
|
|
// RestApiResponse<?> response = null;
|
|
|
|
|
// try {
|
|
|
|
|
// String result = qingHaiPlatformServiceImpl.notificationPowerInfo(stationIds);
|
|
|
|
|
// response = new RestApiResponse<>(result);
|
|
|
|
|
// }catch (Exception e) {
|
|
|
|
|
// logger.error("青海平台推送站点功率 error", e);
|
|
|
|
|
// }
|
|
|
|
|
// logger.info("青海平台推送站点功率 result:{}", response);
|
|
|
|
|
// return response;
|
|
|
|
|
// }
|
2024-04-19 11:15:48 +08:00
|
|
|
|
2024-04-25 15:01:44 +08:00
|
|
|
/**
|
|
|
|
|
* 推送设备状态变化
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2025-02-25 10:48:15 +08:00
|
|
|
// @PostMapping("/pushRealTimeInfo")
|
|
|
|
|
// public RestApiResponse<?> pushStationPower(@RequestBody PushRealTimeInfoDTO dto) {
|
|
|
|
|
// RestApiResponse<?> response = null;
|
|
|
|
|
// try {
|
|
|
|
|
// String result = qingHaiPlatformServiceImpl.notificationStationStatus(dto);
|
|
|
|
|
// response = new RestApiResponse<>(result);
|
|
|
|
|
// }catch (Exception e) {
|
|
|
|
|
// logger.error("青海平台推送设备状态变化 error", e);
|
|
|
|
|
// }
|
|
|
|
|
// logger.info("青海平台推送设备状态变化 result:{}", response);
|
|
|
|
|
// return response;
|
|
|
|
|
// }
|
2024-04-25 15:01:44 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 推送充电状态
|
|
|
|
|
* @param orderCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2025-02-25 10:48:15 +08:00
|
|
|
// @GetMapping("/notificationEquipChargeStatus/{orderCode}")
|
|
|
|
|
// public RestApiResponse<?> notificationEquipChargeStatus(@PathVariable("orderCode") String orderCode) {
|
|
|
|
|
// RestApiResponse<?> response = null;
|
|
|
|
|
// try {
|
|
|
|
|
// String result = qingHaiPlatformServiceImpl.notificationEquipChargeStatus(orderCode);
|
|
|
|
|
// response = new RestApiResponse<>(result);
|
|
|
|
|
// }catch (Exception e) {
|
|
|
|
|
// logger.error("青海平台推送充电状态 error", e);
|
|
|
|
|
// }
|
|
|
|
|
// logger.info("青海平台推送充电状态 result:{}", response);
|
|
|
|
|
// return response;
|
|
|
|
|
// }
|
2024-04-25 15:01:44 +08:00
|
|
|
|
2024-04-29 17:01:12 +08:00
|
|
|
/**
|
|
|
|
|
* 推送订单
|
|
|
|
|
* @param orderCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2025-07-04 14:41:20 +08:00
|
|
|
@GetMapping("/pushOrderInfo/{orderCode}")
|
|
|
|
|
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode") String orderCode) {
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
String result = platformLogic.notificationChargeOrderInfo(orderCode);
|
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
logger.error("青海平台推送订单信息 error", e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("青海平台推送订单信息 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/pushOrdersInfo")
|
|
|
|
|
public RestApiResponse<?> pushOrdersInfo(@RequestBody PushOrderDTO dto) {
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
List<String> orderCodeList = dto.getOrderCodeList();
|
|
|
|
|
orderCodeList.forEach(orderCode -> {
|
|
|
|
|
try {
|
|
|
|
|
platformLogic.notificationChargeOrderInfo(orderCode);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("青海平台推送订单信息 error", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
response = new RestApiResponse<>();
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
logger.error("青海平台推送订单信息 error", e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("青海平台推送订单信息 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
2024-04-29 17:01:12 +08:00
|
|
|
|
2024-04-19 11:15:48 +08:00
|
|
|
}
|