2023-04-14 16:50:49 +08:00
|
|
|
package com.jsowell.lianlian;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
|
|
|
|
import com.jsowell.common.core.controller.BaseController;
|
2023-05-26 08:58:42 +08:00
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
2023-04-29 10:33:16 +08:00
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2023-04-14 16:50:49 +08:00
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
2023-05-29 14:40:46 +08:00
|
|
|
import com.jsowell.common.util.JWTUtils;
|
2023-05-26 08:58:42 +08:00
|
|
|
import com.jsowell.common.util.StringUtils;
|
2023-05-27 15:56:26 +08:00
|
|
|
import com.jsowell.pile.domain.DockingPlatformConfig;
|
2023-05-26 09:40:24 +08:00
|
|
|
import com.jsowell.pile.dto.*;
|
2023-05-27 15:56:26 +08:00
|
|
|
import com.jsowell.pile.service.IDockingPlatformConfigService;
|
2023-05-26 16:14:45 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.domain.StationStatsInfo;
|
2023-05-27 15:56:26 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
2023-05-26 16:14:45 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
2023-05-27 15:56:26 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
2023-05-27 16:31:09 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.util.SignUtils;
|
2023-05-26 16:14:45 +08:00
|
|
|
import com.jsowell.thirdparty.lianlian.vo.*;
|
2023-04-14 16:50:49 +08:00
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
2023-05-29 14:40:46 +08:00
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2023-05-26 19:25:35 +08:00
|
|
|
import java.io.UnsupportedEncodingException;
|
2023-04-14 16:50:49 +08:00
|
|
|
import java.util.ArrayList;
|
2023-05-27 16:56:35 +08:00
|
|
|
import java.util.List;
|
2023-05-26 19:25:35 +08:00
|
|
|
import java.util.Map;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 对接联联平台controller
|
|
|
|
|
*
|
|
|
|
|
* @author JS-ZZA
|
|
|
|
|
* @date 2023/4/10 14:58
|
|
|
|
|
*/
|
|
|
|
|
@Anonymous
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/LianLian")
|
|
|
|
|
public class LianLianController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private LianLianService lianLianService;
|
|
|
|
|
|
2023-05-27 15:56:26 +08:00
|
|
|
@Autowired
|
|
|
|
|
private IDockingPlatformConfigService dockingPlatformConfigService;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
2023-05-26 08:58:42 +08:00
|
|
|
/**
|
|
|
|
|
* 推送充电站信息 notification_stationInfo
|
|
|
|
|
* http://localhost:8080/LianLian/pushStationInfo
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-10 08:49:01 +08:00
|
|
|
@PostMapping("/pushStationInfo")
|
2023-05-15 10:30:16 +08:00
|
|
|
public RestApiResponse<?> pushStationInfo(@RequestBody LianLianPushStationInfoDTO dto) {
|
2023-05-10 08:49:01 +08:00
|
|
|
logger.info("推送联联平台充电站信息 params:{}", JSONObject.toJSONString(dto));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
2023-05-26 08:58:42 +08:00
|
|
|
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
}
|
2023-05-15 10:30:16 +08:00
|
|
|
lianLianService.pushStationInfo(dto);
|
2023-05-10 08:49:01 +08:00
|
|
|
response = new RestApiResponse<>();
|
|
|
|
|
}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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-26 09:40:24 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 联联平台设备状态变化推送
|
|
|
|
|
* http://localhost:8080/LianLian/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 = lianLianService.pushConnectorStatus(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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-26 10:11:05 +08:00
|
|
|
/**
|
|
|
|
|
* 推送订单信息
|
|
|
|
|
* @param orderCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/pushOrderInfo/{orderCode}")
|
|
|
|
|
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode")String orderCode) {
|
|
|
|
|
logger.info("联联平台推送订单信息 params:{}", orderCode);
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
if (StringUtils.isBlank(orderCode)) {
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
}
|
|
|
|
|
String result = lianLianService.pushOrderInfo(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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设备充电中状态变化推送
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/pushPileChargeStatusChange/{orderCode}")
|
|
|
|
|
public RestApiResponse<?> pushPileChargeStatusChange(@PathVariable("orderCode")String orderCode) {
|
|
|
|
|
logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode);
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
if (StringUtils.isBlank(orderCode)) {
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
}
|
|
|
|
|
String result = lianLianService.pushPileChargeStatusChange(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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 16:50:49 +08:00
|
|
|
/**
|
|
|
|
|
* 联联平台查询充电站信息
|
|
|
|
|
* http://localhost:8080/LianLian/query_stations_info
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-27 15:56:26 +08:00
|
|
|
// @PostMapping("/query_stations_info")
|
|
|
|
|
// public RestApiResponse<?> query_stations_info(@RequestBody QueryStationInfoDTO dto) {
|
|
|
|
|
// logger.info("联联平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
|
|
|
|
// RestApiResponse<?> response = null;
|
|
|
|
|
// try {
|
|
|
|
|
// // 校验签名
|
|
|
|
|
// // lianLianService.checkoutSign();
|
|
|
|
|
// LianLianPageResponse pageResponse = lianLianService.query_stations_info(dto);
|
|
|
|
|
// response = new RestApiResponse<>(pageResponse);
|
|
|
|
|
// }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;
|
|
|
|
|
// }
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
|
|
|
/**
|
2023-04-18 16:45:49 +08:00
|
|
|
* 联联平台查询充电站状态信息
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_station_status
|
2023-04-18 16:45:49 +08:00
|
|
|
* @param StationIDs
|
2023-04-14 16:50:49 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-27 16:56:35 +08:00
|
|
|
// @PostMapping("/query_station_status")
|
|
|
|
|
// public RestApiResponse<?> query_station_status(@RequestBody ArrayList<String> StationIDs) {
|
|
|
|
|
// logger.info("联联平台查询充电站状态信息 params:{}", StationIDs);
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// if (CollectionUtils.isEmpty(StationIDs)) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// LianLianPageResponse pageResponse = lianLianService.query_station_status(StationIDs);
|
|
|
|
|
// response = new RestApiResponse<>(pageResponse);
|
|
|
|
|
// }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;
|
|
|
|
|
// }
|
2023-04-18 16:45:49 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询统计信息
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_station_stats
|
|
|
|
|
*
|
2023-04-18 16:45:49 +08:00
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-27 17:03:30 +08:00
|
|
|
// @PostMapping("/query_station_stats")
|
|
|
|
|
// public RestApiResponse<?> query_station_stats(@RequestBody QueryStationInfoDTO dto) {
|
|
|
|
|
// logger.info("联联平台查询统计信息 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// StationStatsInfo stationStatsInfo = lianLianService.query_station_stats(dto);
|
|
|
|
|
// response = new RestApiResponse<>(stationStatsInfo);
|
|
|
|
|
// }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;
|
|
|
|
|
// }
|
2023-04-24 13:55:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请求设备认证
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_equip_auth
|
2023-04-24 13:55:33 +08:00
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-31 14:17:13 +08:00
|
|
|
// @PostMapping("/query_equip_auth")
|
|
|
|
|
// public RestApiResponse<?> query_equip_auth(@RequestBody QueryEquipmentDTO dto) {
|
|
|
|
|
// logger.info("联联平台请求设备认证 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// EquipmentAuthVO equipmentAuthVO = lianLianService.query_equip_auth(dto);
|
|
|
|
|
// response = new RestApiResponse<>(equipmentAuthVO);
|
|
|
|
|
// }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_equip_auth")
|
|
|
|
|
public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
logger.info("联联平台请求设备认证 param:{}", JSONObject.toJSONString(dto));
|
2023-04-24 13:55:33 +08:00
|
|
|
try {
|
2023-05-31 14:17:13 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
|
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
|
|
|
|
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_equip_auth(queryEquipmentDTO);
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
2023-04-24 13:55:33 +08:00
|
|
|
} catch (Exception e) {
|
2023-05-31 14:17:13 +08:00
|
|
|
logger.info("联联平台请求设备认证 error:", e);
|
|
|
|
|
e.printStackTrace();
|
2023-04-24 13:55:33 +08:00
|
|
|
}
|
2023-05-31 14:17:13 +08:00
|
|
|
return CommonResult.failed("请求设备认证发生异常");
|
2023-04-24 13:55:33 +08:00
|
|
|
}
|
2023-04-25 11:20:43 +08:00
|
|
|
|
2023-04-29 10:33:16 +08:00
|
|
|
/**
|
|
|
|
|
* 请求启动充电
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_start_charge
|
2023-04-29 10:33:16 +08:00
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-31 14:43:58 +08:00
|
|
|
// @PostMapping("/query_start_charge")
|
|
|
|
|
// public RestApiResponse<?> query_start_charge(@RequestBody QueryStartChargeDTO dto) {
|
|
|
|
|
// logger.info("联联平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// QueryStartChargeVO queryStartChargeVO = lianLianService.query_start_charge(dto);
|
|
|
|
|
// response = new RestApiResponse<>(queryStartChargeVO);
|
|
|
|
|
// }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_start_charge")
|
|
|
|
|
public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2023-04-29 10:33:16 +08:00
|
|
|
logger.info("联联平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
try {
|
2023-05-31 14:43:58 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
|
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
|
|
|
|
queryStartChargeDTO.setOperatorID(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_start_charge(queryStartChargeDTO);
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
2023-04-29 10:33:16 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("联联平台请求启动充电 error", e);
|
|
|
|
|
}
|
2023-05-31 14:43:58 +08:00
|
|
|
return CommonResult.failed("请求启动充电发生异常");
|
2023-04-29 10:33:16 +08:00
|
|
|
}
|
2023-04-25 11:20:43 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询充电状态
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq}
|
2023-04-25 11:20:43 +08:00
|
|
|
* @param startChargeSeq
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-31 15:24:18 +08:00
|
|
|
// @GetMapping("/query_equip_charge_status/{startChargeSeq}")
|
|
|
|
|
// public RestApiResponse<?> query_equip_charge_status(@PathVariable("startChargeSeq") String startChargeSeq) {
|
|
|
|
|
// logger.info("联联平台查询充电状态 params :{}", startChargeSeq);
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// QueryChargingStatusVO vo = lianLianService.query_equip_charge_status(startChargeSeq);
|
|
|
|
|
// response = new RestApiResponse<>(vo);
|
|
|
|
|
// }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/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));
|
2023-04-25 11:20:43 +08:00
|
|
|
try {
|
2023-05-31 15:24:18 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
|
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
|
|
|
|
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_equip_charge_status(queryEquipChargeStatusDTO);
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
2023-04-25 11:20:43 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("联联平台查询充电状态 error", e);
|
|
|
|
|
}
|
2023-05-31 15:33:50 +08:00
|
|
|
return CommonResult.failed("联联平台查询充电状态发生异常");
|
2023-04-25 11:20:43 +08:00
|
|
|
}
|
2023-04-25 14:03:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请求停止充电
|
2023-05-10 08:49:01 +08:00
|
|
|
* http://localhost:8080/LianLian/query_stop_charge
|
2023-04-25 14:03:09 +08:00
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-31 15:33:50 +08:00
|
|
|
// @PostMapping("/query_stop_charge")
|
|
|
|
|
// public RestApiResponse<?> query_stop_charge(@RequestBody QueryStartChargeDTO dto) {
|
|
|
|
|
// logger.info("联联平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
// RestApiResponse<?> response;
|
|
|
|
|
// try {
|
|
|
|
|
// QueryStopChargeVO queryStopChargeVO = lianLianService.query_stop_charge(dto);
|
|
|
|
|
// response = new RestApiResponse<>(queryStopChargeVO);
|
|
|
|
|
// }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/query_stop_charge")
|
|
|
|
|
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2023-04-25 14:03:09 +08:00
|
|
|
logger.info("联联平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
|
|
|
|
try {
|
2023-05-31 15:33:50 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
|
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
|
|
|
|
queryStartChargeDTO.setOperatorID(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_stop_charge(queryStartChargeDTO);
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
2023-04-25 14:03:09 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("联联平台请求停止充电 error", e);
|
|
|
|
|
}
|
2023-05-31 15:33:50 +08:00
|
|
|
return CommonResult.failed("联联平台请求停止充电发生异常");
|
2023-04-25 14:03:09 +08:00
|
|
|
}
|
|
|
|
|
|
2023-05-26 15:46:58 +08:00
|
|
|
/**
|
|
|
|
|
* 获取token接口
|
2023-05-26 16:14:45 +08:00
|
|
|
* http://localhost:8080/LianLian/v1/query_token
|
2023-05-26 15:46:58 +08:00
|
|
|
*/
|
2023-05-26 16:14:45 +08:00
|
|
|
@PostMapping("/v1/query_token")
|
2023-05-29 13:42:22 +08:00
|
|
|
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
|
|
|
|
logger.info("联联平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
2023-05-26 19:25:35 +08:00
|
|
|
try {
|
|
|
|
|
Map<String, String> map = lianLianService.generateToken(dto);
|
2023-05-29 13:42:22 +08:00
|
|
|
logger.info("联联平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
2023-05-29 14:40:46 +08:00
|
|
|
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
2023-05-26 19:25:35 +08:00
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
logger.error("获取token接口 异常");
|
|
|
|
|
return CommonResult.failed("获取token发生异常");
|
|
|
|
|
}
|
2023-05-26 15:46:58 +08:00
|
|
|
}
|
2023-05-27 15:56:26 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 联联平台查询充电站信息
|
|
|
|
|
* http://localhost:8080/LianLian/query_stations_info
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-29 14:40:46 +08:00
|
|
|
@PostMapping("/v1/query_stations_info")
|
|
|
|
|
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
2023-05-27 15:56:26 +08:00
|
|
|
try {
|
2023-05-29 14:40:46 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
2023-05-27 15:56:26 +08:00
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
2023-05-27 16:56:35 +08:00
|
|
|
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_stations_info(queryStationInfoDTO);
|
2023-05-27 16:31:09 +08:00
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
2023-05-27 15:56:26 +08:00
|
|
|
} catch (Exception e) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询充电站信息 error:", e);
|
2023-05-27 15:56:26 +08:00
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2023-05-27 16:56:35 +08:00
|
|
|
return CommonResult.failed("查询充电站信息发生异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 联联平台查询充电站状态信息
|
|
|
|
|
* http://localhost:8080/LianLian/query_station_status
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-29 14:40:46 +08:00
|
|
|
@PostMapping("/v1/query_station_status")
|
|
|
|
|
public CommonResult<?> query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询充电站状态信息 params:{}", JSONObject.toJSONString(dto));
|
2023-05-27 16:56:35 +08:00
|
|
|
try {
|
2023-05-29 14:40:46 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
2023-05-27 16:56:35 +08:00
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
|
|
|
|
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_station_status(queryStationInfoDTO);
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
} catch (Exception e) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询充电站状态信息 error:", e);
|
2023-05-27 16:56:35 +08:00
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.failed("查询充电站状态信息发生异常");
|
2023-05-27 15:56:26 +08:00
|
|
|
}
|
2023-05-27 17:03:30 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询统计信息
|
|
|
|
|
* http://localhost:8080/LianLian/query_station_stats
|
|
|
|
|
*
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-05-29 14:40:46 +08:00
|
|
|
@PostMapping("/v1/query_station_stats")
|
|
|
|
|
public CommonResult<?> query_station_stats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询统计信息 params:{}", JSONObject.toJSONString(dto));
|
2023-05-27 17:03:30 +08:00
|
|
|
try {
|
2023-05-29 14:40:46 +08:00
|
|
|
// 校验令牌
|
|
|
|
|
String token = request.getHeader("Authorization");
|
|
|
|
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
|
|
|
|
// 校验失败
|
|
|
|
|
return CommonResult.failed("令牌校验错误");
|
|
|
|
|
}
|
2023-05-27 17:03:30 +08:00
|
|
|
// 校验签名
|
|
|
|
|
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
|
|
|
|
if (resultMap == null) {
|
|
|
|
|
// 签名错误
|
|
|
|
|
return CommonResult.failed("签名校验错误");
|
|
|
|
|
}
|
|
|
|
|
String operatorSecret = resultMap.get("OperatorSecret");
|
|
|
|
|
String dataString = resultMap.get("Data");
|
|
|
|
|
// 解密data
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
// 转换成相应对象
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
|
|
|
|
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
|
|
|
|
Map<String, String> map = lianLianService.query_station_stats(queryStationInfoDTO);
|
|
|
|
|
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
} catch (Exception e) {
|
2023-05-29 13:29:56 +08:00
|
|
|
logger.info("联联平台查询统计信息 error:", e);
|
2023-05-27 17:03:30 +08:00
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.failed("查询统计信息发生异常");
|
|
|
|
|
}
|
2023-04-14 16:50:49 +08:00
|
|
|
}
|