This commit is contained in:
YAS\29473
2025-04-24 14:42:08 +08:00
parent 52e831969a
commit 6a4f0ba122
2 changed files with 53 additions and 42 deletions

View File

@@ -47,14 +47,14 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
*/ */
@PostMapping("/v1/query_token") @PostMapping("/v1/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) { public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
logger.info("宁波平台请求令牌 params:{}", JSON.toJSONString(dto)); logger.info("微网快电请求令牌 params:{}", JSON.toJSONString(dto));
try { try {
// Map<String, String> map = zdlService.generateToken(dto); // Map<String, String> map = zdlService.generateToken(dto);
Map<String, String> map = platformLogic.queryToken(dto); Map<String, String> map = platformLogic.queryToken(dto);
logger.info("宁波平台请求令牌 result:{}", JSON.toJSONString(map)); logger.info("微网快电请求令牌 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) { } catch (Exception e) {
logger.error("宁波平台 请求令牌接口 异常"); logger.error("微网快电请求令牌接口 异常");
return CommonResult.failed("获取token发生异常"); return CommonResult.failed("获取token发生异常");
} }
} }
@@ -99,35 +99,26 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
* 设备状态推送 * 设备状态推送
* notification_stationStatus * notification_stationStatus
* @param request * @param request
* @param dto
* @return * @return
*/ */
@PostMapping("/v1/notification_stationStatus") @PostMapping("/v1/notification_stationStatus")
public CommonResult<?> notification_stationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { public RestApiResponse<?> notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO, HttpServletRequest request) {
logger.info("{}-设备状态推送 params:{}", platformName, JSON.toJSONString(dto)); RestApiResponse<?> response = null;
try { try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
PushRealTimeInfoDTO pushRealTimeInfoDTO = parseParamsDTO(dto, PushRealTimeInfoDTO.class);
// 执行逻辑
String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO); String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO);
logger.info("{}-设备状态推送 result:{}", platformName, result); logger.info("{}】推送设备状态 result:{}", this.getClass().getSimpleName(), result);
return CommonResult.success(Integer.parseInt(result.split(",")[0]), result.split(",")[1], result.split(",")[2], result.split(",")[3]); response = new RestApiResponse<>(result);
} catch (Exception e) { }catch (BusinessException e) {
logger.info("{}-设备状态推送 error:", platformName, 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);
} }
return CommonResult.failed("设备状态推送发生异常"); logger.info("【{}】推送设备状态 response:{}", this.getClass().getSimpleName(), response);
return response;
} }
/** /**
@@ -309,7 +300,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
* @param * @param
* @return * @return
*/ */
@GetMapping("/v1/notification_start_charge_result") @GetMapping("/v1/notification_start_charge_result/{orderCode}")
public RestApiResponse<?> notification_start_charge_result(@RequestParam("orderCode") String orderCode) { public RestApiResponse<?> notification_start_charge_result(@RequestParam("orderCode") String orderCode) {
logger.info("【{}】推送启动充电结果 params:{}", this.getClass().getSimpleName(), orderCode); logger.info("【{}】推送启动充电结果 params:{}", this.getClass().getSimpleName(), orderCode);
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
@@ -372,7 +363,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
* @param orderCode * @param orderCode
* @return * @return
*/ */
@GetMapping("/v1/notification_equip_charge_status") @GetMapping("/v1/notification_equip_charge_status/{orderCode}")
public RestApiResponse<?> notification_equip_charge_status(@PathVariable("orderCode") String orderCode) { public RestApiResponse<?> notification_equip_charge_status(@PathVariable("orderCode") String orderCode) {
logger.info("推送充电状态 params:{}", orderCode); logger.info("推送充电状态 params:{}", orderCode);
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
@@ -436,7 +427,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
* @return * @return
*/ */
@GetMapping("/v1/notification_stop_charge_result/{orderCode}") @GetMapping("/v1/notification_stop_charge_result/{orderCode}")
public RestApiResponse<?> notificationStopChargeResult(@PathVariable("orderCode") String orderCode) { public RestApiResponse<?> notification_stop_charge_result(@PathVariable("orderCode") String orderCode) {
logger.info("推送停止充电结果 params:{}", orderCode); logger.info("推送停止充电结果 params:{}", orderCode);
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
try { try {
@@ -458,20 +449,20 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController {
* 充电订单信息推送 * 充电订单信息推送
*/ */
@PostMapping("/v1/notification_charge_order_info") @PostMapping("/v1/notification_charge_order_info")
public AjaxResult notificationChargeOrderInfo(@RequestBody NotificationDTO dto) { public RestApiResponse<?> notification_charge_order_info(@RequestBody QueryOrderDTO dto) {
AjaxResult result; RestApiResponse<?> response = null;
try { try {
notificationService.notificationChargeOrderInfo(dto); String result = platformLogic.pushOrderInfo(dto);
logger.info("充电订单信息推送成功"); response = new RestApiResponse<>(result);
result = AjaxResult.success(); }catch (BusinessException e){
} catch (BusinessException e) { logger.error("推送充电订单信息 error",e);
logger.error("充电订单信息推送失败", e); response = new RestApiResponse<>(e.getCode(), e.getMessage());
result = AjaxResult.error(e.getMessage()); }catch (Exception e) {
} catch (Exception e) { logger.error("推送充电订单信息 error", e);
logger.error("充电订单信息推送失败", e); response = new RestApiResponse<>(e);
result = AjaxResult.error();
} }
return result; logger.info("推送充电订单信息 result:{}", response);
return response;
} }

View File

@@ -811,8 +811,28 @@ public class weiWangKuaiDianPlatformServiceImpl implements ThirdPartyPlatformSer
return result; return result;
} }
@Override
public String pushOrderInfo(QueryOrderDTO dto) {
ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getweiWangKuaiDianPlatformSecretInfo();
// 根据站点id 开始时间,结束时间查询出所有的订单信息
// List<OrderListVO> orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto);
List<String> orderCodes = orderBasicInfoService.tempGetOrderCodes(dto);
if (CollectionUtils.isEmpty(orderCodes)) {
return "订单信息为空";
}
// List<String> orderCodeList = orderListVOS.stream().map(OrderListVO::getOrderCode).collect(Collectors.toList());
for (String orderCode : orderCodes) {
try {
String result = notificationChargeOrderInfo(orderCode, wangKuaiDianPlatformSecretInfo);
log.info("订单:{} 推送结果:{}", orderCode, result);
}catch (Exception e) {
log.error("订单:{} 推送error, ", orderCode, e);
}
}
return "Success";
}
//TODO 扩展字段 vin
/** /**
* 推送订单数据 notificationChargeOrderInfo * 推送订单数据 notificationChargeOrderInfo
* @param orderCode 订单编号 * @param orderCode 订单编号