mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 联联查询统计信息接口
This commit is contained in:
@@ -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("查询统计信息发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,11 @@ public class SpringBootTestController {
|
||||
// String dataJson = JSONUtil.toJsonStr(data);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("StationIDs", com.google.common.collect.Lists.newArrayList("1", "2"));
|
||||
// json.put("StationIDs", com.google.common.collect.Lists.newArrayList("1", "2"));
|
||||
json.put("StationID", "2");
|
||||
json.put("StartTime", "2023-02-01");
|
||||
json.put("EndTime", "2023-06-01");
|
||||
|
||||
String dataJson = JSONObject.toJSONString(json);
|
||||
// 加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface LianLianService {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
StationStatsInfo query_station_stats(QueryStationInfoDTO dto);
|
||||
Map<String, String> query_station_stats(QueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -389,17 +389,15 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StationStatsInfo query_station_stats(QueryStationInfoDTO dto) {
|
||||
public Map<String, String> query_station_stats(QueryStationInfoDTO dto) {
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 根据站点id 查出这段时间的充电量
|
||||
List<AccumulativeInfoVO> list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return StationStatsInfo.builder()
|
||||
.StationID(dto.getStationID())
|
||||
.StartTime(dto.getStartTime())
|
||||
.EndTime(dto.getEndTime())
|
||||
.StationElectricity(BigDecimal.ZERO)
|
||||
.equipmentStatsInfos(Lists.newArrayList()) // 设备列表
|
||||
.build();
|
||||
return null;
|
||||
}
|
||||
|
||||
// 根据充电桩编号分组 key=充电桩编号
|
||||
@@ -465,7 +463,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
.equipmentStatsInfos(equipmentStatsInfoList) // 设备列表
|
||||
.build();
|
||||
|
||||
return stationStatsInfo;
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(stationStatsInfo).getBytes(),
|
||||
configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getOperatorSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user