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
package Method;
import DataBase.DatabaseManagement;
import Frame.Tag_gas_value;
import PbuliClass.Shi_jian_cha_sss;
import PbuliClass.Systems;
import person.Person;
import tag.Tag;
import tag.Tag_Dell;
import tbDataModel.Tb_gas_anchor;
 
/**¸Ã·½·¨ÓÃÓÚ½«±êÇ©×ø±ê²åÈëÀúÊ·¹ì¼£Êý¾Ý¿â*/
public class PutPosInHistoryDataBase {
    static StringBuffer suffix = new StringBuffer(); // ±£´æsqlºó׺
    static StringBuffer suffix2 = new StringBuffer(); // ±£´æsqlºó׺
    static StringBuffer suffix3 = new StringBuffer(); // ±£´æsqlºó׺
    static int jishu=0;
    static int jishu3=0;
    static int baowennum=0;//±¨ÎÄÊý
    static String prefix2 = "INSERT INTO tb_yuan_shi_bao_wen (ip,str,addtime)  VALUES ";
    static String prefix3 = "INSERT INTO tag_gas_history (tagid,gasanchorid,taggas,anchorgas,reallgao,time)  VALUES ";
    
    /**baoliu1·Ã¿ÍID 
     * baoliu2¾­¶È
     * baoliu3γ¶È
     * baoliu4¸ß³Ì
     * baoliu5¾«¶È״̬
     * baoliu6SOS״̬
     * baoliu7µçÁ¿*/
    public static void  putInHistory(
            Person per,
            String tagid,
            String x,
            String y,
            String z,
            String layer,
            String gps_state,
            String jwd
            ) {
        if(Systems.isSaveguiji()) {//Èç¹û¿ªÆô¹ì¼£±£´æ¹¦ÄÜ
            String time=GetNowTime.timestamp2();
            String baoliu1=per.getBaoliu1();//·Ã¿ÍID
            String baoliu2=per.getBaoliu2();//¾­¶È
            String baoliu3=per.getBaoliu3();//γ¶È
            String baoliu4=per.getBaoliu4();//¸ß³Ì
            String baoliu5=gps_state;//¾«¶È״̬
            String baoliu6=jwd;//¾­Î³¶È¶È¸ñʽ
            String baoliu7=per.getP_power();//µçÁ¿
            String baoliu8=per.getP_name();
            String tb_track="tb_track_"+GetNowTime.getyearmd();
            String prefix = "INSERT INTO "+tb_track
                    +" (tagid,x,y,z,layer,time,baoliu1,baoliu2,baoliu3,baoliu4,baoliu5,baoliu6,baoliu8,baoliu7)  VALUES ";
 
            //½«±êǩʵʱλÖòåÈëÀúÊ·¹ì¼£Êý¾Ý¿âÖÐseq,tagid,x,y,z,layer,year,month,day,time,timestamp
            jishu++;                     
            suffix.append("('"+
                    tagid+"','"+
                    x+"','"+
                    y+"','"+
                    z+"','"+
                    layer+"','"+
                    time+"','"+
                    baoliu1+"','"+
                    baoliu2+"','"+
                    baoliu3+"','"+    
                    baoliu4+"','"+    
                    baoliu5+"','"+    
                    baoliu6+"','"+
                    baoliu8+"','"+
                    baoliu7+"'),");
            if(jishu==100) {
                StringBuffer sql =new StringBuffer(prefix + suffix.substring(0, suffix.length() - 1)) ; // ¹¹½¨ÍêÕûsql
                DatabaseManagement.insert_fast(sql.toString(),1);
                suffix.setLength(0); 
                jishu=0;
            }
 
            tb_track=null;
            prefix =null;
        }
    }
 
 
    public static boolean insert_baowen(String str,String ip,String time) {
        boolean inok=false;
        suffix2.append("('"+ip+"','"+str+"','"+time+"'),");
        StringBuffer sql =new StringBuffer(prefix2 + suffix2.substring(0, suffix2.length() - 1)) ; // ¹¹½¨ÍêÕûsql
        DatabaseManagement.insert_fast(sql.toString(),3); 
        suffix2.setLength(0);
        inok=true;
        return inok;
    }
 
    /**λÖùýÂ˹¦ÄÜ*/
    public static boolean  guijiguolv(Person per,String tagid,String x,String y) {
        boolean ok=false;        
        String lastokpostime=per.getLastokpostime();
        double xd=Double.parseDouble(x);
        double yd=Double.parseDouble(y);
        if(lastokpostime==null) {
            ok=true;
            per.setLastokpostime(GetNowTime.now());
            per.setLastokposx(xd);
            per.setLastokposy(yd);
        }else {
            double x0=per.getLastokposx();
            double y0=per.getLastokposy();
            double d2=(x0-xd)*(x0-xd)+(y0-yd)*(y0-yd);
            double d=Math.sqrt(d2);
            int b= Shi_jian_cha_sss.get_time_cha_s(GetNowTime.now(),lastokpostime);//ʱ¼ä²î
            Tag tag=Tag_Dell.get_tag(tagid);
            double sudu=Double.parseDouble(tag.getTag_sulv());
            double realsudu=d/b;
            if(realsudu<sudu) {
                ok=true;
                per.setLastokpostime(GetNowTime.now());
                per.setLastokposx(xd);
                per.setLastokposy(yd);
            }
        }
 
        return ok;        
    }
 
    /**½«ÆøÑ¹Êý¾Ý±£´æ½øÈëÊý¾Ý¿â*/
    public static void inset_tag_gas_in_history(
            Tb_gas_anchor ancgas,
            String tagid,
            String gasanchorid,
            String taggas,            
            String reallgao,
            String time
            ) {
        if(Tag_gas_value.isSave_history_gas_value()) {//Èç¹û¿ªÆô±£´æÀúÊ·ÆøÑ¹Öµ
            jishu3++;
            String anchorgas=ancgas.getGasvalue();
            suffix3.append("('"+tagid+"','"+gasanchorid+"','"+taggas+"','"+anchorgas+"','"+reallgao+"','"+time+"'),");
            if(jishu3==100) {
                StringBuffer sql =new StringBuffer(prefix3 + suffix3.substring(0, suffix3.length() - 1)) ; // ¹¹½¨ÍêÕûsql
                DatabaseManagement.insert_fast(sql.toString(),1);
                suffix3.setLength(0); 
                jishu3=0;
            }
        }
        
    }
 
}