许鹏程
2023-06-30 3bbfaa3d7d416afbd154576453c8ee9e7e2f8899
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.product.data.center.controller;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.data.center.config.ErrorCode;
import com.product.data.center.service.JournalManagerService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
 
/**
 *     监控
 * @author 86151
 *
 */
@RequestMapping("/api/monitor")
@RestController
public class MonitorController extends AbstractBaseController{
 
    @Autowired
    JournalManagerService journalManagerService;
 
    /**
     *     左侧分组
     * @param request
     * @return
     */
    @PostMapping("/list-monitor/{version}")
    @ApiVersion(1)
    public String listMonitor(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(journalManagerService.journalServerView());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_LIST_LEFT_GROUP_FAIL);
        }
    }
 
    /**
     *     右侧视图
     * @param request
     * @return
     */
    @PostMapping("/find-monitor/{version}")
    @ApiVersion(1)
    public String findMonitorView(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(journalManagerService.groupCountErrorLog(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_LIST_RIGHT_VIEW_FAIL);
        }
    }
 
    /**
     *     日志列表
     * @param request
     * @return
     */
    @PostMapping("/list-log/{version}")
    @ApiVersion(1)
    public String listLogInfo(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            if(BaseUtil.strIsNull(fse.getString("cpage"))|| BaseUtil.strIsNull(fse.getString("pagesize"))) {
                fse.setValue("cpage", 1);
                fse.setValue("pagesize", 20);
            }
            return OK_List(journalManagerService.listJournal(fse, false));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_LIST_LOG_FAIL);
        }
    }
 
    /**
     *     错误日志列表
     * @param request
     * @return
     */
    @PostMapping("/list-error-log/{version}")
    @ApiVersion(1)
    public String listErrorLogInfo(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            if(BaseUtil.strIsNull(fse.getString("cpage"))|| BaseUtil.strIsNull(fse.getString("pagesize"))) {
                fse.setValue("cpage", 1);
                fse.setValue("pagesize", 20);
            }
            return OK_List(journalManagerService.listJournal(fse, true));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_LIST_ERROR_LOG_FAIL);
        }
    }
 
    /**
     *     日志详情
     * @param request
     * @return
     */
    @PostMapping("/find-log/{version}")
    @ApiVersion(1)
    public String findLogInfo(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(journalManagerService.findJournal(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_FIND_LOG_FAIL);
        }
    }
 
    /**
     *     错误日志重新处理
     * @param request
     * @return
     */
    @PostMapping("/reprocess-log/{version}")
    @ApiVersion(1)
    public String reprocessLog(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            journalManagerService.secondOperation(fse.getUUID());
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.LOGMONITOR_OPERATE_FAIL+e.getMessage());
        }
    }
 
    /**
     *     错误日志标识处理
     * @param request
     * @return
     */
    @PostMapping("/identification-log/{version}")
    @ApiVersion(1)
    public String identificationLog(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
 
            journalManagerService.signOperation(fse.getUUID());
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.MONITOR_SIGN_ERROR_LOG_FAIL);
        }
    }
}