综合管理平台数据库数据模拟程序
whyclxw
2021-03-25 230b4029e603c22c6160063cb109001080123670
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
package com.thread;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import com.base.Com;
import com.mode.Device_Inf;
import com.mode.Dynamicload_State_rt;
import com.mode.Electric_State_2kw;
import com.mode.Electric_state;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
 
public class Manage_Simul_SQL {
 
    /**
     *     ¼ÓÔØËùÓеÄÉ豸
     * @param gB_MysqlConnPool
     * @param devices
     */
    public static void queryAllDevice(MysqlConnPool pool, List<Device_Inf> devices) {
        String sql_str = " SELECT * FROM "+ Sql_Mysql.Tb_Device_Inf_Table;
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            res = sql.sqlMysqlQuery(sql_str);
            while(res.next()) {
                Device_Inf dev = new Device_Inf();
                dev.setDevice_id(res.getInt("device_id"));
                dev.setDevice_ip(res.getString("device_ip"));
                dev.setDevice_name(res.getString("device_name"));
                dev.setMaint_cycle(res.getInt("maint_cycle"));
                dev.setSystem_id(res.getInt("system_id"));
                dev.setSystem_name(res.getString("system_name"));
                dev.setUse_starttime(res.getDate("use_starttime"));
                dev.setUser_id(res.getInt("user_id"));
                devices.add(dev);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            sql.close_con();
        }
    }
    
    //¼ÓÔØ¸ºÔØÊµÊ±Êý¾Ý
    public static void updateDynamicload(MysqlConnPool conn_pool, Dynamicload_State_rt state) {
        String sql_str = " UPDATE  " + Sql_Mysql.Tb_Dynamicload_State_Rt_Table 
                + " SET "
                +" record_time='" + Com.getDateTimeFormat(state.getRecord_time(), Com.DTF_YMDhms)+"'"
                +",start_auto=" + state.getStart_auto()
                +",stop_auto=" + state.getStop_auto()
                +",sudden_crease=" + state.getSudden_crease()
                +",all_open=" + state.getAll_open()
                +",actual_set_power=" + state.getActual_set_power()
                +",output_power=" + state.getOutput_power()
                +",set_power=" + state.getSet_power()
                +",interval_time=" + state.getInterval_time()
                +",actual_curr=" + state.getActual_curr()
                +",actual_mov=" + state.getActual_mov()
                +",switch_on=" + state.getSwitch_on()
                +",FZ_autostate1=" + state.getFZ_autostate1()
                +",FZ_autostate2=" + state.getFZ_autostate2()
                +",FZ_autostate3=" + state.getFZ_autostate3()
                +",FZ_autostate4=" + state.getFZ_autostate4()
                +",FZ_autostate5=" + state.getFZ_autostate5()
                +",react_overtem=" + state.getReact_overtem()
                +",water_overtem=" + state.getWater_overtem()
                +",water_level_low=" + state.getWater_level_low()
                +",water_pressure_high=" + state.getWater_pressure_high()
                +",local_control=" + state.getLocal_control()
                +",back_control=" + state.getBack_control()
                +",central_control=" + state.getCentral_control()
                +",switch_state=" + state.getSwitch_state()
                +",inter_volume_M200=" + state.getInter_volume_M200()
                +",fan_button=" + state.getFan_button()
                +",fan_output=" + state.getFan_output()
                +",allow_close=" + state.allow_close
                + " WHERE dev_id = " + state.dev_id;
        Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
        try {
            //System.out.println(sql_str);
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    //¼ÓÔØ4MWµçԴʵʱÊý¾Ý
    public static void update4MWPower(MysqlConnPool conn_pool, Electric_state state) {
        String sql_str = " update "+ Sql_Mysql.Tb_Electric_State_Table  +" "
                + " SET case_trip_output = "+state.case_trip_output+","
                +"  record_time='" + Com.getDateTimeFormat(state.getRecord_time(), Com.DTF_YMDhms)+"',"
                + " fault_reset_signal = "+state.fault_reset_signal+","
                + " high_vol_switch_status = "+state.high_vol_switch_status+","
                + " stop_button = "+state.stop_button+","
                + " main_cabinet_fan_status = "+state.main_cabinet_fan_status+","
                + " trans_cabinet_door_lock = "+state.trans_cabinet_door_lock+","
                + " trans_cabinet_overtem_alarm = "+state.trans_cabinet_overtem_alarm+","
                + " trans_cabinet_overtem_trip = "+state.trans_cabinet_overtem_trip+","
                + " qs1_state = "+state.qs1_state+","
                + " qs2_state = "+state.qs2_state+","
                + " switch_cabinet_door_status = "+state.switch_cabinet_door_status+","
                + " alldcvol = "+state.alldcvol+","
                + " alldccurr = "+state.alldccurr+","
                + " conn_flag = "+state.conn_flag+" "
                + " WHERE electric_id ="+state.electric_id;
        Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
        try {
            //System.out.println(sql_str);
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    //¼ÓÔØ2MWµçԴʵʱÊý¾Ý
    public static void update2MWPower(MysqlConnPool conn_pool, Electric_State_2kw state) {
        String sql_str = " UPDATE "+Sql_Mysql.Tb_Electric2mw_State_Table +
                " Set brachdcvol= " + state.brachdcvol +
                ",record_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) +
                "',brachdccurr=" + state.brachdccurr +
                ",alldcvol=" + state.alldcvol +
                ",alldccurr=" + state.alldccurr +
                ",stopchargevol_one=" + state.stopchargevol_one +
                ",stopchargevol_two=" + state.stopchargevol_two +
                ",stopchargevol_three=" + state.stopchargevol_three + 
                ",stopchargevol_four=" + state.stopchargevol_four +
                ",stopchargevol_five=" + state.stopchargevol_five +
                ",controlangle=" + state.controlangle +
                ",localgivevol=" + state.localgivevol +
                ",volset=" + state.volset +
                ",localgivecurr=" + state.localgivecurr +
                ",currset=" + state.currset +
                ",chargecurr_one=" + state.chargecurr_one +
                ",chargecurr_two=" + state.chargecurr_two +
                ",chargecurr_three=" + state.chargecurr_three +
                ",chargecurr_four=" + state.chargecurr_four +
                ",chargecurr_five=" + state.chargecurr_five +
                ",consvolmode_chargecurr=" +state.consvolmode_chargecurr+ 
                " Where electric2KW_id = " + state.electric2KW_id;
        Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
        try {
            //System.out.println(sql_str);
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}