From 6a4f0ba122e94caeab69cb3b6ac6bd9c05f7018e Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Thu, 24 Apr 2025 14:42:08 +0800 Subject: [PATCH] update --- .../thirdparty/WeiWangKuaiDianController.java | 73 ++++++++----------- .../weiWangKuaiDianPlatformServiceImpl.java | 22 +++++- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/WeiWangKuaiDianController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/WeiWangKuaiDianController.java index 453e8a9ae..8b3a288dd 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/WeiWangKuaiDianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/WeiWangKuaiDianController.java @@ -47,14 +47,14 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { */ @PostMapping("/v1/query_token") public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { - logger.info("宁波平台请求令牌 params:{}", JSON.toJSONString(dto)); + logger.info("微网快电请求令牌 params:{}", JSON.toJSONString(dto)); try { // Map map = zdlService.generateToken(dto); Map 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")); } catch (Exception e) { - logger.error("宁波平台 请求令牌接口 异常"); + logger.error("微网快电请求令牌接口 异常"); return CommonResult.failed("获取token发生异常"); } } @@ -99,35 +99,26 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { * 设备状态推送 * notification_stationStatus * @param request - * @param dto + * @return */ @PostMapping("/v1/notification_stationStatus") - public CommonResult notification_stationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("{}-设备状态推送 params:{}", platformName, JSON.toJSONString(dto)); + public RestApiResponse notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO, HttpServletRequest request) { + RestApiResponse response = null; 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); - logger.info("{}-设备状态推送 result:{}", platformName, result); - return CommonResult.success(Integer.parseInt(result.split(",")[0]), result.split(",")[1], result.split(",")[2], result.split(",")[3]); - } catch (Exception e) { - logger.info("{}-设备状态推送 error:", platformName, e); + 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); } - return CommonResult.failed("设备状态推送发生异常"); + logger.info("【{}】推送设备状态 response:{}", this.getClass().getSimpleName(), response); + return response; + } /** @@ -309,7 +300,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { * @param * @return */ - @GetMapping("/v1/notification_start_charge_result") + @GetMapping("/v1/notification_start_charge_result/{orderCode}") public RestApiResponse notification_start_charge_result(@RequestParam("orderCode") String orderCode) { logger.info("【{}】推送启动充电结果 params:{}", this.getClass().getSimpleName(), orderCode); RestApiResponse response = null; @@ -372,7 +363,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { * @param orderCode * @return */ - @GetMapping("/v1/notification_equip_charge_status") + @GetMapping("/v1/notification_equip_charge_status/{orderCode}") public RestApiResponse notification_equip_charge_status(@PathVariable("orderCode") String orderCode) { logger.info("推送充电状态 params:{}", orderCode); RestApiResponse response = null; @@ -436,7 +427,7 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { * @return */ @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); RestApiResponse response = null; try { @@ -458,20 +449,20 @@ public class WeiWangKuaiDianController extends ThirdPartyBaseController { * 充电订单信息推送 */ @PostMapping("/v1/notification_charge_order_info") - public AjaxResult notificationChargeOrderInfo(@RequestBody NotificationDTO dto) { - AjaxResult result; + public RestApiResponse notification_charge_order_info(@RequestBody QueryOrderDTO dto) { + RestApiResponse response = null; try { - notificationService.notificationChargeOrderInfo(dto); - logger.info("充电订单信息推送成功"); - result = AjaxResult.success(); - } catch (BusinessException e) { - logger.error("充电订单信息推送失败", e); - result = AjaxResult.error(e.getMessage()); - } catch (Exception e) { - logger.error("充电订单信息推送失败", e); - result = AjaxResult.error(); + 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); } - return result; + logger.info("推送充电订单信息 result:{}", response); + return response; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/weiWangKuaiDianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/weiWangKuaiDianPlatformServiceImpl.java index bb9700165..e866a4dea 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/weiWangKuaiDianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/weiWangKuaiDianPlatformServiceImpl.java @@ -811,8 +811,28 @@ public class weiWangKuaiDianPlatformServiceImpl implements ThirdPartyPlatformSer return result; } + @Override + public String pushOrderInfo(QueryOrderDTO dto) { + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getweiWangKuaiDianPlatformSecretInfo(); + + // 根据站点id, 开始时间,结束时间查询出所有的订单信息 + // List orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto); + List orderCodes = orderBasicInfoService.tempGetOrderCodes(dto); + if (CollectionUtils.isEmpty(orderCodes)) { + return "订单信息为空"; + } + // List 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 * @param orderCode 订单编号