mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
428
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/xindiantu/XDTController.java
vendored
Normal file
428
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/xindiantu/XDTController.java
vendored
Normal file
@@ -0,0 +1,428 @@
|
||||
package com.jsowell.web.controller.thirdparty.xindiantu;
|
||||
|
||||
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.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.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.xindiantu.service.XDTService;
|
||||
import com.jsowell.thirdparty.zhongdianlian.service.ZDLService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 新电途平台 Controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/3 13:41:46
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/xindiantu")
|
||||
public class XDTController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private XDTService xdtService;
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/xindiantu/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("新电途平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = xdtService.generateToken(dto);
|
||||
logger.info("新电途平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException 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("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密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);
|
||||
Map<String, String> map = xdtService.queryStationsInfo(queryStationInfoDTO);
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("新电途平台查询充电站信息 error", e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途平台查询统计信息
|
||||
* http://localhost:8080/zdl/v1/query_stations_stats
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_stats")
|
||||
public CommonResult<?> queryStationStats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("新电途平台查询统计信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
|
||||
// 解密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 = xdtService.queryStationStats(queryStationInfoDTO);
|
||||
logger.info("新电途平台查询统计信息 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("新电途平台查询统计信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
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("新电途平台请求设备认证 param:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
||||
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = xdtService.queryEquipAuth(queryEquipmentDTO);
|
||||
logger.info("新电途平台请求设备认证 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("新电途平台请求设备认证 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
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 :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密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 = xdtService.queryStartCharge(queryStartChargeDTO);
|
||||
logger.info("新电途平台请求启动充电 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("新电途平台请求启动充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* http://localhost:8080/LianLian/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 :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = xdtService.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
||||
logger.info("新电途平台查询充电状态 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("新电途平台查询充电状态 error", e);
|
||||
}
|
||||
return CommonResult.failed("新电途平台查询充电状态发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stop_charge")
|
||||
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("新电途平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = xdtService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密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 = xdtService.queryStopCharge(queryStartChargeDTO);
|
||||
logger.info("新电途平台请求停止充电 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("新电途平台请求停止充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("新电途平台请求停止充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途推送停止充电结果
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushStopChargeResult/{orderCode}")
|
||||
public RestApiResponse<?> pushStopChargeResult(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("新电途平台推送停止充电结果 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = xdtService.notificationStopChargeResult(orderCode);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途推送充电订单信息
|
||||
* http://localhost:8080/ycbc/pushChargeOrderInfo
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushChargeOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushChargeOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("新电途平台推送充电订单信息 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = xdtService.pushChargeOrderInfo(orderCode);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途推送充电状态
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushChargeStatus/{orderCode}")
|
||||
public RestApiResponse<?> pushChargeStatus(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("新电途平台推送充电状态 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = xdtService.notificationEquipChargeStatus(orderCode);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途推送启动充电结果
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushStartChargeResult/{orderCode}")
|
||||
public RestApiResponse<?> pushStartChargeResult(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("新电途平台推送启动充电结果 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = xdtService.notificationStartChargeResult(orderCode);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新电途平台设备状态变化推送
|
||||
* http://localhost:8080/ycbc/pushStationStatus
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationStatus")
|
||||
public RestApiResponse<?> pushStationStatus(@RequestBody PushInfoParamDTO dto) {
|
||||
logger.info("新电途平台设备状态变化推送 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
|
||||
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = xdtService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus());
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class ZDLController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台设备状态变化推送
|
||||
* 中电联平台设备状态变化推送
|
||||
* http://localhost:8080/zdl/v1/pushStationStatus
|
||||
* @param dto
|
||||
* @return
|
||||
|
||||
@@ -209,6 +209,11 @@ public class CacheConstants {
|
||||
*/
|
||||
public static final String MQTT_CONNECT_SN = "MQTT_CONNECT_SN:";
|
||||
|
||||
/**
|
||||
* 江苏省推送桩状态信息
|
||||
*/
|
||||
public static final String JIANGSU_PUSH_PILE_STATUS = "JIANGSU_PUSH_PILE_STATUS:";
|
||||
|
||||
/**
|
||||
* 桩硬件故障
|
||||
*/
|
||||
|
||||
@@ -366,7 +366,7 @@ public class UploadRealTimeMonitorHandler extends AbstractHandler {
|
||||
}
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), relationInfo.getThirdPartyType())) {
|
||||
// 先判断缓存中是否有数据
|
||||
String redisKey = "JIANGSU_PUSH_PILE_STATUS:" + pileConnectorCode;
|
||||
String redisKey = CacheConstants.JIANGSU_PUSH_PILE_STATUS + pileConnectorCode;
|
||||
Object cacheObject = redisCache.getCacheObject(redisKey);
|
||||
|
||||
// 江苏省平台(充电状态至少一分钟推送一次)
|
||||
|
||||
@@ -19,6 +19,12 @@ public class QueryStartChargeDTO {
|
||||
@JsonProperty(value = "StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
|
||||
/**
|
||||
* 业务策略查询流水号
|
||||
*/
|
||||
@JsonProperty(value = "EquipBizSeq")
|
||||
private String equipBizSeq;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.jsowell.pile.vo.zdl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务策略信息体VO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/3 16:24:51
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EquipBusinessPolicyVO {
|
||||
/**
|
||||
* 业务策略查询流水号
|
||||
*/
|
||||
@JsonProperty(value = "equipBizSeq")
|
||||
private String equipBizSeq;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
*/
|
||||
@JsonProperty(value = "ConnectorID")
|
||||
private String connectorId;
|
||||
|
||||
/**
|
||||
* 操作结果
|
||||
* 0:成功
|
||||
* 1:失败
|
||||
*/
|
||||
@JsonProperty(value = "SuccStat")
|
||||
private Integer succStat;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
* 0:无
|
||||
* 1:此充电桩业务策略不存在
|
||||
*/
|
||||
@JsonProperty(value = "FailReason")
|
||||
private Integer failReason;
|
||||
|
||||
/**
|
||||
* 时段数
|
||||
* 0-32
|
||||
*/
|
||||
@JsonProperty(value = "SumPeriod")
|
||||
private Integer sumPeriod;
|
||||
|
||||
/**
|
||||
* 计费信息
|
||||
*/
|
||||
@JsonProperty(value = "PolicyInfos")
|
||||
private List<PolicyInfo> policyInfos;
|
||||
|
||||
@Data
|
||||
public static class PolicyInfo {
|
||||
/**
|
||||
* 时段开始时间
|
||||
*/
|
||||
@JsonProperty(value = "StartTime")
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 电费
|
||||
* 保留小数点后四位
|
||||
*/
|
||||
@JsonProperty(value = "ElecPrice")
|
||||
private BigDecimal elecPrice;
|
||||
|
||||
/**
|
||||
* 服务费
|
||||
* 保留小数点后四位
|
||||
*/
|
||||
@JsonProperty(value = "SevicePrice")
|
||||
private BigDecimal servicePrice;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,12 @@ public interface XDTService {
|
||||
*/
|
||||
Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param dto
|
||||
*/
|
||||
Map<String, String> checkoutSign(CommonParamsDTO dto);
|
||||
|
||||
/**
|
||||
* 查询站点信息
|
||||
* @param dto
|
||||
|
||||
@@ -45,6 +45,11 @@ public class XDTServiceImpl implements XDTService {
|
||||
return zdlService.generateToken(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> checkoutSign(CommonParamsDTO dto) {
|
||||
return zdlService.checkoutSign(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点信息
|
||||
* @param dto
|
||||
|
||||
@@ -35,7 +35,6 @@ public interface ZDLService {
|
||||
*/
|
||||
public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 查询统计信息
|
||||
* @param dto
|
||||
@@ -43,7 +42,6 @@ public interface ZDLService {
|
||||
*/
|
||||
Map<String, String> queryStationStats(QueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 设备接口状态查询
|
||||
* 此接口用于批量查询设备实时状态
|
||||
@@ -53,7 +51,6 @@ public interface ZDLService {
|
||||
*/
|
||||
Map<String, String> queryStationStatus(QueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 设备状态变化推送
|
||||
* @param pileConnectorCode
|
||||
@@ -130,4 +127,10 @@ public interface ZDLService {
|
||||
* @return
|
||||
*/
|
||||
String notificationEquipChargeStatus(String orderCode) throws UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param dto
|
||||
*/
|
||||
Map<String, String> checkoutSign(CommonParamsDTO dto);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ import com.jsowell.pile.service.*;
|
||||
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.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
@@ -74,6 +77,9 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
@Autowired
|
||||
private IThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* @param dto
|
||||
@@ -353,13 +359,63 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 查询业务策略信息结果
|
||||
* 查询业务策略信息结果
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> queryEquipBusinessPolicy(QueryStartChargeDTO dto) {
|
||||
return null;
|
||||
List<EquipBusinessPolicyVO.PolicyInfo> policyInfoList = new ArrayList<>();
|
||||
String pileConnectorCode = dto.getConnectorID();
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 截取桩号
|
||||
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
|
||||
// 查询该桩的站点id
|
||||
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
|
||||
// 根据桩号查询正在使用的计费模板
|
||||
List<BillingPriceVO> 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();
|
||||
policyInfo.setStartTime(billingPriceVO.getStartTime());
|
||||
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();
|
||||
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(vo).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,6 +456,15 @@ public class ZDLServiceImpl implements ZDLService {
|
||||
return lianLianService.pushStopChargeResult(orderCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> checkoutSign(CommonParamsDTO dto) {
|
||||
return lianLianService.checkoutSign(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送充电状态
|
||||
* @param orderCode
|
||||
|
||||
Reference in New Issue
Block a user