mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-05 10:30:12 +08:00
update 联联平台查询站点状态接口
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -182,26 +183,26 @@ public class LianLianController extends BaseController {
|
||||
* @param StationIDs
|
||||
* @return
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
// @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;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询统计信息
|
||||
@@ -361,12 +362,46 @@ public class LianLianController extends BaseController {
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
Map<String, String> map = lianLianService.query_stations_info(dto.getOperatorID(), queryStationInfoDTO);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_stations_info(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 联联平台查询充电站状态信息
|
||||
* http://localhost:8080/LianLian/query_station_status
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/query_station_status")
|
||||
public CommonResult<?> query_station_status(@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_status(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站状态信息发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,11 +232,14 @@ public class SpringBootTestController {
|
||||
String operatorId = "I4XLPQPV";
|
||||
String operatorSecret = "3DSBTWHVIC6KVCKI";
|
||||
// 请求data
|
||||
Map<String, String> data = new HashMap<>();
|
||||
// Map<String, String> data = new HashMap<>();
|
||||
// data.put("OperatorID", operatorId);
|
||||
// data.put("OperatorSecret", operatorSecret);
|
||||
String dataJson = JSONUtil.toJsonStr(data);
|
||||
// String dataJson = JSONUtil.toJsonStr(data);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("StationIDs", com.google.common.collect.Lists.newArrayList("1", "2"));
|
||||
String dataJson = JSONObject.toJSONString(json);
|
||||
// 加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
|
||||
operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
|
||||
@@ -61,4 +61,12 @@ public class QueryStationInfoDTO {
|
||||
*/
|
||||
@JsonProperty(value = "EndTime")
|
||||
private String EndTime;
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
*/
|
||||
private String operatorId;
|
||||
|
||||
@JsonProperty(value = "StationIDs")
|
||||
private List<String> stationIds;
|
||||
}
|
||||
|
||||
@@ -28,16 +28,16 @@ public interface LianLianService {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> query_stations_info(String operatorId, QueryStationInfoDTO dto);
|
||||
Map<String, String> query_stations_info(QueryStationInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 设备接口状态查询
|
||||
* 此接口用于批量查询设备实时状态
|
||||
*
|
||||
* @param StationIDs
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
LianLianPageResponse query_station_status(List<String> StationIDs);
|
||||
Map<String, String> query_station_status(QueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,7 +211,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> query_stations_info(String operatorId, QueryStationInfoDTO dto) {
|
||||
public Map<String, String> query_stations_info(QueryStationInfoDTO dto) {
|
||||
List<StationInfo> resultList = new ArrayList<>();
|
||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
@@ -222,7 +222,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
// 未查到数据
|
||||
return null;
|
||||
}
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -295,15 +295,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* 设备接口状态查询
|
||||
* 此接口用于批量查询设备实时状态
|
||||
*
|
||||
* @param StationIDs
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LianLianPageResponse query_station_status(List<String> StationIDs) {
|
||||
public Map<String, String> query_station_status(QueryStationInfoDTO dto) {
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
List<StationStatusInfo> StationStatusInfos = new ArrayList<>();
|
||||
List<Object> ConnectorStatusInfos = new ArrayList<>();
|
||||
|
||||
for (String stationId : StationIDs) {
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
for (String stationId : stationIds) {
|
||||
// 根据站点id查询
|
||||
List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId));
|
||||
for (ConnectorInfoVO connectorInfoVO : list) {
|
||||
@@ -363,7 +367,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
.list(collect)
|
||||
.ItemSize(total)
|
||||
.build();
|
||||
return response;
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(response).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