mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-14 23:08:35 +08:00
update 0x31报文回复不足位数补零
This commit is contained in:
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.primitives.Bytes;
|
||||||
import com.huifu.adapay.model.Refund;
|
import com.huifu.adapay.model.Refund;
|
||||||
import com.jsowell.JsowellApplication;
|
import com.jsowell.JsowellApplication;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
@@ -16,6 +17,7 @@ import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
|||||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.StartModeEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.*;
|
import com.jsowell.common.util.*;
|
||||||
import com.jsowell.common.util.http.HttpUtils;
|
import com.jsowell.common.util.http.HttpUtils;
|
||||||
@@ -145,6 +147,9 @@ public class SpringBootTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IMemberTransactionRecordService memberTransactionRecordService;
|
private IMemberTransactionRecordService memberTransactionRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMemberPlateNumberRelationService memberPlateNumberRelationService;
|
||||||
|
|
||||||
static final String MAC_KEY = "53TtFpc4gdVZbF3x";
|
static final String MAC_KEY = "53TtFpc4gdVZbF3x";
|
||||||
|
|
||||||
static final String ALGORITHM_MAC = "HmacMD5";
|
static final String ALGORITHM_MAC = "HmacMD5";
|
||||||
@@ -226,6 +231,117 @@ public class SpringBootTestController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVinCode() {
|
||||||
|
String msg = "880000000000210203000000000000000000000000000000000000000000000000004C5257594743454B584D43303437313434";
|
||||||
|
// 获取消息体
|
||||||
|
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
||||||
|
|
||||||
|
int startIndex = 0;
|
||||||
|
int length = 7;
|
||||||
|
|
||||||
|
// 桩编码
|
||||||
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String pileSn = BytesUtil.binary(pileSnByteArr, 16);
|
||||||
|
|
||||||
|
// 保存时间
|
||||||
|
// saveLastTime(pileSn);
|
||||||
|
|
||||||
|
// 枪号
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String connectorCode = BytesUtil.bcd2Str(connectorNumByteArr);
|
||||||
|
|
||||||
|
// 启动方式
|
||||||
|
// 0x01 表示通过刷卡启动充电
|
||||||
|
// 0x02 表求通过帐号启动充电 (暂不支持)
|
||||||
|
// 0x03 表示vin码启动充电
|
||||||
|
startIndex += length;
|
||||||
|
byte[] startModeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String startMode = BytesUtil.bcd2Str(startModeByteArr);
|
||||||
|
|
||||||
|
// 是否需要密码 0x00 不需要 0x01 需要
|
||||||
|
startIndex += length;
|
||||||
|
byte[] needPasswordFlagByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String needPasswordFlag = BytesUtil.bcd2Str(needPasswordFlagByteArr);
|
||||||
|
|
||||||
|
// 物理卡号 不足 8 位补 0
|
||||||
|
startIndex += length;
|
||||||
|
length = 8;
|
||||||
|
byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String physicsCard = BytesUtil.binary(cardNumByteArr, 16);
|
||||||
|
|
||||||
|
// 输入密码 对用户输入的密码进行16 位MD5 加密,采用小写上传
|
||||||
|
startIndex += length;
|
||||||
|
length = 16;
|
||||||
|
byte[] inputPasswordByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
|
||||||
|
// VIN码
|
||||||
|
startIndex += length;
|
||||||
|
length = 17;
|
||||||
|
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
|
||||||
|
System.out.println("桩号:" + pileSn +"申请充电VIN码:" + vinCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷卡启动充电
|
||||||
|
*/
|
||||||
|
String logicCard = "";
|
||||||
|
byte[] authenticationFlagByteArr = Constants.zeroByteArray; // 鉴权成功标识
|
||||||
|
byte[] accountBalanceByteArr = Constants.zeroByteArray; // 账户余额
|
||||||
|
String transactionCode = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* VIN码启动充电
|
||||||
|
*/
|
||||||
|
if (StringUtils.equals("03", startMode)) {
|
||||||
|
// 通过vin码查询数据库绑定用户信息
|
||||||
|
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
||||||
|
if (plateInfo == null) {
|
||||||
|
throw new BusinessException("", "未查到绑定用户信息");
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals("1", plateInfo.getVinStatus())) {
|
||||||
|
// 1- 正常使用
|
||||||
|
throw new BusinessException("", "vin状态不正确");
|
||||||
|
}
|
||||||
|
// vin码生成订单 vin启动充电
|
||||||
|
GenerateOrderDTO dto = new GenerateOrderDTO();
|
||||||
|
dto.setMemberPlateNumberRelation(plateInfo);
|
||||||
|
dto.setPileSn(pileSn);
|
||||||
|
dto.setConnectorCode(connectorCode);
|
||||||
|
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
||||||
|
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(dto);
|
||||||
|
if (map != null) {
|
||||||
|
transactionCode = (String) map.get("transactionCode");
|
||||||
|
accountBalanceByteArr = YKCUtils.getPriceByte(String.valueOf(map.get("accountBalance")), 2);
|
||||||
|
// 鉴权成功标识 0x00 失败 0x01 成功
|
||||||
|
authenticationFlagByteArr = Constants.oneByteArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (BusinessException e){
|
||||||
|
System.out.println(e);
|
||||||
|
// log.error("VIN码启动充电鉴权 error:{}, {}", e.getCode(), e.getMessage());
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// log.error("VIN码启动充电鉴权 error", e);
|
||||||
|
}
|
||||||
|
byte[] serialNumByteArr = BytesUtil.str2Bcd(transactionCode);
|
||||||
|
|
||||||
|
byte[] defeatReasonByteArr = Constants.zeroByteArray;
|
||||||
|
|
||||||
|
// 不足位数的值补零
|
||||||
|
cardNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
|
||||||
|
serialNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(serialNumByteArr, 32);
|
||||||
|
pileSnByteArr = BytesUtil.checkLengthAndBehindAppendZero(pileSnByteArr, 14);
|
||||||
|
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
|
||||||
|
|
||||||
|
// 拼装消息体
|
||||||
|
byte[] msgBodyByteArr = Bytes.concat(serialNumByteArr, pileSnByteArr, connectorNumByteArr, cardNumByteArr, accountBalanceByteArr,
|
||||||
|
authenticationFlagByteArr, defeatReasonByteArr);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateLianlianToken() throws UnsupportedEncodingException {
|
public void testGenerateLianlianToken() throws UnsupportedEncodingException {
|
||||||
String OperatorID = "425010765";
|
String OperatorID = "425010765";
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* TODO VIN码启动充电
|
* VIN码启动充电
|
||||||
*/
|
*/
|
||||||
if (StringUtils.equals("03", startMode)) {
|
if (StringUtils.equals("03", startMode)) {
|
||||||
// 通过vin码查询数据库绑定用户信息
|
// 通过vin码查询数据库绑定用户信息
|
||||||
@@ -222,6 +222,12 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
|
|||||||
*/
|
*/
|
||||||
byte[] defeatReasonByteArr = Constants.zeroByteArray;
|
byte[] defeatReasonByteArr = Constants.zeroByteArray;
|
||||||
|
|
||||||
|
// 不足位数的值补零
|
||||||
|
cardNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
|
||||||
|
serialNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(serialNumByteArr, 32);
|
||||||
|
pileSnByteArr = BytesUtil.checkLengthAndBehindAppendZero(pileSnByteArr, 14);
|
||||||
|
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
|
||||||
|
|
||||||
// 拼装消息体
|
// 拼装消息体
|
||||||
byte[] msgBodyByteArr = Bytes.concat(serialNumByteArr, pileSnByteArr, connectorNumByteArr, cardNumByteArr, accountBalanceByteArr,
|
byte[] msgBodyByteArr = Bytes.concat(serialNumByteArr, pileSnByteArr, connectorNumByteArr, cardNumByteArr, accountBalanceByteArr,
|
||||||
authenticationFlagByteArr, defeatReasonByteArr);
|
authenticationFlagByteArr, defeatReasonByteArr);
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ public class OrderListVO {
|
|||||||
@Excel(name = "逻辑卡号")
|
@Excel(name = "逻辑卡号")
|
||||||
private String logicCard;
|
private String logicCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vin码
|
||||||
|
*/
|
||||||
|
@Excel(name = "vin码")
|
||||||
|
private String vinCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动方式(0-后管启动;1-用户app启动)
|
* 启动方式(0-后管启动;1-用户app启动)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -168,6 +168,7 @@
|
|||||||
t1.pile_sn as pileSn,
|
t1.pile_sn as pileSn,
|
||||||
t1.connector_code as connectorCode,
|
t1.connector_code as connectorCode,
|
||||||
t1.logic_card as logicCard,
|
t1.logic_card as logicCard,
|
||||||
|
t1.vin_code as vinCode,
|
||||||
t1.start_mode as startMode,
|
t1.start_mode as startMode,
|
||||||
t1.pay_mode as payMode,
|
t1.pay_mode as payMode,
|
||||||
t1.pay_status as payStatus,
|
t1.pay_status as payStatus,
|
||||||
@@ -316,6 +317,9 @@
|
|||||||
<if test="logicCard != null">
|
<if test="logicCard != null">
|
||||||
logic_card,
|
logic_card,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="logicCard != null">
|
||||||
|
vin_code,
|
||||||
|
</if>
|
||||||
<if test="startMode != null">
|
<if test="startMode != null">
|
||||||
start_mode,
|
start_mode,
|
||||||
</if>
|
</if>
|
||||||
@@ -411,6 +415,9 @@
|
|||||||
<if test="logicCard != null">
|
<if test="logicCard != null">
|
||||||
#{logicCard},
|
#{logicCard},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="vinCode != null">
|
||||||
|
#{vinCode,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
<if test="startMode != null">
|
<if test="startMode != null">
|
||||||
#{startMode},
|
#{startMode},
|
||||||
</if>
|
</if>
|
||||||
@@ -507,6 +514,9 @@
|
|||||||
<if test="logicCard != null">
|
<if test="logicCard != null">
|
||||||
logic_card = #{logicCard},
|
logic_card = #{logicCard},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="vinCode != null">
|
||||||
|
vin_code = #{vinCode},
|
||||||
|
</if>
|
||||||
<if test="startMode != null">
|
<if test="startMode != null">
|
||||||
start_mode = #{startMode},
|
start_mode = #{startMode},
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user