mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 华为ControllerV2
This commit is contained in:
@@ -3,24 +3,25 @@ package com.jsowell.web.controller.thirdparty.huawei;
|
||||
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.common.util.JWTUtils;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.dto.huawei.*;
|
||||
import com.jsowell.pile.vo.huawei.QueryChargeStatusVO;
|
||||
import com.jsowell.pile.vo.huawei.QueryEquipAuthVO;
|
||||
import com.jsowell.pile.vo.huawei.QueryStartChargeVO;
|
||||
import com.jsowell.thirdparty.huawei.HuaweiServiceV2;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
||||
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -71,24 +72,262 @@ public class HuaWeiControllerV2 extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求设备计费信息
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/request_equip_business_policy")
|
||||
public CommonResult<?> requestEquipBusinessPolicy(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
return null;
|
||||
logger.info("华为请求设备计费信息 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
RequestEquipBusinessPolicyDTO requestEquipBusinessPolicyDTO = JSONObject.parseObject(dataStr, RequestEquipBusinessPolicyDTO.class);
|
||||
requestEquipBusinessPolicyDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.requestEquipBusinessPolicy(requestEquipBusinessPolicyDTO);
|
||||
return CommonResult.success(0, "请求设备计费信息成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收启动充电结果
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/notification_start_charge_result")
|
||||
public CommonResult<?> receiveStartChargeResult(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("接收华为启动充电结果 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
ReceiveStartChargeResultDTO receiveStartChargeResultDTO = JSONObject.parseObject(dataStr, ReceiveStartChargeResultDTO.class);
|
||||
// receiveStartChargeResultDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.receiveStartChargeResult(receiveStartChargeResultDTO);
|
||||
return CommonResult.success(0, "推送启动充电结果成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收设备充电状态
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/notification_equip_charge_status")
|
||||
public CommonResult<?> receiveEquipChargeStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("接收华为设备充电状态 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
ReceiveEquipChargeStatusDTO receiveEquipChargeStatusDTO = JSONObject.parseObject(dataStr, ReceiveEquipChargeStatusDTO.class);
|
||||
// receiveEquipChargeStatusDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.receiveEquipChargeStatus(receiveEquipChargeStatusDTO);
|
||||
return CommonResult.success(0, "接收设备充电状态成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收华为所推送的停止充电结果
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/notification_stop_charge_result")
|
||||
public CommonResult<?> receiveStopChargeResult(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("接收华为停止充电结果 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
ReceiveStopChargeResultVO receiveStopChargeResultVO = JSONObject.parseObject(dataStr, ReceiveStopChargeResultVO.class);
|
||||
// receiveStopChargeResultVO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.receiveStopChargeResult(receiveStopChargeResultVO);
|
||||
return CommonResult.success(0, "接收停止充电结果成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收订单信息
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/notification_charge_order_info")
|
||||
public CommonResult<?> receiveOrderInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("接收华为订单信息 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
ReceiveOrderInfoDTO receiveOrderInfoDTO = JSONObject.parseObject(dataStr, ReceiveOrderInfoDTO.class);
|
||||
// receiveOrderInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.receiveOrderInfo(receiveOrderInfoDTO);
|
||||
return CommonResult.success(0, "接收订单信息成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
/**
|
||||
* vin启动充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/insert_start_charge")
|
||||
public CommonResult<?> vinStartCharge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("华为vin启动充电 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
VinStartChargeDTO vinStartChargeDTO = JSONObject.parseObject(dataStr, VinStartChargeDTO.class);
|
||||
// receiveOrderInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> resultMap = null;
|
||||
try {
|
||||
resultMap = huaweiServiceV2.vinStartCharge(vinStartChargeDTO);
|
||||
}catch (Exception e) {
|
||||
logger.error("华为vin启动充电 error", e);
|
||||
}
|
||||
if (resultMap != null) {
|
||||
return CommonResult.success(0, "vin启动充电成功!", resultMap.get("Data"), resultMap.get("Sig"));
|
||||
}else {
|
||||
return CommonResult.failed("vin启动充电 error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发计费策略响应
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/notification_deliver_equip_business_policy_result")
|
||||
public CommonResult<?> receiveDeliverEquipBusinessPolicyResult(HttpServletRequest request, @RequestBody CommonParamsDTO dto){
|
||||
logger.info("华为下发计费策略响应 params:{}", JSONObject.toJSONString(dto));
|
||||
String dataStr = checkAuth(request, dto);
|
||||
// 转换成相应对象
|
||||
DeliverBusinessPolicyResponseDTO deliverPolicyResponseDTO = JSONObject.parseObject(dataStr, DeliverBusinessPolicyResponseDTO.class);
|
||||
// receiveOrderInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = huaweiServiceV2.receiveDeliverEquipBusinessPolicyResult(deliverPolicyResponseDTO);
|
||||
return CommonResult.success(0, "接收下发计费策略响应信息成功!", map.get("Data"), map.get("Sig"));
|
||||
}
|
||||
|
||||
|
||||
// ======================== 以上为 华为 --> 万车充 ========================
|
||||
// ======================== 下面为 万车充 --> 华为 ========================
|
||||
|
||||
|
||||
/**
|
||||
* 平台充电设备编码同步
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v2/notification_operation_system_info/{stationId}")
|
||||
public String notificationOperationSystemInfo(@PathVariable("stationId") String stationId) {
|
||||
logger.info("华为平台充电设备编码同步 stationId:{}", stationId);
|
||||
String result = null;
|
||||
try {
|
||||
result = huaweiServiceV2.notificationOperationSystemInfo(stationId);
|
||||
} catch (Exception e) {
|
||||
logger.error("华为平台充电设备编码同步 error", e);
|
||||
}
|
||||
logger.info("华为平台充电设备编码同步 result:{}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备接口状态查询
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/query_station_status")
|
||||
public List<StationStatusInfo> queryStationStatus(@RequestBody List<String> stationIds) {
|
||||
logger.info("查询华为设备接口状态 stationIds:{}", stationIds);
|
||||
List<StationStatusInfo> list = null;
|
||||
try {
|
||||
list = huaweiServiceV2.queryStationStatus(stationIds);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询华为设备接口状态 error", e);
|
||||
}
|
||||
logger.info("查询华为设备接口状态 result:{}", list);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
* @param connectorId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/query_equip_auth")
|
||||
public QueryEquipAuthVO queryEquipAuth(@RequestBody String connectorId) {
|
||||
logger.info("请求华为设备认证 connectorId:{}", connectorId);
|
||||
QueryEquipAuthVO vo = null;
|
||||
try {
|
||||
vo = huaweiServiceV2.queryEquipAuth(connectorId);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求华为设备认证 error", e);
|
||||
}
|
||||
logger.info("请求华为设备认证 result:{}", JSONObject.toJSONString(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/query_start_charge")
|
||||
public QueryStartChargeVO queryStartCharge(@RequestBody HWQueryStartChargeDTO dto) {
|
||||
logger.info("请求华为启动充电 param:{}", JSONObject.toJSONString(dto));
|
||||
QueryStartChargeVO vo = null;
|
||||
try {
|
||||
vo = huaweiServiceV2.queryStartCharge(dto);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求华为启动充电 error", e);
|
||||
}
|
||||
logger.info("请求华为启动充电 result:{}", JSONObject.toJSONString(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* @param startChargeSeq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/query_equip_charge_status")
|
||||
public QueryChargeStatusVO queryChargeStatus(@RequestBody String startChargeSeq) {
|
||||
logger.info("查询华为充电状态 startChargeSeq:{}", startChargeSeq);
|
||||
QueryChargeStatusVO vo = null;
|
||||
try {
|
||||
vo = huaweiServiceV2.queryChargeStatus(startChargeSeq);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询华为充电状态 error", e);
|
||||
}
|
||||
logger.info("查询华为充电状态 result:{}", JSONObject.toJSONString(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param startChargeSeq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v2/query_stop_charge")
|
||||
public QueryStartChargeVO queryStopCharge(@RequestBody String startChargeSeq) {
|
||||
logger.info("请求华为停止充电 startChargeSeq:{}", startChargeSeq);
|
||||
QueryStartChargeVO vo = null;
|
||||
try {
|
||||
vo = huaweiServiceV2.queryStopCharge(startChargeSeq)
|
||||
}catch (Exception e) {
|
||||
logger.error("请求华为停止充电 error", e);
|
||||
}
|
||||
logger.info("请求华为停止充电 result:{}", JSONObject.toJSONString(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验令牌
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private String checkAuth(HttpServletRequest request, CommonParamsDTO dto) {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
|
||||
Reference in New Issue
Block a user