zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package urt;
 
import BaoWen.Udp_Out;
import BaoWen.Urt_7000_port;
import DataBase.DatabaseManagement;
import Frame.UtrSet;
import Method.BaoWenShow;
import Method.GetNowTime;
import Method.InsertData;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import VectroData.ForwardDatas;
import engbs.BS_urt_add_fence;
import engbs.Bs_look_baowen;
import jiekou.Warnig;
import person.Person;
import person.person_Dell;
import tag.Tag_Dell;
import tbDataModel.Tb_gps;
 
public class Dell_Urt_XTB {
 
    /**
     * ´¦ÀíURTÐÄÌø°ü
     */
    //¸ñʽ£º°üÍ·+±êÇ©ID+µçÁ¿+°æ±¾+CCID+£¨UWB״̬£¬°´¼ü£©+RTCMÔ´
    //$XTB,2205,82%,Ãâ²¼Ïß1.55,898604A52121C0699992,10,2120.253.239.161abkc8163
 
    //$XTB,3473,59%,0.16,89860423192090090715,0,RTCM:121.33.226.42:9039
    //$XTB,ID,µçÁ¿,°æ±¾,  CCID,°´¼ü,RTCMÔ´
    //$XTB,2205,82%,1.45,898604A52121C0699992,0,2140.143.212.42test007
    //ÊÇ·ñ´æÔÚÊý¾Ýת·¢
    //$XTB,2231,65%,Ãâ²¼Ïß1.55,898604A52121C0699968,10,2140.143.212.42test001
    static int size = ForwardDatas.get_tb_forward_datas().size();
    static String tagid ;
    static String vbat ;
    static String version;
    static String ccid;
    static String button;
    static String sos;
    static String ip;
    static int port;
    static String crm = "";
    static Person person=null;
 
    public static void dell_XTB(String message, String ip1, int port1) {
        ip=ip1;
        port=port1;
        String[] a = message.split(",");
        int aa = a.length;
        if (aa == 7 || aa == 6) {
            tagid = a[1];            
            vbat = a[2].replace("%", "");
            version = a[3];
            ccid = a[4];
            button = a[5];
            sos = a[5];
            crm =get_crm(aa,a[6]);//RTCMÔ´
            Bs_look_baowen.insert_all(message,tagid);//BS¶Ë²é¿´±¨ÎÄ20230725
            have_tagid_do();//ÓбêÇ©IDÐèÒª×öµÄÊÂÇé
            have_button_do();
            mian_bu_xian_do();//ϵͳÃâ²¼ÏßģʽÐèÒª×öµÄÊÂÇé
            Udp_Out.GNGGA_udptcp_out(message, tagid);//ת·¢Êý¾Ý
            Dell_gps.alert_cps(tagid, sos, ccid, version, ip, port, crm);
            Tag_Dell.tagstate3(tagid, version);
            BaoWenShow.show3(message, "GNSS", ip, String.valueOf(port), tagid);            
            zi_dong_shengji();//Èç¹û¿ªÆô×Ô¶¯Éý¼¶Ä£Ê½  ÐÞ¸Ä×Ô¶¯Éý¼¶µÄÂß¼­  2023.07.21 zsh            
        }
    }
    
    public static void sosdo(String tagid, Person person) {
        Warnig.urt_gps_sos(tagid);
        String type = person.getBaoliu19();
        if (type.equals("URT+CO")) {
            Control_urt.say_voice(tagid, "ÒÑÊÕµ½SOSÐÅÏ¢", 0, 10);
        }
    }
 
    /**yang20230721*/
    public static void have_tagid_do() {        
        person = person_Dell.get_Person(tagid);
        if (person == null) {
            Tag_Dell.add_tag(tagid,"×Ô¶¯Ìí¼Ó","150","1000","1",0,"ÈÚºÏÖÕ¶Ë",0);//×Ô¶¯Ìí¼Ó±êÇ©
        }else {
            person.setBaoliu5("3");//½«±êÇ©ÉèÖÃΪ´øgnss±êÇ©
            person.setBaoliu8(ip);//ÉèÖñêÇ©µÄIPµØÖ·
            person.setBaoliu9(port + "");//ÉèÖñêÇ©¶Ë¿Ú
            person.setGpson_off(1);//GPS¿ª¹Ø×´Ì¬1¿ªÆô
            person.setBaoliu11(crm);
        }
    }
 
    public static String get_crm(int aa,String a6) {
        String crm="";
        if (aa == 7) {
            crm =a6;
            if (crm.length() > 50) {
                crm = "error";
            }
        }
        return crm;
    }
 
    /**yang20230721*/
    public static void have_button_do() {
        if (button.length() > 1) {
            sos = button.substring(1, 2);
            String uwbstate = button.substring(0, 1);
            int uwbopen = Integer.parseInt(uwbstate);
            if (person != null) {
                person.setUwbopen(uwbopen);
            }
        }
    }
 
    /**Ãâ²¼ÏßģʽÐèÒª×öµÄÊÂÇéyang20230721*/
    public static void mian_bu_xian_do() {
        if (Systems.isWuxian()) {
            Urt_read.read_tag(tagid, "01", "33", 0);//¶ÁÈ¡»ùÕ¾²ÎÊý
            if (button.length() > 1) {
                String uwb = button.substring(0, 1);
                int uwbint = Integer.parseInt(uwb);//UWB¿ª¹Ø×´Ì¬
                if (person != null) {
                    person.setUwbopen(uwbint);
                }
            }
        }
    }
    /**yang20230721*/
    public static void gpsdo() {
        Tb_gps gps0 = Dell_gps.get_tb_gps(tagid);
        if (gps0 == null) {
            gps0 = new Tb_gps();
            gps0.setTagid(tagid);
            gps0.setAddtime(GetNowTime.timestamp2());
            gps0.setIp(ip);
            gps0.setPort(String.valueOf(port));
            gps0.setVersion(version);
            gps0.setCcid(ccid);
            gps0.setBaoliu4(crm);
            Dell_gps.getGps_vector().add(gps0);
            if (ccid.length() > 5) {
                String[] ziduan = {"ccid", "tagid"};
                String[] zhi = {ccid, tagid};
                DatabaseManagement.fast_alert_dbase("tb_gps", ziduan, zhi);
            }
            if (Systems.isUrtopen()) {
                gps0.setGps_power(vbat);
            }
 
        } else {
            if (sos.equals("1")) {
                ShowMessage.zidingyi(tagid + "°´ÏÂSOS°´¼üpower:" + vbat);
                Control_urt.say_voice(tagid, "ÊÕµ½SOSÐÅÏ¢", 1, 3);
                sosdo(tagid, person);
                String a1 = gps0.getGsp_jingdu() + "," + gps0.getGps_weidu();
                InsertData.sosInsertTbWarning(tagid, "SOS", "δ´¦Àí", a1);
                String tagid1 = BS_urt_add_fence.getTagid();
                if (tagid1.equals(tagid)) {
                    BS_urt_add_fence.getZuob().append(a1 + ";");
                    if (BS_urt_add_fence.isDrawfence()) {
                        gps0.setBaidufenczb(a1);
                        BS_urt_add_fence.setDrawfence(false);
                    }
                }
                if (size != 0) {                    
                    Warnig.sos(tagid);
                }
            }
        }
    }
 
    /**×Ô¶¯Éý¼¶Öն˹̼þ·½·¨*/
    public static void zi_dong_shengji() {
        if (UtrSet.isUpdataurt()) {//Èç¹û¿ªÆô×Ô¶¯Éý¼¶Ä£Ê½
            String upperCase = UtrSet.getVersion().toUpperCase();//ÐèÒªÉý¼¶µÄ°æ±¾ºÅ
            if (version.contains("V")){
                version = version.replace("V", "");
            }
            if (upperCase.contains("V")){
                upperCase=upperCase.replace("V","");
            }
 
            if (!version.equals(upperCase)) {//É豸µ±Ç°°æ±¾ºÅÈç¹û²»µÈÓÚÐèÒªÉý¼¶µÄ°æ±¾ºÅ
                //eg:$update,6788,http://39.106.210.13:8080/hfs/URT-F4Ãâ²¼Ïß±êÇ©V2.32-6.5G.Bin,V2021051001
                String data = "$update," + tagid + "," + "http://39.106.210.13:8080/hfs/" + 
                UtrSet.getVersionname()+","+"V2021051001";
                int size = data.getBytes().length;
                String port1 = String.valueOf(port);//É豸µ±Ç°µÄ¶Ë¿Ú
                Urt_7000_port.udp_out(data.getBytes(), size, ip, port1, tagid, data);//UDPÏ·¢×Ô¶¯Éý¼¶Ö¸Áî¸øÉ豸µ±Ç°¶Ë¿ÚºÍµØÖ·
                ShowMessage.zidingyi("Éý¼¶" + tagid + "," + ip + ":" + port + "·¢ËÍ" + data);
            }
        }
    }
    
    /**»Ø¸´É豸ÐÄÌø°üyang20230721*/
    public static void hui_fu_heart() {
        String xtbok = "$xtbok";
        byte[] bytes = xtbok.getBytes();
        Urt_7000_port.outlora(bytes, bytes.length, ip, port, xtbok);
    }
}