whycxzp
2021-07-09 489cc658a7f1a166058138bd4c57b6ce3e64ca72
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
package com.whyc.service;
 
import com.whyc.dto.TableDTO;
import com.whyc.mapper.ClearTableMapper;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
 
@Service
public class ClearTableService {
 
    @Resource
    private ClearTableMapper mapper;
 
    public void clearTable(){
        List<TableDTO> tableList = new LinkedList<>();
        //传入需要清空的表对应的库名,表名
        tableList.add(new TableDTO("db_alarm","tb_battalarm_data"));
        tableList.add(new TableDTO("db_alarm","tb_battalarm_data_history"));
        tableList.add(new TableDTO("db_alarm","tb_bts_station_event"));
        tableList.add(new TableDTO("db_alarm","tb_devalarm_data"));
        tableList.add(new TableDTO("db_alarm","tb_devalarm_data_history"));
        tableList.add(new TableDTO("db_app_sys","tb_app_bts_battgroup"));
        tableList.add(new TableDTO("db_app_sys","tb_app_bts_comm_task"));
        tableList.add(new TableDTO("db_app_sys","tb_dashboard_chart_type"));
        tableList.add(new TableDTO("db_app_sys","tb_dashboard_module"));
        tableList.add(new TableDTO("db_app_sys","tb_dashboard_module_chart"));
        tableList.add(new TableDTO("db_app_sys","tb_fbsdev_statechange_inf"));
        tableList.add(new TableDTO("db_batt_history","tb_btsstaechange_inf"));
        tableList.add(new TableDTO("db_batt_testdata","tb_battresdata_inf"));
        tableList.add(new TableDTO("db_batt_testdata","tb_batttestdata_inf"));
        tableList.add(new TableDTO("db_battinf","tb_batt_alm_param"));
        tableList.add(new TableDTO("db_battinf","tb_batt_maint_inf"));
        tableList.add(new TableDTO("db_battinf","tb_batt_maint_process"));
        tableList.add(new TableDTO("db_battinf","tb_battcurr_inf"));
        tableList.add(new TableDTO("db_battinf","tb_battinf"));
        tableList.add(new TableDTO("db_battinf","tb_battinf_apply"));
        tableList.add(new TableDTO("db_battinf","tb_battinf_ex"));
        tableList.add(new TableDTO("db_battinf","tb_battinf_rebuild"));
        tableList.add(new TableDTO("db_battinf","tb_battmon_testcap"));
        tableList.add(new TableDTO("db_battinf","tb_deverror_record"));
        tableList.add(new TableDTO("db_ld9_testdata","tb_ld9testdata_inf"));
        tableList.add(new TableDTO("db_param","tb_alarm_param"));
        tableList.add(new TableDTO("db_param","tb_dev_param"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_alarm"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_alarm_history"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_alarm_param"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_time_adj_alarm"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_time_out_alarm"));
        tableList.add(new TableDTO("db_pwrdev_data_history","tb_pwrdev_acdata"));
        tableList.add(new TableDTO("db_pwrdev_data_rt","tb_pwrdev_acdcdata"));
        tableList.add(new TableDTO("db_pwrdev_data_rt","tb_pwrdev_dcdata"));
        tableList.add(new TableDTO("db_pwrdev_inf","tb_pwrdev_inf"));
        tableList.add(new TableDTO("db_ram_db","cmcc_power_data"));
        tableList.add(new TableDTO("db_ram_db","tb_61850_jhstate"));
        tableList.add(new TableDTO("db_ram_db","tb_batt_rsalarm"));
        tableList.add(new TableDTO("db_ram_db","tb_batt_rtalarm"));
        tableList.add(new TableDTO("db_ram_db","tb_batt_rtdata"));
        tableList.add(new TableDTO("db_ram_db","tb_batt_rtstate"));
        tableList.add(new TableDTO("db_ram_db","tb_bpm7100_state"));
        tableList.add(new TableDTO("db_ram_db","tb_bts_gprs_state"));
        tableList.add(new TableDTO("db_ram_db","tb_bts_station_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_battparam"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_chargerstate"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_collectionstate"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_insulatstate"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_offlineyhplan"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_offlineyhplan"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100_sysparam"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100s_dcdc_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100s_dfu_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100s_fod_param"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100s_fod_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9100s_nibian_state"));
        tableList.add(new TableDTO("db_ram_db","tb_fbs9600_state"));
        tableList.add(new TableDTO("db_ram_db","tb_hard_dev_sms_state"));
        tableList.add(new TableDTO("db_ram_db","tb_ld9_concentrateparam"));
        tableList.add(new TableDTO("db_ram_db","tb_ld9_concentratestate"));
        tableList.add(new TableDTO("db_ram_db","tb_ld9_setparam"));
        tableList.add(new TableDTO("db_ram_db","tb_ld9_state"));
        tableList.add(new TableDTO("db_ram_db","tb_ld9_updatestatue"));
        tableList.add(new TableDTO("db_ram_db","tb_lithium_data"));
        tableList.add(new TableDTO("db_ram_db","tb_socketclient_state"));
        tableList.add(new TableDTO("db_user","tb_user_battgroup_baojigroup_battgroup"));
        tableList.add(new TableDTO("db_user","tb_user_battmaint_check"));
        tableList.add(new TableDTO("db_user","tb_user_battmaint_check_process"));
        tableList.add(new TableDTO("db_user","tb_user_face"));
        tableList.add(new TableDTO("db_user","tb_user_jiejiari"));
        tableList.add(new TableDTO("db_user","tb_user_limit"));
        tableList.add(new TableDTO("db_user","tb_user_log"));
        tableList.add(new TableDTO("db_user","tb_user_paixiu"));
        tableList.add(new TableDTO("db_user","tb_user_sms"));
        tableList.add(new TableDTO("db_user","tb_user_sms_format"));
        tableList.add(new TableDTO("db_user","tb_user_task"));
        tableList.add(new TableDTO("db_user","tb_user_task_batt_check"));
        tableList.add(new TableDTO("db_user","tb_user_task_batt_template"));
        tableList.add(new TableDTO("db_user","tb_user_task_batt_test"));
        tableList.add(new TableDTO("db_user","tb_user_task_change"));
        tableList.add(new TableDTO("db_user","tb_user_task_param"));
        tableList.add(new TableDTO("db_user","tb_user_task_template"));
        tableList.add(new TableDTO("db_user","tb_user_task_user_list"));
        tableList.add(new TableDTO("web_site","mac_license"));
        tableList.add(new TableDTO("web_site","tb_3d_station"));
        tableList.add(new TableDTO("web_site","tb_announce"));
        tableList.add(new TableDTO("web_site","tb_avoid_plan"));
        tableList.add(new TableDTO("web_site","tb_badbatt_mon"));
        tableList.add(new TableDTO("web_site","tb_badbatt_mon_flag"));
        tableList.add(new TableDTO("web_site","tb_batt_attention"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_cm"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_cm1"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_ct"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_ct1"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_cu"));
        tableList.add(new TableDTO("web_site","tb_batt_devdischarge_cu1"));
        tableList.add(new TableDTO("web_site","tb_batt_discharge"));
        tableList.add(new TableDTO("web_site","tb_batt_electricity"));
        tableList.add(new TableDTO("web_site","tb_batt_electricity1"));
        tableList.add(new TableDTO("web_site","tb_batt_electricity2"));
        tableList.add(new TableDTO("web_site","tb_batt_endurance"));
        tableList.add(new TableDTO("web_site","tb_batt_replace"));
        tableList.add(new TableDTO("web_site","tb_battdischarge_plan"));
        tableList.add(new TableDTO("web_site","tb_battinf_change"));
        tableList.add(new TableDTO("web_site","tb_battmap_information"));
        tableList.add(new TableDTO("web_site","tb_battpower_off"));
        tableList.add(new TableDTO("web_site","tb_dev_restart_plan"));
        tableList.add(new TableDTO("web_site","tb_devstate_usr"));
        tableList.add(new TableDTO("web_site","tb_devtmp_record"));
        tableList.add(new TableDTO("web_site","tb_stationtraffic"));
 
        mapper.clearTable(tableList);
    }
 
    public void dropTable(){
        List<TableDTO> tableList = new LinkedList<>();
        tableList.add(new TableDTO("db_batt_history","tb_batt_realdata_"));
        tableList.add(new TableDTO("db_pwrdev_alarm","tb_pwrdev_alarm_param_"));
        tableList.add(new TableDTO("db_pwrdev_data_history","tb_pwrdev_historydata_"));
        //查询库中需要删除的表名
        List<TableDTO> resTableList = findTableListLike(tableList);
        //传入需要删除的表对应的库名,表名
        if(!resTableList.isEmpty()){
            mapper.dropTable(resTableList);
        }
    }
 
    private List<TableDTO> findTableListLike(List<TableDTO> tableList) {
        return mapper.findTableListLike(tableList);
    }
 
}