This commit is contained in:
2023-05-27 17:49:32 +08:00
4 changed files with 74 additions and 28 deletions

View File

@@ -211,23 +211,23 @@ public class LianLianController extends BaseController {
* @param dto
* @return
*/
@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;
}
// @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;
// }
/**
* 请求设备认证
@@ -404,4 +404,36 @@ public class LianLianController extends BaseController {
}
return CommonResult.failed("查询充电站状态信息发生异常");
}
/**
* 查询统计信息
* http://localhost:8080/LianLian/query_station_stats
*
* @param dto
* @return
*/
@PostMapping("/query_station_stats")
public CommonResult<?> query_station_stats(@RequestBody CommonParamsDTO dto) {
try {
// 校验签名
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) {
e.printStackTrace();
}
return CommonResult.failed("查询统计信息发生异常");
}
}