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
package jiekou;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import com.alibaba.fastjson.JSONObject;
import BaoWen.DellMessage;
import BaoWen.Udp_Out;
import Method.GetNowTime;
import person.Person;
import person.person_Dell;
import static Method.GetNowTime.timestamp;
 
public class Custom1 {
    static String timestamp;
    /**data_type;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÊý¾ÝÀàÐÍ£¬¶¨Î»Êý¾ÝΪ¡°1¡±
     * tag_id;      Êý¾ÝÀàÐÍString;  ËµÃ÷£º¶¨Î»±êÇ©id£¬Ê®Áù½øÖÆ
     * tag_id_dec;      Êý¾ÝÀàÐÍString;  ËµÃ÷£º¶¨Î»±êÇ©id£¬Ê®½øÖÆ
     * x;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºX×ø±ê
     * y;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºY×ø±ê
     * z;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºZ×ø±ê£¬Ä¬ÈÏ1. 000000
     * floor;   Êý¾ÝÀàÐÍString;  ËµÃ÷£º±êÇ©ËùÔڵIJã
     * timestamp;      Êý¾ÝÀàÐÍString;  ËµÃ÷£º¶¨Î»Ê±¼ä´Á£¬µ¥Î»:ºÁÃë
     * sn;      Êý¾ÝÀàÐÍString;  ËµÃ÷£º¶¨Î»ÐòºÅ£¬0-255Ò»¸öÖÜÆÚ
     * battery;      Êý¾ÝÀàÐÍString;  ËµÃ÷£º±êÇ©µç³ØÊ£Óàµçѹ£¬µ¥Î»£ºV £»-1±íʾ³õʼ»¯£»
     * heart_rates;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÐÄÂÊÊý¾Ý, heart_rate_val£ºÊý¾ÝÖµ
     * systolic_val;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÑªÑ¹¸ßÖµ£¨ÊÕËõѹ£©£»-1±íʾ³õʼ»¯£»
     * diastolic_val;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÑªÑ¹µÍÖµ£¨ÊæÕÅѹ£© £»-1±íʾ³õʼ»¯£»
     * oxygen_val;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÑªÑõ£¨Î´ÆôÓã© £»-1±íʾ³õʼ»¯£»
     * temp_val;      Êý¾ÝÀàÐÍString;  ËµÃ÷£ºÎ¶ȣ¨Î´ÆôÓã© £»-1±íʾ³õʼ»¯£»
     * anchors    Array    µ±Ç°¶¨Î»»ùÕ¾£¬Ò»¸ö»òÕß¶à¸ö £»-1±íʾ³õʼ»¯£»
     * events    Array    ±êǩʼþ£¬event_typeÒ»¸ö»òÕß¶à¸ö
     * MOVE    Òƶ¯ £»-1±íʾ³õʼ»¯£»0±íʾ¾²Ö¹£¬1±êÇ©ÒÆ¶¯
     * SOS    °´Å¥£»-1±íʾ³õʼ»¯£»0±íʾûÓа´Ï£¬1±íʾ°´ÏÂ
     * MOTIONLESS    ¾²Ö¹ £»-1±íʾ³õʼ»¯£»0±íʾ¾²Ö¹£¬1±íʾδ¾²Ö¹
     * LOCK    Ëø×¡ £»-1±íʾ³õʼ»¯£»0±íʾûÓÐËø×¡£¬1±íÊ¾Ëø×¡
     * DISMANTLE    ²ð³ý£»-1±íʾ³õʼ»¯£»0±íʾ²ð³ý£¬1±íʾûÓвð³ý6
     * */
 
    public static void  costom1out(String tagid){
        Person person=person_Dell.get_Person(tagid);
        if(person==null) {
            return;
        }
        String  tag_id_dec=person.getP_tagid();
        String tag_id=DellMessage.decodeHEX(tag_id_dec)+"";
        String x=String.valueOf(person.getP_x());
        String y=String.valueOf(person.getP_y());
        String z=String.valueOf(person.getP_z());
        double x1 = Double.parseDouble(x)/100;
        double y1 = Double.parseDouble(y)/100;
        double z1 = Double.parseDouble(z)/100;
        String floor=person.getP_floor();
        timestamp=String.valueOf(GetNowTime.timestamp2());
 
        String sn=person.getSn();
        String battery=person.getP_power();
//        String MOVE=person.getJingzhi();
//        String SOS=person.getSos_state();
//        String MOTIONLESS=person.getSleep();
//        String LOCK=person.getLOCK();
//        String DISMANTLE=person.getTagoff();
 
        JSONObject json = new JSONObject(true);
        json.put("data_type", "1");
        json.put("tag_id_dec", tag_id_dec);
        json.put("tag_id", tag_id);
        json.put("x", String.valueOf(x1));
        json.put("y", String.valueOf(y1));
        json.put("z", String.valueOf(z1));
        json.put("floor", floor);
        json.put("timestamp", String.valueOf(timestamp(timestamp)));
        json.put("sn", sn);
        json.put("battery",battery);
        json.put("heart_rates",heart_rate_val(person));
        json.put("blood_pressure",blood_pressure(person));
        json.put("blood_oxygen",blood_blood_oxygen( person));
        json.put("temperature",temperature( person));
        json.put("anchors",getanchorids(person));
        json.put("events",getEvents(person));
        Udp_Out.coustom1_udptcp_out(json.toString(), tag_id_dec);
    }
 
    /**»ñÈ¡²â¾à»ùÕ¾µÄ¼¯ºÏ*/
    public static Object[] getanchorids(Person person){
        String[] anchorids=person.getAnchors();
        if(anchorids==null) {
            return null;
        }
        int size=anchorids.length;
        Object[] bbb = new Object[size];
        for (int i = 0; i < size; i++) {
            Map<String, String> hash=new HashMap<String, String>();
            hash.put("anchar_id", anchorids[i]);
            bbb[i] = hash;
        }
        return bbb;
    }
 
    /**»ñµÃ±êǩʼþ**/
    @SuppressWarnings("rawtypes")
    public static  Object[] getEvents(Person person){
        
        Vector<Map> vector=new Vector<Map>();
        Map<String, String> hash=new HashMap<String, String>();
        Map<String, String> hash1=new HashMap<String, String>();
        Map<String, String> hash2=new HashMap<String, String>();
        Map<String, String> hash3=new HashMap<String, String>();
        if ("0".equals(person.getTagoff())){
            hash.put("event_type","DISMANTLE");
            vector.add(hash);
        }
        if ("0".equals(person.getJingzhi())){
            hash1.put("event_type","MOVE");
            vector.add(hash1);
        }
        if ("1".equals(person.getJingzhi())){
            hash1.put("event_type","MOTIONLESS");
            vector.add(hash1);
        }
        if ("1".equals(person.getP_sos())){
            hash2.put("event_type","SOS");
            vector.add(hash2);
        }
        if ("1".equals(person.getXiumian())){
            hash3.put("event_type","LOCK");
            vector.add(hash3);
        }
        Object[] objects=new Object[vector.size()];
        for (int i = 0; i < vector.size(); i++) {
            objects[i]=vector.get(i);
        }
 
        return objects;
    }
 
    /**»ñÈ¡heart_rates¼¯ºÏ*/
    public static Map<String, String> heart_rate_val(Person person){
        String heart_rates=person.getBaoliu16();
        int i = Integer.parseInt(heart_rates);
 
        if (i<=0){
            i=70;
        }
        Map<String, String> hash=new HashMap<>();
        hash.put("heart_rate_val", String.valueOf(i));
        return hash;
    }
 
    /**»ñÈ¡blood_pressure¼¯ºÏ*/
    public static Map<String, String> blood_pressure(Person person){
        String systolic_val=person.getSystolic_val();
        int i = Integer.parseInt(systolic_val);
        if (i<0){
            i=0;
        }
        String diastolic_val=person.getDiastolic_val();
        int i1 = Integer.parseInt(diastolic_val);
        if (i1<0){
            i1=0;
        }
        Map<String, String> hash=new HashMap<String, String>();
        hash.put("systolic_val", String.valueOf(i));
        hash.put("diastolic_val", String.valueOf(i1));
        hash.put("timestamp", String.valueOf(timestamp(timestamp)));
 
        return hash;
    }
 
    /**»ñÈ¡blood_oxygen¼¯ºÏ*/
    public static Map<String, String> blood_blood_oxygen(Person person){
        String oxygen_val=person.getOxygen_val();
        int i = Integer.parseInt(oxygen_val);
        if (i<0){
            i=0;
        }
        Map<String, String> hash=new HashMap<String, String>();
        hash.put("oxygen_val",String.valueOf(i));
        hash.put("timestamp", String.valueOf(timestamp(timestamp)));
        return hash;
    }
 
    /**»ñÈ¡temperature¼¯ºÏ*/
    public static Map<String, String> temperature(Person person){
        String temp_val=person.getTemp_val();
        int i1 = Integer.parseInt(temp_val);
        if (i1<0){
            i1=0;
        }
        Map<String, String> hash=new HashMap<String, String>();
        hash.put("temp_val",String.valueOf(i1));
        hash.put("timestamp", String.valueOf(timestamp(timestamp)));
 
        return hash;
    }
 
 
 
}