whycxzp
2022-01-12 e9f7312050bfefbd1afa6921a7ddd854fb4aff8f
src/main/java/com/whyc/service/ClearTableService.java
@@ -129,6 +129,29 @@
        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"));
        tableList.add(new TableDTO("web_site","tb_database_backup"));
        tableList.add(new TableDTO("db_analysis","tb_mon_cap"));
        tableList.add(new TableDTO("db_analysis","tb_mon_res"));
        tableList.add(new TableDTO("db_analysis","tb_mon_tmp"));
        tableList.add(new TableDTO("db_analysis","tb_mon_vol"));
        //进行一次过滤,查询出来所有的库中表
        List<TableDTO> tableList2 = mapper.findAllTables();
        for (int i = 0; i < tableList.size(); i++) {
            boolean compareFlag = false;
            for (int j = 0; j < tableList2.size(); j++) {
                if((tableList.get(i).getDbName()+tableList.get(i).getTableName())
                .equals(tableList2.get(j).getDbName()+tableList2.get(j).getTableName())){
                    compareFlag = true;
                    break;
                }
            }
            //匹配ok
            if(!compareFlag){
                tableList.remove(i);
                i--;
            }
        }
        mapper.clearTable(tableList);
    }
@@ -138,6 +161,9 @@
        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_"));
        tableList.add(new TableDTO("db_pwrdev_data_history","tb_pwrdev_historydata_"));
        tableList.add(new TableDTO("db_batt_testdata","tb_battresdata_"));
        tableList.add(new TableDTO("db_batt_testdata","tb_batttestdatastop_"));
        //查询库中需要删除的表名
        List<TableDTO> resTableList = findTableListLike(tableList);
        //传入需要删除的表对应的库名,表名
@@ -150,4 +176,7 @@
        return mapper.findTableListLike(tableList);
    }
    public void clearColumn() {
        mapper.clearColumn();
    }
}