jiangping
2025-02-14 e3067f58cce422bbd26a7729bf59f5f4f34a530f
server/jtt808_parent/jtt808-server/src/main/java/org/yzh/web/endpoint/JTHandlerInterceptor.java
@@ -1,15 +1,24 @@
package org.yzh.web.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.github.yezhihao.netmc.core.HandlerInterceptor;
import io.github.yezhihao.netmc.session.Session;
import netscape.javascript.JSObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yzh.commons.util.Byte2NumberUtils;
import org.yzh.protocol.basics.JTMessage;
import org.yzh.protocol.commons.JT808;
import org.yzh.protocol.commons.transform.AttributeKey;
import org.yzh.protocol.commons.transform.attribute.Battery;
import org.yzh.protocol.t808.T0001;
import org.yzh.protocol.t808.T0200;
import org.yzh.web.model.entity.DeviceDO;
import org.yzh.web.model.enums.SessionKey;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class JTHandlerInterceptor implements HandlerInterceptor<JTMessage> {
@@ -73,8 +82,16 @@
        boolean transform = request.transform();
        if (messageId == JT808.位置信息汇报) {
            DeviceDO device = SessionKey.getDevice(session);
            if (device != null)
            if (device != null){
                device.setLocation((T0200) request);
                if(device.getLocation()!=null && device.getLocation().getAttributes()!=null ){
                   Battery battery= (Battery) device.getLocation().getAttributes().get(AttributeKey.Battery);
                    if(battery !=null){
                        device.setBatteryVoltage(battery.getVoltage());
                    }
                }
            }
            return transform;
        }
        if (!session.isRegistered()) {