mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
新增 0xDB协议解析Handler
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 0xDB
|
||||
* 上传桩端故障记录
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2025/4/29 15:09:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class UploadPileFaultRecordHandler extends AbstractYkcHandler{
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.UPLOAD_PILE_FAULT_RECORD_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
||||
// 获取消息体
|
||||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||
// log.info("上传实时数据msgBody:{}", BytesUtil.bcd2Str(msgBody));
|
||||
int startIndex = 0;
|
||||
int length = 7;
|
||||
|
||||
// 桩编码
|
||||
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||||
|
||||
startIndex += length;
|
||||
// 自定义参数
|
||||
byte[] params = BytesUtil.copyBytes(msgBody, startIndex, msgBody.length - 7);
|
||||
String paramsStr = BytesUtil.bin2HexStr(params);
|
||||
|
||||
log.info("【==接收到桩端故障记录==】, 桩编号:{}, 自定义参数:{}", pileSn, paramsStr);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String msg = "88240000010058c001e907041d0209320d5e0250354633594230300500000005000000e90040004f010000000055504e511080";
|
||||
// 获取消息体
|
||||
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
||||
// log.info("上传实时数据msgBody:{}", BytesUtil.bcd2Str(msgBody));
|
||||
int startIndex = 0;
|
||||
int length = 7;
|
||||
|
||||
// 桩编码
|
||||
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||||
|
||||
startIndex += length;
|
||||
// 自定义参数
|
||||
byte[] params = BytesUtil.copyBytes(msgBody, startIndex, msgBody.length - 7);
|
||||
String paramsStr = BytesUtil.bin2HexStr(params);
|
||||
|
||||
log.info("【==接收到桩端故障记录==】, 桩编号:{}, 自定义参数:{}", pileSn, paramsStr);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user