ChargingBusinessServiceImpl.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.zsElectric.boot.charging.service.impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.google.gson.Gson;
  4. import com.google.gson.JsonObject;
  5. import com.zsElectric.boot.charging.dto.StartChargingRequestDTO;
  6. import com.zsElectric.boot.charging.dto.StartChargingResponseVO;
  7. import com.zsElectric.boot.charging.service.ChargingBusinessService;
  8. import com.zsElectric.boot.charging.vo.*;
  9. import com.zsElectric.boot.common.constant.ConnectivityConstants;
  10. import com.zsElectric.boot.common.util.electric.ChargingUtil;
  11. import lombok.RequiredArgsConstructor;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.springframework.stereotype.Service;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. @Slf4j
  18. @Service
  19. @RequiredArgsConstructor
  20. public class ChargingBusinessServiceImpl implements ChargingBusinessService {
  21. private final ChargingUtil chargingUtil;
  22. @Override
  23. public ChargingPricePolicyVO queryEquipBusinessPolicy(String equipBizSeq, String connectorID){
  24. Map<String, Object> queryTokenParms = new HashMap<>();
  25. queryTokenParms.put("equipBizSeq", equipBizSeq);
  26. queryTokenParms.put("connectorID", connectorID);
  27. log.info("查询设备价格策略请求参数:{}", queryTokenParms);
  28. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_BUSINESS_POLICY, queryTokenParms, false);
  29. log.info("查询设备价格策略返回结果:{}", jsonObject);
  30. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  31. log.info("查询设备价格策略返回结果解密后:{}", responseDecode);
  32. return new Gson().fromJson(responseDecode, ChargingPricePolicyVO.class);
  33. }
  34. @Override
  35. public EquipmentAuthResponseVO queryEquipAuth(String EquipAuthSeq, String ConnectorID) {
  36. Map<String, Object> queryTokenParms = new HashMap<>();
  37. queryTokenParms.put("EquipAuthSeq", EquipAuthSeq);
  38. queryTokenParms.put("ConnectorID", ConnectorID);
  39. log.info("查询设备认证请求参数:{}", queryTokenParms);
  40. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_AUTH, queryTokenParms, false);
  41. log.info("查询设备认证返回结果:{}", jsonObject);
  42. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  43. log.info("查询设备认证返回结果解密后:{}", responseDecode);
  44. return new Gson().fromJson(responseDecode, EquipmentAuthResponseVO.class);
  45. }
  46. @Override
  47. public QueryStationsInfoVO queryStationsInfo(String LastQueryTime, Integer PageNo, Integer PageSize){
  48. Map<String, Object> queryParms = new HashMap<>();
  49. queryParms.put("LastQueryTime", LastQueryTime);
  50. queryParms.put("PageNo", PageNo);
  51. queryParms.put("PageSize", PageSize);
  52. log.info("查询充电站信息请求参数:{}", queryParms);
  53. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATIONS_INFO, queryParms, true);
  54. log.info("查询充电站信息返回结果:{}", jsonObject);
  55. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  56. log.info("查询充电站信息返回结果解密后:{}", responseDecode);
  57. return new Gson().fromJson(responseDecode, QueryStationsInfoVO.class);
  58. }
  59. @Override
  60. public QueryStationStatusVO queryStationStatus(List<String> stationIDs){
  61. Map<String, Object> queryParms = new HashMap<>();
  62. queryParms.put("StationIDs", stationIDs);
  63. log.info("设备接口状态查询请求参数:{}", queryParms);
  64. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STATION_STATUS, queryParms, true);
  65. log.info("设备接口状态查询返回结果:{}", jsonObject);
  66. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  67. log.info("设备接口状态查询返回结果解密后:{}", responseDecode);
  68. return new Gson().fromJson(responseDecode, QueryStationStatusVO.class);
  69. }
  70. @Override
  71. public StartChargingResponseVO startCharging(StartChargingRequestDTO requestDTO){
  72. Map<String, Object> stringObjectMap = BeanUtil.beanToMap(requestDTO);
  73. log.info("设备接口状态查询请求参数:{}", stringObjectMap);
  74. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_START_CHARGE, stringObjectMap, true);
  75. log.info("设备接口状态查询返回结果:{}", jsonObject);
  76. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  77. log.info("设备接口状态查询返回结果解密后:{}", responseDecode);
  78. return new Gson().fromJson(responseDecode, StartChargingResponseVO.class);
  79. }
  80. @Override
  81. public ChargingStatusQueryResponseVO queryChargingStatus(String StartChargeSeq) {
  82. Map<String, Object> queryParms = new HashMap<>();
  83. queryParms.put("StartChargeSeq", StartChargeSeq);
  84. log.info("查询充电订单状态请求参数:{}", queryParms);
  85. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_EQUIP_CHARGE_STATUS, queryParms, true);
  86. log.info("查询充电订单状态返回结果:{}", jsonObject);
  87. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  88. log.info("查询充电订单状态返回结果解密后:{}", responseDecode);
  89. return new Gson().fromJson(responseDecode, ChargingStatusQueryResponseVO.class);
  90. }
  91. @Override
  92. public StopChargingOperationResponseVO stopCharging(String StartChargeSeq, String ConnectorID) {
  93. Map<String, Object> queryTokenParms = new HashMap<>();
  94. queryTokenParms.put("StartChargeSeq", StartChargeSeq);
  95. queryTokenParms.put("ConnectorID", ConnectorID);
  96. log.info("停止充电请求参数:{}", queryTokenParms);
  97. JsonObject jsonObject = chargingUtil.chargingRequest(ConnectivityConstants.TEST_DOMAIN + ConnectivityConstants.QUERY_STOP_CHARGE, queryTokenParms, true);
  98. log.info("停止充电返回结果:{}", jsonObject);
  99. JsonObject responseDecode = chargingUtil.responseDecode(jsonObject);
  100. log.info("停止充电返回结果解密后:{}", responseDecode);
  101. return new Gson().fromJson(responseDecode, StopChargingOperationResponseVO.class);
  102. }
  103. }