update 电单车协议

This commit is contained in:
Guoqs
2024-08-30 17:23:04 +08:00
parent 07f4f4f76e
commit 0e38ea9e13
9 changed files with 58 additions and 12 deletions

View File

@@ -164,11 +164,23 @@ public class PileService {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
String pileSn;
if (param.length() == 16) {
pileSn = StringUtils.substring(param, 0, param.length() - 2);
// param长度大于10是汽车桩, 否则是电单车桩
if (param.length() > 10) {
// 汽车桩, 桩编号14位, 枪口号2位
if (param.length() == 16) {
pileSn = StringUtils.substring(param, 0, param.length() - 2);
} else {
pileSn = param;
}
} else {
pileSn = param;
// 电单车桩, 桩编号8位, 枪口号2位
if (param.length() == 10) {
pileSn = StringUtils.substring(param, 0, param.length() - 2);
} else {
pileSn = param;
}
}
// 查询充电桩信息
PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
if (pileInfoVO == null) {
@@ -230,9 +242,12 @@ public class PileService {
if (pileConnectorDetailVO == null) {
return null;
}
// 枪口状态不为2占用未充电
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), pileConnectorDetailVO.getConnectorStatus())) {
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
// 不是电单车的桩, 需要判断插枪状态
if (!StringUtils.equals(Constants.THREE, pileConnectorDetailVO.getChargePortType())) {
// 枪口状态不为2占用未充电
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), pileConnectorDetailVO.getConnectorStatus())) {
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
}
}
String pileSn = pileConnectorDetailVO.getPileSn();
AppletPileDetailVO resultVO = getPileDetailByPileSn(pileSn);

View File

@@ -78,7 +78,7 @@ public abstract class AbstractYkcHandler implements InitializingBean {
*/
protected void saveLastTimeAndCheckChannel(String pileSn, ChannelHandlerContext ctx) {
String redisKey = CacheConstants.PILE_LAST_CONNECTION + pileSn;
redisCache.setCacheObject(redisKey, DateUtils.getDateTime(), CacheConstants.cache_expire_time_1d);
redisCache.setCacheObject(redisKey, DateUtils.getDateTime(), CacheConstants.cache_expire_time_30d);
// 保存桩号和channel的关系
PileChannelEntity.checkChannel(pileSn, ctx);

View File

@@ -455,6 +455,17 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
infoVO.setRatedPower(pileModelInfoVO.getRatedPower());
infoVO.setRatedCurrent(pileModelInfoVO.getRatedCurrent());
infoVO.setRatedVoltage(pileModelInfoVO.getRatedVoltage());
String chargePortType;
if (StringUtils.equals(Constants.TWO, pileModelInfoVO.getChargerPileType())) {
chargePortType = Constants.THREE;
} else {
if (StringUtils.equals(Constants.ONE, pileModelInfoVO.getSpeedType())) {
chargePortType = Constants.ONE;
} else {
chargePortType = Constants.TWO;
}
}
infoVO.setChargePortType(chargePortType);
}
connectorInfoList.add(infoVO);
}
@@ -682,14 +693,14 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
* @return true离线
*/
public boolean checkPileOffLine(String pileSn) {
// 获取桩最后连接时间,最后连接到平台的时间在1分钟之前,判定为离线
// 获取桩最后连接时间,最后连接到平台的时间在3分钟之前,判定为离线
String lastConnectionTime = redisCache.getCacheObject(CacheConstants.PILE_LAST_CONNECTION + pileSn);
if (StringUtils.isBlank(lastConnectionTime)) {
// 没有最后连接时间,返回离线
return true;
}
long l = DateUtils.intervalTime(lastConnectionTime, DateUtils.getDateTime());
return l >= 1L;
return l > 3L;
}
/**

View File

@@ -46,6 +46,11 @@ public class ConnectorInfoVO {
*/
private String chargingType;
/**
* 充电接口类型 1-快充2-慢充3-电单车
*/
private String chargePortType;
/**
* 额定功率
*/

View File

@@ -60,6 +60,11 @@ public class PileInfoVO {
*/
private String speedType;
/**
* 充电接口类型 1-快充2-慢充3-电单车
*/
private String chargePortType;
/**
* 枪口编号
*/

View File

@@ -55,5 +55,8 @@ public class PileConnectorDetailVO {
*/
private String softwareProtocol;
/**
* 充电接口类型 1-快充2-慢充3-电单车
*/
private String chargePortType;
}

View File

@@ -132,4 +132,9 @@ public class PileDetailVO {
* 型号名称
*/
private String modelName;
/**
* 充电接口类型 1-快充2-慢充3-电单车
*/
private String chargePortType;
}

View File

@@ -47,7 +47,7 @@ public class PileModelInfoVO {
private String ratedVoltage;
/**
* 充电类型
* 充电类型 1-快充2-慢充)
*/
private String speedType;

View File

@@ -308,10 +308,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t2.pile_connector_code AS pileConnectorCode,
t2.status AS connectorStatus,
t1.business_type AS businessType,
t1.software_protocol AS softwareProtocol
t1.software_protocol AS softwareProtocol,
IF(t3.charger_pile_type = '2','3',(IF(t3.speed_type = '1','1','2'))) AS chargePortType
FROM
pile_basic_info t1
JOIN pile_connector_info t2 ON t1.sn = t2.pile_sn
join pile_model_info t3 on t3.id = t1.model_id
WHERE
t2.pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
</select>