新增 高德查询充电站信息接口

This commit is contained in:
Lemon
2023-06-14 17:21:51 +08:00
parent a3513e3cc0
commit c2c238fb81
9 changed files with 241 additions and 4 deletions

View File

@@ -0,0 +1,42 @@
package com.jsowell.thirdparty.amap.common;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.Value;
/**
* 高德地图通用入参
*
* @author Lemon
* @Date 2023/6/14 13:37
*/
@Data
public class AMapCommonParams {
// 时间戳(毫秒)
@JSONField(name = "utc_timestamp")
private String utcTimestamp;
// 版本号
private String version;
// 字符串编码
private String charset;
// 接口全限定名
private String method;
// 签名
private String sign;
// 签名类型
@JSONField(name = "sign_type")
private String signType;
// 应用id
@JSONField(name = "app_id")
private String appId;
// 请求业务体
@JSONField(name = "biz_content")
private String bizContent;
}

View File

@@ -0,0 +1,55 @@
package com.jsowell.thirdparty.amap.common;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 高德地图通用返回类
*
* @author Lemon
* @Date 2023/6/14 13:11
*/
@Data
public class AMapCommonResult {
private Response response;
@Data
public static class Response{
private String code;
private String msg;
private Object data;
}
public AMapCommonResult(Response response) {
this.response = response;
}
public AMapCommonResult() {
}
/**
* 成功响应
* @param responseData
* @return
*/
public AMapCommonResult successResponse(Object responseData) {
AMapCommonResult result = new AMapCommonResult();
result.response.setCode("1000");
result.response.setMsg("请求成功");
result.response.setData(responseData);
return new AMapCommonResult(result.response);
}
public AMapCommonResult failedResponse() {
AMapCommonResult result = new AMapCommonResult();
result.response.setCode("40004");
result.response.setMsg("接口异常");
return new AMapCommonResult(result.response);
}
}

View File

@@ -85,7 +85,7 @@ public class AMapStationInfo {
* 7不对外开放
*/
@JSONField(name = "OpenType")
private String openType;
private Integer openType;
// 车位数量 可停放进行充电的车位总数默认0 未知
@JSONField(name = "ParkNums")

View File

@@ -1,5 +1,10 @@
package com.jsowell.thirdparty.amap.service;
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
import java.util.List;
/**
* 高德地图Service
*
@@ -7,4 +12,11 @@ package com.jsowell.thirdparty.amap.service;
* @Date 2023/6/14 11:38
*/
public interface AMapService {
/**
* 高德拉取充电站静态数据
* @param dto
* @return
*/
List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto);
}

View File

@@ -0,0 +1,107 @@
package com.jsowell.thirdparty.amap.service.impl;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.PileStationInfo;
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileStationInfoService;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
import com.jsowell.thirdparty.amap.service.AMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 高德地图Service
*
* @author Lemon
* @Date 2023/6/14 13:54
*/
@Service
public class AMapServiceImpl implements AMapService {
@Autowired
private IPileStationInfoService pileStationInfoService;
@Autowired
private IPileConnectorInfoService pileConnectorInfoService;
/**
* 高德拉取充电站静态数据
* @param dto
* @return
*/
@Override
public List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto) {
List<AMapStationInfo> resultList = new ArrayList<>();
if (StringUtils.equals("page", dto.getType())) {
int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage();
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
// 设置分页参数
PageUtils.startPage(pageNo, pageSize);
}
// 查询站点信息
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfosByThirdParty();
if (CollectionUtils.isEmpty(stationInfos)) {
return new ArrayList<>();
}
AMapStationInfo aMapInfo;
// 拼装高德格式数据
for (PileStationInfo stationInfo : stationInfos) {
aMapInfo = new AMapStationInfo();
aMapInfo.setStationID(String.valueOf(stationInfo.getId()));
aMapInfo.setOperatorID("");
aMapInfo.setEquipmentOwnerID("");
aMapInfo.setOperatorName("");
aMapInfo.setStationName(stationInfo.getStationName());
aMapInfo.setCountryCode(stationInfo.getCountryCode());
aMapInfo.setAreaCode(stationInfo.getAreaCode());
aMapInfo.setAddress(stationInfo.getAddress());
aMapInfo.setServiceTel(stationInfo.getServiceTel());
aMapInfo.setStationType(Integer.parseInt(stationInfo.getStationType()));
aMapInfo.setStationStatus(Integer.parseInt(stationInfo.getStationStatus()));
Integer openType = Integer.parseInt(stationInfo.getPublicFlag()) == 0 ? 7 : 0;
aMapInfo.setOpenType(openType);
aMapInfo.setParkNums(0);
aMapInfo.setStationLng(new BigDecimal(stationInfo.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP));
aMapInfo.setStationLat(new BigDecimal(stationInfo.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP));
String construction = stationInfo.getConstruction();
if (StringUtils.equals("12", construction) || StringUtils.equals("13", construction) ||
StringUtils.equals("14", construction) || StringUtils.equals("15", construction)) {
construction = "255";
}
aMapInfo.setConstruction(Integer.parseInt(construction));
aMapInfo.setBusineHours(stationInfo.getBusinessHours());
// aMapInfo.setAMapPriceChargingInfo();
int fastTotal = 0;
int slowTotal = 0;
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(stationInfo.getId());
for (ConnectorInfoVO connectorVO : connectorList) {
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
// 快充
fastTotal += 1;
} else {
// 慢充
slowTotal += 1;
}
}
aMapInfo.setFastEquipmentNum(fastTotal);
aMapInfo.setSlowEquipmentNum(slowTotal);
// aMapInfo.setAMapEquipmentInfos();
resultList.add(aMapInfo);
}
return resultList;
}
}

View File

@@ -227,7 +227,7 @@ public class LianLianServiceImpl implements LianLianService {
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
PageUtils.startPage(pageNo, pageSize);
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfoForLianLian();
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfosByThirdParty();
if (CollectionUtils.isEmpty(stationInfos)) {
// 未查到数据
return null;