diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/amap/GetStationInfoDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/amap/GetStationInfoDTO.java new file mode 100644 index 000000000..79abe4dff --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/amap/GetStationInfoDTO.java @@ -0,0 +1,21 @@ +package com.jsowell.pile.dto.amap; + +import lombok.Data; + +/** + * 高德地图查询充电站信息DTO + * + * @author Lemon + * @Date 2023/6/14 13:50 + */ +@Data +public class GetStationInfoDTO { + // type=page表示分页查询 + private String type; + + // 当前请求页数,从1开始 + private Integer currentPage; + + // 每页记录数,最大20 + private Integer pageSize; +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileStationInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileStationInfoService.java index 20f502766..77e3e7ab2 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileStationInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileStationInfoService.java @@ -91,7 +91,7 @@ public interface IPileStationInfoService { PileStationVO getStationInfoByPileSn(String pileSn); - List getStationInfoForLianLian(); + List getStationInfosByThirdParty(); List queryByStationDeptIds(List stationIds); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index d14aadf6e..d39c64b67 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -158,7 +158,7 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService { } @Override - public List getStationInfoForLianLian() { + public List getStationInfosByThirdParty() { // PageUtils.startPage(pageNum, pageSize); return pileStationInfoMapper.getStationInfoForLianLian(); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonParams.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonParams.java new file mode 100644 index 000000000..dcb5954c1 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonParams.java @@ -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; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java new file mode 100644 index 000000000..fed8a1520 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java @@ -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); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/domain/AMapStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/domain/AMapStationInfo.java index 89d45066b..abf04f895 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/domain/AMapStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/domain/AMapStationInfo.java @@ -85,7 +85,7 @@ public class AMapStationInfo { * 7:不对外开放 */ @JSONField(name = "OpenType") - private String openType; + private Integer openType; // 车位数量 可停放进行充电的车位总数,默认:0 未知 @JSONField(name = "ParkNums") diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java index 0ea26708a..9d95e4c37 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java @@ -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 getStationInfos(GetStationInfoDTO dto); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java new file mode 100644 index 000000000..795056fcf --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java @@ -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 getStationInfos(GetStationInfoDTO dto) { + List 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 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 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; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index 4538a0c1a..8af2620c7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -227,7 +227,7 @@ public class LianLianServiceImpl implements LianLianService { int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); PageUtils.startPage(pageNo, pageSize); - List stationInfos = pileStationInfoService.getStationInfoForLianLian(); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(); if (CollectionUtils.isEmpty(stationInfos)) { // 未查到数据 return null;