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
package com.dev.restartplan;
 
import java.util.Date;
import java.util.List;
 
import com.base.Com;
import com.batt.dischargeplan.FBS9100Param_SQL;
import com.batt.dischargeplan.FBS9100_ComBase;
import com.sql.MysqlConnPool;
 
public class Dev_Restart_Plan_Thread implements Runnable{
    public MysqlConnPool pool;
    
    public Dev_Restart_Plan_Thread(MysqlConnPool pool){
        this.pool = pool;
    }
    
    @Override
    public void run() {
        System.out.println(" Dev_Restart_Plan_Thread Start at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        while(true) {
            try {
                //²éѯÐèÒªÖØÆôµÄÉ豸
                List<Dev_Restart_Plan> plans = Dev_Restart_Plan_Thread_SQL.queryEffectRestartPlan(pool);
                for(int i = 0;i < plans.size();i++) {
                    //System.out.println(plans.get(i).dev_id+" ¿ªÊ¼ÖØÆô");
                    //¿ªÊ¼ÖØÆôµ±Ç°É豸
                    if(FBS9100Param_SQL.sendCmdToFBS9100Dev(pool, plans.get(i).dev_id, FBS9100_ComBase.CMD_ResetSystem)) {
                        System.out.println(plans.get(i).dev_id+" ¶¨Ê±Ô¶³ÌÖØÆô³É¹¦  "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
                        //ÖØÆô³É¹¦
                        plans.get(i).setLast_restarttime(new Date());
                    }
                }        
                
                Dev_Restart_Plan_Thread_SQL.updateRestartPlan(pool,plans);
                Thread.sleep(2000);
            } catch (Exception e) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                e.printStackTrace();
            }
        }
    }
}