mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
新增第三方吉林平台接口代码
This commit is contained in:
266
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/JiLinPlatformController.java
vendored
Normal file
266
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/JiLinPlatformController.java
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
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.QueryEquipmentDTO;
|
||||
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||
import 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
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jilin")
|
||||
@Anonymous
|
||||
public class JiLinPlatformController extends ThirdPartyBaseController{
|
||||
private final String platformName = "吉林省平台";
|
||||
|
||||
|
||||
private final String platformType = ThirdPlatformTypeEnum.JI_LIN_PLATFORM.getTypeCode();
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("jiLinPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
|
||||
/**
|
||||
* getToken
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-请求令牌 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> 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_operator_info
|
||||
*/
|
||||
@PostMapping("/v1/query_operator_info")
|
||||
public CommonResult<?> query_operator_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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryOperatorInfoDTO queryOperatorInfoDTO = parseParamsDTO(dto , QueryOperatorInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryOperatorInfo(queryOperatorInfoDTO);
|
||||
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_stations_info
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询充电站信息 params:{}" , platformName , JSON.toJSONString(dto));
|
||||
try {
|
||||
logger.info("{}-携带的token:{}",platformName, request.getHeader("Authorization"));
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> 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("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设备接口状态查询 query_station_status
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_station_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<String, String> 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("设备接口状态查询发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
*
|
||||
* @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<String, String> map = platformLogic.queryEquipAuth(queryEquipmentDTO);
|
||||
logger.info("{}-请求设备认证 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求设备认证成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求设备认证 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求设备认证发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/start_charge")
|
||||
public CommonResult<?> 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<String, String> map = platformLogic.queryStartCharge(queryStartChargeDTO);
|
||||
logger.info("{}-请求启动充电 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求启动充电成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求启动充电 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推送启动充电结果
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_start_charge_result/{orderCode}")
|
||||
public RestApiResponse<?> notification_start_charge_result(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("【{}】推送启动充电结果 params:{}" , this.getClass().getSimpleName() , orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStartChargeResult(orderCode);
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , result);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e.getCode() , e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -195,9 +195,17 @@ public class SiChuanController extends ThirdPartyBaseController {
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电站信息
|
||||
*/
|
||||
@PostMapping("/v1/supervise_push_stations_info/{stationId}")
|
||||
public CommonResult<?> supervise_push_stations_info(HttpServletRequest request , @PathVariable("stationId") String stationId) {
|
||||
logger.info("{}-推送充电站信息 params:{}" , platformName , JSON.toJSONString(stationId));
|
||||
|
||||
String s = platformLogic.notificationStationInfo(stationId);
|
||||
logger.info("{}-推送充电站信息 result:{}" , platformName , s);
|
||||
|
||||
|
||||
|
||||
return CommonResult.success(0 , "推送充电站信息成功!" , s , null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public enum ThirdPlatformTypeEnum {
|
||||
HU_ZHOU_PLATFORM("24", "湖州市监管平台", "MA27U00HZ"),
|
||||
CHANG_ZHOU_PLATFORM("25", "新运常畅充", "0585PCW57"),
|
||||
SI_CHUAN_PLATFORM("26", "四川省平台", ""),
|
||||
JI_LIN_PLATFORM("27", "吉林省平台", ""),
|
||||
;
|
||||
|
||||
private String typeCode;
|
||||
|
||||
@@ -16,4 +16,7 @@ public class QueryEquipChargeStatusDTO {
|
||||
|
||||
@JsonProperty(value = "OperatorID")
|
||||
private String OperatorID;
|
||||
|
||||
@JsonProperty(value = "orderNo")
|
||||
private String orderNo;
|
||||
}
|
||||
|
||||
@@ -99,4 +99,10 @@ public class QueryStartChargeDTO {
|
||||
*/
|
||||
@JsonProperty(value = "LastQueryEndTime")
|
||||
private String lastQueryEndTime;
|
||||
|
||||
/**
|
||||
* 充电订单号 格式“运营商ID+唯一编号”
|
||||
*/
|
||||
@JsonProperty(value = "OrderNO")
|
||||
private String orderNO;
|
||||
}
|
||||
|
||||
@@ -167,4 +167,17 @@ public class ConnectorInfoDTO {
|
||||
@JSONField(name = "OpreateHours")
|
||||
private String opreateHours;
|
||||
|
||||
|
||||
/**
|
||||
* 有无地锁
|
||||
*/
|
||||
@JSONField(name = "HasLock")
|
||||
private Integer hasLock;
|
||||
|
||||
/**
|
||||
* 充电二维码
|
||||
*/
|
||||
@JSONField(name = "ChargingQrCode")
|
||||
private String chargingQrCode;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,4 +46,41 @@ public class QueryStartChargeVO {
|
||||
*/
|
||||
@JSONField(name = "FailReason")
|
||||
private int failReason;
|
||||
|
||||
// 《*** 吉林平台接口返回参数字段 ***》
|
||||
|
||||
/**
|
||||
* 充电订单号
|
||||
*/
|
||||
@JSONField(name = "orderNo")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 充电订单状态
|
||||
* 1:启动中; 2:充电中; 3:停止中; 4:充电完成;5:订单挂起;6:充电异常 结束;7:启动失败
|
||||
*/
|
||||
@JSONField(name = "orderStatus")
|
||||
private Integer orderStatus;
|
||||
|
||||
/**
|
||||
* 充电启动超时时间
|
||||
*/
|
||||
@JSONField(name = "overTime")
|
||||
private Integer overTime;
|
||||
|
||||
/**
|
||||
* 失败码
|
||||
* 0:无;1:此设备不存在(设备已下线或站 点非正常使用状态时,认为设备不存在); 2:此设备离线; 3:无此设备使用权限; 4:此设备正忙;50~999:自定义
|
||||
*/
|
||||
@JSONField(name = "FailReasonCode")
|
||||
private Integer failReasonCode;
|
||||
|
||||
/**
|
||||
* 失败信息
|
||||
*/
|
||||
@JSONField(name = "FailReasonMsg")
|
||||
private String failReasonMsg;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -282,20 +282,16 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
if (StringUtils.isNotBlank(pileStationInfo.getPictures())) {
|
||||
stationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(",")));
|
||||
}
|
||||
List<BillingPriceVO> priceList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
|
||||
StringBuilder electricityFee = new StringBuilder();
|
||||
StringBuilder serviceFee = new StringBuilder();
|
||||
// 查询计费模板
|
||||
List<BillingPriceVO> priceList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
|
||||
|
||||
for (BillingPriceVO billingPriceVO : priceList) {
|
||||
electricityFee.append(billingPriceVO.getStartTime())
|
||||
.append("-").append(billingPriceVO.getEndTime())
|
||||
.append(":").append(billingPriceVO.getElectricityPrice())
|
||||
.append(",");
|
||||
serviceFee.append(billingPriceVO.getStartTime())
|
||||
.append("-").append(billingPriceVO.getEndTime())
|
||||
.append(":").append(billingPriceVO.getServicePrice())
|
||||
.append(",");
|
||||
String timeRange = billingPriceVO.getStartTime() + "-" + billingPriceVO.getEndTime() + ":";
|
||||
electricityFee.append(timeRange).append(billingPriceVO.getElectricityPrice()).append(",");
|
||||
serviceFee.append(timeRange).append(billingPriceVO.getServicePrice()).append(",");
|
||||
}
|
||||
|
||||
// 去除最后一位的分号
|
||||
electricityFee.deleteCharAt(electricityFee.length() - 1);
|
||||
serviceFee.deleteCharAt(serviceFee.length() - 1);
|
||||
@@ -337,7 +333,7 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
*/
|
||||
@Override
|
||||
public String notificationStationInfo(String stationId) {
|
||||
List<SupStationInfo> stationInfos = new ArrayList<>();
|
||||
List<SupStationInfoDTO> stationInfos = new ArrayList<>();
|
||||
// 通过id查询站点相关信息
|
||||
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId));
|
||||
// 查询相关配置信息
|
||||
@@ -398,19 +394,14 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
info.setOfficialRunTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileStationInfo.getCreateTime()));
|
||||
|
||||
|
||||
List<BillingPriceVO> priceList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
|
||||
StringBuilder electricityFee = new StringBuilder();
|
||||
StringBuilder serviceFee = new StringBuilder();
|
||||
// 查询计费模板
|
||||
List<BillingPriceVO> priceList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
|
||||
|
||||
for (BillingPriceVO billingPriceVO : priceList) {
|
||||
electricityFee.append(billingPriceVO.getStartTime())
|
||||
.append("-").append(billingPriceVO.getEndTime())
|
||||
.append(":").append(billingPriceVO.getElectricityPrice())
|
||||
.append(",");
|
||||
serviceFee.append(billingPriceVO.getStartTime())
|
||||
.append("-").append(billingPriceVO.getEndTime())
|
||||
.append(":").append(billingPriceVO.getServicePrice())
|
||||
.append(",");
|
||||
String timeRange = billingPriceVO.getStartTime() + "-" + billingPriceVO.getEndTime() + ":";
|
||||
electricityFee.append(timeRange).append(billingPriceVO.getElectricityPrice()).append(",");
|
||||
serviceFee.append(timeRange).append(billingPriceVO.getServicePrice()).append(",");
|
||||
}
|
||||
// 去除最后一位的分号
|
||||
electricityFee.deleteCharAt(electricityFee.length() - 1);
|
||||
@@ -1188,7 +1179,7 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
connectorInfo.setVoltageLowerLimits(new BigDecimal(pileDetailInfoVO.getRatedVoltage()).setScale(4, RoundingMode.HALF_UP));
|
||||
connectorInfo.setCurrent(new BigDecimal(pileDetailInfoVO.getRatedCurrent()).setScale(4, RoundingMode.HALF_UP));
|
||||
connectorInfo.setPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(4, RoundingMode.HALF_UP));
|
||||
connectorInfo.setNationalStandard(StringUtils.equals("1", pileDetailInfoVO.getSpeedType()) ? 12 : 11);
|
||||
connectorInfo.setNationalStandard(2);
|
||||
connectorInfo.setAuxPower(3); // 3-兼容12V和24V
|
||||
connectorInfo.setOperateStatus(50); // 50-正常使用
|
||||
|
||||
|
||||
Reference in New Issue
Block a user