whyclj
2020-08-31 bcf67488c65c420984de5b68e2aad77e31bcf75d
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
package com.dev_fbs9600s.data;
 
import java.sql.SQLException;
import java.util.Date;
 
import com.battmonitor.base.Com;
import com.battmonitor.sql.MysqlConnPool;
import com.battmonitor.sql.Sql_Mysql;
 
public class FBS9600S_SocketClient_Thread_SQL {
    
    /**
     * ¸üÐÂ9600ϵͳ״̬
     * @param pool
     * @param devdata
     */
    public static void insertOrUpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SocketClient_Thread thread) {
        String sql_str_base = Sql_Mysql.FBS9100State_Table +
                  " SET dev_id = '"+ thread.dev_id+"', "
                + " dev_ip='"+ thread.dev_ip+"',"  
                + " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
                + " dev_workstate = '"+thread.sysState.work_state+"',"
                + " dev_captest_groupvol='"+thread.sysState.group_vol+"',"
                + " dev_captest_curr='"+thread.sysState.group_curr+"',"
                + " dev_commcount='"+thread.CommCount+"',"
                + " dev_errcommcount='"+thread.ErrCommCount+"'";
                    
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        String sql_str_replace = "REPLACE INTO " + sql_str_base;
        try {
            sql.sqlMysqlExecute(sql_str_replace);
        } catch (SQLException e) {
            System.err.println("Ö´ÐРinsertOrUpdateFBS9600StateByDev_id Òì³£    at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
            e.printStackTrace();
        } finally{
            sql.close_con();
        }
    }
    
    
    /**
     * ¸üÐÂ9600ϵͳ״̬
     * @param pool
     * @param devdata
     */
    public static void insertOrUpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SystemState state) {
        String sql_str_base = Sql_Mysql.FBS9100State_Table +
                  " SET dev_id = '"+ state.dev_id+"', "
                + " dev_ip='"+ state.dev_ip+"',"  
                + " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
                + " dev_workstate = '"+state.work_state+"',"
                + " dev_captest_groupvol='"+state.group_vol+"',"
                + " dev_captest_curr='"+state.group_curr+"',"
                + " dev_commcount='"+state.CommCount+"',"
                + " dev_errcommcount='"+state.ErrCommCount+"' ";
                     
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        String sql_str_replace = " REPLACE INTO " + sql_str_base;
        try {
            sql.sqlMysqlExecute(sql_str_replace);
        } catch (SQLException e) {
            //System.err.println("Ö´ÐРinsertOrUpdateFBS9600StateByDev_id Òì³£    at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
            e.printStackTrace();
        } finally{
            sql.close_con();
        }
    }
    
    /**
     * ¸üÐÂ9600ϵͳ״̬
     * @param pool
     * @param devdata
     */
    public static void UpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SystemState state) {
        String sql_str_base = Sql_Mysql.FBS9100State_Table +
                  " SET dev_id = '"+ state.dev_id+"', "
                + " dev_ip='"+ state.dev_ip+"',"  
                + " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
                + " dev_workstate = '"+state.work_state+"',"
                + " dev_captest_groupvol='"+state.group_vol+"',"
                + " dev_captest_curr='"+state.group_curr+"',"
                + " dev_commcount='"+state.CommCount+"',"
                + " dev_errcommcount='"+state.ErrCommCount+"' "
                + " WHERE dev_id = " + state.dev_id;
                     
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        String sql_str_replace = " Update " + sql_str_base;
        try {
            sql.sqlMysqlExecute(sql_str_replace);
        } catch (SQLException e) {
            //System.err.println("Ö´ÐРinsertOrUpdateFBS9600StateByDev_id Òì³£    at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
            e.printStackTrace();
        } finally{
            sql.close_con();
        }
    }
    
    //¸üе±Ç°Ïß³ÌµÄÆô¶¯Ê±¼äÒÔ¼°Èí¼þ³ÌÐòµÄ°æ±¾ºÅ
    public static boolean updateServerStartInfTo_RamDB_Table(MysqlConnPool conn_pool, double ver)
    {
        boolean res = false;
        Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
        try {
            sql.sqlMysqlUseDB("web_site");
            if(true == sql.sqlMysqlCheckIfTableExist("tb_process_survey")) {
                String sql_str_1 = "UPDATE " + "tb_process_survey" + " SET " 
                                    + " Process_starttime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "', "
                                    + " ProcessVersion='" + String.format("V%1.3f", ver) + "' "
                                    + " WHERE Processid = 11011";
                sql.sqlMysqlExecute(sql_str_1);
                res = true;
            }
        } catch (SQLException e) {
            res = false;
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
        
        return res;
    }
    
    //¸üе±Ç°Ï̵߳ÄÔËÐÐʱ¼ä
    public static boolean updateServerTimeTo_RamDB_Table(MysqlConnPool conn_pool)
    {
        boolean res = false;
        Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
        try {
            sql.sqlMysqlUseDB("web_site");
            if(true == sql.sqlMysqlCheckIfTableExist("tb_process_survey")) {
                String sql_str_1 = " UPDATE " + "tb_process_survey" + " SET " 
                                    + " ProcessTime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'"
                                    + " WHERE Processid = 11011";
                sql.sqlMysqlExecute(sql_str_1);
                res = true;
            }
        } catch (SQLException e) {
            res = false;
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
        
        return res;
    }
}