mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 15:28:41 +08:00
update 电单车协议
This commit is contained in:
@@ -12,7 +12,7 @@ import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.util.SnUtils;
|
||||
import com.jsowell.pile.service.PileSnGenerateService;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.PileTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
@@ -48,7 +48,7 @@ public class PileService {
|
||||
private TransactionService pileTransactionService;
|
||||
|
||||
@Resource
|
||||
private SnUtils snUtils;
|
||||
private PileSnGenerateService snUtils;
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@@ -61,7 +61,7 @@ import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.util.SnUtils;
|
||||
import com.jsowell.pile.service.PileSnGenerateService;
|
||||
import com.jsowell.pile.vo.base.MemberWalletVO;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails;
|
||||
@@ -121,7 +121,7 @@ public class SpringBootTestController {
|
||||
String wechatAppId2 = "wx20abc5210391649c"; // 嘉佳充电
|
||||
|
||||
@Autowired
|
||||
private SnUtils snUtils;
|
||||
private PileSnGenerateService snUtils;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@@ -32,16 +32,26 @@ public class Constants {
|
||||
public static final String ILLEGAL_TRANSACTION_CODE = "00000000000000000000000000000000";
|
||||
|
||||
// 充电桩sn号长度
|
||||
public static final int PILE_SN_LENGTH = 14;
|
||||
public static final int PILE_SN_LENGTH_FOR_EV = 14;
|
||||
|
||||
// 充电桩枪口号长度
|
||||
public static final int CONNECTOR_CODE_LENGTH = 2;
|
||||
public static final int CONNECTOR_CODE_LENGTH_FOR_EV = 2;
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH = PILE_SN_LENGTH_FOR_EV + CONNECTOR_CODE_LENGTH_FOR_EV;
|
||||
|
||||
// 充电桩sn号长度
|
||||
public static final int PILE_SN_LENGTH_FOR_EBIKE = 14;
|
||||
|
||||
// 充电桩枪口号长度
|
||||
public static final int CONNECTOR_CODE_LENGTH_FOR_EBIKE = 2;
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE = PILE_SN_LENGTH_FOR_EBIKE + CONNECTOR_CODE_LENGTH_FOR_EBIKE;
|
||||
|
||||
// 汇付手续费费率
|
||||
public static final String FEE_RATES = "0.0055";
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH = PILE_SN_LENGTH + CONNECTOR_CODE_LENGTH;
|
||||
|
||||
public static final String SOCKET_IP = "127.0.0.1";
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.jsowell.common.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class YKCUtils {
|
||||
@@ -67,11 +71,6 @@ public class YKCUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
byte[] length = new byte[]{0x22};
|
||||
System.out.println(BytesUtil.bytesToIntLittle(length));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换电压电流以及起始soc
|
||||
* 精确到小数点后一位;待机置零
|
||||
@@ -152,4 +151,66 @@ public class YKCUtils {
|
||||
public static String parseVin(byte[] vinCodeByteArr) {
|
||||
return BytesUtil.ascii2Str(vinCodeByteArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析充电桩编号
|
||||
*/
|
||||
public static Map<String, String> parsePileConnectorCode(String pileConnectorCode) {
|
||||
// 长度大于10是汽车桩, 否则是电单车桩
|
||||
String pileSn;
|
||||
String connectorCode = "";
|
||||
if (pileConnectorCode.length() > 10) {
|
||||
// 汽车桩, 桩编号14位, 枪口号2位
|
||||
if (pileConnectorCode.length() == 16) {
|
||||
pileSn = StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2);
|
||||
connectorCode = StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2);
|
||||
} else if (pileConnectorCode.length() == 14){
|
||||
pileSn = pileConnectorCode;
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
} else {
|
||||
// 电单车桩, 桩编号8位, 枪口号2位
|
||||
if (pileConnectorCode.length() == 10) {
|
||||
pileSn = StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2);
|
||||
connectorCode = StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2);
|
||||
} else if (pileConnectorCode.length() == 8){
|
||||
pileSn = pileConnectorCode;
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
}
|
||||
Map<String, String> resultMap = Maps.newHashMap();
|
||||
resultMap.put("pileSn", pileSn);
|
||||
resultMap.put("connectorCode", connectorCode);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pileSn
|
||||
* @param pileConnectorCode 充电桩枪口编号
|
||||
* @return
|
||||
*/
|
||||
public static String getPileSn(String pileConnectorCode) {
|
||||
Map<String, String> map = parsePileConnectorCode(pileConnectorCode);
|
||||
return map.get("pileSn");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枪口号
|
||||
* @param pileConnectorCode 充电桩枪口编号
|
||||
* @return
|
||||
*/
|
||||
public static String getConnectorCode(String pileConnectorCode) {
|
||||
Map<String, String> map = parsePileConnectorCode(pileConnectorCode);
|
||||
return map.get("connectorCode");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String pileConnectorCode = "8800000000000201";
|
||||
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
||||
System.out.println(pileSn);
|
||||
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||
System.out.println(connectorCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.jsowell.common.enums.ykc.PileChannelEntity;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||
import com.jsowell.netty.handler.electricbicycles.AbstractEBikeHandler;
|
||||
import com.jsowell.netty.service.electricbicycles.EBikeBusinessService;
|
||||
@@ -35,7 +36,7 @@ public class EBikeBusinessServiceImpl implements EBikeBusinessService {
|
||||
public byte[] process(byte[] msg, ChannelHandlerContext ctx) {
|
||||
EBikeDataProtocol eBikeDataProtocol = new EBikeDataProtocol(msg);
|
||||
// 获取帧类型
|
||||
String command = BytesUtil.bin2HexStr(eBikeDataProtocol.getCommand());
|
||||
String command = YKCUtils.frameType2Str(eBikeDataProtocol.getCommand());
|
||||
log.info("收到消息, channelId:{}, 指令:{}, msg:{}", ctx.channel().id().toString(), command, BytesUtil.binary(msg, 16));
|
||||
// 获取业务处理handler
|
||||
AbstractEBikeHandler invokeStrategy = EBikeOperateFactory.getInvokeStrategy(command);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.jsowell.pile.util;
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -18,9 +17,9 @@ import java.util.List;
|
||||
* 生成sn号Util
|
||||
*/
|
||||
@Component
|
||||
public class SnUtils {
|
||||
public class PileSnGenerateService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SnUtils.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(PileSnGenerateService.class);
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@@ -65,16 +64,6 @@ public class SnUtils {
|
||||
return increResult;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String pileSn = "88230000002060";
|
||||
// String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||
// long l = Long.parseLong(substring);
|
||||
// System.out.println(substring);
|
||||
// System.out.println(l);
|
||||
|
||||
Long a = 3147483647L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成sn号
|
||||
*
|
||||
@@ -2993,7 +2993,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
}
|
||||
} else {
|
||||
// 说明pileSn 和 connectorCode前端传了,那就校验一下长度
|
||||
if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) {
|
||||
if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH_FOR_EV || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH_FOR_EV
|
||||
|| dto.getPileSn().length() != Constants.PILE_SN_LENGTH_FOR_EBIKE || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH_FOR_EBIKE) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user