mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-14 23:08:35 +08:00
新增 青海平台推送站点实时功率接口
This commit is contained in:
151
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/qinghai/QingHaiController.java
vendored
Normal file
151
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/qinghai/QingHaiController.java
vendored
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
package com.jsowell.web.controller.thirdparty.qinghai;
|
||||||
|
|
||||||
|
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.response.RestApiResponse;
|
||||||
|
import com.jsowell.common.util.JWTUtils;
|
||||||
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
|
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||||
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||||
|
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
||||||
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||||
|
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
||||||
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||||
|
import com.jsowell.thirdparty.platform.util.Encodes;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 青海平台Controller
|
||||||
|
*
|
||||||
|
* @author Lemon
|
||||||
|
* @Date 2024/4/18 13:46:26
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/qinghai")
|
||||||
|
public class QingHaiController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("qingHaiPlatformServiceImpl")
|
||||||
|
private ThirdPartyPlatformService qingHaiPlatformServiceImpl;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取token接口
|
||||||
|
*/
|
||||||
|
@PostMapping("/v1/query_token")
|
||||||
|
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||||
|
logger.info("青海平台请求令牌 params:{}", JSON.toJSONString(dto));
|
||||||
|
try {
|
||||||
|
// Map<String, String> map = lianLianService.generateToken(dto);
|
||||||
|
Map<String, String> map = qingHaiPlatformServiceImpl.queryToken(dto);
|
||||||
|
logger.info("青海平台请求令牌 result:{}", JSON.toJSONString(map));
|
||||||
|
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取token接口 异常");
|
||||||
|
return CommonResult.failed("获取token发生异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询充电站信息
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
@RequestMapping("/v1/query_stations_info")
|
||||||
|
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
|
logger.info("青海平台查询充电站信息 params:{}", JSON.toJSONString(dto));
|
||||||
|
try {
|
||||||
|
// 校验令牌
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||||
|
// 校验失败
|
||||||
|
return CommonResult.failed("令牌校验错误");
|
||||||
|
}
|
||||||
|
// 查询配置信息
|
||||||
|
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
||||||
|
String operatorSecret = platformConfig.getOperatorSecret();
|
||||||
|
String dataString = dto.getData();
|
||||||
|
String dataSecret = platformConfig.getDataSecret();
|
||||||
|
String dataSecretIV = platformConfig.getDataSecretIv();
|
||||||
|
|
||||||
|
// 解密data
|
||||||
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||||
|
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||||
|
// 转换成相应对象
|
||||||
|
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||||
|
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||||
|
Map<String, String> map = qingHaiPlatformServiceImpl.queryStationsInfo(queryStationInfoDTO);
|
||||||
|
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("青海平台查询充电站信息 error", 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:{}", JSON.toJSONString(dto));
|
||||||
|
try {
|
||||||
|
// 校验令牌
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||||
|
// 校验失败
|
||||||
|
return CommonResult.failed("令牌校验错误");
|
||||||
|
}
|
||||||
|
// 查询配置信息
|
||||||
|
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
||||||
|
String operatorSecret = platformConfig.getOperatorSecret();
|
||||||
|
String dataString = dto.getData();
|
||||||
|
String dataSecret = platformConfig.getDataSecret();
|
||||||
|
String dataSecretIV = platformConfig.getDataSecretIv();
|
||||||
|
|
||||||
|
// 解密data
|
||||||
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||||
|
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||||
|
// 转换成相应对象
|
||||||
|
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
||||||
|
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
||||||
|
Map<String, String> map = qingHaiPlatformServiceImpl.queryEquipBusinessPolicy(queryStartChargeDTO);
|
||||||
|
return CommonResult.success(0, "查询业务策略信息成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("青海平台查询业务策略信息 error", e);
|
||||||
|
}
|
||||||
|
return CommonResult.failed("查询业务策略信息异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送站点功率
|
||||||
|
* @param stationIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/pushStationPower")
|
||||||
|
public RestApiResponse<?> pushStationPower(List<String> stationIds) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String result = qingHaiPlatformServiceImpl.notificationPowerInfo(stationIds);
|
||||||
|
response = new RestApiResponse<>(result);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("青海平台推送站点功率 error", e);
|
||||||
|
}
|
||||||
|
logger.info("青海平台推送站点功率 result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -179,10 +179,11 @@ public class CommonService {
|
|||||||
// 海南
|
// 海南
|
||||||
result = haiNanChargeService.pushStationInfoV2(dto);
|
result = haiNanChargeService.pushStationInfoV2(dto);
|
||||||
}
|
}
|
||||||
// if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), dto.getThirdPartyType())) {
|
if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), dto.getThirdPartyType())) {
|
||||||
// // 青海平台
|
// 青海平台
|
||||||
// qingHaiPlatformService.
|
insertInfo2DataBase(dto);
|
||||||
// }
|
result = dto.getThirdPartyType() + ":" + "OK";
|
||||||
|
}
|
||||||
finalResult.append(result).append("\n");
|
finalResult.append(result).append("\n");
|
||||||
}
|
}
|
||||||
return finalResult.toString();
|
return finalResult.toString();
|
||||||
@@ -319,8 +320,24 @@ public class CommonService {
|
|||||||
if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), thirdPartyType)) {
|
if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), thirdPartyType)) {
|
||||||
// 青海省平台
|
// 青海省平台
|
||||||
String result = qingHaiPlatformService.notificationStationStatus(pileConnectorCode, changedStatus);
|
String result = qingHaiPlatformService.notificationStationStatus(pileConnectorCode, changedStatus);
|
||||||
log.info("推送甬城泊车平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}, result:{}"
|
log.info("推送青海平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}, result:{}"
|
||||||
, pileConnectorCode, changedStatus, result);
|
, pileConnectorCode, changedStatus, result);
|
||||||
|
// 先判断缓存中是否有数据
|
||||||
|
String redisKey = CacheConstants.JIANGSU_PUSH_PILE_STATUS + pileConnectorCode;
|
||||||
|
Object cacheObject = redisCache.getCacheObject(redisKey);
|
||||||
|
|
||||||
|
if (StringUtils.equals(connectorStatus, "03")) {
|
||||||
|
// 充电状态, 查出订单信息
|
||||||
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果缓存有数据,证明上次推送未超过2分钟,不予推送,若缓存中无数据,说明需要推送
|
||||||
|
if (cacheObject == null) {
|
||||||
|
String pushResult = qingHaiPlatformService.notificationEquipChargeStatus(orderInfo.getOrderCode());
|
||||||
|
redisCache.setCacheObject(redisKey, realTimeMonitorData, 2, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -394,6 +411,10 @@ public class CommonService {
|
|||||||
// log.info("甬城泊车平台 推送充电订单信息 result:{}", result);
|
// log.info("甬城泊车平台 推送充电订单信息 result:{}", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (StringUtils.equals(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(), thirdPartyType)) {
|
||||||
|
// 青海平台
|
||||||
|
qingHaiPlatformService.notificationChargeOrderInfo(orderBasicInfo.getOrderCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
|||||||
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
|
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方平台对接需要的api集合
|
* 第三方平台对接需要的api集合
|
||||||
@@ -328,6 +325,15 @@ public interface ThirdPartyPlatformService {
|
|||||||
throw new UnsupportedOperationException("This method is not yet implemented");
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送充换电站实时功率
|
||||||
|
* @param stationIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default String notificationPowerInfo(List<String> stationIds) {
|
||||||
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------- 以下是公用方法 --------------------------------------- //
|
// -------------------------------------- 以下是公用方法 --------------------------------------- //
|
||||||
/**
|
/**
|
||||||
* 从联联平台获取令牌
|
* 从联联平台获取令牌
|
||||||
@@ -458,4 +464,5 @@ public interface ThirdPartyPlatformService {
|
|||||||
return StringUtils.equals(sig, sign);
|
return StringUtils.equals(sig, sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ import com.jsowell.common.util.DateUtils;
|
|||||||
import com.jsowell.common.util.PageUtils;
|
import com.jsowell.common.util.PageUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.*;
|
import com.jsowell.pile.domain.*;
|
||||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
|
|
||||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
|
||||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.thirdparty.ZDLEquipmentInfo;
|
import com.jsowell.pile.thirdparty.ZDLEquipmentInfo;
|
||||||
import com.jsowell.pile.thirdparty.ZDLStationInfo;
|
import com.jsowell.pile.thirdparty.ZDLStationInfo;
|
||||||
|
|||||||
Reference in New Issue
Block a user