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
package tbDataModel_Dell;
import java.awt.Image;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.ImageIcon;
import DataBase.DatabaseManagement;
import Method.GetNowTime;
import PbuliClass.Shi_jian_cha_sss;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import home.Open_soft_dialog;
import tag.Tag_Dell;
import tbDataModel.Tb_gas_anchor;
 
/**´¦ÀíÆøÑ¹»ùÕ¾Êý¾Ý
 * @author yang20230730*/
@SuppressWarnings("rawtypes")
public class Dell_tb_gas_anchor {
    static Vector<Tb_gas_anchor> gas_anchorvc = new Vector<>();
    static String on="image/anchor/gasanchoronlie.png";
    static String off="image/anchor/gasanchoroff.png";
    static Image zaixian= new ImageIcon(on).getImage();// »ùվͼƬ
    static Image lixian= new ImageIcon(off).getImage();// »ùվͼƬ
    static Vector<Tb_gas_anchor> gasanchor_vector=new Vector<Tb_gas_anchor>();//´øÆøÑ¹»ùÕ¾µÄ¼¯ºÏ
    static {
        Open_soft_dialog.addara("¼ÓÔØtb_suanfa2");
        List list=DatabaseManagement.get_alldate_indatabase("tb_gas_anchor");
        Iterator iterator =list.iterator() ;
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ        
            List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
            Tb_gas_anchor tbgasanchor=new Tb_gas_anchor();
            String id=(String) info.get(0); //ÐòºÅ
            String anchorid=(String) info.get(1); //ÆøÑ¹»ùÕ¾ID
            String anchorid2=(String) info.get(2); //±¸ÓÃÆøÑ¹»ùÕ¾ID
            String anchorx=(String) info.get(3); //ÆøÑ¹»ùÕ¾X×ø±ê
            String anchory=(String) info.get(4); //ÆøÑ¹»ùÕ¾Y×ø±ê
            String anchorz=(String) info.get(5); //ÆøÑ¹»ùÕ¾Z×ø±ê
//            String onlie=(String) info.get(6); //ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
//            String gasvalue=(String) info.get(7); //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ
            String refresh_time=(String) info.get(8); //ÆøÑ¹»ùÕ¾¸üÐÂÊý¾Ýʱ¼ä
            tbgasanchor.setId(id);
            tbgasanchor.setAnchorid(anchorid);
            tbgasanchor.setAnchorid2(anchorid2);
            if(anchorx.length()<1) {
                anchorx="0";
            }
            if(anchory.length()<1) {
                anchory="0";
            }
            tbgasanchor.setAnchorx(anchorx);
            tbgasanchor.setAnchory(anchory);
            tbgasanchor.setAnchorz(anchorz);
            tbgasanchor.setOnlie("-1");
            tbgasanchor.setGasvalue("-1");
            tbgasanchor.setRefresh_time(refresh_time);
            tbgasanchor.setAnchorqiyagaodu(-1);
            tbgasanchor.setAnc_image(lixian);
            gas_anchorvc.add(tbgasanchor);            
        }
    }
 
    /**ͨ¹ýÉ豸±àºÅÕÒµ½É豸*/
    public static Tb_gas_anchor get_Tb_gas_anchor(String anchorid) {
        Tb_gas_anchor tbgasanchor=null;
        int size=gas_anchorvc.size();
        if(size>0) {
            for(int i=0;i<size;i++) {
                Tb_gas_anchor tbgasanchor1=gas_anchorvc.get(i);
                String ancid=tbgasanchor1.getAnchorid();
                if(anchorid.equals(ancid)) {
                    tbgasanchor=tbgasanchor1;
                    break;
                }
            }
        }
        return tbgasanchor;
    }
 
    /**ÐÂÔö»òÕßÐ޸ĶÔÏó*/
    public static void add_alert(
            String anchorid,//ÆøÑ¹»ùÕ¾ID
            String anchorid2, //±¸ÓÃÆøÑ¹»ùÕ¾ID
            String anchorx,//ÆøÑ¹»ùÕ¾X×ø±ê
            String anchory, //ÆøÑ¹»ùÕ¾Y×ø±ê
            String anchorz, //ÆøÑ¹»ùÕ¾Z×ø±ê
            String onlie,//ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
            String gasvalue //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ            
            ) {
        Tb_gas_anchor tbgasanchor=get_Tb_gas_anchor(anchorid);
        String refresh_time=GetNowTime.now();
        int type=0;
        if(tbgasanchor==null) {
            tbgasanchor=new Tb_gas_anchor();
            tbgasanchor.setAnchorid(anchorid);
            tbgasanchor.setAnchorid2(anchorid2);
            tbgasanchor.setAnchorx(anchorx);
            tbgasanchor.setAnchory(anchory);
            tbgasanchor.setAnchorz(anchorz);
            tbgasanchor.setOnlie(onlie);
            tbgasanchor.setGasvalue(gasvalue);
            tbgasanchor.setRefresh_time(refresh_time);
            gas_anchorvc.add(tbgasanchor);
 
        }else {
            tbgasanchor.setAnchorid(anchorid);
            tbgasanchor.setAnchorid2(anchorid2);
            tbgasanchor.setAnchorx(anchorx);
            tbgasanchor.setAnchory(anchory);
            tbgasanchor.setAnchorz(anchorz);
            tbgasanchor.setOnlie(onlie);
            tbgasanchor.setGasvalue(gasvalue);
            tbgasanchor.setRefresh_time(refresh_time);
            type=1;
        }
        insert_database(
                type,//0ÊDzåÈ룬1ÊÇÐÞ¸Ä
                anchorid,//ÆøÑ¹»ùÕ¾ID
                anchorid2, //±¸ÓÃÆøÑ¹»ùÕ¾ID
                anchorx,//ÆøÑ¹»ùÕ¾X×ø±ê
                anchory, //ÆøÑ¹»ùÕ¾Y×ø±ê
                anchorz, //ÆøÑ¹»ùÕ¾Z×ø±ê
                onlie,//ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
                gasvalue, //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ
                refresh_time
                );
    }
 
 
    /**Êý¾Ý²åÈë²ã×éÊý¾Ý¿â*/
    public static void insert_database(
            int type,//0ÊDzåÈ룬1ÊÇÐÞ¸Ä
            String anchorid,//ÆøÑ¹»ùÕ¾ID
            String anchorid2, //±¸ÓÃÆøÑ¹»ùÕ¾ID
            String anchorx,//ÆøÑ¹»ùÕ¾X×ø±ê
            String anchory, //ÆøÑ¹»ùÕ¾Y×ø±ê
            String anchorz, //ÆøÑ¹»ùÕ¾Z×ø±ê
            String onlie,//ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
            String gasvalue, //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ
            String refresh_time
            ) {
 
        String[] ziduan= {                 
                "anchorid2",  
                "anchorx",  
                "anchory",  
                "anchorz",  
                "onlie",   
                "gasvalue",  
                "refresh_time",
                "anchorid"
        };
 
        String[] zhi= {                 
                anchorid2,  
                anchorx,  
                anchory,  
                anchorz,  
                onlie,   
                gasvalue,  
                refresh_time,
                anchorid
        };
        if(type==0) {
            DatabaseManagement.insertfast("tb_gas_anchor", ziduan, zhi);
            Tag_Dell.add_tag(anchorid, "ÆøÑ¹»ùÕ¾",anchorz,"1000","1",0,"ϵͳĬÈÏ",0);
            ShowMessage.zidingyi(anchorid+"±£´æ³É¹¦...");
        }else {
            DatabaseManagement.fast_alert_dbase("tb_gas_anchor", ziduan, zhi);
            ShowMessage.zidingyi(anchorid+"Ð޸ijɹ¦...");
        }
 
    }
 
    /**ÐÞ¸Äij¸ö×ֶεÄÖµ*/
    public static void alert_one_dabase(String valuename,String vlue,String anchorid) {
        String[] ziduan= {valuename,anchorid};
        String[] zhi= {vlue,anchorid};
        DatabaseManagement.fast_alert_dbase("tb_gas_anchor", ziduan, zhi);
    }
 
 
    /**ÅÐ¶ÏÆøÑ¹»ùÕ¾ÊÇ·ñÀëÏß*/
    public static void gasanchor_off() {
        int size=gas_anchorvc.size();
        if(size !=0) {
            for(int i=0;i<size;i++) {
                Tb_gas_anchor ac=gas_anchorvc.get(i);
                String state=ac.getOnlie();                
                if(state.equals("1")) {//Èç¹û»ùվ֮ǰ´¦ÓÚÔÚÏß״̬ÔÙÅжÏÊÇ·ñÀëÏß
                    String tm=ac.getRefresh_time();                        
                    int a= Shi_jian_cha_sss.get_time_cha_s(GetNowTime.now(),tm);
                    int b=30;
                    if( a>b) {
                        ac.setOnlie("0");
                        String anchorid=ac.getAnchorid();
                        alert_one_dabase("onlie","0",anchorid);
                        ac.setAnc_image(lixian);
                        ac.setOnlie("0");
                        ac.setGasvalue("-1");
                    }
                }
            }
        }
    }
 
    /**ÐÞ¸ÄÉ豸״̬*/
    public static void alert_state(Tb_gas_anchor ac,String gasvalue) {
        if(ac!=null) {
            ac.setOnlie("1");
            ac.setAnc_image(zaixian);
            ac.setGasvalue(gasvalue);
            ac.setRefresh_time(GetNowTime.now());
        }
 
    }
 
 
    /**ËÑËØÄ³¸öÆøÑ¹»ùÕ¾¶ÔÏó*/
    public static Vector<Tb_gas_anchor>  getserch_gasanchor(String anchorid){
        Vector<Tb_gas_anchor> gasvc=new Vector<Tb_gas_anchor>();
        Tb_gas_anchor tbgasanchor=get_Tb_gas_anchor(anchorid);
        if(tbgasanchor!=null) {
            String tagid=tbgasanchor.getAnchorid();
            if(tagid.equals(anchorid)) {
                gasvc.add(tbgasanchor);
            }
        }
        return gasvc;
    }
 
    /**»ñÈ¡ÆøÑ¹»ùÕ¾¼¯ºÏ*/
    public static Vector<Tb_gas_anchor> getGas_anchorvc() {
        return gas_anchorvc;
    }
 
    public static void setGas_anchorvc(Vector<Tb_gas_anchor> gas_anchorvc) {
        Dell_tb_gas_anchor.gas_anchorvc = gas_anchorvc;
    }
 
    /**»ñÈ¡Èýά²Î¿¼»ùÕ¾IDµÄ¼¯ºÏ*/
    public static String[] get_gasanchoridstrs() {
        String[] anchoridstr=null;
        if(Systems.isIssanwei()) {
            int size=gasanchor_vector.size();        
            anchoridstr=new String[size+1];
            anchoridstr[0]="Ñ¡Ôñ²Î¿¼»ùÕ¾";
            if(size !=0) {
                for(int i=0;i<size;i++) {
                    anchoridstr[i+1]=gasanchor_vector.get(i).getAnchorid();
                }
            }
        }else {
            anchoridstr=new String[1];
            anchoridstr[0]="Ñ¡Ôñ²Î¿¼»ùÕ¾";
        }
        return anchoridstr;        
    }
 
    public static Vector<Tb_gas_anchor> getGasanchor_vector() {
        return gasanchor_vector;
    }
 
    public static void setGasanchor_vector(Vector<Tb_gas_anchor> gasanchor_vector) {
        Dell_tb_gas_anchor.gasanchor_vector = gasanchor_vector;
    }
}