充放电一体机FGCD通信程序【二期初版】
Administrator
2022-04-26 993f8a639ce8eb9124da3a901065a87eea9f3994
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
package com.dev.fgcd.comm;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import com.battmonitor.sql.Com;
import com.battmonitor.sql.MysqlConnPool;
import com.battmonitor.sql.Sql_Mysql;
import com.dev.fgcd.data.FGCD_ComBase;
import com.dev.fgcd.data.FGCD_Station_inf;
import com.dev.fgcd.data.FGCD_TestFBOFile;
import com.dev.fgcd.data.FGCD_TestFBOFile.FBOFile;
import com.dev.fgcd.fbo.FboData;
import com.dev.fgcd.fbo.FboDataInf;
import com.mchange.v2.resourcepool.ResourcePoolListener;
 
public class FGCD_Task_Thread_SQL {
    /**
     *     ²éѯµ±Ç°op_cmd
     * @param pool
     * @param BattGroupId
     * @return
     */
    public static int quereyDownLoadState_UserCancel(MysqlConnPool pool,int battgroupid) {
        int op_cmd = 0;
        String sql_str = " SELECT op_cmd " + 
                         " FROM " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                         " WHERE BattGroupId = " + battgroupid;
        Sql_Mysql sql = new Sql_Mysql(pool);
        ResultSet res = null;
        try {
            res = sql.sqlMysqlQuery(sql_str);
            if(res.next()) {
                op_cmd = res.getInt("op_cmd");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            sql.close_con();
        }
        return op_cmd;
    }
 
    /**
     *     ²åÈëFBOÀúÊ·Êý¾Ý
     * @param pool
     * @param file
     * @param fbo
     * @param datas
     * @return
     */
    public static boolean insertFBODataIntoTable(MysqlConnPool pool,FBOFile file,FboDataInf fbo,List<FboData> datas,int BattGoupId) {
        boolean success = false;
        if(fbo.getTestTimeLong() > 0) {
            createTb_FboTestData_Table(pool, BattGoupId);
            int max_test_record_count = quereyBattMaxTestRecordCount(pool, BattGoupId);
            ArrayList<String> sql_strs = new ArrayList<>();
            sql_strs.add("INSERT INTO " + Sql_Mysql.Tb_FboTestData_Inf_Table + 
                    "(BattGroupId,test_record_count,test_starttime,test_timelong,device,test_type,hourrate,save_interval,monomervol,moncapstd,test_curr,test_cap,monvol_limit,gourpvol_limit,mon_count,monvol_limitcount,stop_type,download_time) " + 
                    " VALUES(" + BattGoupId
                    + "," +max_test_record_count
                    + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                    + "'," + fbo.getTestTimeLong()
                    + "," + fbo.Device
                    + "," + fbo.DataType 
                    + "," + fbo.HourRate
                     + "," + fbo.SaveInterval
                    + "," + fbo.MonomerVol
                    + "," + fbo.STDCap
                    + "," + fbo.TestCur 
                    + "," + fbo.TestCap
                    + "," + fbo.MVLLimit
                     + "," + fbo.SumVLLimit
                    + "," + fbo.BattSum
                    + "," + fbo.MVLLimitCount
                    + "," + fbo.StopType
                    + ",'" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
                    + "')");
            for(int i = 0;i<datas.size();i++) {
                FboData data = datas.get(i);
                //System.out.println("²âÊÔʱ³¤"+data.m_TestTime.getTestTimeString());
                String sql_str = "INSERT INTO "+Sql_Mysql.Tb_FboTestData_Table+BattGoupId+"(BattGroupId,test_record_count,test_starttime,test_timelong,record_time,record_num,online_vol,sum_vol,test_curr,test_cap,mon_num,mon_vol) " + 
                                 " VALUES";
                Date record_time = new Date(fbo.TestStartTime.getFBODateTime().getTime()+data.m_TestTime.getTestTimeLong()*1000);
                if(data.BattSum > 0) {
                    //Óе¥Ìåʱ
                    for(int k=0;k<data.BattSum && k<data.SingleVol.length;k++) {
                        sql_strs.add(sql_str + "("
                                + "" + BattGoupId
                                + "," + max_test_record_count
                                + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                                + "'," + data.m_TestTime.getTestTimeLong()
                                + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
                                + "'," + (i+1)
                                + "," + data.OnlineVol
                                + "," + data.SumVoltage
                                + "," + data.SumCurrent
                                + "," + data.AllCap
                                + "," + (k+1)
                                + "," + data.SingleVol[k]
                                + ")");
                    }                    
                }else {        
                    //ûÓе¥ÌåÊý¾Ýʱ
                    sql_strs.add(sql_str + "("
                            + "" + BattGoupId
                            + "," + max_test_record_count
                            + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                            + "'," + data.m_TestTime.getTestTimeLong()
                            + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
                            + "'," + (i+1)
                            + "," + data.OnlineVol
                            + "," + data.SumVoltage
                            + "," + data.SumCurrent
                            + "," + data.AllCap
                            + "," + 0
                            + "," + 0
                            + ")");
                }            
            }        
            Sql_Mysql sql = new Sql_Mysql(pool);
            ResultSet res = null;
            try {
                res = sql.sqlMysqlQuery(" SELECT * " + 
                        " FROM " + Sql_Mysql.Tb_FboTestData_Inf_Table +
                        " WHERE BattGroupId = "+BattGoupId+" AND test_starttime = '"+Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)+"'");
                if(!res.next()) {                
                    success = sql.makeManualCommit(sql_strs);
                }else {
                    //System.out.println("ÒÑ´æÔÚµ±Ç°²âÊÔÊý¾Ý");
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                if(null != res) {
                    try {
                        res.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
                sql.close_con();
            }
        }    
        return success;
    }
    //²åÈëFBO¡ª¡ªinfÐÅÏ¢
    public static boolean insertFBOInfIntoTable(MysqlConnPool pool,FboDataInf fbo,int BattGoupId,int max_test_record_count) {
        boolean flag=true;
        if(fbo.getTestTimeLong() > 0) {
            String sql_str="INSERT INTO " + Sql_Mysql.Tb_FboTestData_Inf_Table + 
                    "(BattGroupId,test_record_count,test_starttime,test_timelong,device,test_type,hourrate,save_interval,monomervol,moncapstd,test_curr,test_cap,monvol_limit,gourpvol_limit,mon_count,monvol_limitcount,stop_type,download_time) " + 
                    " VALUES(" + BattGoupId
                    + "," +max_test_record_count
                    + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                    + "'," + fbo.getTestTimeLong()
                    + "," + fbo.Device
                    + "," + fbo.DataType 
                    + "," + fbo.HourRate
                     + "," + fbo.SaveInterval
                    + "," + fbo.MonomerVol
                    + "," + fbo.STDCap
                    + "," + fbo.TestCur 
                    + "," + fbo.TestCap
                    + "," + fbo.MVLLimit
                     + "," + fbo.SumVLLimit
                    + "," + fbo.BattSum
                    + "," + fbo.MVLLimitCount
                    + "," + fbo.StopType
                    + ",'" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
                    + "')";
            Sql_Mysql sql = new Sql_Mysql(pool);
            ResultSet res = null;
            try {
                res = sql.sqlMysqlQuery(" SELECT * " + 
                        " FROM " + Sql_Mysql.Tb_FboTestData_Inf_Table +
                        " WHERE BattGroupId = "+BattGoupId+" AND test_starttime = '"+Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)+"'");
                if(!res.next()) {
                    //Èç¹û²»´æÔÚÔòÌí¼Óinf±í¼Ç¼
                    sql.sqlMysqlExecute(sql_str);
                }else {
                    //System.out.println("ÒÑ´æÔÚµ±Ç°²âÊÔÊý¾Ý");
                    flag=false;
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                if(null != res) {
                    try {
                        res.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
                sql.close_con();
            }
        }
        return flag;    
    }    
    
    //²åÈëFBOÀúÊ·Êý¾Ý
    public static boolean insertFBODataIntoTableByOneSql(MysqlConnPool pool,FboDataInf fbo,FboData data,int BattGoupId,int record_num,int max_test_record_count) {
        boolean success = false;
        if(fbo.getTestTimeLong() > 0) {
            createTb_FboTestData_Table(pool, BattGoupId);
            ArrayList<String> sql_strs = new ArrayList<>();
            String sql_str = "INSERT INTO "+Sql_Mysql.Tb_FboTestData_Table+BattGoupId+"(BattGroupId,test_record_count,test_starttime,test_timelong,record_time,record_num,online_vol,sum_vol,test_curr,test_cap,mon_num,mon_vol) " + 
                             " VALUES";
            Date record_time = new Date(fbo.TestStartTime.getFBODateTime().getTime()+data.m_TestTime.getTestTimeLong()*1000);
            if(data.BattSum > 0) {
                //Óе¥Ìåʱ
                for(int k=0;k<data.BattSum && k<data.SingleVol.length;k++) {
                    sql_strs.add(sql_str + "("
                            + "" + BattGoupId
                            + "," + max_test_record_count
                            + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                            + "'," + data.m_TestTime.getTestTimeLong()
                            + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
                            + "'," + record_num
                            + "," + data.OnlineVol
                            + "," + data.SumVoltage
                            + "," + data.SumCurrent
                            + "," + data.AllCap
                            + "," + (k+1)
                            + "," + data.SingleVol[k]
                            + ")");
                }                    
            }else {        
                //ûÓе¥ÌåÊý¾Ýʱ
                sql_strs.add(sql_str + "("
                        + "" + BattGoupId
                        + "," + max_test_record_count
                        + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
                        + "'," + data.m_TestTime.getTestTimeLong()
                        + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
                        + "'," +record_num
                        + "," + data.OnlineVol
                        + "," + data.SumVoltage
                        + "," + data.SumCurrent
                        + "," + data.AllCap
                        + "," + 0
                        + "," + 0
                        + ")");
            }
            Sql_Mysql sql = new Sql_Mysql(pool);
            success = sql.makeManualCommit(sql_strs);
            sql.close_con();
        }    
        return success;
    }    
    
    /**
     *     ´´½¨FBOÀúÊ·Êý¾Ý_ID±í
     * @param pool
     * @param BattGroupId
     */
    public static void createTb_FboTestData_Table(MysqlConnPool pool,int BattGroupId) {
        String sql_str = " CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_FboTestData_Table+BattGroupId+" (" + 
                "  `num` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü'," + 
                "  `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT 'µç³Ø×éID'," + 
                "  `test_record_count` int(11) NOT NULL DEFAULT '1' COMMENT '²âÊÔ±ÊÊý'," + 
                "  `test_starttime` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '²âÊÔ¿ªÊ¼Ê±¼ä'," + 
                "  `test_timelong` int(11) NOT NULL," + 
                "  `record_time` datetime NOT NULL," + 
                "  `record_num` int(11) NOT NULL DEFAULT '1' COMMENT '¼Ç¼±ÊÊý'," + 
                "  `online_vol` float NOT NULL DEFAULT '0' COMMENT 'ÔÚÏßµçѹ'," + 
                "  `sum_vol` float NOT NULL DEFAULT '0' COMMENT '×ܵçѹ'," + 
                "  `test_curr` float NOT NULL DEFAULT '0' COMMENT '²âÊÔµçÁ÷'," + 
                "  `test_cap` float NOT NULL DEFAULT '0' COMMENT '²âÊÔÈÝÁ¿'," + 
                "  `mon_num` int(11) NOT NULL DEFAULT '0' COMMENT 'µ¥Ìå±àºÅ'," + 
                "  `mon_vol` float NOT NULL DEFAULT '0' COMMENT 'µ¥Ìåµçѹ'," + 
                "  PRIMARY KEY (`num`)" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8; ";
        Sql_Mysql sql = new Sql_Mysql(pool);
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     *     ²éѯµ±Ç°µç³Ø×鵱ǰ×î´óµÄ¼Ç¼±ÊÊý+1
     * @param pool
     * @param BattGroupId
     * @return
     */
    public static int quereyBattMaxTestRecordCount(MysqlConnPool pool,int BattGroupId) {
        int test_record_count = 0;
        String sql_str = " SELECT MAX(test_record_count) as test_record_count " + 
                         " FROM " + Sql_Mysql.Tb_FboTestData_Inf_Table +
                         " WHERE BattGroupId = " + BattGroupId;
        Sql_Mysql sql = new Sql_Mysql(pool);
        ResultSet res = null;
        try {
            res = sql.sqlMysqlQuery(sql_str);
            if(res.next()) {
                test_record_count = res.getInt("test_record_count");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            sql.close_con();
        }
        return (test_record_count+1);
    }
    //ÊÖ¶¯Í£Ö¹Ê±£¬Èç¹ûûÓе¼ÈëÍ꣬ɾ³ý¼Ç¼
    public static void delete_UserCancel(MysqlConnPool pool,int BattGoupId,int max_test_record_count) {
            ArrayList<String> sql_strs = new ArrayList<>();
            String sql_str_inf = "delete from   "+Sql_Mysql.Tb_FboTestData_Inf_Table+" where test_record_count="+max_test_record_count;
            sql_strs.add(sql_str_inf);
            String sql_str_id = " delete from   "+Sql_Mysql.Tb_FboTestData_Table+BattGoupId+" where test_record_count="+max_test_record_count;
            sql_strs.add(sql_str_id);
            Sql_Mysql sql = new Sql_Mysql(pool);
            sql.makeManualCommit(sql_strs);
            sql.close_con();
    }    
    //Îļþµ¼Èë½ø¶ÈÐÞ¸Ä
    public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,int battgroupid,int file_downloadNum) {
        //System.out.println("file_downloadNum:"+file_downloadNum);
        String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                         " set now_data_block"+(file_downloadNum+1)+"="+file_block+",total_data_block"+(file_downloadNum+1)+"="+file_sum+" WHERE BattGroupId = " + battgroupid;
        Sql_Mysql sql = new Sql_Mysql(pool);
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    //Îļþµ¼Èë״̬   op_cmd="+FGCD_ComBase.CMD_DownLoadFBDFile_Over_ACK+",
    public static void updateFBOStateByOneSql(MysqlConnPool pool,int download_flag,int download_state,int battgroupid,int file_downloadNum) {
        String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                         " set download_flag"+(file_downloadNum+1)+"="+download_flag+",download_state"+(file_downloadNum+1)+"="+download_state+" WHERE BattGroupId = " + battgroupid;
        Sql_Mysql sql = new Sql_Mysql(pool);
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    public static void updateFBOFIleExportFlag(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
        String sql_str = " Update  " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                         " Set ";
        for(int i=0;i<fbofile.files.length;i++) {
            if(i>0) {
                sql_str += ",";
            }
            sql_str += " download_flag"+(i+1)+" = "+fbofile.files[i].download_flag+""
                     + " ,download_state"+(i+1)+" =" +fbofile.files[i].download_state;
        }
        sql_str += " WHERE dev_id = " + fbofile.dev_id;
        Sql_Mysql sql = new Sql_Mysql(pool);
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     *     ¸üе±Ç°ÏÂÔØ×´Ì¬,ÒÔ¼°Òì³£½áÊøÔ­Òò
     * @param pool
     * @param file 
     * op_cmd =  " + file.op_cmd + " ,
     */
    public static void updateFgcd_Filedownload_TableCmdByDevId(MysqlConnPool pool,FGCD_TestFBOFile file,int file_downloadNum) {
        String sql_str = " UPDATE " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                         " SET stop_reason =  " + file.getStop_reason() +
                         " ,download_flag"+(file_downloadNum+1)+" =  " + FGCD_TestDataDownLoad.DownloadFlag_Fail+
                         " ,download_state"+(file_downloadNum+1)+" =  " + FGCD_TestDataDownLoad.DownLoadState_DownLoadCancel +
                         " WHERE dev_id =  " + file.dev_id;
        Sql_Mysql sql = new Sql_Mysql(pool);
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
 
    /**
     *     ¸üе±Ç°É豸µÄÏÂÔØ×´Ì¬
     * @param pool
     * @param fbofile
     */
    public static void updateFgcd_FiledownloadState_TableByDevId(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
        String sql_str_base = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table + " Set stop_reason = " + fbofile.getStop_reason();
        for(int i=0;i<fbofile.files.length;i++) {
            FBOFile file = fbofile.files[i];
            sql_str_base += " ,download_flag"+(i+1) + " = "+file.download_flag+","
                          + " download_state"+(i+1) + " = "+file.download_state;
        }
        sql_str_base += " WHERE dev_id = " + fbofile.dev_id;
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str_base);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     *     ²åÈë»ò¸üе±Ç°É豸µÄÅäÖÃÐÅÏ¢
     * @param pool
     */
    public static void insertOrUpdateA059_Station_Inf_Table(MysqlConnPool pool,FGCD_Station_inf station) {
        String sql_str_sel = " SELECT * FROM " + Sql_Mysql.A059_Station_Inf_Table +
                "WHERE dev_num = '"+station.dev_num+"' ";
        ResultSet res = null;
        String sql_str_upd = "UPDATE " + Sql_Mysql.A059_Station_Inf_Table  
                + " SET station_province  = '" + station.station_province +"'"
                + ",station_city = '" + station.station_city +"'"
                + ",station_county = '" + station.station_county +"'"
                + ",station_name = '" + station.station_name + "'"
                + ",station_name_ex = '" + station.station_name_ex + "'"
                + ",dev_name = '" + station.dev_name + "'"
                + ",batt_name = '" + station.batt_name + "'"
                + ",mon_count = " + station.mon_count 
                + ",monStdCap = " + station.monStdCap 
                + ",monStdVol = " + station.monStdVol 
                + ",load_curr = " + station.load_curr
                + ",video_url = '" + station.video_url + "'"
                + ",dev_num = '" + station.dev_num + "'" 
                + ",last_update_time = '" + Com.getDateTimeFormat(station.getLast_update_time(), Com.DTF_YMDhms)+"'"
                + " WHERE dev_num = '" + station.dev_num +"';";
        String sql_str_ins = "INSERT INTO " + Sql_Mysql.A059_Station_Inf_Table  + "(station_province,station_city,station_county,station_name,station_name_ex,dev_name,batt_name,mon_count,monStdCap,monStdVol,load_curr,video_url,dev_num,last_update_time) " + 
                "VALUES('"+station.station_province+"'"
                        + ",'" + station.station_city + "'"
                        + ",'" + station.station_county + "'"
                        + ",'" + station.station_name + "'"
                        + ",'" + station.station_name_ex + "'"
                        + ",'" + station.dev_name + "'"
                        + ",'" + station.batt_name + "'"
                        + "," + station.mon_count + ""
                        + "," + station.monStdCap + ""
                        + "," + station.monStdVol + ""
                        + "," + station.load_curr + ""
                        + ",'" + station.video_url + "'"
                        + ",'" + station.dev_num + "'"
                        + ",'" + Com.getDateTimeFormat(station.last_update_time, Com.DTF_YMDhms) + "'"
                        + ");";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            res = sql.sqlMysqlQuery(sql_str_sel);
            if(res.next()) {
                //¸üÐÂÉ豸»ú·¿ÅäÖÃÐÅÏ¢
                System.out.println(sql_str_upd);
                sql.sqlMysqlExecute(sql_str_upd);
            }else {
                //²åÈë»ú·¿ÅäÖÃÐÅÏ¢
                sql.sqlMysqlExecute(sql_str_ins);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            sql.close_con();
        }
    }
    
    
//    public static void main(String[] args) {
//        FGCD_Station_inf inf = new FGCD_Station_inf();
//        inf.dev_num = "9921";
//        inf.last_update_time = new Date();
//        MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 5);
//        insertOrUpdateA059_Station_Inf_Table(pool, inf);
//    }
}