diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java index ec192f0a9..5cd824320 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java @@ -2,7 +2,6 @@ package com.jsowell.api.thirdparty; import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; -import com.jsowell.common.core.domain.AjaxResult; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; @@ -219,4 +218,4 @@ public class GuiZhouPlatformController extends ThirdPartyBaseController { return response; } -} \ No newline at end of file +} diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HuZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HuZhouController.java index 724bb28ac..11659c812 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HuZhouController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HuZhouController.java @@ -13,7 +13,6 @@ import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; -import io.minio.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.*; 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-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java index 098c2d9cb..16038e4de 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java @@ -1,32 +1,22 @@ package com.jsowell.api.thirdparty; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; -import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; -import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.dto.*; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.pile.thirdparty.CommonParamsDTO; -import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; -import com.jsowell.thirdparty.platform.service.impl.ZhongDianLianPlatformServiceImpl; -import com.jsowell.thirdparty.platform.util.Cryptos; -import com.jsowell.thirdparty.platform.util.Encodes; -import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; 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.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; import java.util.Map; /** diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/OrderBasicInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/OrderBasicInfoController.java index ef07e5323..68a39ee45 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/OrderBasicInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/OrderBasicInfoController.java @@ -1,7 +1,6 @@ package com.jsowell.web.controller.pile; import com.alibaba.fastjson2.JSON; -import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableMap; import com.jsowell.common.annotation.Log; import com.jsowell.common.core.controller.BaseController; diff --git a/jsowell-admin/src/main/resources/application-dev.yml b/jsowell-admin/src/main/resources/application-dev.yml index 019e1fa09..7f319657c 100644 --- a/jsowell-admin/src/main/resources/application-dev.yml +++ b/jsowell-admin/src/main/resources/application-dev.yml @@ -266,6 +266,6 @@ dubbo: password: 79HMu!6nlOiLm^Q[ protocol: name: dubbo - port: 20880 + port: -1 consumer: check: false # 关键配置:启动时不检查提供者 diff --git a/jsowell-admin/src/main/resources/application-sit.yml b/jsowell-admin/src/main/resources/application-sit.yml index aa713d8cd..b7767686a 100644 --- a/jsowell-admin/src/main/resources/application-sit.yml +++ b/jsowell-admin/src/main/resources/application-sit.yml @@ -8,7 +8,7 @@ spring: # redis 配置 redis: # 地址 - host: 192.168.8.2 + host: 192.168.0.32 # 端口,默认为6379 port: 6379 # 数据库索引 @@ -35,9 +35,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://192.168.8.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.0.32:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: jsowell_dev -# url: jdbc:mysql://192.168.8.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# url: jdbc:mysql://192.168.0.32:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # username: jsowell_prd_copy password: 123456 # 从库数据源 @@ -89,7 +89,7 @@ spring: # rabbitmq配置 sit rabbitmq: - host: 192.168.8.2 + host: 192.168.0.32 port: 5672 username: admin password: admin @@ -257,7 +257,7 @@ dubbo: name: wcc-server qosEnable: false registry: - address: nacos://192.168.8.2:8848 + address: nacos://192.168.0.32:8848 parameters: namespace: e328faaf-8516-42d0-817a-7406232b3581 username: nacos diff --git a/jsowell-common/src/main/java/com/jsowell/common/config/mq/DirectRabbitConfig.java b/jsowell-common/src/main/java/com/jsowell/common/config/mq/DirectRabbitConfig.java index a865855ee..72fa9643d 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/config/mq/DirectRabbitConfig.java +++ b/jsowell-common/src/main/java/com/jsowell/common/config/mq/DirectRabbitConfig.java @@ -35,10 +35,10 @@ public class DirectRabbitConfig { // return new Queue(RabbitConstants.QUEUE_HEART_BEAT); // } // - // @Bean - // public Queue realtimeDataQueue() { - // return new Queue(RabbitConstants.QUEUE_REALTIME_DATA); - // } + @Bean + public Queue realtimeDataQueue() { + return new Queue(RabbitConstants.QUEUE_REALTIME_DATA); + } // // @Bean // public Queue priceSenderQueue() { @@ -88,10 +88,10 @@ public class DirectRabbitConfig { // return BindingBuilder.bind(heartBeatQueue()).to(exchange()).with(RabbitConstants.QUEUE_HEART_BEAT); // } // - // @Bean - // public Binding bindRealtimeData() { - // return BindingBuilder.bind(realtimeDataQueue()).to(exchange()).with(RabbitConstants.QUEUE_REALTIME_DATA); - // } + @Bean + public Binding bindRealtimeData() { + return BindingBuilder.bind(realtimeDataQueue()).to(exchange()).with(RabbitConstants.QUEUE_REALTIME_DATA); + } // // @Bean // public Binding bindPriceSender() { 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..417933293 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", "运维平台", "MA27QY0F4"), ; private String typeCode; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/dto/EquipmentInfoDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfoDTO.java similarity index 100% rename from jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/dto/EquipmentInfoDTO.java rename to jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfoDTO.java diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/zdl/EquipBusinessPolicyVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/zdl/EquipBusinessPolicyVO.java index 699fde1e8..7c0d5eaba 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/zdl/EquipBusinessPolicyVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/zdl/EquipBusinessPolicyVO.java @@ -1,5 +1,6 @@ package com.jsowell.pile.vo.zdl; +import com.alibaba.fastjson2.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -82,5 +83,16 @@ public class EquipBusinessPolicyVO { */ @JsonProperty(value = "SevicePrice") private BigDecimal servicePrice; + + /** + * 单位:元/度,小数点后 4 位。 基础设施运营商和客户运营商协议电 价。无协议电价,则填写基础电费价 格 + */ + @JSONField(name = "DiscountElecPrice") + private BigDecimal discountElecPrice; + + + @JSONField(name = "DiscountServicePrice") + private BigDecimal discountServicePrice; + } } 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..1bb3941ec 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 @@ -1,7 +1,6 @@ package com.jsowell.thirdparty.common; 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.util.StringUtils; @@ -11,15 +10,11 @@ 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.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.spec.InvalidKeySpecException; import java.util.List; /** diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo1.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo1.java new file mode 100644 index 000000000..6064970fb --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo1.java @@ -0,0 +1,512 @@ +package com.jsowell.thirdparty.platform.common; + + +import com.alibaba.fastjson2.annotation.JSONField; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.thirdparty.publicinfo.BaseStationInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 充电站信息 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +public class StationInfo1 extends BaseStationInfo { + /** + * 充电站ID Y + * 对接平台自定义的唯一编码 + * <=20字符 + */ + @JSONField(name = "StationID") + private String stationID; + + /** + * 运营商ID Y + * 运营商ID + * 9字符 + */ + @JSONField(name = "OperatorID") + private String operatorID; + + /** + * 设备所属运营商ID Y + * 设备所属运营商组织机构代码 + * 9字符 + */ + @JSONField(name = "EquipmentOwnerID") + private String equipmentOwnerID; + + /** + * 充电站名称 Y + * 充电站名称的描述 + * <=50字符 + */ + @JSONField(name = "StationName") + private String stationName; + + /** + * 充电站国家代码 Y + * 比如CN + * 2字符 + */ + @JSONField(name = "CountryCode") + private String countryCode; + + /** + * 充电站省市辖区编码 Y + * 填写内容为参照GB/T 2260-2007 + * 20字符 + */ + @JSONField(name = "AreaCode") + private String areaCode; + + /** + * 街道编码 + */ + @JSONField(name = "StreetCode") + private String streetCode; + + /** + * 详细地址 Y + * <=50字符 + */ + @JSONField(name = "Address") + private String address; + + /** + * 站点电话 Y + * 能够联系场站工作人员进行协助的联系电话 + * <=30字符 + */ + @JSONField(name = "StationTel") + private String stationTel; + + /** + * 服务电话 Y + * 平台服务电话,例如400的电话 + * <=30字符 + */ + @JSONField(name = "ServiceTel") + private String serviceTel; + + /** + * 站点类型 Y + * 1-公共 + * 50-个人 + * 100-公交(专用) + * 101-环卫(专用) + * 102-物流(专用) + * 103-出租车(专用) + * 104-分时租赁(专用) + * 105-小区共享(专用) + * 106-单位(专用) + * 255-其他 + */ + @JSONField(name = "StationType") + private Integer stationType; + + /** + * 站点状态 Y + * 0:未知 + * 1:建设中 + * 5:关闭下线 + * 6:维护中 + * 50:正常使用 + */ + @JSONField(name = "StationStatus") + private Integer stationStatus; + + /** + * 经度 Y + * GCJ-02坐标系 + * 保留小数点后6位 + */ + @JSONField(name = "StationLng") + private BigDecimal stationLng; + + /** + * 纬度 Y + * GCJ-02坐标系 + * 保留小数点后6位 + */ + @JSONField(name = "StationLat") + private BigDecimal stationLat; + + /** + * 站点引导 N + * 描述性文字,用于引导车主找到充电车位 + * <=100字符 + */ + @JSONField(name = "SiteGuide") + private String siteGuide; + + /** + * 站点额定总功率 + * 单位 kW,保留 1 位小数 + */ + @JSONField(name = "RatedPower") + private BigDecimal ratedPower; + + /** + * 建设场所 Y + * 1:居民区 + * 2:公共机构 + * 3:企事业单位 + * 4:写字楼 + * 5:工业园区 + * 6:交通枢纽 + * 7:大型文体设施 + * 8:城市绿地 + * 9:大型建筑配建停车场 + * 10:路边停车位 + * 11:城际高速服务区 + * 12:风景区 + * 13:公交场站 + * 14:加油加气站 + * 15:出租车 + * 255:其他 + */ + @JSONField(name = "Construction") + private Integer construction; + + /** + * 站点照片 N + * 充电设备照片、充电车位照片、停车场入口照片 + */ + @JSONField(name = "Pictures") + private List pictures; + + /** + * 使用车型描述 N + * 描述该站点接受的车大小以及类型,如大巴、物流车、私家乘用车、出租车等 + * <=100字符 + */ + @JSONField(name = "MatchCars") + private List matchCars; + + /** + * 车位楼层及数量描述 N + * 车位楼层以及数量信息 + * <=100字符 + */ + @JSONField(name = "ParkInfo") + private String parkInfo; + + /** + * 营业时间 N + * 营业时间描述,推荐格式:周一至周日00:00-24:00 + * <=100字符 + */ + @JSONField(name = "BusineHours") + private String busineHours; + + /** + * 充电电费率 N + * 充电费描述,推荐格式:XX 元/度 + * <=256字符 + */ + @JSONField(name = "ElectricityFee") + private String electricityFee; + + /** + * 服务费率 N + * 服务费率描述,推荐格式:XX 元/度 + * <=100字符 + */ + @JSONField(name = "ServiceFee") + private String serviceFee; + + /** + * 是否停车免费 0:否 1:是 + */ + @JSONField(name = "ParkFree") + private Integer parkFree; + + /** + * 停车费 N + * 停车费率描述 + */ + @JSONField(name = "ParkFee") + private String parkFee; + + /** + * 支付方式 N + * 支付方式:刷卡、线上、现金 其中电子钱包类卡为刷卡,身份鉴权卡、微信/ 支付宝、APP为线上 + * <=20字符 + */ + @JSONField(name = "Payment") + private String payment; + + /** + * 备注 N + * 其他备注信息 + * <=100字符 + */ + @JSONField(name = "Remark") + private String remark; + + /** + * 充电设备信息列表 Y + * 该充电站所有充电设备信息对象集合 + */ + @JSONField(name = "EquipmentInfos") + private List equipmentInfos; + + /** + * 投建日期 + * + */ + @JSONField(name = "RunDate") + private String runDate; + + /** + * 投建日期 + * + */ + @JSONField(name = "BuildDate") + private String buildDate; + + /** + * 是否独立报桩 (0-否;1-是) Y + * 如果是独立报桩需要填写户号以及容量 + */ + @JSONField(name = "IsAloneApply") + private Integer isAloneApply; + + /** + * 户号 N + * 国网电费账单户号 + */ + @JSONField(name = "AccountNumber") + private String accountNumber; + + /** + * 容量(单位KW) N + * 独立电表申请的功率 + */ + @JSONField(name = "Capacity") + private BigDecimal capacity; + + /** + * 峰谷分时 + * 0:否 1:是 + */ + @JSONField(name = "PeriodFee") + private Integer periodFee; + + /** + * 视频监控配套情况 + * 0:无 1:有 + */ + @JSONField(name = "VideoMonitor") + private Integer videoMonitor; + + /** + * 是否是公共停车场库 (0-否;1-是) Y + * 如果是公共停车场库需要填写场库编号 + */ + @JSONField(name = "IsPublicParkingLot") + private Integer isPublicParkingLot; + + /** + * 停车场库编号 N + * 公共停车场库编号 + */ + @JSONField(name = "ParkingLotNumber") + private String parkingLotNumber; + + /** + * 停车场产权方 N + * 停车场产权人 + */ + // private String ParkOwner; + + /** + * 停车场管理方 N + * 停车场管理人(如:XX 物业) + */ + // private String ParkManager; + + /** + * 全天开放 Y + * 是否全天开放(0-否;1-是),如果为0,则营业时间必填 + */ + @JSONField(name = "OpenAllDay") + private Integer openAllDay; + + + /** + * 最低单价 Y + * 最低充电电费率 + */ + @JSONField(name = "MinElectricityPrice") + private BigDecimal minElectricityPrice; + + /** + * 停车收费类型 Y + * 0:停车收费; + * 1:停车免费; + * 2:限时免费; + * 3:充电限免 + */ + @JSONField(name = "ParkFeeType") + private Integer parkFeeType; + + /** + * 是否靠近卫生间(0-否;1-是) Y + */ + @JSONField(name = "ToiletFlag") + private Integer toiletFlag; + + /** + * 是否靠近便利店(0-否;1-是) Y + */ + @JSONField(name = "StoreFlag") + private Integer storeFlag; + + /** + * 是否靠近餐厅(0-否;1-是) Y + */ + @JSONField(name = "RestaurantFlag") + private Integer restaurantFlag; + + /** + * 是否靠近休息室(0-否;1-是) Y + */ + @JSONField(name = "LoungeFlag") + private Integer loungeFlag; + + /** + * 是否有雨棚(0-否;1-是) Y + */ + @JSONField(name = "CanopyFlag") + private Integer canopyFlag; + + /** + * 是否有小票机(0-否;1-是) Y + */ + @JSONField(name = "PrinterFlag") + private Integer printerFlag; + + /** + * 是否有道闸(0-否;1-是) Y + */ + @JSONField(name = "BarrierFlag") + private Integer barrierFlag; + + /** + * 是否有地锁(0-否;1-是) Y + */ + @JSONField(name = "ParkingLockFlag") + private Integer parkingLockFlag; + + /** + * 投入运营日期 + */ + @JSONField(name = "OfficialRunTime") + private String officialRunTime; + + /** + * 站点类别 + * 1:充电站 + * 2:换电站 + * 3:充换电一体站 + */ + @JSONField(name = "StationClassification") + private Integer stationClassification; + + /** + * 站点类别子分类 + * 1:集中式:专营充电业务的场站 + * 2:分散式:充电和停车功能复合的场站 + */ + @JSONField(name = "SubStationClassification") + private Integer subStationClassification; + + /** + * 充电接口标准支持 + * 0:国标 + * 1:欧标 + */ + @JSONField(name = "SupportStandard") + private String supportStandard; + + /** + * 土地所有权 + * 1: 国有临时用地 + * 2: 国有建设用地 + * 3: 集体土地 + */ + @JSONField(name = "OwnershipOfLand") + private Integer ownershipOfLand; + + /** + * 城市用地分类 + * 1: 居住用地 + * 2: 商业服务用地 + * 3: 公共管理与服务设施用地 + * 4: 工业用地 + * 5: 物流仓储用地 + * 6: 交通设施用地 + * 7: 绿地与广场用地 + * 8:公用设施用地 + * 255: 其它用地 + */ + @JSONField(name = "LandProperty") + private Integer landProperty; + + /** + * 服务车辆类型 + * 1:公交车 + * 2:出租车 + * 3:物流车 + * 4:通勤车 + * 5:大巴车 + * 6:私家车 + * 7:环卫车 + * 8:泥头、重卡车 + * 9:公务车 + * 10:网约车 + * 11:港口码头作业车 + * 255:其它 + */ + @JSONField(name = "ServiceCarTypes") + private String serviceCarTypes; + + /** + * 充电计费信息 + */ + @JSONField(name = "PolicyInfos") + private List policyInfos; + + + @Data + public static class PolicyInfo{ + @JSONField(name = "StartTime") + private String startTime; + + @JSONField(name = "ElecPrice") + private BigDecimal elecPrice; + + @JSONField(name = "ServicePrice") + private BigDecimal servicePrice; + + /** + * 单位:元/度,小数点后 4 位。 基础设施运营商和客户运营商协议电 价。无协议电价,则填写基础电费价 格 + */ + @JSONField(name = "DiscountElecPrice") + private BigDecimal discountElecPrice; + + @JSONField(name = "DiscountServicePrice") + private BigDecimal discountServicePrice; + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo1.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo1.java new file mode 100644 index 000000000..10c078a49 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo1.java @@ -0,0 +1,174 @@ +package com.jsowell.thirdparty.platform.domain; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.jsowell.thirdparty.platform.common.StationInfo; +import com.jsowell.thirdparty.platform.common.StationInfo1; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * 吉林省平台-充电站信息1 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +public class SupStationInfo1 extends StationInfo1 { + /** + * 充换电站唯一编码 + * 行政区划代码,区县地区码(6位)+运营商ID(9位)+充换电站ID + */ + @JSONField(name = "StationUniqueNumber") + private String stationUniqueNumber; + + /** + * 充换电站所在县以下行政区划代码 + * 填写内容为12位行政区划代码,1-6位为县及以上行政区划代码,7-12位为县以下区划代码; + * 参考地址:http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2022/ + */ + @JSONField(name = "AreaCodeCountryside") + private String areaCodeCountryside; + + + @JSONField(name = "TownCode") + private String townCode; + + /** + * 站点分类 + * 1:充电站 + * 2:换电站 + * 3:充换电一体站 + */ + @JSONField(name = "StationClassification") + private Integer stationClassification; + + /** + * 7*24小时营业 + * 0:否 + * 1:是 + */ + @JSONField(name = "RoundTheClock") + private Integer roundTheClock; + + + /** + * 停车费类型 + * 0:免费 + * 1:不免费 + * 2:限时免费停车 + * 3:充电限时减免 + * 255:参考场地实际收费标准 + */ + @JSONField(name = "ParkType") + private Integer parkType; + + /** + * 电费类型 + * 1:商业用电 + * 2:普通工业用电 + * 3:大工业用电 + * 4:其它用电 + */ + @JSONField(name = "ElectricityType") + private Integer electricityType; + + /** + * 报装类型 + * 是否独立报装: + * 0:否 + * 1:是 + */ + @JSONField(name = "BusinessExpandType") + private Integer businessExpandType; + + /** + * 正式投运时间 + */ + @JSONField(name = "OfficialRunTime") + private String officialRunTime; + + /** + * 建站时间 + */ + @JSONField(name = "BuildTime") + private String buildTime; + + /** + * 充换电站方位 + * 1:地面-停车场 + * 2:地面-路侧 + * 3:地下停车场 + * 4:立体式停车楼 + */ + @JSONField(name = "StationOrientation") + private String stationOrientation; + + /** + * 充换电站建筑面积 + * 该充电场站建设用 地面积 + */ + @JSONField(name = "StationArea") + private String stationArea; + + /** + * 充换电站人工值守 + * 0:无 + * 1:有 + */ + @JSONField(name = "HavePerson") + private String havePerson; + + /** + * 周边配套设施 + * 1:卫生间 + * 2:便利店 + * 3:餐厅 + * 4:休息室 + * 5:雨棚 + */ + @JSONField(name = "SupportingFacilities") + private String supportingFacilities; + + /** + * 设备所属方名称 + */ + @JSONField(name = "EquipmentOwnerName") + private String equipmentOwnerName; + + /** + * 供电类型 + * 1:直供电 2:转供电 + */ + @JSONField(name = "SupplyType") + private Integer supplyType; + + /** + * 供电局用户编号 + */ + @JSONField(name = "ResidentNo") + private String residentNo; + + /** + * 表号 + */ + @JSONField(name = "WattHourMeterNo") + private String wattHourMeterNo; + + /** + * 外电功率 + */ + @JSONField(name = "ForwardPower") + private String forwardPower; + + /** + * 充电站全省 唯一备案号 + */ + @JSONField(name = "RecordUniqueNo") + private String recordUniqueNo; + + private List PolicyInfos; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/SupStationInfoDTO1.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/SupStationInfoDTO1.java new file mode 100644 index 000000000..7031f3409 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/SupStationInfoDTO1.java @@ -0,0 +1,27 @@ +package com.jsowell.thirdparty.platform.dto; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.jsowell.pile.thirdparty.EquipmentInfoDTO; +import com.jsowell.thirdparty.platform.domain.SupStationInfo; +import com.jsowell.thirdparty.platform.domain.SupStationInfo1; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + + +/** + * 内蒙古平台站点信息 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +public class SupStationInfoDTO1 extends SupStationInfo1 { + + @JSONField(name = "EquipmentInfos") + private List equipmentInfosDTO; + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index 5d97b4b58..003a67bf8 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -1,6 +1,5 @@ package com.jsowell.thirdparty.platform.service.impl; -import cn.hutool.core.util.PageUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageHelper; @@ -10,11 +9,9 @@ import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.core.redis.RedisCache; -import com.jsowell.common.enums.lianlian.StationPaymentEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; 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.*; @@ -33,7 +30,6 @@ 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.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO; @@ -45,7 +41,6 @@ import com.jsowell.thirdparty.platform.domain.*; 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.GBSignUtils; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; @@ -59,7 +54,6 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; -import java.text.DecimalFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Function; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HuZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HuZhouPlatformServiceImpl.java index d64640631..66f13f9bb 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HuZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HuZhouPlatformServiceImpl.java @@ -11,7 +11,6 @@ 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.*; @@ -26,12 +25,10 @@ import com.jsowell.pile.thirdparty.ConnectorInfo; import com.jsowell.pile.thirdparty.EquipmentInfo; 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.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileModelInfoVO; -import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/JiLinPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/JiLinPlatformServiceImpl.java index 04b9c7672..e8fa7f4bf 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/JiLinPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/JiLinPlatformServiceImpl.java @@ -14,7 +14,6 @@ import com.jsowell.common.enums.ykc.*; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; import com.jsowell.pile.domain.*; -import com.jsowell.pile.domain.ykcCommond.RemoteControlGroundLockCommand; import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; import com.jsowell.pile.dto.*; import com.jsowell.pile.mapper.PileBasicInfoMapper; @@ -38,8 +37,7 @@ import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.vo.*; import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.dto.ChargeOrderInfoDTO; -import com.jsowell.thirdparty.platform.dto.QueryParkingLockDTO; -import com.jsowell.thirdparty.platform.dto.SupStationInfoDTO; +import com.jsowell.thirdparty.platform.dto.SupStationInfoDTO1; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.Cryptos; @@ -219,19 +217,19 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { public Map queryStationsInfo(QueryStationInfoDTO dto) { int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); int pageSize = dto.getPageSize() == null ? 50 : dto.getPageSize(); - dto.setThirdPlatformType("25"); + dto.setThirdPlatformType(thirdPlatformType); PageUtils.startPage(pageNo, pageSize); List stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto); if (CollectionUtils.isEmpty(stationInfos)) { // 未查到数据 return null; } - ThirdPartySecretInfoVO thirdPartySecretInfoVO = null; + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getJiLinSecretInfo(); PageInfo pageInfo = new PageInfo<>(stationInfos); - List resultList = new ArrayList<>(); + List resultList = new ArrayList<>(); for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { - SupStationInfoDTO stationInfo = new SupStationInfoDTO(); + SupStationInfoDTO1 stationInfo = new SupStationInfoDTO1(); stationInfo.setStationID(String.valueOf(pileStationInfo.getId())); stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码 String organizationCode = pileStationInfo.getOrganizationCode(); @@ -268,6 +266,9 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { // 站点图片 if (StringUtils.isNotBlank(pileStationInfo.getPictures())) { stationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(","))); + }else{ + // 无照片传空数组 + stationInfo.setPictures(Lists.newArrayList()); } stationInfo.setRoundTheClock(Constants.one); //计费信息 @@ -277,24 +278,28 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { if (CollectionUtils.isEmpty(billingPriceVOList)) { return null; } - SupStationInfo.PolicyInfo policyInfo = null; + SupStationInfo1.PolicyInfo policyInfo = null; // 获取计费模板 - List policyInfoList = new ArrayList<>(); + List policyInfoList = new ArrayList<>(); for (BillingPriceVO billingPriceVO : billingPriceVOList) { // 将时段开始时间、电费、服务费信息进行封装 - policyInfo = new SupStationInfo.PolicyInfo(); + policyInfo = new SupStationInfo1.PolicyInfo(); String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 // 需要将中间的冒号去掉,改为 000000 格式 String replace = StringUtils.replace(startTime, ":", ""); - policyInfo.setStartTime(replace); - policyInfo.setElecFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); - policyInfo.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + BigDecimal elecPrice = new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4 , BigDecimal.ROUND_HALF_UP); + BigDecimal servicePrice = new BigDecimal(billingPriceVO.getServicePrice()).setScale(4 , BigDecimal.ROUND_HALF_UP); + policyInfo.setStartTime(replace); + policyInfo.setElecPrice(elecPrice); + policyInfo.setServicePrice(servicePrice); + policyInfo.setDiscountElecPrice(elecPrice); + policyInfo.setDiscountServicePrice(servicePrice); policyInfoList.add(policyInfo); } stationInfo.setPolicyInfos(policyInfoList); - stationInfo.setParkType("255"); + stationInfo.setParkType(255); stationInfo.setElectricityType(Constants.one); stationInfo.setBusinessExpandType(Integer.valueOf(pileStationInfo.getAloneApply())); //是否独立报装 //0,否 1,是 // 报装电源容量 @@ -340,7 +345,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public String notificationStationInfo(String stationId) { - List stationInfos = new ArrayList<>(); + List stationInfos = new ArrayList<>(); // 通过id查询站点相关信息 PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); // 查询相关配置信息 @@ -355,7 +360,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { // 组装中电联平台所需要的数据格式 - SupStationInfoDTO info = SupStationInfoDTO.builder() + SupStationInfoDTO1 info = SupStationInfoDTO1.builder() .stationID(stationId) .operatorID(Constants.OPERATORID_JIANG_SU) .stationName(pileStationInfo.getStationName()) @@ -363,7 +368,6 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { .areaCode(pileStationInfo.getAreaCode()) .address(pileStationInfo.getAddress()) .serviceTel(pileStationInfo.getStationTel()) - .stationClassification(Constants.one) .stationType(Integer.valueOf(pileStationInfo.getStationType())) .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) @@ -372,12 +376,12 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { .stationLat(new BigDecimal(pileStationInfo.getStationLat()).setScale(6, RoundingMode.HALF_UP)) .construction(Integer.valueOf(pileStationInfo.getConstruction())) .roundTheClock(Constants.one)//7*24小时营业 0:否 1:是 - .parkType("255")//0:免费 1:不免费 2:限时免费停车 3:充电限时减免 255:参考场地实际收费标准 + .parkType(255)//0:免费 1:不免费 2:限时免费停车 3:充电限时减免 255:参考场地实际收费标准 .electricityType(Constants.one) //1:商业用电 2:普通工业用电 3:大工业用电 4:其他用电 - .businessExpandType(Constants.one) + .businessExpandType(Integer.valueOf(pileStationInfo.getAloneApply())) .videoMonitor(Constants.zero) - .equipmentOwnerName("通榆县公路客运总站(通榆县开通客运服务有限公司)") - .supplyType(Constants.one) +// .equipmentOwnerName("通榆县公路客运总站(通榆县开通客运服务有限公司)") +// .supplyType(Constants.one) .build(); // 报装电源容量 @@ -402,19 +406,23 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { if (CollectionUtils.isEmpty(billingPriceVOList)) { return null; } - SupStationInfo.PolicyInfo policyInfo = null; + SupStationInfo1.PolicyInfo policyInfo = null; // 获取计费模板 - List policyInfoList = new ArrayList<>(); + List policyInfoList = new ArrayList<>(); for (BillingPriceVO billingPriceVO : billingPriceVOList) { // 将时段开始时间、电费、服务费信息进行封装 - policyInfo = new SupStationInfo.PolicyInfo(); + policyInfo = new SupStationInfo1.PolicyInfo(); String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 // 需要将中间的冒号去掉,改为 000000 格式 String replace = StringUtils.replace(startTime, ":", ""); - policyInfo.setStartTime(replace); - policyInfo.setElecFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); - policyInfo.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + BigDecimal elecPrice = new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4 , BigDecimal.ROUND_HALF_UP); + BigDecimal servicePrice = new BigDecimal(billingPriceVO.getServicePrice()).setScale(4 , BigDecimal.ROUND_HALF_UP); + policyInfo.setStartTime(replace); + policyInfo.setElecPrice(elecPrice); + policyInfo.setServicePrice(servicePrice); + policyInfo.setDiscountElecPrice(elecPrice); + policyInfo.setDiscountServicePrice(servicePrice); policyInfoList.add(policyInfo); } info.setPolicyInfos(policyInfoList); @@ -529,8 +537,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { Map map = new LinkedHashMap<>(); map.put("StationStatusInfos", stationStatusInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO.getOurDataSecret(), - thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); return resultMap; } @@ -666,7 +673,8 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { 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)); - + policyInfo.setDiscountElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + policyInfo.setDiscountServicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); policyInfoList.add(policyInfo); } @@ -1010,8 +1018,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { log.info("请求参数:{}", JSON.toJSONString(json)); - return ThirdPartyPlatformUtils.generateResultMapV2(json, jiLinSecretInfo.getOurDataSecret() - , jiLinSecretInfo.getOurDataSecretIv(), jiLinSecretInfo.getOurSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(json, jiLinSecretInfo); } @@ -1273,8 +1280,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { Map map = new LinkedHashMap<>(); map.put("StationStats", supStationStatsInfo); - Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), - thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); return resultMap; } @@ -1711,6 +1717,8 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { chargeOrderInfo.setConnectorID(orderBasicInfo.getPileConnectorCode()); chargeOrderInfo.setStartSoc(startSoc.setScale(1, BigDecimal.ROUND_HALF_UP)); chargeOrderInfo.setEndSoc(endSoc.setScale(1, BigDecimal.ROUND_HALF_UP)); + chargeOrderInfo.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + chargeOrderInfo.setEndTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())); // 累计充电量 chargeOrderInfo.setTotalPower(orderDetail.getTotalUsedElectricity().setScale(4, BigDecimal.ROUND_HALF_UP)); chargeOrderInfo.setPushTimeStamp(DateUtils.getDateTime()); // 推送时间戳 @@ -1767,8 +1775,6 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { List connectorList = getConnectorList(pileDetailInfoVO,pileStationInfo); equipmentInfo.setConnectorInfos(connectorList); - equipmentInfo.setConnectorInfos(connectorList); - resultList.add(equipmentInfo); } @@ -1819,7 +1825,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { connectorInfo.setNationalStandard(2); connectorInfo.setAuxPower(3); connectorInfo.setOpreateStatus(Integer.valueOf(pileStationInfo.getStationStatus())); - connectorInfo.setOperateStatus(Integer.valueOf(pileStationInfo.getStationStatus())); +// connectorInfo.setOperateStatus(Integer.valueOf(pileStationInfo.getStationStatus())); String parkingLockFlag = pileStationInfo.getParkingLockFlag() == null ? "0" : pileStationInfo.getParkingLockFlag(); connectorInfo.setHasLock(Integer.valueOf(parkingLockFlag)); //有无地锁 0 无 1 有 @@ -1832,7 +1838,7 @@ public class JiLinPlatformServiceImpl implements ThirdPartyPlatformService { } else { // 为null时,使用默认生成的 String pileConnectorQrCodeUrl = pileConnectorInfoService.getPileConnectorQrCodeUrl(connectorInfo.getConnectorID()); - connectorInfo.setChargingQrCode(pileConnectorQrCodeUrl+pileConnectorCode); // https://api.jsowellcloud.com/app-xcx-h5/pile/connectorDetail/8825000001536502 + connectorInfo.setChargingQrCode(pileConnectorQrCodeUrl); // https://api.jsowellcloud.com/app-xcx-h5/pile/connectorDetail/8825000001536502 } connectorInfo.setEquipmentClassification(Constants.one); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java index 4643ed0dc..cdfe2f4a9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java @@ -23,7 +23,6 @@ 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.common.util.bean.BeanUtils; import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; import com.jsowell.pile.dto.*; @@ -41,7 +40,6 @@ import com.jsowell.pile.vo.lianlian.PushStationFeeVO; import com.jsowell.pile.vo.lianlian.StationElectStatsInfos; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; -import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.vo.*; import com.jsowell.thirdparty.platform.common.ChargeDetail; 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..3418b2d00 --- /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.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); + vo.setOperatorID(dto.getOperatorID()); + logger.info("queryToken result: " + JSON.toJSONString(vo)); + 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 = getYunWeiSecretInfoVO(); + 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 = getYunWeiSecretInfoVO(); + // 根据站点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 = getYunWeiSecretInfoVO(); + + 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 = getYunWeiSecretInfoVO(); + 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 = getYunWeiSecretInfoVO(); + 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 = getYunWeiSecretInfoVO(); + // 生成订单 + 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 = getYunWeiSecretInfoVO(); + + // 截取桩号 + // 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 = getYunWeiSecretInfoVO(); + 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 = getYunWeiSecretInfoVO(); + // 根据订单号查询订单信息 + 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(QueryOrder2DTO 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 getYunWeiSecretInfoVO() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java index 88e870ed1..17b8ef6a7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java @@ -24,7 +24,6 @@ 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;