From 225940825bb4ba2f9535118b171a96e85ee2586e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 24 Apr 2024 23:34:21 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E8=AE=BE=E7=BD=AE=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E5=8F=82=E6=95=B0...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/jt1078/proc/response/J8103.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java index 4c06875ed..9002526fd 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java @@ -5,8 +5,11 @@ import com.genersoft.iot.vmp.jt1078.bean.JTDeviceConfig; import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute; import com.genersoft.iot.vmp.jt1078.bean.config.*; import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -22,6 +25,8 @@ import java.util.Map; @MsgId(id = "8103") public class J8103 extends Rs { + private final static Logger log = LoggerFactory.getLogger(J8103.class); + private JTDeviceConfig config; @Override @@ -32,7 +37,7 @@ public class J8103 extends Rs { Map fieldConfigAttributeMap = new HashMap<>(); for (Field field : declaredFields) { try{ - Method method = configClass.getDeclaredMethod("get" + StringUtils.capitalize(field.getName()), String.class); + Method method = configClass.getDeclaredMethod("get" + StringUtils.capitalize(field.getName())); Object invoke = method.invoke(config); if (invoke == null) { continue; @@ -42,7 +47,7 @@ public class J8103 extends Rs { fieldConfigAttributeMap.put(field, configAttribute); } }catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { - throw new RuntimeException(e); + log.error("[设置终端参数 ] 编码失败", e ); } } @@ -57,8 +62,8 @@ public class J8103 extends Rs { case "Long": buffer.writeByte(4); field.setAccessible(true); - Long longval = (Long)field.get(config); - buffer.writeLong(longval); + Long longVal = (Long)field.get(config); + buffer.writeLong(longVal); continue; case "String": field.setAccessible(true); @@ -90,11 +95,12 @@ public class J8103 extends Rs { continue; } }catch (Exception e) { - throw new RuntimeException(e); + log.error("[设置终端参数 ] 编码失败", e ); } } } + System.out.println(ByteBufUtil.hexDump(buffer)); return buffer; }