lxw
2022-06-13 f29af40a15451cb15d399130c887fcfc95026411
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
package com.fgkj.actions.ram;
 
import com.fgkj.actions.ActionUtil;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.ram.Server_state;
import com.fgkj.services.Process_surveyService;
import com.fgkj.services.ram.Server_stateService;
import org.apache.struts2.json.annotations.JSON;
 
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
public class Server_stateAction extends ActionUtil{
    private Server_stateService service = new Server_stateService();
    private Process_surveyService serviceP=new Process_surveyService();
    private String result;
    private String json;
 
    public String add() {
        Server_state server_state = ActionUtil.getGson().fromJson(json, Server_state.class);
        ServiceModel model = service.add(server_state);
        result = tojson(model);
        return SUCCESS;
        
    }
    public String update() {
        Server_state server_state = ActionUtil.getGson().fromJson(json, Server_state.class);
        ServiceModel model = service.update(server_state);
        result = tojson(model);
        return SUCCESS;    
    }
    public String delete() {
        Server_state server_state = ActionUtil.getGson().fromJson(json, Server_state.class);
        ServiceModel model = service.delete(server_state);
        result = tojson(model);
        return SUCCESS;        
    }
     public String serchByCondition(){
        Server_state server_state = ActionUtil.getGson().fromJson(json, Server_state.class);
         ServiceModel model = service.serchByCondition(server_state);
         result = tojson(model);
         return SUCCESS;    
    }
    //查询服务器信息和线程信息 serverState:服务器信息,processSurvey:进程信息
    public String serchServerManageInfo() {
        Map dataMap = new HashMap();
        //查询服务器信息
        ServiceModel serverModel = service.searchAll();
        dataMap.put("serverState", serverModel);
        //查询线程状态
        ServiceModel processModel = serviceP.searchAll();
        dataMap.put("processSurvey", processModel);
 
        return SUCCESS;
    }
    /**查询系统的硬件状态-通过数据库*/
    public String searchAll(){
         ServiceModel model = service.searchAll();
         result = tojson(model);
         return SUCCESS;    
    }
 
    /**查询系统的硬件状态-代码计算*/
    public String searchAll2(){
        ServiceModel model = service.searchAll2();
        result = tojson(model);
        return SUCCESS;
    }
 
    /**查询系统时间戳*/
    @JSON(serialize = false)
    public String getTimestamp(){
        ServiceModel model = new ServiceModel();
        long l = System.currentTimeMillis();
        model.set(1,l);
        result = getGson().toJson(model);
        return SUCCESS;
    }
 
    public String getResult() {
        return result;
    }
    public void setJson(String json) {
        this.json = json;
    }
}