diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java index 1b69a8cde..83263c1b9 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java @@ -4,8 +4,13 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.response.RestApiResponse; import com.jsowell.common.util.JWTUtils; +import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.dto.PushInfoParamDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.ThirdPartyPlatformConfigService; import com.jsowell.pile.thirdparty.CommonParamsDTO; @@ -15,10 +20,7 @@ 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.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.nio.charset.StandardCharsets; @@ -217,84 +219,134 @@ public class LianLianController extends BaseController { } /** - * 联联平台设备状态变化推送 - * http://localhost:8080/LianLian/pushStationStatus + * 充电站信息变化推送 notificationStationInfo + */ + @PostMapping("/notificationStationInfo") + public RestApiResponse notificationStationInfo(@RequestBody PushInfoParamDTO dto) { + logger.info("联联平台充电站信息变化推送 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) || + StringUtils.isBlank(String.valueOf(dto.getStatus()))) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + String result = lianLianService.notificationStationInfo(dto.getStationId()); + 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; + } + + /** + * 联联平台设备状态变化推送 notification_stationStatus + * http://localhost:8080/LianLian/notificationStationStatus * @param dto * @return */ - // @PostMapping("/pushStationStatus") - // public RestApiResponse pushStationStatus(@RequestBody PushInfoParamDTO dto) { - // logger.info("联联平台设备状态变化推送 params:{}", JSON.toJSONString(dto)); - // RestApiResponse response = null; - // try { - // if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) || - // StringUtils.isBlank(String.valueOf(dto.getStatus()))) { - // throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - // } - // String result = lianLianService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus()); - // 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("/notificationStationStatus") + public RestApiResponse notificationStationStatus(@RequestBody PushInfoParamDTO dto) { + logger.info("联联平台设备状态变化推送 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) || + StringUtils.isBlank(String.valueOf(dto.getStatus()))) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + String result = lianLianService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus()); + 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; + } /** - * 推送订单信息 + * 站点费率变化推送 notification_stationFee + */ + @PostMapping("/notificationStationFee") + public RestApiResponse notificationStationFee(@RequestBody PushInfoParamDTO dto) { + logger.info("联联平台站点费率变化推送 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) || + StringUtils.isBlank(String.valueOf(dto.getStatus()))) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + String result = lianLianService.notificationStationFee(dto.getStationId()); + 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; + } + + /** + * 设备充电中状态变化推送 notification_connector_charge_status + * @return + */ + @GetMapping("/notificationConnectorChargeStatus/{orderCode}") + public RestApiResponse notificationConnectorChargeStatus(@PathVariable("orderCode")String orderCode) { + logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode); + RestApiResponse response = null; + try { + if (StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + // String result = lianLianService.pushPileChargeStatusChange(orderCode); + String result = lianLianService.notificationConnectorChargeStatus(orderCode); + 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; + } + + /** + * 推送订单信息 notification_orderInfo * @param orderCode * @return */ - // @GetMapping("/pushOrderInfo/{orderCode}") - // public RestApiResponse pushOrderInfo(@PathVariable("orderCode")String orderCode) { - // logger.info("联联平台推送订单信息 params:{}", orderCode); - // RestApiResponse response = null; - // try { - // if (StringUtils.isBlank(orderCode)) { - // throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - // } - // String result = lianLianService.notificationOrderInfo(orderCode); - // 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; - // } - - /** - * 设备充电中状态变化推送 - * @return - */ - // @GetMapping("/pushPileChargeStatusChange/{orderCode}") - // public RestApiResponse pushPileChargeStatusChange(@PathVariable("orderCode")String orderCode) { - // logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode); - // RestApiResponse response = null; - // try { - // if (StringUtils.isBlank(orderCode)) { - // throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - // } - // // String result = lianLianService.pushPileChargeStatusChange(orderCode); - // String result = lianLianService.notificationEquipChargeStatus(orderCode); - // 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; - // } + @GetMapping("/notificationOrderInfo/{orderCode}") + public RestApiResponse notificationOrderInfo(@PathVariable("orderCode")String orderCode) { + logger.info("联联平台推送订单信息 params:{}", orderCode); + RestApiResponse response = null; + try { + if (StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + String result = lianLianService.notificationOrderInfo(orderCode); + 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; + } /** * 请求设备认证 diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushInfoParamDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushInfoParamDTO.java index c1c188aa7..64a78061f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushInfoParamDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PushInfoParamDTO.java @@ -13,4 +13,6 @@ public class PushInfoParamDTO { private String pileConnectorCode; private String status; + + private String stationId; }