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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
package BaoWen;
import java.awt.geom.Point2D;
import java.util.logging.Logger;
 
import Method.GetNowTime;
import Method.PutPosInHistoryDataBase;
import PbuliClass.Shi_jian_cha_sss;
import PbuliClass.Systems;
import fence.Fences;
import fence.PointIsInWall;
import fence.PointIsInshinei;
import fence.PointIsInwuxiao;
import jiekou.display;
import person.Person;
import tag.Tag;
import tag.Tag_Dell;
import tbDataModel.Tb_gps;
import tbDataModel_Dell.Dell_ReallPoint;
import tbDataModel_Dell.Dell_tb_suanfa2;
import tbDataModel_Dell.Map_Dell;
import urt.xytoutm;
import zijisuan.Zjsdo;
 
/**ÅжϱêÇ©ÔÚÊÒÍ⻹ÊÇÔÚÊÒÍâ*/
public class Juge_indoor {
    static Logger logger= Logger.getLogger(String.valueOf(Juge_indoor.class));
    static int jiange=Integer.parseInt(Systems.sys().getBaoliu22());    
    static String jwd="0";//¾­Î³¶ÈתΪ¶È¸ñʽ±£´æ
 
    /**µ±Êý¾ÝÀ´Ô´ÊÇUWBµÄʱºò*/
    public static void data_from_uwb(Person person,String baoxu,String intime) {
        String gnggatime=person.getReceive_gngga_time();
        if(gnggatime.equals("-1")) {//ûÓÐÊÕµ½ÓÐЧµÄGNGGAÊý¾Ý
            pos_form_uwb_or_gps(1,person,baoxu,intime);
            person.setIndoor_or_outdoor(1);
            person.setReason_indoor_from("δÊÕµ½GNGGA");
        }else {
            boolean aa=Shi_jian_cha_sss.shijiancha(gnggatime,3);
            if(aa) {//Èç¹û3ÃëÖÓÄÚûÓÐÊÕµ½ÓÐЧµÄÎÀÐǶ¨Î»Êý¾Ý
                pos_form_uwb_or_gps(1,person,baoxu,intime);
                person.setIndoor_or_outdoor(1);
                person.setReason_indoor_from("3sδÊÕµ½GNGGA");
            }else {//Èç¹û3ÃëÖÓÄÚÓÐÊÕµ½ÓÐЧµÄÎÀÐǶ¨Î»Êý¾Ý
                if(Dell_tb_suanfa2.isJuli_juge_in()) {//Èç¹û¿ªÆôͨ¹ý¾àÀëÅжÏÊÒÄÚÍâ
                    if(person.getdistance_juge_indoor()==1) {//ÔÚÊÒÄÚ
                        person.setIndoor_or_outdoor(1);
                        person.setReason_indoor_from("²â¾à¾àÀëÅжÏ");
                        if(person.getGngga_state() !=4) {//GNGGA²»ÊǸ߾«¶È״̬
                            pos_form_uwb_or_gps(1,person,baoxu,intime);
                        }
                    }else {//ͨ¹ý¾àÀëÅжϲ»ÔÚÊÒÄÚ
                        juge_indoor_fence(person,baoxu,intime);
                    }
                }else {//Èç¹ûû¿ªÆôͨ¹ý¾àÀëÅжÏÊÒÄÚÍâ
                    juge_indoor_fence(person,baoxu,intime);
                }
            }
        }
 
    }
 
    /**µ±Êý¾ÝÀ´Ô´ÊÇGPSµÄʱºò*/
    public static void data_from_gps(Person person,Tb_gps gps,String gpsxinhao,String tagid) {
        String intime=GetNowTime.timestamp2();
        String uwbtime=person.getReceive_uwbpos_time();
        if(uwbtime.equals("-1")) {//ûÓÐÊÕµ½ÓÐЧµÄUWBÊý¾Ý
            pos_form_uwb_or_gps(0,person,"65535",intime);
            person.setIndoor_or_outdoor(0);
            person.setReason_indoor_from("δÊÕµ½UWB");
        }else {
            boolean aa=Shi_jian_cha_sss.shijiancha(uwbtime,5);
            if(aa) {//Èç¹û5ÃëÖÓÄÚûÓÐÊÕµ½ÓÐЧµÄUWB¶¨Î»Êý¾Ý
                pos_form_uwb_or_gps(0,person,"65535",intime);
                person.setIndoor_or_outdoor(0);
                person.setReason_indoor_from("5sδÊÕµ½UWB");
            }else {//Èç¹û5ÃëÖÓÄÚÓÐÊÕµ½ÓÐЧµÄuwb¶¨Î»Êý¾Ý
                if(person.getGngga_state() ==4) {//GNGGAÊǸ߾«¶È״̬
                    pos_form_uwb_or_gps(0,person,"65535",intime);
                    person.setIndoor_or_outdoor(0);
                    person.setReason_indoor_from("¸ß¾«¶È״̬");
                }else {
                    if(person.getdistance_juge_indoor()  !=1 && person.getIndoor_fence() !=1) {//Èç¹ûUWBûÓÐÅжϳöÊÇ·ñÔÚÊÒÄÚ
                        if(Dell_tb_suanfa2.isGps_xinhao_in()) {//¿ªÆôÎÀÐÇÐźÅÅжÏÊÒÄÚÍâ
                            juge_urt_indorr_to_xinhao(gps,gpsxinhao,tagid,person,intime);
                        }else {//û¿ªÆôÎÀÐÇÐźÅÅжÏÊÒÄÚÍâ
                            pos_form_uwb_or_gps(0,person,"65535",intime);
                            person.setIndoor_or_outdoor(0);
                            person.setReason_indoor_from("UWBÅжϲ»ÔÚÊÒÄÚ");
                        }
                    }
                }
            }
        }
    }
 
    /**È·¶¨Î»ÖÃÀ´Ô´ÊÇGPS»òÕßUWB
     * int datafrom=0±íʾÊý¾ÝÀ´Ô´GPS£¬1±íʾÀ´Ô´ÓÚUWB*/
    public static void pos_form_uwb_or_gps(int datafrom,Person person,String baoxu,String intime) {
        String tagid=person.getP_tagid();
        Tag tag = Tag_Dell.get_tag(tagid);
        int x=person.getUwb_x();
        int y=person.getUwb_y();
        double z=person.getUwb_z();    
        String floor=person.getP_floor();
        if(datafrom==0) {//Èç¹ûÊý¾ÝÀ´Ô´ÊÇGNGGA
            x=person.getGps_x();
            y=person.getGps_y();
            z=person.getGps_z();
            floor=String.valueOf(person.getGps_floor());
        }
        if (Fences.get_fence_vector("Î§Ç½ÇøÓò").size()>0){//Èç¹ûÎ§Ç½ÇøÓò´æÔÚ
            if(tag.getTag_in_wall()==0) {
                int[] ints = PointIsInWall.inwall(x, y,floor);
                if (ints!=null) {
                    x = ints[0];
                    y = ints[1];
                }
            }
        }
        String xx=String.valueOf(x);
        String yy=String.valueOf(y);
        int intz=(int)z;
        String zz=String.valueOf(intz);    
        String batarry=person.getP_power();
        String state=person.getJingzhi();
        String sos=person.getP_sos();
        person.setPosfrom(datafrom);
        person.setP_online("1");
        int intfloor=Integer.parseInt(floor);
        PointIsInwuxiao.juge(person, x, y,intfloor,intz);//ÅжϱêÇ©ÊÇ·ñÔÚÎÞÐ§ÇøÓò
        int inwuxiao=person.getInwuxiaoqu();//ֵΪ1±íʾÔÚÎÞÐ§ÇøÓò0²»ÊÇ
        if(inwuxiao ==1) {//ÔÚÎÞÐ§ÇøÓòÔò·µ»Ø
            person.setReason_indoor_from("ÔÚÎÞÐ§ÇøÓò");
            return;
        }
        person.setP_x(x);
        person.setP_y(y);
        person.setP_z(intz);
        person.setP_floor(floor);        
        person.setLasttime(GetNowTime.now());        
        Dell_ReallPoint.insertpoid(tagid, x, y,floor);//½«Î»ÖÃÐÅÏ¢·ÅÈë¹ì¼£¼¯ºÏ,Èç¹û²»ÊDz»ÏÔʾʵʱ¹ì¼£
        if(Systems.isGps2000()) {//Èç¹û¿ªÆôxyתgnss    
            double[] xycs=Map_Dell.get_xycs(floor);
            if (xycs!=null) {
                String a[] = xytoutm.xy2jwd(xx, yy, xycs);
                String jingdu = String.valueOf(a[1]);//¶È¸ñʽ
                String weidu = String.valueOf(a[0]);//¶È¸ñʽ
                jwd=jingdu+","+weidu;
                display.out2(tagid, jingdu, weidu, zz, batarry);
                person.setBaoliu2(jingdu);
                person.setBaoliu3(weidu);
                person.setBaoliu4(zz);
 
            }
        }else {//Èç¹ûûÓпªÆôxyתgnss    
            display(x,y,tagid, baoxu, intime,floor, xx, yy,zz, batarry,state,sos,person);
        }        
        //Èç¹ûÊÇÓÐЧµÄλÖÃÐÅÏ¢ÐèÒª×öЩÊÂÇé
        HaveOkPosDo.do_something(tagid,baoxu,x,y,intz,floor,zz,batarry);
        PutPosInHistoryDataBase.putInHistory(person,tagid,xx,yy,zz,floor,"-1",jwd);//Êý¾Ý´æÈë¹ì¼£Êý¾Ý¿â
 
    }
 
 
    /**ת·¢Î»ÖÃÊý¾Ý*/
    public static void display(
            int x,
            int y,
            String tagid, 
            String baoxu, 
            String intime, 
            String ceng, 
            String xx, 
            String yy,
            String zz, 
            String batarry,
            String state, 
            String sos,
            Person per) {
        if(Systems.isRealzhuanfa()) {//Èç¹û¿ªÆôʵʱλÖÃת·¢¼ä¸ô
            if(per.getZhuanfatime()==null) {                
                display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
                per.setZhuanfatime(GetNowTime.now());
            }else {
                display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
                per.setZhuanfatime(GetNowTime.now());
 
            }
        }else {//Èç¹ûûÓпªÆôʵʱλÖÃת·¢¼ä¸ô
            display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
        }
        /**Êý¾Ý¸ñʽ£º
         * °üÐò+±êÇ©ID£¨Î¨Ò»£©+X×ø±ê+Y×ø±ê+Z×ø±ê£¨×ø±êµ¥Î»ÀåÃ×£©+¾­¶È+ά¶È+¸ß³Ì+Êý¾ÝÀ´Ô´(1±íʾUWB£¬0±íʾÎÀÐÇ)*/
        if(Systems.getZijiesuan() !=0) {//×Ô½âËãģʽÈç¹û¿ªÆô
            double[] xycs=Map_Dell.get_xycs(ceng);
            String a[]=xytoutm.xy2jwd(xx, yy,xycs);            
            String jingdu2=String.valueOf(a[3]);//¶È·Ö¸ñʽ
            String weidu2=String.valueOf(a[2]);//¶È·Ö¸ñʽ
            double dz=Double.parseDouble(zz);
            Zjsdo.sendxy(per,tagid, baoxu, x, y,dz,jingdu2,weidu2,ceng);
        }
    }
 
 
    /**ÅжÏÊÇ·ñÔÚÊÒÄÚÇøÓòͨ¹ýÊÒÄÚÇøÓòÅжÏ*/    
    public static void juge_indoor_fence(Person person,String baoxu,String intime) {
        if(Dell_tb_suanfa2.isInuwbarea()) {    //Èç¹û¿ªÆôÊÒÄÚÇøÓòÅжϹ¦ÄÜ            
            int size=Fences.getShinei_fences().size();
            if(size !=0 ) {
                int x=person.getUwb_x();
                int y=person.getUwb_y();
                String floor=person.getP_floor();
                String tagid=person.getP_tagid();
                Point2D.Double point=new Point2D.Double(x,y);
                PointIsInshinei.is_in_shinei(size,Fences.getShinei_fences(),
                        tagid,x,y, floor,point);
                int inddorfc=person.getIndoor_fence();
                if(inddorfc==1) {//ÔÚÊÒÄÚÇøÓò
                    person.setIndoor_or_outdoor(1);
                    person.setReason_indoor_from("ÔÚÊÒÄÚÇø");
                    if(person.getGngga_state() !=4) {//GNGGA²»ÊǸ߾«¶È״̬
                        pos_form_uwb_or_gps(1,person,baoxu,intime);
                    }
                }else {
                    person.setReason_indoor_from("²»ÔÚÊÒÄÚÇø");
                }
            }
        }
    }
 
    /**¸ù¾ÝÐźÅÇ¿¶ÈÅжÏURTÊÇ·ñÔÚÊÒÄÚ
     * @param lenthGNGGA±¨Îij¤¶È
     * @param gpsxinhao URTÐźÅÇ¿¶È*/
    public static void juge_urt_indorr_to_xinhao(Tb_gps gps,String gpsxinhao,
            String tagid,Person person,String intime) {
 
        //ÎÀÐÇÐźÅÇ¿¶È
        int gpsqiangdu=Integer.parseInt(gpsxinhao);
        int jishu=gps.getGpsxinhaonum();
        int xinhao=gps.getGpsxinhao();
        if(jishu<Dell_tb_suanfa2.getGpsjishu()) {
            gps.setGpsxinhao(xinhao+gpsqiangdu);
            int num=jishu+1;
            gps.setGpsxinhaonum(num);
        }else {
            double pingjun=xinhao/jishu;
            person.setGpsxinhao10(String.valueOf(pingjun));                        
            //Èç¹ûÐźÅÇ¿¶È´óÓÚµÈÓÚmax
            if(pingjun>=Dell_tb_suanfa2.getMax()) {
                person.setIndoor_or_outdoor(0);
                person.setReason_indoor_from("GPSÐźÅÇ¿¶ÈÇ¿");
                pos_form_uwb_or_gps(0,person,"65535",intime);
            }else if(pingjun<=Dell_tb_suanfa2.getSmall()) {
                person.setIndoor_or_outdoor(1);
                person.setReason_indoor_from("GPSÐźÅÇ¿¶ÈÈô");
                pos_form_uwb_or_gps(1,person,"65535",intime);
            }                                
            gps.setGpsxinhao(0);
            gps.setGpsxinhaonum(0);
        }
    }
 
    /**½«XY×ø±êתΪ¶È¸ñÊ½×ø±ê
     * @param xxΪX×ø±ê
     * @param yyΪY×ø±ê
     * @param floorËùÔÚ²ã*/
    public static  String[] xy2d(String xx,String yy,String floor) {
        String[] jw= {"0","0"};
        if(Systems.isGps2000()) {//Èç¹û¿ªÆôxyתgnss    
            double[] xycs=Map_Dell.get_xycs(floor);
            if (xycs!=null) {
                String a[] = xytoutm.xy2jwd(xx, yy, xycs);
                jw[0] = String.valueOf(a[1]);//¶È¸ñʽ
                jw[1] = String.valueOf(a[0]);//¶È¸ñʽ                
            }
        }
        return jw;
    }
 
 
    /**½«xyת»»ºóµÄÊý¾Ý·¢Ë͸øÖ÷»ùÕ¾
     * @param tagid
     * @param lat
     * @param lon
     *//*
    public static void data2ac(String tagid, String lat, String lon, String anchorid){
        String out2ac="uwb,"+tagid+","+lat+","+lon+","+GetNowTime.sss();
        byte[] byt= out2ac.getBytes(StandardCharsets.UTF_8);
 
        if (!anchorid.equals("gps")) {
            Anchor anchor = Anchor_Dell.get_anchor(anchorid);
            if (anchor!=null) {
                Udp_Receive.out(byt, byt.length, anchor, "Ï·¢uwb");
            }
        }
    }*/
 
}