mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
新增 对接南瑞平台 推送站点信息接口
This commit is contained in:
@@ -64,6 +64,13 @@ public class PileStationVO {
|
||||
*/
|
||||
private Integer pileNum;
|
||||
|
||||
/**
|
||||
* 是否全天开放
|
||||
* 0:否
|
||||
* 1:是
|
||||
*/
|
||||
private String openAllDay;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.jsowell.thirdparty.nanrui.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -12,6 +15,9 @@ import java.math.BigDecimal;
|
||||
* @Date 2023/9/25 13:53
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class NRConnectorInfo {
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.jsowell.thirdparty.nanrui.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@@ -13,6 +16,9 @@ import java.util.List;
|
||||
* @Date 2023/9/25 13:49
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class NREquipmentInfo {
|
||||
/**
|
||||
* 设备编码
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.jsowell.thirdparty.nanrui.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@@ -13,6 +16,9 @@ import java.util.List;
|
||||
* @Date 2023/9/25 13:38
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class NRStationInfo {
|
||||
/**
|
||||
* 充电站id
|
||||
@@ -114,8 +120,7 @@ public class NRStationInfo {
|
||||
* 102:公共停车场
|
||||
* 103:城市交通节点
|
||||
* 104:加油站
|
||||
* 105:具备停车条件的
|
||||
* 充电区域
|
||||
* 105:具备停车条件的充电区域
|
||||
* 106:高速服务区
|
||||
* 201:政府机关
|
||||
* 202:公共机构
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jsowell.thirdparty.nanrui.service;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* 南瑞Service
|
||||
*
|
||||
@@ -8,5 +10,5 @@ package com.jsowell.thirdparty.nanrui.service;
|
||||
*/
|
||||
public interface NRService {
|
||||
|
||||
public String notification_stationInfo(String stationId);
|
||||
public String notification_stationInfo(String stationId) throws ParseException;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,32 @@
|
||||
package com.jsowell.thirdparty.nanrui.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.enums.ykc.PileStatusEnum;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileModelInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorInfo;
|
||||
import com.jsowell.thirdparty.nanrui.domain.NRConnectorInfo;
|
||||
import com.jsowell.thirdparty.nanrui.domain.NREquipmentInfo;
|
||||
import com.jsowell.thirdparty.nanrui.domain.NRStationInfo;
|
||||
import com.jsowell.thirdparty.nanrui.service.NRService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -9,10 +35,132 @@ import com.jsowell.thirdparty.nanrui.service.NRService;
|
||||
* @Date 2023/9/26 9:20
|
||||
*/
|
||||
public class NRServiceImpl implements NRService {
|
||||
@Override
|
||||
public String notification_stationInfo(String stationId) {
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileModelInfoService pileModelInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
/**
|
||||
* 充电站信息变化推送
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String notification_stationInfo(String stationId) throws ParseException {
|
||||
PileStationVO stationInfoVO = pileStationInfoService.getStationInfo(stationId);
|
||||
if (stationInfoVO == null) {
|
||||
return null;
|
||||
}
|
||||
// 拼装南瑞平台所需参数
|
||||
NRStationInfo nrStationInfo = NRStationInfo.builder()
|
||||
.stationId("NR" + stationInfoVO.getId())
|
||||
.operatorID(Constants.OPERATORID_LIANLIAN)
|
||||
.equipmentOwnerID(Constants.OPERATORID_LIANLIAN)
|
||||
.stationName(stationInfoVO.getStationName())
|
||||
.countryCode("CN")
|
||||
.areaCode(stationInfoVO.getAreaCode())
|
||||
.address(stationInfoVO.getAddress())
|
||||
.serviceTel(stationInfoVO.getStationTel())
|
||||
// .stationType()
|
||||
.stationStatus(stationInfoVO.getStationStatus())
|
||||
.parkNums(0)
|
||||
.stationLng(new BigDecimal(stationInfoVO.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP))
|
||||
.stationLat(new BigDecimal(stationInfoVO.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP))
|
||||
// .construction()
|
||||
.openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.parseDate(stationInfoVO.getCreateTime())))
|
||||
.openAllDay(Integer.parseInt(stationInfoVO.getOpenAllDay()))
|
||||
.busineHours(stationInfoVO.getBusinessHours())
|
||||
.minElectricityPrice(stationInfoVO.getElectricityPrice().add(stationInfoVO.getServicePrice()))
|
||||
// .equipmentInfos()
|
||||
.build();
|
||||
// 站点图片
|
||||
if (CollectionUtils.isNotEmpty(stationInfoVO.getPictureList())) {
|
||||
nrStationInfo.setPictures(stationInfoVO.getPictureList());
|
||||
}
|
||||
String stationType = stationInfoVO.getStationType();
|
||||
if (!StringUtils.equals("1", stationType) && !StringUtils.equals("255", stationType)) {
|
||||
// 不为1-公共并且不为255-其他,都为专用
|
||||
stationType = "2";
|
||||
}
|
||||
nrStationInfo.setStationType(Integer.parseInt(stationType));
|
||||
nrStationInfo.setConstruction(255);
|
||||
|
||||
// TODO 推送到平台
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private List<NREquipmentInfo> getEquipmentInfo(String stationId) {
|
||||
List<NREquipmentInfo> resultList = new ArrayList<>();
|
||||
List<PileBasicInfo> list = pileBasicInfoService.getPileListByStationId(stationId);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return resultList;
|
||||
}
|
||||
// 封装成南瑞平台对象
|
||||
for (PileBasicInfo pileBasicInfo : list) {
|
||||
String pileSn = pileBasicInfo.getSn();
|
||||
// 获取桩状态
|
||||
Map<String, String> pileStatusMap = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn));
|
||||
String pileStatus = pileStatusMap.get(pileSn);
|
||||
if (StringUtils.equals(PileStatusEnum.ON_LINE.getValue(), pileStatus)) {
|
||||
pileStatus = "50"; // 50-正常使用
|
||||
} else if (StringUtils.equals(PileStatusEnum.OFF_LINE.getValue(), pileStatus)
|
||||
|| StringUtils.equals(PileStatusEnum.FAULT.getValue(), pileStatus)) {
|
||||
pileStatus = "6"; // 6-维护中
|
||||
}
|
||||
// 获取桩型号信息
|
||||
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||
|
||||
NREquipmentInfo equipmentInfo = NREquipmentInfo.builder()
|
||||
.equipmentID(pileSn)
|
||||
.equipmentName(pileSn)
|
||||
.openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime()))
|
||||
.equipmentType(Integer.parseInt(modelInfo.getSpeedType()))
|
||||
.equipmentStatus(Integer.parseInt(pileStatus))
|
||||
.power(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP))
|
||||
.build();
|
||||
// 获取枪口信息
|
||||
List<NRConnectorInfo> connectorInfos = getConnectorInfo(pileSn);
|
||||
equipmentInfo.setConnectorInfos(connectorInfos);
|
||||
|
||||
resultList.add(equipmentInfo);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
private List<NRConnectorInfo> getConnectorInfo(String pileSn) {
|
||||
List<NRConnectorInfo> resultList = new ArrayList<>();
|
||||
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileSn);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return resultList;
|
||||
}
|
||||
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||
int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3;
|
||||
// 封装成南瑞平台对象
|
||||
for (PileConnectorInfo pileConnectorInfo : list) {
|
||||
NRConnectorInfo connectorInfo = NRConnectorInfo.builder()
|
||||
.connectorId(pileConnectorInfo.getPileConnectorCode())
|
||||
.connectorName(pileConnectorInfo.getPileConnectorCode())
|
||||
.connectorType(connectorType)
|
||||
.voltageUpperLimits(Integer.parseInt(modelInfo.getRatedVoltage()))
|
||||
.voltageLowerLimits(Integer.parseInt(modelInfo.getRatedVoltage()))
|
||||
.current(Integer.parseInt(modelInfo.getRatedCurrent()))
|
||||
.power(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP))
|
||||
.nationalStandard(2)
|
||||
|
||||
.build();
|
||||
resultList.add(connectorInfo);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user