mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-23 20:45:10 +08:00
新增 商家推送充电设备动态数据 接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.thirdparty.amap.service;
|
||||
|
||||
import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO;
|
||||
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
||||
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
|
||||
|
||||
@@ -19,4 +20,12 @@ public interface AMapService {
|
||||
* @return
|
||||
*/
|
||||
List<AMapStationInfo> getStationInfos(GetStationInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 商家推送充电设备动态数据
|
||||
* @param pileConnectorCode
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
String pushChargingDeviceDynamics(String pileConnectorCode) throws Exception;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.jsowell.thirdparty.amap.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO;
|
||||
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.thirdparty.amap.domain.AMapConnectorInfo;
|
||||
import com.jsowell.thirdparty.amap.domain.AMapEquipmentInfo;
|
||||
import com.jsowell.thirdparty.amap.domain.AMapPriceChargingInfo;
|
||||
import com.jsowell.thirdparty.amap.domain.AMapStationInfo;
|
||||
import com.jsowell.thirdparty.amap.domain.*;
|
||||
import com.jsowell.thirdparty.amap.service.AMapService;
|
||||
import com.jsowell.thirdparty.amap.util.AMapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -102,12 +104,10 @@ public class AMapServiceImpl implements AMapService {
|
||||
aMapInfo.setAMapPriceChargingInfo(priceList);
|
||||
|
||||
Map<String, Integer> pileNumMap = getPileNum(stationInfo.getId());
|
||||
|
||||
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
|
||||
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
|
||||
|
||||
List<AMapEquipmentInfo> aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfo.getId()));
|
||||
|
||||
aMapInfo.setAMapEquipmentInfos(aMapEquipmentInfos);
|
||||
|
||||
resultList.add(aMapInfo);
|
||||
@@ -116,6 +116,47 @@ public class AMapServiceImpl implements AMapService {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家推送充电设备动态数据
|
||||
* @param pileConnectorCode
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String pushChargingDeviceDynamics(String pileConnectorCode) throws Exception {
|
||||
// 根据枪口号查出桩信息
|
||||
PileConnectorDetailVO pileConnectorDetailVO = pileBasicInfoService.queryPileConnectorDetail(pileConnectorCode);
|
||||
if (pileConnectorDetailVO == null) {
|
||||
throw new BusinessException("", "");
|
||||
}
|
||||
String stationId = pileConnectorDetailVO.getStationId();
|
||||
Map<String, Integer> pileNumMap = getPileNum(Long.parseLong(stationId));
|
||||
|
||||
AMapConnectorStatusInfo info = new AMapConnectorStatusInfo();
|
||||
info.setConnectorID(pileConnectorCode);
|
||||
info.setEquipmentID(pileConnectorDetailVO.getPileSn());
|
||||
info.setStatus(pileConnectorDetailVO.getConnectorStatus());
|
||||
|
||||
// 拼装业务参数
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("stationID", stationId);
|
||||
json.put("fast_free", pileNumMap.get("fastFree"));
|
||||
json.put("fast_total", pileNumMap.get("fastTotal"));
|
||||
json.put("slow_free", pileNumMap.get("slowFree"));
|
||||
json.put("slow_total", pileNumMap.get("slowTotal"));
|
||||
json.put("connectorStatusInfo", info);
|
||||
|
||||
String SPI = "amap.charging.pushStationStatus";
|
||||
|
||||
Map<String, String> map = AMapUtils.generateParamMap(json, SPI);
|
||||
|
||||
// 调用高德接口
|
||||
return AMapUtils.sendPost(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据站点id查询快、慢充设备数量
|
||||
* @param stationId
|
||||
@@ -123,20 +164,30 @@ public class AMapServiceImpl implements AMapService {
|
||||
*/
|
||||
private Map<String, Integer> getPileNum(Long stationId) {
|
||||
int fastTotal = 0;
|
||||
int fastFree = 0;
|
||||
int slowTotal = 0;
|
||||
int slowFree = 0;
|
||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(stationId);
|
||||
for (ConnectorInfoVO connectorVO : connectorList) {
|
||||
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
|
||||
// 快充
|
||||
fastTotal += 1;
|
||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
||||
fastFree += 1;
|
||||
}
|
||||
} else {
|
||||
// 慢充
|
||||
slowTotal += 1;
|
||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
||||
slowFree += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Integer> map = new LinkedHashMap<>();
|
||||
map.put("fastTotal", fastTotal);
|
||||
map.put("fastFree", fastFree);
|
||||
map.put("slowTotal", slowTotal);
|
||||
map.put("slowFree", slowFree);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user