From 89cea0f19d05c885f810336104ad330912b966fc Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 18 Jun 2025 09:36:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=96=B0=E8=BF=90=E5=B8=B8=E7=95=85=E5=85=85=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/thirdparty/ChangZhouController.java | 470 ++++++++++ .../thirdparty/ThirdPlatformTypeEnum.java | 1 + .../impl/ChangZhouPlatformServiceImpl.java | 884 ++++++++++++++++++ 3 files changed, 1355 insertions(+) create mode 100644 jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java new file mode 100644 index 000000000..01036c1c6 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java @@ -0,0 +1,470 @@ +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.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; + +/** + * 常州对接Controller + */ +@Anonymous +@RestController +@RequestMapping("/changzhou") +public class ChangZhouController extends ThirdPartyBaseController { + private final String platformName = "新运常畅充"; + + + private final String platformType = ThirdPlatformTypeEnum.CHANG_ZHOU_PLATFORM.getTypeCode(); + + + @Autowired + @Qualifier("changZhouPlatformServiceImpl") + 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 { + // 校验令牌 + 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(Integer.parseInt(map.get("Ret")) , map.get("Msg") , 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(Integer.parseInt(map.get("Ret")) , map.get("Msg") , 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(Integer.parseInt(map.get("Ret")) , map.get("Msg") , 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(Integer.parseInt(map.get("Ret")) , map.get("Msg") , 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; + } + +} 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 0e2bb41da..c5394243d 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 @@ -35,6 +35,7 @@ public enum ThirdPlatformTypeEnum { HE_NAN_PLATFORM("22", "河南省平台", "050880341"), WEI_WANG_XIN_DIAN("23", "微网新电", "MA005DBW1"), HU_ZHOU_PLATFORM("24", "湖州市监管平台", "MA27U00HZ"), + CHANG_ZHOU_PLATFORM("25", "新运常畅充", "0585PCW57"), ; private String typeCode; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java new file mode 100644 index 000000000..286629eb0 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java @@ -0,0 +1,884 @@ +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.CommonParamsDTO; +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.ThirdPartyStationInfoVO; +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.ConnectorChargeStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; +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 lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.bouncycastle.crypto.CryptoException; +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.*; + +@Service +@Slf4j +public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { + + private final String thirdPlatformType = ThirdPlatformTypeEnum.CHANG_ZHOU_PLATFORM.getTypeCode(); + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileModelInfoService pileModelInfoService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private YKCPushCommandService ykcPushCommandService; + + @Autowired + private PileRemoteService pileRemoteService; + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + + /** + * 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); + + return ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getTheirDataSecret(), + thirdPartySecretInfoVO.getTheirDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); + } + + + + /** + * 查询站点信息 + * @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 = getChangZhouSecretInfo(); + + 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("ItemSize", resultList.size()); + map.put("PageCount", pageInfo.getPages()); + map.put("PageNo", pageInfo.getPageNum()); + map.put("StationInfos", resultList); + + + log.info("query_token 返回参数:{}", JSON.toJSONString(map)); + + return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + } + + + /** + * 设备状态推送 + * @param stationId 站点id + * @param pileConnectorCode 充电桩枪口编号 + * @param status + * @param secretInfoVO + * @return + */ + @Override + public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // 通过站点id查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + 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_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); + log.info("参数:{}", jsonString); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + log.info("token:{}", token); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + log.info("返回结果:{}", result); + return result; + } + + /** + * 设备接口状态查询 query_station_status + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List stationStatusInfos = new ArrayList<>(); + ThirdPartySecretInfoVO ningBoSecretInfoVO = getChangZhouSecretInfo(); + + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo = new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); + List connectorStatusInfos = new ArrayList<>(); + + 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 connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + + connectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos); + stationStatusInfos.add(stationStatusInfo); + } + + int total = stationStatusInfos.size(); + + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", stationStatusInfos); + + log.info("返回参数:{}", JSON.toJSONString(map)); + + return ThirdPartyPlatformUtils.generateResultMap(map, ningBoSecretInfoVO); + } + + + + /** + * 请求设备认证 query equip auth + * @param dto 请求设备认证 + * @return + */ + @Override + public Map queryEquipAuth(QueryEquipmentDTO dto) { + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + EquipmentAuthVO vo = new EquipmentAuthVO(); + + String equipAuthSeq = dto.getEquipAuthSeq(); + 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.setEquipAuthSeq(equipAuthSeq); + vo.setConnectorID(pileConnectorCode); + } else { + vo.setFailReason(2); // 设备检测失败 + vo.setFailReasonMsg("未查到该桩的数据"); + } + log.info("返回参数:{}", JSON.toJSONString(vo)); + + return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), + wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + } + + + + + /** + * 查询业务策略 query_equip_business_policy + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { + List policyInfoList = new ArrayList<>(); + String pileConnectorCode = dto.getConnectorID(); + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + + // 截取桩号 + // 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(); + + log.info("返回参数:{}", JSON.toJSONString(vo)); + + return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), + wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + } + + + /** + * 请求启动充电 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 wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + // 生成订单 + 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(); + log.info("返回参数:{}", JSON.toJSONString(vo)); + + return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), + wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + } + + + + /** + * 推送启动充电结果 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 = getChangZhouSecretInfo(); + 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); + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + + /** + * 查询充电状态 query equip charge status + * @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 wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + 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(); + } + log.info("返回参数:{}", JSON.toJSONString(vo)); + return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), + wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + } + + + + /** + * 推送充电状态 notification_equip_charge_status + * @param orderCode 订单编号 + * @return + */ + @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 = getChangZhouSecretInfo(); + + 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); + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + /** + * 请求停止充电 query_stop_charge + * @param dto + * @return + */ + @Override + public Map queryStopCharge(QueryStartChargeDTO dto) { + QueryStopChargeVO vo = new QueryStopChargeVO(); + String orderCode = dto.getStartChargeSeq(); + + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + // 根据订单号查询订单信息 + 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); + vo.setStartChargeSeq(orderCode); + log.info("返回参数:{}", JSON.toJSONString(vo)); + return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getOurDataSecret() + , wangKuaiDianPlatformSecretInfo.getOurDataSecretIv(), wangKuaiDianPlatformSecretInfo.getOurSigSecret()); + } + + + /** + * 推送停止充电结果 notification_stop_charge_result + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStopChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = wangKuaiDianPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = wangKuaiDianPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = wangKuaiDianPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = wangKuaiDianPlatformSecretInfo.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); + + log.info("请求参数:{}", jsonString); + + 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 pushOrderInfo(QueryOrderDTO dto) { + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + + // 根据站点id, 开始时间,结束时间查询出所有的订单信息 + // List orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto); + List orderCodes = orderBasicInfoService.tempGetOrderCodes(dto); + if (CollectionUtils.isEmpty(orderCodes)) { + return "订单信息为空"; + } + // List orderCodeList = orderListVOS.stream().map(OrderListVO::getOrderCode).collect(Collectors.toList()); + for (String orderCode : orderCodes) { + try { + String result = notificationChargeOrderInfo(orderCode, wangKuaiDianPlatformSecretInfo); + log.info("订单:{} 推送结果:{}", orderCode, result); + }catch (Exception e) { + log.error("订单:{} 推送error, ", orderCode, e); + } + } + return "Success"; + } + + /** + * 推送订单数据 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); + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + /** + * 获取配置密钥信息 + * + * @return + */ + private ThirdPartySecretInfoVO getChangZhouSecretInfo() { + // 通过第三方平台类型查询相关配置信息 + 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; + } + + + + /** + * 获取桩列表信息 + * + * @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; + } + +} From b4a13bc59e7297e9c7fb05392962add689fbdc1f Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 18 Jun 2025 10:06:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9pre=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=92=8C=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-pre.yml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/jsowell-admin/src/main/resources/application-pre.yml b/jsowell-admin/src/main/resources/application-pre.yml index 690bbf530..90f0eed99 100644 --- a/jsowell-admin/src/main/resources/application-pre.yml +++ b/jsowell-admin/src/main/resources/application-pre.yml @@ -8,17 +8,17 @@ spring: # redis 配置 redis: # 地址 - host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com -# host: 106.14.94.149 +# host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com + host: 106.14.94.149 # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 账号 - username: jsowell - # 密码 - password: js@160829 -# password: js160829 +# username: jsowell +# # 密码 +# password: js@160829 + password: js160829 # 连接超时时间 timeout: 10s lettuce: @@ -38,12 +38,12 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: jsowell - password: js@160829 -# url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# username: jsowell_pre -# password: Js@160829 +# url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: jsowell +# password: js@160829 + url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: jsowell_pre + password: Js@160829 # 从库数据源 slave: # 从数据源开关/默认关闭 From adde60e6126966a631db323974a60f6c8c111ec4 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 18 Jun 2025 11:12:24 +0800 Subject: [PATCH 3/6] update --- .../java/com/jsowell/api/thirdparty/ChangZhouController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java index 01036c1c6..642e5cbfb 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java @@ -62,6 +62,7 @@ public class ChangZhouController extends ThirdPartyBaseController { 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"))) { // 校验失败 From f4e0356d2ff2ec93c41be2d43ae8b4d0efdfdbd8 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 18 Jun 2025 16:36:57 +0800 Subject: [PATCH 4/6] update --- .../impl/ChangZhouPlatformServiceImpl.java | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java index 286629eb0..38838a180 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java @@ -139,8 +139,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { vo.setFailReason(failReason); vo.setSuccStat(succStat); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getTheirDataSecret(), - thirdPartySecretInfoVO.getTheirDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); } @@ -270,7 +269,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { public Map queryStationStatus(QueryStationInfoDTO dto) { List stationIds = dto.getStationIds(); List stationStatusInfos = new ArrayList<>(); - ThirdPartySecretInfoVO ningBoSecretInfoVO = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); for (String stationId : stationIds) { StationStatusInfo stationStatusInfo = new StationStatusInfo(); @@ -328,7 +327,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { log.info("返回参数:{}", JSON.toJSONString(map)); - return ThirdPartyPlatformUtils.generateResultMap(map, ningBoSecretInfoVO); + return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); } @@ -340,7 +339,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public Map queryEquipAuth(QueryEquipmentDTO dto) { - ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); EquipmentAuthVO vo = new EquipmentAuthVO(); String equipAuthSeq = dto.getEquipAuthSeq(); @@ -371,8 +370,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { } log.info("返回参数:{}", JSON.toJSONString(vo)); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), - wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); } @@ -387,7 +385,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { List policyInfoList = new ArrayList<>(); String pileConnectorCode = dto.getConnectorID(); - ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); // 截取桩号 // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); @@ -426,8 +424,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { log.info("返回参数:{}", JSON.toJSONString(vo)); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), - wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); } @@ -445,7 +442,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { // 平台已存在订单 return null; } - ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); // 生成订单 Map map = orderBasicInfoService.generateOrderForThirdParty(dto); String orderCode = (String) map.get("orderCode"); @@ -473,8 +470,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { .build(); log.info("返回参数:{}", JSON.toJSONString(vo)); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), - wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); } @@ -491,13 +487,13 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { if (orderInfo == null) { return null; } - ThirdPartySecretInfoVO ningBoSecretInfoVO = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); 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 operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); // 推送启动充电结果(调用接口 notification_start_charge_result) String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); @@ -533,7 +529,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { if (orderInfo == null) { return null; } - ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); // 通过订单号查询实时数据 List realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); @@ -583,8 +579,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { .build(); } log.info("返回参数:{}", JSON.toJSONString(vo)); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getTheirDataSecret(), - wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(), wangKuaiDianPlatformSecretInfo.getTheirSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); } @@ -605,14 +600,14 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); // 查询相关配置信息 - ThirdPartySecretInfoVO ningBoSecretInfoVO = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); 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 operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); @@ -672,8 +667,7 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { vo.setFailReason(0); vo.setStartChargeSeq(orderCode); log.info("返回参数:{}", JSON.toJSONString(vo)); - return ThirdPartyPlatformUtils.generateResultMapV2(vo, wangKuaiDianPlatformSecretInfo.getOurDataSecret() - , wangKuaiDianPlatformSecretInfo.getOurDataSecretIv(), wangKuaiDianPlatformSecretInfo.getOurSigSecret()); + return ThirdPartyPlatformUtils.generateResultMap(vo, wangKuaiDianPlatformSecretInfo); } @@ -689,13 +683,13 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { if (orderInfo == null) { return null; } - ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getChangZhouSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); String operatorId = Constants.OPERATORID_JIANG_SU; - String operatorSecret = wangKuaiDianPlatformSecretInfo.getTheirOperatorSecret(); - String signSecret = wangKuaiDianPlatformSecretInfo.getTheirSigSecret(); - String dataSecret = wangKuaiDianPlatformSecretInfo.getTheirDataSecret(); - String dataSecretIv = wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(); - String urlAddress = wangKuaiDianPlatformSecretInfo.getTheirUrlPrefix(); + 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_STOP_CHARGE_RESULT.getValue(); From ea5c5a1cb5b8a1419c04289b8fef9388f9e9d3cf Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Thu, 19 Jun 2025 08:50:58 +0800 Subject: [PATCH 5/6] update --- .../com/jsowell/api/thirdparty/ChangZhouController.java | 8 ++++---- .../service/impl/ChangZhouPlatformServiceImpl.java | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java index 642e5cbfb..2d62bac9c 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java @@ -216,7 +216,7 @@ public class ChangZhouController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryEquipAuth(queryEquipmentDTO); logger.info("{}-请求设备认证 result:{}" , platformName , map); - return CommonResult.success(Integer.parseInt(map.get("Ret")) , map.get("Msg") , map.get("Data") , map.get("Sig")); + return CommonResult.success(0 , "请求设备认证成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { logger.error("{}-请求设备认证 error:" , platformName , e); } @@ -250,7 +250,7 @@ public class ChangZhouController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryEquipBusinessPolicy(queryStartChargeDTO); logger.info("{}-查询业务策略信息 result:{}" , platformName , map); - return CommonResult.success(Integer.parseInt(map.get("Ret")) , map.get("Msg") , map.get("Data") , map.get("Sig")); + return CommonResult.success(0 , "查询业务策略信息成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { logger.info("{}-查询业务策略信息 error:" , platformName , e); } @@ -287,7 +287,7 @@ public class ChangZhouController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryStartCharge(queryStartChargeDTO); logger.info("{}-请求启动充电 result:{}" , platformName , map); - return CommonResult.success(Integer.parseInt(map.get("Ret")) , map.get("Msg") , map.get("Data") , map.get("Sig")); + return CommonResult.success(0 , "请求启动充电成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { logger.error("{}-请求启动充电 error:" , platformName , e); } @@ -349,7 +349,7 @@ public class ChangZhouController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO); logger.info("{}-查询充电状态 result:{}" , platformName , map); - return CommonResult.success(Integer.parseInt(map.get("Ret")) , map.get("Msg") , map.get("Data") , map.get("Sig")); + return CommonResult.success(0 , "查询充电状态成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { logger.error("{}-查询充电状态 error:" , platformName , e); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java index 38838a180..b172e3699 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java @@ -215,7 +215,6 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { map.put("StationInfos", resultList); - log.info("query_token 返回参数:{}", JSON.toJSONString(map)); return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); } From fd455ea9c095cb7ac69fa779374dd859cdbd904e Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Thu, 19 Jun 2025 09:27:14 +0800 Subject: [PATCH 6/6] update --- .../impl/ChangZhouPlatformServiceImpl.java | 42 +++---------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java index b172e3699..1cab38bbb 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java @@ -278,50 +278,18 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { List connectorStatusInfos = new ArrayList<>(); 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 connectorStatusInfo = new ConnectorStatusInfo(); - connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); - connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); - - connectorStatusInfos.add(connectorStatusInfo); - } + // 其他 + ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + connectorStatusInfos.add(connectorStatusInfo); } stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos); stationStatusInfos.add(stationStatusInfo); } - int total = stationStatusInfos.size(); Map map = new LinkedHashMap<>(); - map.put("Total", total); map.put("StationStatusInfos", stationStatusInfos); log.info("返回参数:{}", JSON.toJSONString(map));