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