diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/YunWeiPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/YunWeiPlatformController.java new file mode 100644 index 000000000..f321da2b1 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/YunWeiPlatformController.java @@ -0,0 +1,503 @@ +package com.jsowell.api.thirdparty; + +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.response.RestApiResponse; +import com.jsowell.pile.dto.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.dto.RetryOrderDTO; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +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.util.Map; + +@Anonymous +@RestController +@RequestMapping("/yunwei") +public class YunWeiPlatformController extends ThirdPartyBaseController{ + + + private final String platformName = "运维平台"; + + + private final String platformType = ThirdPlatformTypeEnum.YUN_WEI_PLATFORM.getTypeCode(); + + + @Autowired + @Qualifier("yunWeiPlatformServiceImpl") + private ThirdPartyPlatformService platformLogic; + + + /** + * getToken + */ + @PostMapping("/v1/query_token") + public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { + logger.info("{}-请求令牌 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // Map map = zdlService.generateToken(dto); + Map map = platformLogic.queryToken(dto); + logger.info("{}-请求令牌 result:{}" , platformName , map); + return CommonResult.success(0 , "请求令牌成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.info("{}-请求令牌 error:" , platformName , e); + return CommonResult.failed("获取token发生异常"); + } + } + + + /** + * 查询充电站信息 + * query_stations_info + */ + @PostMapping("/v1/query_stations_info") + public CommonResult query_stations_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询充电站信息 params:{}" , platformName , JSON.toJSONString(dto)); + try { + logger.info("{}-携带的token:{}",platformName, request.getHeader("Authorization")); + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryStationsInfo(queryStationInfoDTO); + logger.info("{}-查询充电站信息 result:{}" , platformName , JSON.toJSONString(map)); + return CommonResult.success(0 , "查询充电站信息成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.info("{}-查询充电站信息 error:" , platformName , e); + } + return CommonResult.failed("查询充电站信息发生异常"); + } + + + /** + * 设备状态推送 + * notification_stationStatus + * + * @param request + * @return + */ + @PostMapping("/v1/notification_stationStatus") + public RestApiResponse notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO , HttpServletRequest request) { + RestApiResponse response = null; + try { + String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO); + 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); + } + logger.info("【{}】推送设备状态 response:{}" , this.getClass().getSimpleName() , response); + return response; + + } + + /** + * 设备接口状态查询 query_station_status + * + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_station_status") + public CommonResult query_stations_status(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-设备接口状态查询 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryStationStatus(queryStationInfoDTO); + logger.info("{}-设备接口状态查询 result:{}" , platformName , map); + return CommonResult.success(0 , "设备接口状态查询成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.info("{}-设备接口状态查询 error:" , platformName , e); + } + return CommonResult.failed("设备接口状态查询发生异常"); + } + + /** + * 统计信息查询 query_station_stats + * + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_station_stats") + public CommonResult query_station_stats(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询统计信息 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class); + // 执行逻辑 + Map map = platformLogic.queryStationStats(queryStationInfoDTO); + logger.info("{}-查询统计信息 result:{}" , platformName , map); + return CommonResult.success(0 , "查询统计信息成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.info("{}-查询统计信息 error:" , platformName , e); + } + return CommonResult.failed("查询统计信息发生异常"); + } + + /** + * 请求设备认证 + * + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_equip_auth") + public CommonResult query_equip_auth(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-请求设备认证 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + dto.setPlatformType(platformType); + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryEquipmentDTO queryEquipmentDTO = parseParamsDTO(dto , QueryEquipmentDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryEquipAuth(queryEquipmentDTO); + logger.info("{}-请求设备认证 result:{}" , platformName , map); + return CommonResult.success(0 , "请求设备认证成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-请求设备认证 error:" , platformName , e); + } + return CommonResult.failed("请求设备认证发生异常"); + } + + /** + * 查询业务策略信息 + * + * @param dto + */ + @RequestMapping("/v1/query_equip_business_policy") + public CommonResult query_equip_business_policy(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询业务策略信息 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryEquipBusinessPolicy(queryStartChargeDTO); + logger.info("{}-查询业务策略信息 result:{}" , platformName , map); + return CommonResult.success(0 , "查询业务策略信息成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.info("{}-查询业务策略信息 error:" , platformName , e); + } + return CommonResult.failed("查询业务策略信息发生异常"); + } + + + /** + * 请求启动充电 + * + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_start_charge") + public CommonResult query_start_charge(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-请求启动充电 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + dto.setPlatformType(platformType); + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class); + // 执行逻辑 + Map map = platformLogic.queryStartCharge(queryStartChargeDTO); + logger.info("{}-请求启动充电 result:{}" , platformName , map); + return CommonResult.success(0 , "请求启动充电成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-请求启动充电 error:" , platformName , e); + } + return CommonResult.failed("请求启动充电发生异常"); + } + + /** + * 推送启动充电结果 + * + * @param + * @return + */ + @GetMapping("/v1/notification_start_charge_result/{orderCode}") + public RestApiResponse notification_start_charge_result(@PathVariable("orderCode") String orderCode) { + logger.info("【{}】推送启动充电结果 params:{}" , this.getClass().getSimpleName() , orderCode); + RestApiResponse response = null; + try { + String result = platformLogic.notificationStartChargeResult(orderCode); + logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , result); + response = new RestApiResponse<>(result); + } catch (BusinessException e) { + logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e); + response = new RestApiResponse<>(e.getCode() , e.getMessage()); + } catch (Exception e) { + logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e); + response = new RestApiResponse<>(e); + } + logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , response); + return response; + } + + /** + * 查询充电状态 + * http://localhost:8080/xindiantu/query_equip_charge_status/{startChargeSeq} + * + * @param dto + * @return + */ + @PostMapping("/v1/query_equip_charge_status") + public CommonResult query_equip_charge_status(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询充电状态 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + dto.setPlatformType(platformType); + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto , QueryEquipChargeStatusDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO); + logger.info("{}-查询充电状态 result:{}" , platformName , map); + return CommonResult.success(0 , "查询充电状态成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-查询充电状态 error:" , platformName , e); + } + return CommonResult.failed("查询充电状态发生异常"); + + } + + + /** + * 推送充电状态 + * http://localhost:8080/hainan/notificationEquipChargeStatus + * + * @param orderCode + * @return + */ + @GetMapping("/v1/notification_equip_charge_status/{orderCode}") + public RestApiResponse notification_equip_charge_status(@PathVariable("orderCode") String orderCode) { + logger.info("推送充电状态 params:{}" , orderCode); + RestApiResponse response = null; + try { + String result = platformLogic.notificationEquipChargeStatus(orderCode); + logger.info("推送充电状态 result:{}" , result); + 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; + } + + + /** + * 请求停止充电 + * + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_stop_charge") + public CommonResult query_stop_charge(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-请求停止充电 params :{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class); + logger.info("{}-请求停止充电 params :{}" , platformName , JSON.toJSONString(queryStartChargeDTO)); + // 执行逻辑 + Map map = platformLogic.queryStopCharge(queryStartChargeDTO); + + return CommonResult.success(0 , "请求停止充电成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-请求停止充电 error" , platformName , e); + } + return CommonResult.failed("{}-请求停止充电发生异常"); + } + + + /** + * 推送停止充电结果 + * http://localhost:8080/hainan/notificationStopChargeResult + * + * @param orderCode + * @return + */ + @GetMapping("/v1/notification_stop_charge_result/{orderCode}") + public RestApiResponse notification_stop_charge_result(@PathVariable("orderCode") String orderCode) { + logger.info("推送停止充电结果 params:{}" , orderCode); + RestApiResponse response = null; + try { + String result = platformLogic.notificationStopChargeResult(orderCode); + logger.info("推送停止充电结果 result:{}" , result); + 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("/v1/notification_charge_order_info") + public RestApiResponse notification_charge_order_info(@RequestBody QueryOrderDTO dto) { + RestApiResponse response = null; + try { + 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); + } + logger.info("推送充电订单信息 result:{}" , response); + return response; + } + + /** + * 获取充电订单信息 + * retry_notification_order_info + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/retry_notification_order_info") + public CommonResult retry_notification_order_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-获取充电订单信息 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + // 解析入参 + RetryOrderDTO retryOrderDTO = parseParamsDTO(dto , RetryOrderDTO.class); + // 执行逻辑 + Map map = platformLogic.retryNotificationOrderInfo(retryOrderDTO.getStartChargeSeqs()); + logger.info("{}-获取充电订单信息 result:{}" , platformName , map); + return CommonResult.success(0 , "获取充电订单信息成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-获取充电订单信息 error" , platformName , e); + } + return CommonResult.failed("{}-获取充电订单信息发生异常"); + + } +} diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index 72416ebac..cb69af35e 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -38,6 +38,7 @@ public enum ThirdPlatformTypeEnum { CHANG_ZHOU_PLATFORM("25", "新运常畅充", "0585PCW57"), SI_CHUAN_PLATFORM("26", "四川省平台", "MA01H3BQ2"), JI_LIN_PLATFORM("27", "吉林省平台", "723195753"), + YUN_WEI_PLATFORM("28", "运维平台", ""), ; private String typeCode; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 93415d0a4..0324dcf0f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -4,29 +4,29 @@ import com.google.common.collect.Lists; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.service.thirdparty.ThirdPartyPlatformApi; import com.jsowell.common.util.StringUtils; +import com.jsowell.common.util.spring.SpringUtils; import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.dubbo.factory.DynamicThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import org.apache.commons.collections4.CollectionUtils; -import org.bouncycastle.crypto.CryptoException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.spec.InvalidKeySpecException; +import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; /** - * 主动通知Service - * 说明:创建此接口目的是为了简化开发 - * 在需要通知第三方平台的地方,异步调用此类中对应的方法 - * 通知方法中应该根据对接平台,自动找到响应的平台处理逻辑 + * 主动通知Service - 异步改造版 */ @Service public class NotificationService { @@ -35,9 +35,43 @@ public class NotificationService { @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; + // 引入线程池 + private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); + + + // 判断是否使用old还是new平台 + private boolean isRemotePlatform(String platformType) { + for (ThirdPlatformTypeEnum item : ThirdPlatformTypeEnum.values()) { + if (StringUtils.equals(item.getTypeCode(), platformType)) { + return true; // true: 使用old平台 + } + } + return false; // false: 使用new平台 + } + + /** + * 根据平台类型获取对应的服务实例 + */ + private Object getPlatformService(String platformType) { + if (isRemotePlatform(platformType)) { + return ThirdPartyPlatformFactory.getInvokeStrategy(platformType); + } else { + return DynamicThirdPartyPlatformFactory.getPlatformService(platformType); + } + } + + /** + * VO对象转换 + */ + private com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO getConversion(ThirdPartySecretInfoVO secretInfoVO) { + com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversion = + new com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO(); + BeanUtils.copyProperties(secretInfoVO, conversion); + return conversion; + } + /** * 充电站信息变化推送 - * notification_stationInfo */ public String notificationStationInfo(NotificationDTO dto) { String stationId = dto.getStationId(); @@ -46,33 +80,58 @@ public class NotificationService { if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { - return null; + return "该站点未绑定任何平台"; } - // 调用相应平台的处理方法 + StringBuilder result = new StringBuilder(); + List> futures = new ArrayList<>(); + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue + String currentPlatformType = secretInfoVO.getPlatformType(); + if (StringUtils.isNotBlank(platformType) && !platformType.equals(currentPlatformType)) { continue; } + try { - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - String postResult = platformService.notificationStationInfo(stationId); - result.append(postResult).append("\n"); + Object service = getPlatformService(currentPlatformType); + + if (service instanceof ThirdPartyPlatformService) { + String pushResult = ((ThirdPartyPlatformService) service).notificationStationInfo(stationId); + result.append("old平台[").append(secretInfoVO.getPlatformName()) + .append("]推送结果:").append(pushResult).append("\n"); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture future = CompletableFuture.supplyAsync(() -> { + try { + return apiService.notificationStationInfo(stationId); + } catch (Exception e) { + return "推送失败:" + e.getMessage(); + } + }, executor).thenAccept(pushResult -> { + synchronized (result) { + result.append("new平台[").append(secretInfoVO.getPlatformName()) + .append("]推送结果:").append(pushResult).append("\n"); + } + }); + futures.add(future); + } } catch (Exception e) { - logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 充电站信息变化推送error:{}", - secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, e.getMessage()); + result.append("平台[").append(secretInfoVO.getPlatformName()) + .append("]处理异常:").append(e.getMessage()).append("\n"); } } + + // 等待所有异步任务完成 + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); return result.toString(); } /** * 设备状态变化推送 - * notification_stationStatus */ public void notificationStationStatus(NotificationDTO dto) { String stationId = dto.getStationId(); @@ -83,21 +142,35 @@ public class NotificationService { if (StringUtils.isBlank(stationId) || StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } + try { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationStationStatus( + stationId, pileConnectorCode, status, secretInfoVO); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationStationStatus(stationId, pileConnectorCode, status, conversionVO); + } catch (Exception e) { + logger.error("new平台[{}]设备状态推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 枪口编号:{}, 设备状态变化推送error:{}", secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, pileConnectorCode, e.getMessage()); @@ -107,153 +180,178 @@ public class NotificationService { /** * 设备充电中状态变化推送 - * notification_connector_charge_status - * notification_equip_charge_status */ public void notificationConnectorChargeStatus(NotificationDTO dto) { String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + try { - platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationConnectorChargeStatus(orderCode, secretInfoVO); + ((ThirdPartyPlatformService) service).notificationEquipChargeStatus(orderCode); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationConnectorChargeStatus(orderCode, conversionVO); + } catch (Exception e) { + logger.error("new平台[{}]充电中状态推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationEquipChargeStatus(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]设备充电状态推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}", secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage()); } - finally { - try { - platformService.notificationEquipChargeStatus(orderCode); - }catch (Exception e){ - logger.error("notification_equip_charge_status error", e); - } - } } } /** * 充电订单信息推送 - * notification_orderInfo/notification_charge_order_info */ public void notificationChargeOrderInfo(NotificationDTO dto) { String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } - // 根据平台类型获取Service - ThirdPartyPlatformService platformService =null; + + Object service = null; try { - // 根据平台类型获取Service - platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - }catch (Exception e){ + service = getPlatformService(secretInfoVO.getPlatformType()); + } catch (Exception e) { logger.error("获取平台服务失败", e); + continue; } - //充电订单信息推送 + + com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO); + try { - if(platformService != null){ - platformService.notificationChargeOrderInfo(orderCode, secretInfoVO); + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode, secretInfoVO); + ((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode); + ((ThirdPartyPlatformService) service).notificationStopChargeResult(orderCode); + ((ThirdPartyPlatformService) service).notificationPayOrderInfo(orderCode); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationChargeOrderInfo(orderCode, conversionVO); + } catch (Exception e) { + logger.error("new平台[{}]充电订单信息推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationChargeOrderInfo(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]订单信息推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationStopChargeResult(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]停止充电结果推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationPayOrderInfo(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]充电账单推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); } } catch (Exception e) { - logger.error("充电订单信息推送error", e); + logger.error("充电订单信息推送异常", e); } - //订单信息推送 - try { - if (platformService != null) { - platformService.notificationChargeOrderInfo(orderCode); - } - }catch (Exception e){ - logger.error("订单信息推送error", e); - } - //停止充电结果推送 - try { - if (platformService != null) { - platformService.notificationStopChargeResult(orderCode); - } - }catch (Exception e){ - logger.error("停止充电结果推送error", e); - } - //推送充换电站用能统计信息 -/* try { - if (platformService != null) { - platformService.notificationOperationStatsInfo(stationId); - } - }catch (Exception e){ - logger.error("推送充换电站用能统计信息error", e); - }*/ - //推送充电账单信息 - try { - if (platformService != null) { - platformService.notificationPayOrderInfo(orderCode); - } - }catch (Exception e){ - logger.error("推送充电账单信息error", e); - } - //推送充电历史订单信息 -/* try { - // 根据平台类型获取Service - if (platformService != null) { - platformService.notificationChargeOrderInfoHistory(orderCode); - } - } catch (Exception e) { - logger.error("历史充电订单信息推送error", e); - }*/ } } - - - + /** + * 开始充电结果推送 + */ public void commonPushStartChargeResult(NotificationDTO dto) { logger.info("开始调用commonPushStartChargeResult接口"); String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } + try { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - platformService.notificationStartChargeResult(orderCode); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationStartChargeResult(orderCode); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationStartChargeResult(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]开始充电结果推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("充电订单信息推送error", e); } @@ -262,26 +360,38 @@ public class NotificationService { /** * 站点功率信息推送 - * notification_orderInfo/notification_charge_order_info */ public void notificationStationPowerInfo(NotificationDTO dto) { String stationId = dto.getStationId(); String platformType = dto.getPlatformType(); - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } + try { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - platformService.notificationPowerInfo(Lists.newArrayList(stationId)); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + List stationIds = Lists.newArrayList(stationId); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationPowerInfo(stationIds); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationPowerInfo(stationIds); + } catch (Exception e) { + logger.error("new平台[{}]站点功率信息推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("站点功率信息推送error", e); } @@ -290,7 +400,6 @@ public class NotificationService { /** * 站点费率变化推送 - * notification_stationFee */ public void notificationStationFee(NotificationDTO dto) { String stationId = dto.getStationId(); @@ -299,21 +408,34 @@ public class NotificationService { if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } + try { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - platformService.notificationStationFee(stationId, secretInfoVO); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationStationFee(stationId, secretInfoVO); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationStationFee(stationId, conversionVO); + } catch (Exception e) { + logger.error("new平台[{}]站点费率推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("站点费率变化推送error", e); } @@ -322,74 +444,105 @@ public class NotificationService { /** * 历史充电订单信息推送 - * notification_orderInfo/notification_charge_order_info */ public void notificationChargeOrderInfoHistory(NotificationDTO dto) { String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - try { - platformService.notificationChargeOrderInfo(orderCode); - } catch (Exception e) { - logger.error("历史充电订单信息推送 error", e); - } try { - platformService.notificationChargeOrderInfoHistory(orderCode); + Object service = getPlatformService(secretInfoVO.getPlatformType()); + + if (service instanceof ThirdPartyPlatformService) { + ((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode); + ((ThirdPartyPlatformService) service).notificationChargeOrderInfoHistory(orderCode); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationChargeOrderInfo(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]历史订单信息推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + + CompletableFuture.runAsync(() -> { + try { + apiService.notificationChargeOrderInfoHistory(orderCode); + } catch (Exception e) { + logger.error("new平台[{}]历史充电订单推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { - logger.error("历史充电订单信息推送error", e); + logger.error("历史充电订单信息推送 error", e); } } } /** * 充电设备告警信息推送 - * notification_alarmInfo - * @param dto */ public void notificationAlarmInfo(NotificationDTO dto) { String stationId = dto.getStationId(); String pileConnectorCode = dto.getPileConnectorCode(); String status = dto.getStatus(); String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(status) || StringUtils.isBlank(pileConnectorCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { return; } - // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { - // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } + try { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + Object service = getPlatformService(secretInfoVO.getPlatformType()); PushAlarmInfoDTO pushAlarmInfoDTO = new PushAlarmInfoDTO(); pushAlarmInfoDTO.setPileConnectorCode(pileConnectorCode); pushAlarmInfoDTO.setConnectorStatus(status); - platformService.notificationAlarmInfo(pushAlarmInfoDTO); + com.jsowell.common.service.thirdparty.dto.PushAlarmInfoDTO dtoConvert = + new com.jsowell.common.service.thirdparty.dto.PushAlarmInfoDTO(); + BeanUtils.copyProperties(pushAlarmInfoDTO, dtoConvert); + + if (service instanceof ThirdPartyPlatformService) { + + ((ThirdPartyPlatformService) service).notificationAlarmInfo(pushAlarmInfoDTO); + } else if (service instanceof ThirdPartyPlatformApi) { + // 后续新平台异步处理 + ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service; + CompletableFuture.runAsync(() -> { + try { + apiService.notificationAlarmInfo(dtoConvert); + } catch (Exception e) { + logger.error("new平台[{}]设备告警信息推送失败", secretInfoVO.getPlatformName(), e); + } + }, executor); + } } catch (Exception e) { logger.error("充电设备告警信息推送error", e); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/OrderBasicInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/OrderBasicInfoApiImpl.java new file mode 100644 index 000000000..c3feb6533 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/OrderBasicInfoApiImpl.java @@ -0,0 +1,109 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.dto.RealTimeMonitorData; + +import com.jsowell.common.service.thirdparty.domin.OrderBasicInfo; +import com.jsowell.common.service.thirdparty.domin.OrderDetail; +import com.jsowell.common.service.thirdparty.dto.*; +import com.jsowell.common.service.thirdparty.tempservice.OrderBasicInfoApi; +import com.jsowell.common.service.thirdparty.vo.*; +import com.jsowell.pile.service.OrderBasicInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@DubboService(group = "thirdparty" , version = "1.0.0") +public class OrderBasicInfoApiImpl implements OrderBasicInfoApi { + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + /** + * 转换实体类 + * @param orderBasicInfo + * @return + */ + public OrderBasicInfo getOrderBasicInfoVO(com.jsowell.pile.domain.OrderBasicInfo orderBasicInfo){ + OrderBasicInfo orderBasicInfoVO = new OrderBasicInfo(); + BeanUtils.copyProperties(orderBasicInfo, orderBasicInfoVO); + return orderBasicInfoVO; + } + + + @Override + public OrderBasicInfo getOrderInfoByOrderCode(String orderCode) { + com.jsowell.pile.domain.OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + return getOrderBasicInfoVO(orderInfoByOrderCode); + } + + + + @Override + public OrderBasicInfo queryChargingByPileConnectorCode(String pileConnectorCode) { + com.jsowell.pile.domain.OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode); + + return getOrderBasicInfoVO(orderBasicInfo); + } + + @Override + public OrderDetail getOrderDetailByOrderCode(String orderCode) { + com.jsowell.pile.domain.OrderDetail orderDetailByOrderCode = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetailByOrderCode == null) { + return null; + } + OrderDetail orderDetail = new OrderDetail(); + BeanUtils.copyProperties(orderDetailByOrderCode, orderDetail); + return orderDetail; + } + + + + @Override + public List getChargingRealTimeData(String transactionCode) { + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(transactionCode); + List result = new ArrayList<>(); + chargingRealTimeData.forEach(realTimeMonitorData -> { + RealTimeMonitorData monitorData = new RealTimeMonitorData(); + BeanUtils.copyProperties(realTimeMonitorData, monitorData); + result.add(monitorData); + }); + return result; + + } + + + @Override + public List getAccumulativeInfoForLianLian(QueryStationInfoDTO dto) { + com.jsowell.pile.dto.QueryStationInfoDTO queryStationInfoDTO = new com.jsowell.pile.dto.QueryStationInfoDTO(); + BeanUtils.copyProperties(dto, queryStationInfoDTO); + List accumulativeInfoForLianLian = orderBasicInfoService.getAccumulativeInfoForLianLian(queryStationInfoDTO); + List result = new ArrayList<>(); + accumulativeInfoForLianLian.forEach(accumulativeInfoVO -> { + AccumulativeInfoVO info = new AccumulativeInfoVO(); + BeanUtils.copyProperties(accumulativeInfoVO, info); + result.add(info); + }); + return result; + } + + @Override + public Map generateOrderForThirdParty(QueryStartChargeDTO dto) { + com.jsowell.pile.dto.QueryStartChargeDTO queryStartChargeDTO = new com.jsowell.pile.dto.QueryStartChargeDTO(); + BeanUtils.copyProperties(dto, queryStartChargeDTO); + return orderBasicInfoService.generateOrderForThirdParty(queryStartChargeDTO); + } + + @Override + public List tempGetOrderCodes(QueryOrder2DTO dto) { + com.jsowell.pile.dto.QueryOrderDTO queryOrderDTO = new com.jsowell.pile.dto.QueryOrderDTO(); + BeanUtils.copyProperties(dto, queryOrderDTO); + return orderBasicInfoService.tempGetOrderCodes(queryOrderDTO); + } + + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBasicInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBasicInfoApiImpl.java new file mode 100644 index 000000000..c7f15f2bb --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBasicInfoApiImpl.java @@ -0,0 +1,89 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.domin.PileBasicInfo; +import com.jsowell.common.service.thirdparty.tempservice.PileBasicInfoApi; +import com.jsowell.common.service.thirdparty.vo.PileConnectorDetailVO; +import com.jsowell.common.service.thirdparty.vo.PileDetailInfoVO; +import com.jsowell.common.vo.PileInfoVO; +import com.jsowell.pile.service.PileBasicInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@DubboService(group = "thirdparty" , version = "1.0.0") +public class PileBasicInfoApiImpl implements PileBasicInfoApi { + + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Override + public PileBasicInfo selectPileBasicInfoBySN(String pileSn) { + com.jsowell.pile.domain.PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + if (pileBasicInfo == null) { + return null; + } + PileBasicInfo result = new PileBasicInfo(); + BeanUtils.copyProperties(pileBasicInfo, result); + return result; + } + + @Override + public PileInfoVO selectPileInfoBySn(String pileSn) { + com.jsowell.pile.vo.base.PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn); + if (pileInfoVO == null) { + return null; + } + PileInfoVO result = new PileInfoVO(); + BeanUtils.copyProperties(pileInfoVO, result); + return result; + } + + + + @Override + public PileConnectorDetailVO queryPileConnectorDetail(String pileConnectorCode) { + com.jsowell.pile.vo.uniapp.customer.PileConnectorDetailVO pileConnectorDetailVO = pileBasicInfoService.queryPileConnectorDetail(pileConnectorCode); + if (pileConnectorDetailVO == null) { + return null; + } + PileConnectorDetailVO result = new PileConnectorDetailVO(); + BeanUtils.copyProperties(pileConnectorDetailVO, result); + return result; + } + + + + + + @Override + public List getPileDetailInfoList(String stationId) { + List pileDetailInfoList = pileBasicInfoService.getPileDetailInfoList(stationId); + if (pileDetailInfoList == null || pileDetailInfoList.isEmpty()) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); + for (com.jsowell.pile.thirdparty.PileDetailInfoVO pileDetailInfoVO : pileDetailInfoList) { + PileDetailInfoVO info = new PileDetailInfoVO(); + BeanUtils.copyProperties(pileDetailInfoVO, info); + result.add(info); + } + return result; + } + + @Override + public List getPileListByStationId(String stationId) { + List pileListByStationId = pileBasicInfoService.getPileListByStationId(stationId); + List result = new ArrayList<>(); + for (com.jsowell.pile.domain.PileBasicInfo basicInfo : pileListByStationId) { + PileBasicInfo pileBasicInfo = new PileBasicInfo(); + BeanUtils.copyProperties(basicInfo, pileBasicInfo); + result.add(pileBasicInfo); + } + return result; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBillingTemplateApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBillingTemplateApiImpl.java new file mode 100644 index 000000000..0036d80cd --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBillingTemplateApiImpl.java @@ -0,0 +1,47 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.tempservice.PileBillingTemplateApi; +import com.jsowell.common.service.thirdparty.vo.BillingPriceVO; +import com.jsowell.common.vo.BillingTemplateVO; +import com.jsowell.pile.service.PileBillingTemplateService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@DubboService(group = "thirdparty",version = "1.0.0") +public class PileBillingTemplateApiImpl implements PileBillingTemplateApi { + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + + @Override + public List queryBillingPrice(String stationId) { + List billingPriceVOS = pileBillingTemplateService.queryBillingPrice(stationId); + if (billingPriceVOS == null || billingPriceVOS.isEmpty()){ + return Collections.emptyList(); + } + List billingPriceVOList = new ArrayList<>(); + for (com.jsowell.pile.vo.uniapp.customer.BillingPriceVO billingPriceVO : billingPriceVOS){ + BillingPriceVO vo = new BillingPriceVO(); + BeanUtils.copyProperties(billingPriceVO,vo); + } + return billingPriceVOList; + } + + @Override + public BillingTemplateVO selectBillingTemplateDetailByPileSn(String pileSn) { + com.jsowell.pile.vo.web.BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn); + if (billingTemplateVO == null){ + return null; + } + BillingTemplateVO vo = new BillingTemplateVO(); + BeanUtils.copyProperties(billingTemplateVO,vo); + return vo; + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileConnectorInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileConnectorInfoApiImpl.java new file mode 100644 index 000000000..65047d2f4 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileConnectorInfoApiImpl.java @@ -0,0 +1,74 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.domin.PileConnectorInfo; + +import com.jsowell.common.service.thirdparty.tempservice.PileConnectorInfoApi; +import com.jsowell.common.service.thirdparty.vo.ConnectorInfoVO; +import com.jsowell.common.service.thirdparty.vo.PileConnectorInfoVO; +import com.jsowell.pile.service.PileConnectorInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +@DubboService(group = "thirdparty" , version = "1.0.0") +public class PileConnectorInfoApiImpl implements PileConnectorInfoApi { + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + + + @Override + public List selectPileConnectorInfoList(String pileSn) { + List pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileSn); + if (pileConnectorInfos == null || pileConnectorInfos.isEmpty()) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); + for (com.jsowell.pile.domain.PileConnectorInfo info : pileConnectorInfos) { + PileConnectorInfo resultInfo = new PileConnectorInfo(); + BeanUtils.copyProperties(info, resultInfo); + result.add(resultInfo); + } + return result; + } + + + + @Override + public PileConnectorInfoVO getPileConnectorInfoByConnectorCode(String connectorCode) { + com.jsowell.pile.vo.web.PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(connectorCode); + if (info == null) { + return null; + } + PileConnectorInfoVO resultInfo = new PileConnectorInfoVO(); + BeanUtils.copyProperties(info, resultInfo); + return resultInfo; + } + + @Override + public List batchSelectConnectorList(List stationIds) { + return Collections.emptyList(); + } + + @Override + public List getConnectorListForLianLian(Long stationId) { + List connectorListForLianLian = pileConnectorInfoService.getConnectorListForLianLian(stationId); + if (connectorListForLianLian == null || connectorListForLianLian.isEmpty()) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); + for (com.jsowell.pile.vo.base.ConnectorInfoVO info : connectorListForLianLian) { + ConnectorInfoVO resultInfo = new ConnectorInfoVO(); + BeanUtils.copyProperties(info, resultInfo); + result.add(resultInfo); + } + return result; + } + + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileMerchantInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileMerchantInfoApiImpl.java new file mode 100644 index 000000000..9b767634e --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileMerchantInfoApiImpl.java @@ -0,0 +1,27 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.tempservice.PileMerchantInfoApi; +import com.jsowell.common.service.thirdparty.vo.MerchantInfoVO; +import com.jsowell.pile.service.PileMerchantInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +@DubboService(group = "thirdparty", version = "1.0.0") +public class PileMerchantInfoApiImpl implements PileMerchantInfoApi { + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Override + public MerchantInfoVO getMerchantInfoVO(String merchantId) { + com.jsowell.pile.vo.base.MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId); + if (merchantInfoVO == null) { + return null; + } + MerchantInfoVO vo = new MerchantInfoVO(); + BeanUtils.copyProperties(merchantInfoVO, vo); + return vo; + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileModelInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileModelInfoApiImpl.java new file mode 100644 index 000000000..2c5e33f30 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileModelInfoApiImpl.java @@ -0,0 +1,30 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + + +import com.jsowell.common.service.thirdparty.tempservice.PileModelInfoApi; +import com.jsowell.common.service.thirdparty.vo.PileModelInfoVO; +import com.jsowell.pile.service.PileModelInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + + +@DubboService(group = "thirdparty", version = "1.0.0") +public class PileModelInfoApiImpl implements PileModelInfoApi { + + @Autowired + private PileModelInfoService pileModelInfoService; + + + @Override + public PileModelInfoVO getPileModelInfoByPileSn(String pileSn) { + com.jsowell.pile.vo.web.PileModelInfoVO pileModelInfoByPileSn = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + if (pileModelInfoByPileSn == null) { + return null; + } + PileModelInfoVO pileModelInfoVO = new PileModelInfoVO(); + BeanUtils.copyProperties(pileModelInfoByPileSn, pileModelInfoVO); + return pileModelInfoVO; + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileRemoteApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileRemoteApiImpl.java new file mode 100644 index 000000000..fa651dfcc --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileRemoteApiImpl.java @@ -0,0 +1,20 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.tempservice.PileRemoteApi; +import com.jsowell.pile.service.PileRemoteService; +import org.apache.dubbo.config.annotation.DubboService; + +import javax.annotation.Resource; + + +@DubboService(group = "thirdparty", version = "1.0.0") +public class PileRemoteApiImpl implements PileRemoteApi { + + @Resource + private PileRemoteService pileRemoteService; + + @Override + public void remoteStopCharging(String pileSn , String connectorCode , String transactionCode) { + pileRemoteService.remoteStopCharging(pileSn, connectorCode, transactionCode); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileStationInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileStationInfoApiImpl.java new file mode 100644 index 000000000..d7a2e6d95 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileStationInfoApiImpl.java @@ -0,0 +1,54 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.domin.PileStationInfo; + +import com.jsowell.common.service.thirdparty.dto.QueryStationInfoDTO; +import com.jsowell.common.service.thirdparty.tempservice.PileStationInfoApi; +import com.jsowell.common.service.thirdparty.vo.ThirdPartyStationInfoVO; +import com.jsowell.pile.service.PileStationInfoService; + +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@DubboService(group = "thirdparty", version = "1.0.0") +public class PileStationInfoApiImpl implements PileStationInfoApi { + + @Autowired + private PileStationInfoService pileStationInfoService; + + + @Override + public PileStationInfo selectPileStationInfoById(Long id) { + com.jsowell.pile.domain.PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(id); + if (pileStationInfo == null) { + return null; + } + PileStationInfo result = new PileStationInfo(); + BeanUtils.copyProperties(pileStationInfo, result); + return result; + } + + + @Override + public List selectStationInfosByThirdParty(QueryStationInfoDTO dto) { + com.jsowell.pile.dto.QueryStationInfoDTO dto1 = new com.jsowell.pile.dto.QueryStationInfoDTO(); + BeanUtils.copyProperties(dto, dto1); + List thirdPartyStationInfoVOS = pileStationInfoService.selectStationInfosByThirdParty(dto1); + if (thirdPartyStationInfoVOS == null) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); + for (com.jsowell.pile.vo.base.ThirdPartyStationInfoVO stationInfo : thirdPartyStationInfoVOS) { + ThirdPartyStationInfoVO thirdPartyStationInfoVO = new ThirdPartyStationInfoVO(); + BeanUtils.copyProperties(stationInfo, thirdPartyStationInfoVO); + result.add(thirdPartyStationInfoVO); + } + return result; + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/ThirdpartySecretInfoApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/ThirdpartySecretInfoApiImpl.java new file mode 100644 index 000000000..dc9979659 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/ThirdpartySecretInfoApiImpl.java @@ -0,0 +1,71 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.tempservice.ThirdpartySecretInfoApi; +import com.jsowell.common.service.thirdparty.vo.StationInfoVO; +import com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +@DubboService(group = "thirdparty", version = "1.0.0") +public class ThirdpartySecretInfoApiImpl implements ThirdpartySecretInfoApi { + + @Autowired + public ThirdpartySecretInfoService thirdpartySecretInfoService; + + /** + * 通过组织结构代码,查询平台密钥配置信息 + * @param theirOperatorId 组织结构代码 + * @return + */ + @Override + public ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId) { + com.jsowell.pile.vo.ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(theirOperatorId); + if (thirdPartySecretInfoVO == null){ + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO1 = new ThirdPartySecretInfoVO(); + BeanUtils.copyProperties(thirdPartySecretInfoVO, thirdPartySecretInfoVO1); + return thirdPartySecretInfoVO1; + } + + /** + * 通过第三方平台类型,查询平台密钥配置信息 + * @param thirdPlatformType 第三方平台类型, 参见{@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} + * @return + */ + @Override + public ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType) { + com.jsowell.pile.vo.ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + if (thirdPartySecretInfoVO == null){ + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO1 = new ThirdPartySecretInfoVO(); + BeanUtils.copyProperties(thirdPartySecretInfoVO, thirdPartySecretInfoVO1); + return thirdPartySecretInfoVO1; + + } + + /** + * 根据第三方平台类型查询对接第三方平台的站点列表 + * @param thirdPlatformType + * @return + */ + @Override + public List selectStationList(String thirdPlatformType) { + List stationInfoVOS = thirdpartySecretInfoService.selectStationList(thirdPlatformType); + if (stationInfoVOS == null || stationInfoVOS.isEmpty()){ + return null; + } + List stationInfoVOList = new java.util.ArrayList<>(); + for (com.jsowell.pile.vo.base.StationInfoVO stationInfoVO : stationInfoVOS){ + StationInfoVO stationInfoVO1 = new StationInfoVO(); + BeanUtils.copyProperties(stationInfoVO, stationInfoVO1); + stationInfoVOList.add(stationInfoVO1); + } + return stationInfoVOList; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/YKCPushCommandApiImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/YKCPushCommandApiImpl.java new file mode 100644 index 000000000..12874cfab --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/YKCPushCommandApiImpl.java @@ -0,0 +1,22 @@ +package com.jsowell.thirdparty.dubbo.api.impl; + +import com.jsowell.common.service.thirdparty.domin.ykcCommond.StartChargingCommand; +import com.jsowell.common.service.thirdparty.tempservice.YKCPushCommandApi; +import com.jsowell.pile.service.YKCPushCommandService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +@DubboService(group = "thirdparty" ,version = "1.0.0") +public class YKCPushCommandApiImpl implements YKCPushCommandApi { + + @Autowired + private YKCPushCommandService ykcpushCommandService; + + @Override + public void pushStartChargingCommand(StartChargingCommand startChargingCommand) { + com.jsowell.pile.domain.ykcCommond.StartChargingCommand command = new com.jsowell.pile.domain.ykcCommond.StartChargingCommand(); + BeanUtils.copyProperties(startChargingCommand, command); + ykcpushCommandService.pushStartChargingCommand(command); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/factory/DynamicThirdPartyPlatformFactory.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/factory/DynamicThirdPartyPlatformFactory.java new file mode 100644 index 000000000..262c931e9 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/factory/DynamicThirdPartyPlatformFactory.java @@ -0,0 +1,88 @@ +package com.jsowell.thirdparty.dubbo.factory; + +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.service.thirdparty.ThirdPartyPlatformApi; +import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.springframework.stereotype.Component; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * 动态服务工厂 + */ +@Component +@Slf4j +public class DynamicThirdPartyPlatformFactory { + + // 缓存已获取的服务代理 + private static final ConcurrentHashMap serviceCache = new ConcurrentHashMap<>(); + + /** + * 根据平台类型动态获取远程服务 + * @param platformType 平台类型(需与远程服务的@DubboService(group)一致) + * @return 远程服务代理 + */ + public static ThirdPartyPlatformApi getPlatformService(String platformType) { + + if (platformType == null || platformType.isEmpty()) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } + + // 1. 先从缓存获取 + ThirdPartyPlatformApi service = serviceCache.get(platformType); + + if (service != null) { + return service; + } + + // 2. 动态创建服务引用 + synchronized (DynamicThirdPartyPlatformFactory.class) { + service = serviceCache.get(platformType); + if (service != null) { + return service; + } + + try { + // 创建ReferenceConfig实例 + // 要与jsowell-charge-thirdparty的远程服务的@DubboService配置一致 + ReferenceConfig referenceConfig = new ReferenceConfig<>(); + referenceConfig.setInterface(ThirdPartyPlatformApi.class); + referenceConfig.setGroup(platformType); + referenceConfig.setVersion("1.0.0"); + referenceConfig.setTimeout(10000); // 设置超时时间为10秒,默认为1秒 + referenceConfig.setRetries(2); //失败重试次数为2 +// referenceConfig.setAsync(true); //异步调用 + + + // 根据特定的配置,在nacos中寻找jsowell-charge-thirdparty注册的服务 + // 使用DubboBootstrap注册并获取服务 + DubboBootstrap + .getInstance() // 获取DubboBootstrap实例 + .reference( // 引用服务配置 + referenceConfig, + DubboBootstrap + .getInstance() + .getApplicationModel() + .getDefaultModule()); + + // 获取服务代理 + service = referenceConfig.get(); + serviceCache.put(platformType, service); + log.info("缓存中有的缓存有: "+ serviceCache.toString()); + return service; + } catch (Exception e) { + throw new BusinessException(ReturnCodeEnum.valueOf("获取平台[" + platformType + "]的服务失败: " + e.getMessage())); + } + } + } + + /** + * 清理缓存 + */ + public static void clearCache() { + serviceCache.clear(); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YunWeiPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YunWeiPlatformServiceImpl.java new file mode 100644 index 000000000..dd6d6f4bf --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YunWeiPlatformServiceImpl.java @@ -0,0 +1,1008 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.OrderStatusEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.*; +import com.jsowell.pile.domain.*; +import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; +import com.jsowell.pile.dto.*; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.*; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.base.MerchantInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; +import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; +import com.jsowell.pile.vo.web.OrderListVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileModelInfoVO; +import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; +import com.jsowell.thirdparty.lianlian.domain.*; +import com.jsowell.thirdparty.lianlian.vo.*; +import com.jsowell.thirdparty.platform.domain.SupStationInfo; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; +import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.apache.commons.collections4.CollectionUtils; +import org.bouncycastle.crypto.CryptoException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.spec.InvalidKeySpecException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 运维平台 + */ +@Service +public class YunWeiPlatformServiceImpl implements ThirdPartyPlatformService { + // 平台类型 + private final String thirdPlatformType = ThirdPlatformTypeEnum.YUN_WEI_PLATFORM.getTypeCode(); + + Logger logger = LoggerFactory.getLogger(QingHaiPlatformServiceImpl.class); + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private PileModelInfoService pileModelInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private YKCPushCommandService ykcPushCommandService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private PileRemoteService pileRemoteService; + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + @Override + public void printServiceName() { + // System.out.println("当前类名:" + this.getClass().getSimpleName()); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret"); + if (StringUtils.isBlank(inputOperatorSecret)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + } + } + // 对比密钥 + List operatorSecretList = Lists.newArrayList(theirOperatorSecret, thirdPartySecretInfoVO.getOurOperatorSecret()); + if (!operatorSecretList.contains(inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 推送站点信息 + * @param stationId 充电站id + * @return + */ + @Override + public String notificationStationInfo(String stationId) { + List stationInfos = new ArrayList<>(); + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + // 查询相关配置信息 + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + // 组装中电联平台所需要的数据格式 + SupStationInfo info = SupStationInfo.builder() + .stationID(stationId) + .operatorID(Constants.OPERATORID_JIANG_SU) + // .equipmentOwnerId(Constants.OPERATORID_JIANG_SU) + .stationName(pileStationInfo.getStationName()) + .countryCode(pileStationInfo.getCountryCode()) + .areaCode(pileStationInfo.getAreaCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + .build(); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + info.setAreaCode(subAreaCode); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + String organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerID(equipmentOwnerId); + } + // 站点图片 + if (StringUtils.isNotBlank(pileStationInfo.getPictures())) { + info.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(","))); + } + + List pileList = getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + stationInfos.add(info); + + // 调用中电联平台接口 + String url = urlAddress + "notification_stationInfo"; + + JSONObject data = new JSONObject(); + data.put("StationInfos", stationInfos); + + String jsonString = JSON.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 查询站点信息 + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + dto.setThirdPlatformType(thirdPlatformType); + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNingBoSecretInfoVO(); + PageInfo pageInfo = new PageInfo<>(stationInfos); + List resultList = new ArrayList<>(); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + SupStationInfo stationInfo = new SupStationInfo(); + stationInfo.setStationID(String.valueOf(pileStationInfo.getId())); + stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码 + String organizationCode = pileStationInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + stationInfo.setEquipmentOwnerID(equipmentOwnerId); + }else { + stationInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU); + } + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + stationInfo.setAreaCode(subAreaCode); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.parseInt(pileStationInfo.getStationType())); + stationInfo.setStationStatus(Integer.parseInt(pileStationInfo.getStationStatus())); + stationInfo.setParkNums(Integer.parseInt(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.parseInt(pileStationInfo.getConstruction())); + // 停车费率描述 + if (StringUtils.isNotBlank(pileStationInfo.getParkFeeDescribe())) { + stationInfo.setParkFee(pileStationInfo.getParkFeeDescribe()); + } + // 站点图片 + if (StringUtils.isNotBlank(pileStationInfo.getPictures())) { + stationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(","))); + } + + List pileList = getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", resultList.size()); + map.put("StationInfos", resultList); + + return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + + } + + /** + * 查询统计信息 query_station_stats + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationStats(QueryStationInfoDTO dto) { + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + // 根据站点id 查出这段时间的充电量 + List list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto); + if (CollectionUtils.isEmpty(list)) { + return null; + } + + // 根据充电桩编号分组 key=充电桩编号 + Map> pileMap = list.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn)); + + // 存放所有充电桩设备 + List equipmentStatsInfoList = Lists.newArrayList(); + // 站点用电量 + BigDecimal stationElectricity = BigDecimal.ZERO; + // 用于记录枪口用电量 在循环每个枪口的时候初始化 + BigDecimal pileElec; + for (String pileSn : pileMap.keySet()) { + // 该充电桩下 所有枪口的用电数据 + List accumulativeInfoVOS = pileMap.get(pileSn); + if (CollectionUtils.isEmpty(accumulativeInfoVOS)) { + continue; + } + + // 存放充电桩用电量 + pileElec = BigDecimal.ZERO; + + // key=枪口编号 value 该枪口的用电数据 + Map> collect = accumulativeInfoVOS.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode)); + + List connectorStatsInfos = Lists.newArrayList(); + for (Map.Entry> entry : collect.entrySet()) { + String pileConnectorCode = entry.getKey(); + List value = entry.getValue(); + // 枪口用电量求和 + BigDecimal connectorElec = value.stream() + .map(AccumulativeInfoVO::getConnectorElectricity) + .map(BigDecimal::new) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + connectorStatsInfos.add( + ConnectorStatsInfo.builder() + .connectorID(pileConnectorCode) + .connectorElectricity(connectorElec) + .build() + ); + // 充电桩电量为枪口用电量累计 + pileElec = pileElec.add(connectorElec); + } + + EquipmentStatsInfo build = EquipmentStatsInfo.builder() + .equipmentID(pileSn) + .equipmentElectricity(pileElec) + .connectorStatsInfos(connectorStatsInfos) + .build(); + equipmentStatsInfoList.add(build); + + // 所有充电桩用电量之和 + stationElectricity = stationElectricity.add(pileElec); + } + + StationStatsInfo stationStatsInfo = StationStatsInfo.builder() + .stationID(dto.getStationID()) + .startTime(dto.getStartTime()) + .endTime(dto.getEndTime()) + .stationElectricity(stationElectricity) + .equipmentStatsInfos(equipmentStatsInfoList) // 设备列表 + .build(); + + Map map = new LinkedHashMap<>(); + map.put("StationStats", stationStatsInfo); + + return ThirdPartyPlatformUtils.generateResultMap(map, ningBoSecretInfoVO); + } + + /** + * 设备接口状态查询 query_station_status + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List StationStatusInfos = new ArrayList<>(); + List ConnectorStatusInfos = new ArrayList<>(); + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + ConnectorStatusInfo connectorStatusInfo; + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo= new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService .getConnectorListForLianLian(Long.parseLong(stationId)); + for (ConnectorInfoVO connectorInfoVO : list) { + + String connectorStatus = connectorInfoVO.getConnectorStatus(); + if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { + // 充电中 + ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); + OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); + if (orderBasicInfo == null) { + continue; + } + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); + if(CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + + info.setStartChargeSeq(orderBasicInfo.getOrderCode()); + info.setConnectorID(orderBasicInfo.getPileConnectorCode()); + info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus())); + info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())); + info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())); + info.setSoc(new BigDecimal(realTimeMonitorData.getSOC())); + info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 + info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 + // info.setElecMoney(); // 累计电费 + // info.setSeviceMoney(); // 累计服务费 + info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); + + ConnectorStatusInfos.add(info); + } + } else { + // 其他 + connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + + ConnectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); + StationStatusInfos.add(stationStatusInfo); + } + // 将 StationStatusInfos 分页 + // int pageNum = 1; + // int pageSize = 10; + // List collect = StationStatusInfos.stream() + // .skip((pageNum - 1) * pageSize) + // .limit(pageSize) + // .collect(Collectors.toList()); + + int total = StationStatusInfos.size(); + // int pages = PageUtil.totalPage(total, pageSize); + + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", StationStatusInfos); + + return ThirdPartyPlatformUtils.generateResultMap(map, ningBoSecretInfoVO); + } + + /** + * 枪口状态变化 notification_station_status + * @return + */ + @Override + public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { + + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + String url = ningBoSecretInfoVO.getTheirUrlPrefix() + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 推送订单数据 notificationChargeOrderInfo + * @param orderCode 订单编号 + * @return + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + * @throws NoSuchProviderException + * @throws CryptoException + */ + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO thirdPartySecretInfoVO) { + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue(); + Date chargeStartTime = orderBasicInfo.getChargeStartTime(); + if (chargeStartTime == null) { + chargeStartTime = orderBasicInfo.getCreateTime(); + } + Date chargeEndTime = orderBasicInfo.getChargeEndTime(); + if (chargeEndTime == null) { + chargeEndTime = orderBasicInfo.getCreateTime(); + } + + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderBasicInfo.getPileConnectorCode()); + json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeStartTime)); + json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime)); + json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("StopReason", 2); // 2:BMS 停止充电 + + String jsonString = JSON.toJSONString(json); + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + /** + * 请求设备认证 + * @param dto 请求设备认证 + * @return + */ + @Override + public Map queryEquipAuth(QueryEquipmentDTO dto) { + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + EquipmentAuthVO vo = new EquipmentAuthVO(); + + String equipAuthSeq = dto.getEquipAuthSeq(); // MA1X78KH5202311071202015732 + String pileConnectorCode = dto.getConnectorID(); + + // 根据桩编号查询数据 + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + vo.setSuccStat(1); // 1-失败 0-成功 默认失败 + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + if (pileBasicInfo != null) { + // 查询当前枪口数据 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), String.valueOf(connectorInfo.getStatus())) + ) { + vo.setSuccStat(0); + vo.setFailReason(0); + } else { + vo.setSuccStat(1); + vo.setFailReason(1); // 1- 此设备尚未插枪; + } + vo.setFailReasonMsg(""); + vo.setEquipAuthSeq(equipAuthSeq); + vo.setConnectorID(pileConnectorCode); + } else { + vo.setFailReason(2); // 设备检测失败 + vo.setFailReasonMsg("未查到该桩的数据"); + } + + return ThirdPartyPlatformUtils.generateResultMap(vo, ningBoSecretInfoVO); + } + + /** + * 请求启动充电 query_start_charge + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryStartCharge(QueryStartChargeDTO dto) { + // 通过传过来的订单号和枪口号生成订单 + String pileConnectorCode = dto.getConnectorID(); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + if (orderInfo != null) { + // 平台已存在订单 + return null; + } + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + // 生成订单 + Map map = orderBasicInfoService.generateOrderForThirdParty(dto); + String orderCode = (String) map.get("orderCode"); + String transactionCode = (String) map.get("transactionCode"); + OrderBasicInfo orderBasicInfo = (OrderBasicInfo) map.get("orderBasicInfo"); + + // 发送启机指令 + StartChargingCommand command = StartChargingCommand.builder() + .pileSn(orderBasicInfo.getPileSn()) + .connectorCode(orderBasicInfo.getConnectorCode()) + .transactionCode(transactionCode) + .chargeAmount(orderBasicInfo.getPayAmount()) + .logicCardNum(null) + .physicsCardNum(null) + .build(); + ykcPushCommandService.pushStartChargingCommand(command); + + // 拼装对应的数据并返回 + QueryStartChargeVO vo = QueryStartChargeVO.builder() + .startChargeSeq(orderCode) + .startChargeSeqStat(2) // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + .connectorID(pileConnectorCode) + .succStat(0) + .failReason(0) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, ningBoSecretInfoVO); + } + + /** + * 查询业务策略 query_equip_business_policy + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { + List policyInfoList = new ArrayList<>(); + String pileConnectorCode = dto.getConnectorID(); + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + // 截取桩号 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // 查询该桩的站点id + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + // 根据桩号查询正在使用的计费模板 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileBasicInfo.getStationId())); + + if (CollectionUtils.isEmpty(billingPriceVOList)) { + return null; + } + EquipBusinessPolicyVO.PolicyInfo policyInfo = null; + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + // 将时段开始时间、电费、服务费信息进行封装 + policyInfo = new EquipBusinessPolicyVO.PolicyInfo(); + String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 + // 需要将中间的冒号去掉,改为 000000 格式 + String replace = StringUtils.replace(startTime, ":", ""); + policyInfo.setStartTime(replace); + policyInfo.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + policyInfo.setServicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + + policyInfoList.add(policyInfo); + } + + // 拼装所需要的数据格式 + EquipBusinessPolicyVO vo = EquipBusinessPolicyVO.builder() + .equipBizSeq(dto.getEquipBizSeq()) + .connectorId(dto.getConnectorID()) + .succStat(0) + .failReason(0) + .sumPeriod(policyInfoList.size()) + .policyInfos(policyInfoList) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, ningBoSecretInfoVO); + } + + /** + * 查询充电状态 + * @param dto 查询充电状态DTO + * @return + */ + @Override + public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { + String operatorID = dto.getOperatorID(); + // 通过订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + // logger.info(operatorName + "查询订单信息 orderInfo:{}", orderInfo); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 通过订单号查询实时数据 + List realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + QueryChargingStatusVO vo; + if (CollectionUtils.isEmpty(realTimeData)) { + vo = new QueryChargingStatusVO(); + } else { + RealTimeMonitorData data = realTimeData.get(0); + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { + // 充电中 + orderStatus = "2"; + }else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) { + // 充电完成 + orderStatus = "4"; + } else { + // 直接给 5-未知 + orderStatus = "5"; + } + String status = data.getConnectorStatus(); + int connectorStatus = 0; + if (StringUtils.isBlank(status)) { + // 查询当前枪口状态 + PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + connectorStatus = connectorInfoVO.getStatus(); + }else { + connectorStatus = Integer.parseInt(status); + } + BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); + BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); + // 拼装联联平台数据 + vo = QueryChargingStatusVO.builder() + .startChargeSeq(dto.getStartChargeSeq()) // 订单号 + .startChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态 + .connectorID(orderInfo.getPileConnectorCode()) // 枪口编码 + .connectorStatus(connectorStatus) // 枪口状态 + .currentA(new BigDecimal(data.getOutputCurrent())) // 电流 + .voltageA(new BigDecimal(data.getOutputVoltage())) // 电压 + .soc(new BigDecimal(data.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间 + .endTime(DateUtils.getDateTime()) // 本次采样时间 + .totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量 + .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费 + .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费 + .totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额 + + .build(); + } + return ThirdPartyPlatformUtils.generateResultMap(vo, ningBoSecretInfoVO); + } + + /** + * 请求停止充电 query_stop_charge + * @param dto + * @return + */ + @Override + public Map queryStopCharge(QueryStartChargeDTO dto) { + QueryStopChargeVO vo = new QueryStopChargeVO(); + String orderCode = dto.getStartChargeSeq(); + + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + // 若状态为充电中,则发送停机指令 + if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) { + // 充电中 + pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode()); + vo.setStartChargeSeq(orderCode); + vo.setStartChargeSeqStat(4); // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + } + vo.setSuccStat(0); + vo.setFailReason(0); + + return ThirdPartyPlatformUtils.generateResultMap(vo, ningBoSecretInfoVO); + } + + /** + * 推送启动充电结果 notification_start_charge_result + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStartChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + // 推送启动充电结果(调用接口 notification_start_charge_result) + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); + // 拼装参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("StartChargeSeqStat", 2); // 一定要给 2-充电中 + json.put("StartTime", DateUtils.getDateTime()); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 推送停止充电结果 notification_stop_charge_result + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStopChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue(); + + // 拼装联联平台参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("StartChargeSeqStat", 4); // 只能给 4-已结束 + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("SuccStat", 0); + json.put("FailReason", 0); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + @Override + public String notificationEquipChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent(); + BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); + String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); + // 查询相关配置信息 + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); + BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); + + QueryChargingStatusVO vo = QueryChargingStatusVO.builder() + .startChargeSeq(orderInfo.getOrderCode()) // 订单号 + .startChargeSeqStat(Integer.parseInt(orderInfo.getOrderStatus())) // 订单状态 + .connectorID(orderInfo.getPileConnectorCode()) // 枪口编码 + .connectorStatus(info.getStatus()) // 枪口状态 + .currentA(info.getCurrent()) // 电流 + .voltageA(info.getVoltage()) // 电压 + .soc(new BigDecimal(info.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间 + .endTime(DateUtils.getDateTime()) // 本次采样时间 + .totalPower(info.getChargingDegree()) // 累计充电量 + .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费 + .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费 + .totalMoney(info.getChargingAmount()) // 已充金额 + + .build(); + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); + // 调用平台接口 + String jsonString = JSON.toJSONString(vo); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 获取桩列表信息 + * + * @param pileStationInfo + * @return + */ + private List getPileList(PileStationInfo pileStationInfo) { + List resultList = new ArrayList<>(); + // 通过站点id查询桩基本信息 + List list = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId())); + // 封装成中电联平台对象 + for (PileBasicInfo pileBasicInfo : list) { + EquipmentInfo equipmentInfo = new EquipmentInfo(); + String pileSn = pileBasicInfo.getSn(); + + equipmentInfo.setEquipmentID(pileSn); + + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + equipmentInfo.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType())); + equipmentInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + + List connectorList = getConnectorList(pileBasicInfo); + equipmentInfo.setConnectorInfos(connectorList); + + resultList.add(equipmentInfo); + } + return resultList; + } + + /** + * 获取枪口列表 + * + * @param pileBasicInfo + * @return + */ + private List getConnectorList(PileBasicInfo pileBasicInfo) { + List resultList = new ArrayList<>(); + + List list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn()); + for (PileConnectorInfo pileConnectorInfo : list) { + ConnectorInfo connectorInfo = new ConnectorInfo(); + + connectorInfo.setConnectorID(pileConnectorInfo.getPileConnectorCode()); + String pileSn = pileConnectorInfo.getPileSn(); + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3; + + connectorInfo.setConnectorType(connectorType); + // 车位号 + if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) { + connectorInfo.setParkNo(pileConnectorInfo.getParkNo()); + } + connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); + connectorInfo.setNationalStandard(2); + // if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) { + // // 如果不是单枪,则枪口功率需要除以枪口数量 + // String ratedPowerStr = modelInfo.getRatedPower(); + // BigDecimal ratedPower = new BigDecimal(ratedPowerStr); + // connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP)); + // }else { + // } + connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + + resultList.add(connectorInfo); + } + + return resultList; + } + + @Override + public String pushOrderInfo(QueryOrderDTO dto) { + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + // 根据站点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, ningBoSecretInfoVO); + logger.info("订单:{} 推送结果:{}", orderCode, result); + }catch (Exception e) { + logger.error("订单:{} 推送error, ", orderCode, e); + } + } + return "Success"; + } + + /** + * 获取宁波平台密钥信息 + * @return + */ + private ThirdPartySecretInfoVO getNingBoSecretInfoVO() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.NING_BO_PLATFORM.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } +}