This commit is contained in:
Lemon
2024-08-28 16:19:30 +08:00
18 changed files with 132 additions and 9 deletions

View File

@@ -320,7 +320,7 @@ public class MemberController extends BaseController {
logger.error("通过 memberId 查询用户个人基本信息 error", e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_MEMBER_CAR_NO_INFO_ERROR);
}
logger.info("通过memberId查询用户个人基本信息, memberId:{}, result:{}", memberId, JSON.toJSONString(response));
// logger.info("通过memberId查询用户个人基本信息, memberId:{}, result:{}", memberId, JSON.toJSONString(response));
return response;
}

View File

@@ -3,6 +3,8 @@ package com.jsowell.netty.handler.electricbicycles;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.bean.SerializationUtil;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
@@ -37,6 +39,16 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
EBikeMessageCmd21 message = (EBikeMessageCmd21) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
// 保存时间
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
try {
byte[] serialize = SerializationUtil.serialize(message);
log.info("心跳包序列化:{}", BytesUtil.binary(serialize, 16));
EBikeMessageCmd21 deserialize = SerializationUtil.deserialize(EBikeMessageCmd21.class, serialize);
log.info("心跳包反序列化:{}", JSON.toJSONString(deserialize));
} catch (Exception e) {
log.info("error", e);
}
EBikeMessageCmd21.DeviceHeartbeat deviceHeartbeat = message.getDeviceHeartbeat();
log.info("设备心跳包:{}", JSON.toJSONString(message));
return getResult(dataProtocol, Constants.zeroByteArray);

View File

@@ -110,9 +110,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
startIndex += length;
length = 17;
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
String vinCode = BytesUtil.ascii2StrLittle(vinCodeByteArr); // 反转
log.info("反转后vin{}", vinCode);
String vinCode = BytesUtil.ascii2StrLittle(vinCodeByteArr);
ConfirmStartChargingData confirmStartChargingData = ConfirmStartChargingData.builder()
.pileSn(pileSn)
@@ -186,7 +184,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
* VIN码启动充电
*/
if (StringUtils.equals("03", startMode)) {
log.info("桩号:{}, 申请充电VIN码:{}", pileSn, vinCode);
log.info("桩号:{}, 申请充电VIN码:{}, 反转后:{}", pileSn, vinCode, StringUtils.reverse(vinCode));
// 通过vin码查询数据库绑定用户信息
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
if (plateInfo == null) {

View File

@@ -52,7 +52,6 @@ public abstract class AbsEBikeMessage {
}
}
public static AbsEBikeMessage parseMessage(byte[] messageBytes) {
if (messageBytes == null || messageBytes.length < 14 || messageBytes.length > 256) {
throw new IllegalArgumentException("Invalid message bytes");
@@ -101,6 +100,8 @@ public abstract class AbsEBikeMessage {
}
}
public abstract byte[] getMessageBytes();
public static void main(String[] args) {
String s = "44 4e 59 00 0d 3b 37 ab 04 b9 00 22 54 33 cc 66 03 7b".replace(" ", "");
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);

View File

@@ -26,6 +26,11 @@ public class EBikeMessageCmd02 extends AbsEBikeMessage {
this.creditCardInfo = new CreditCardInfo(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return null;
}
public CreditCardInfo getCreditCardInfo() {
return creditCardInfo;
}

View File

@@ -6,6 +6,9 @@ import lombok.Data;
import java.util.Arrays;
/**
* 结算消费信息上传03指令
*/
public class EBikeMessageCmd03 extends AbsEBikeMessage {
private SettlementInfo settlementInfo;
@@ -20,6 +23,11 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
this.settlementInfo = new SettlementInfo(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public SettlementInfo getSettlementInfo() {
return settlementInfo;
}

View File

@@ -24,6 +24,11 @@ public class EBikeMessageCmd04 extends AbsEBikeMessage {
this.confirmOrder = new ConfirmOrder(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public ConfirmOrder getSettlementInfo() {
return confirmOrder;
}

View File

@@ -26,6 +26,11 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
this.powerHeartbeat = new PowerHeartbeat(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public PowerHeartbeat getPowerHeartbeat() {
return powerHeartbeat;
}

View File

@@ -23,6 +23,11 @@ public class EBikeMessageCmd20 extends AbsEBikeMessage {
this.deviceRegister = new DeviceRegister(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public DeviceRegister getDeviceRegister() {
return deviceRegister;
}

View File

@@ -29,6 +29,11 @@ public class EBikeMessageCmd21 extends AbsEBikeMessage {
this.deviceHeartbeat = new DeviceHeartbeat(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
/**
* 此为心跳包间隔时间默认为3分钟方便服务器管理SocketIP
* 设备如2次收不到服务器应答则进入离线状态

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.domain.ebike.deviceupload;
import com.jsowell.common.util.bean.SerializationUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import lombok.Getter;
import lombok.Setter;
@@ -22,4 +23,10 @@ public class EBikeMessageCmd22 extends AbsEBikeMessage {
}
@Override
public byte[] getMessageBytes() {
byte[] serialize = SerializationUtil.serialize(this);
return serialize;
}
}

View File

@@ -18,4 +18,9 @@ public class EBikeMessageCmd81 extends AbsEBikeMessage {
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
}

View File

@@ -24,6 +24,11 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
this.specificData = new SpecificData(dataBytes);
}
@Override
public byte[] getMessageBytes() {
return new byte[0];
}
public SpecificData getSpecificData() {
return specificData;
}

View File

@@ -340,7 +340,7 @@ public class PileRemoteService {
String failedReason = BytesUtil.bcd2Str(failedReasonByteArr);
String failedReasonMsg = ChargingFailedReasonEnum.getMsgByCode(Integer.parseInt(failedReason, 16));
log.info("0x59预约充电响应sync, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
log.info("0x59预约充电响应sync, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果(00-失败; 01成功):{}, 失败原因:{}",
transactionCode, pileSn, connectorCode, resultCode, failedReasonMsg);
}

View File

@@ -0,0 +1,34 @@
package com.jsowell.pile.service.impl;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 电单车发送指令service
*/
@Slf4j
@Service
public class EBikeSendCommandService {
/**
* 公共方法发送指令
* @param pileSn 装编号
* @param msg 消息
* @param timeout 超时时间
* @param unit 时间单位
*/
private void sendCommand(String pileSn, Class<? extends AbsEBikeMessage> msg, long timeout, TimeUnit unit) {
// 通过桩编号获取channel
ChannelHandlerContext ctx = PileChannelEntity.getChannelByPileSn(pileSn);
if (Objects.isNull(ctx)) {
log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", "value", pileSn);
throw new NullPointerException("channel");
}
}
}

View File

@@ -3826,8 +3826,36 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.reason(chargingStartupResult.getFailReason())
.build();
BigDecimal sharpElectricityPrice = BigDecimal.ZERO;
BigDecimal sharpServicePrice = BigDecimal.ZERO;
BigDecimal sharpPrice = BigDecimal.ZERO;
BigDecimal peakElectricityPrice = BigDecimal.ZERO;
BigDecimal peakServicePrice = BigDecimal.ZERO;
BigDecimal peakPrice = BigDecimal.ZERO;
BigDecimal flatElectricityPrice = BigDecimal.ZERO;
BigDecimal flatServicePrice = BigDecimal.ZERO;
BigDecimal flatPrice = BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = BigDecimal.ZERO;
BigDecimal valleyServicePrice = BigDecimal.ZERO;
BigDecimal valleyPrice = BigDecimal.ZERO;
OrderDetail orderDetail = OrderDetail.builder()
.orderCode(orderCode)
.sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice)
.sharpPrice(sharpPrice)
.peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice)
.peakPrice(peakPrice)
.flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice)
.flatPrice(flatPrice)
.valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice)
.valleyPrice(valleyPrice)
.delFlag(DelFlagEnum.NORMAL.getValue())
.build();

View File

@@ -688,7 +688,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
response = null;
}
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作(01-启动; 02-取消; 03-修改):{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
return response;
}

View File

@@ -2547,7 +2547,7 @@
<!--AND t1.member_id = #{memberId,jdbcType=VARCHAR}-->
AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
AND t1.order_status = '6'
<!--AND t1.order_status = '6'-->
AND t1.del_flag = '0'
order by t1.create_time desc
</select>