|
|
@@ -1,26 +1,23 @@
|
|
|
package com.kym.service.admin.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
-import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.alibaba.fastjson2.JSONReader;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.kym.common.enums.EnPlusApi;
|
|
|
import com.kym.common.utils.AESUtil;
|
|
|
import com.kym.entity.admin.Station;
|
|
|
+import com.kym.entity.enplus.StationStatusInfo;
|
|
|
import com.kym.mapper.admin.StationMapper;
|
|
|
import com.kym.service.admin.StationService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.kym.service.enplus.EnPlusService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.json.JacksonJsonParser;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -39,7 +36,7 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, Station> impl
|
|
|
private EnPlusService enPlusService;
|
|
|
|
|
|
@Override
|
|
|
- public List<Station> queryStationInfo(int pageNum, int pageSize) throws JsonProcessingException {
|
|
|
+ public List<Station> queryStationInfo(int pageNum, int pageSize) {
|
|
|
var param = """
|
|
|
{
|
|
|
"PageNo":%d,
|
|
|
@@ -53,13 +50,14 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, Station> impl
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
// var station = mapper.convertValue(enStations.get("StationInfos"), List<Station>.class);
|
|
|
- var stations = JSONArray.parseArray(enStations.get("StationInfos").toString(),Station.class);
|
|
|
+ var stations = JSONArray.parseArray(enStations.get("StationInfos").toString(), Station.class);
|
|
|
return stations;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject stationStatus(String[] ids) {
|
|
|
+ public List<StationStatusInfo> stationStatus(String[] ids) {
|
|
|
var param = """
|
|
|
{
|
|
|
"StationIDs":["%s"]
|
|
|
@@ -67,7 +65,8 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, Station> impl
|
|
|
""".formatted(String.join("\",\"", ids));
|
|
|
var response = enPlusService.enPlusPost(EnPlusApi.EN_PLUS_QUERY_STATION_STATUS.getApi(), enPlusService.buildParams(param));
|
|
|
// TODO: 2023-08-12 包装成自己的数据格式
|
|
|
- return JSONObject.parseObject(AESUtil.decrypt(response.getData()));
|
|
|
+ var enStationStatus = JSONObject.parseObject(AESUtil.decrypt(response.getData()));
|
|
|
+ return enStationStatus.getJSONArray("StationStatusInfos").toJavaList(StationStatusInfo.class, JSONReader.Feature.SupportArrayToBean);
|
|
|
}
|
|
|
|
|
|
@Override
|