| | |
| | | import java.util.Date;
|
| | |
|
| | | import com.power.mysql.MysqlConnPool;
|
| | | import com.base.Com;
|
| | | import com.power.data.PowerData_RT;
|
| | | import com.power.data.PowerData_RT_Array;
|
| | |
|
| | |
| | | Logger logger = null;
|
| | |
|
| | | public static int MinRecordTimeLong = 60; //每次记录的最短时间间隔--60S
|
| | | public static int MaxRecordTimeLong = 366*3; //最大记录历史数据时间--3年
|
| | | // public static int MaxRecordTimeLong = 366*3; //最大记录历史数据时间--3年
|
| | | public static int MaxRecordTimeLong = 366; //最大记录历史数据时间--1年
|
| | |
|
| | |
|
| | | public PowerRealDataSave_Thread(MysqlConnPool pool,PowerData_RT_Array data) {
|
| | |
| | | public void run() {
|
| | |
|
| | | logger.info("PowerRealDataSave_Thread: Started ...");
|
| | | |
| | | Date lastdelTime = new Date(0);
|
| | | Date lastTime = new Date();
|
| | | //线程启动前休眠60秒
|
| | | for(int i =0; i<60; i++) {
|
| | |
| | | /**********************************************************/
|
| | | nowTime = new Date();
|
| | | long timelong =(nowTime.getTime()-lastTime.getTime())/1000;
|
| | | long deltimelong = (nowTime.getTime()-lastdelTime.getTime())/1000;
|
| | | try {
|
| | | /**************** lijun add @ 20200906 ***************/
|
| | | //获取指定天数之前的时间
|
| | | Date critical = PowerDataSave_SQL.getDateBefore(nowTime, MaxRecordTimeLong);
|
| | | //删除修改时间超时的数据表
|
| | | PowerDataSave_SQL.deleteHistoryData(m_ConnPool, critical);
|
| | | if(deltimelong > 60*60*24) {
|
| | | |
| | | //获取指定天数之前的时间
|
| | | Date critical = PowerDataSave_SQL.getDateBefore(nowTime, MaxRecordTimeLong);
|
| | | logger.info("开始循环删除"+Com.get_DTF(critical, Com.DTF_YMDhms)+"之前创建的电源历史实时数据库表");
|
| | | //删除修改时间超时的数据表
|
| | | PowerDataSave_SQL.deleteHistoryData(m_ConnPool, critical);
|
| | | |
| | | lastdelTime = nowTime;
|
| | | }
|
| | | |
| | | /**********************************************************/
|
| | | if(timelong < MinRecordTimeLong) {
|
| | | continue;
|