Authored by FengRuwei

历史查询

@@ -159,18 +159,40 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { @@ -159,18 +159,40 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper {
159 long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end"))); 159 long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end")));
160 long costTime = (endTime - startTime); 160 long costTime = (endTime - startTime);
161 161
162 - String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));  
163 162
164 javaApiStaticsModel.setStartTime(DateFormatUtil.parseLongToTimeStr(startTime)); 163 javaApiStaticsModel.setStartTime(DateFormatUtil.parseLongToTimeStr(startTime));
165 javaApiStaticsModel.setEndTime(DateFormatUtil.parseLongToTimeStr(endTime)); 164 javaApiStaticsModel.setEndTime(DateFormatUtil.parseLongToTimeStr(endTime));
166 165
167 javaApiStaticsModel.setCostTime((int) costTime); 166 javaApiStaticsModel.setCostTime((int) costTime);
168 167
  168 +
  169 + int a_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("api_id"))).intValue();
  170 + int m_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("mobj_id"))).intValue();
  171 +
  172 + javaApiStaticsModel.setServiceId(a_id);
  173 + javaApiStaticsModel.setMObjectId(m_id);
  174 +
  175 +
  176 + String m_ip = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_ip"));
  177 + String m_port = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_port"));
  178 + String m_name = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_name"));
  179 + javaApiStaticsModel.setMIp(m_ip);
  180 + javaApiStaticsModel.setMPort(m_port);
  181 + javaApiStaticsModel.setMName(m_name);
  182 +
  183 + String time = (String) series.getValues().get(0).get(series.getColumns().indexOf("time"));
  184 +
  185 + javaApiStaticsModel.setTime(DateFormatUtil.displayFormat(time));
  186 +
169 if (is_exception == true) { 187 if (is_exception == true) {
170 javaApiStaticsModel.setStatus(0); 188 javaApiStaticsModel.setStatus(0);
  189 + String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));
171 javaApiStaticsModel.setException(exception); 190 javaApiStaticsModel.setException(exception);
172 - } else 191 + } else {
173 javaApiStaticsModel.setStatus(1); 192 javaApiStaticsModel.setStatus(1);
  193 + String response = (String) series.getValues().get(0).get(series.getColumns().indexOf("response"));
  194 + javaApiStaticsModel.setResponse(response);
  195 + }
174 list.add(javaApiStaticsModel); 196 list.add(javaApiStaticsModel);
175 } 197 }
176 return list; 198 return list;
@@ -5,6 +5,8 @@ import com.monitor.javaserver.service.IJavaApiStatusService; @@ -5,6 +5,8 @@ import com.monitor.javaserver.service.IJavaApiStatusService;
5 import com.monitor.model.request.JavaApiStatusReq; 5 import com.monitor.model.request.JavaApiStatusReq;
6 import com.monitor.model.response.BaseResponse; 6 import com.monitor.model.response.BaseResponse;
7 import com.monitor.model.response.JavaApiStatusRep; 7 import com.monitor.model.response.JavaApiStatusRep;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
8 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Controller; 11 import org.springframework.stereotype.Controller;
10 import org.springframework.web.bind.annotation.RequestBody; 12 import org.springframework.web.bind.annotation.RequestBody;
@@ -22,6 +24,7 @@ import java.util.List; @@ -22,6 +24,7 @@ import java.util.List;
22 @RequestMapping("javaApiStatus") 24 @RequestMapping("javaApiStatus")
23 public class JavaAppInfoCtrl { 25 public class JavaAppInfoCtrl {
24 26
  27 + Logger log = LoggerFactory.getLogger(JavaAppInfoCtrl.class);
25 @Autowired 28 @Autowired
26 IJavaApiStatusService javaApiStatusService; 29 IJavaApiStatusService javaApiStatusService;
27 30
@@ -34,6 +37,7 @@ public class JavaAppInfoCtrl { @@ -34,6 +37,7 @@ public class JavaAppInfoCtrl {
34 JavaApiStatusRep javaApiStatusRep = javaApiStatusService.getJavaApiStatus(req); 37 JavaApiStatusRep javaApiStatusRep = javaApiStatusService.getJavaApiStatus(req);
35 rep.setData(javaApiStatusRep); 38 rep.setData(javaApiStatusRep);
36 } catch (Exception e) { 39 } catch (Exception e) {
  40 + log.warn("queryOne failed req :{} ", req, e);
37 rep.setCode(400); 41 rep.setCode(400);
38 rep.setMessage(e.getMessage()); 42 rep.setMessage(e.getMessage());
39 } 43 }
@@ -51,6 +55,7 @@ public class JavaAppInfoCtrl { @@ -51,6 +55,7 @@ public class JavaAppInfoCtrl {
51 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusList(list); 55 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusList(list);
52 rep.setData(javaApiStatusRepList); 56 rep.setData(javaApiStatusRepList);
53 } catch (Exception e) { 57 } catch (Exception e) {
  58 + log.warn("query failed req :{} ", req, e);
54 rep.setCode(400); 59 rep.setCode(400);
55 rep.setMessage(e.getMessage()); 60 rep.setMessage(e.getMessage());
56 } 61 }
@@ -81,6 +86,7 @@ public class JavaAppInfoCtrl { @@ -81,6 +86,7 @@ public class JavaAppInfoCtrl {
81 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisLatest(api_id, mobj_id); 86 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisLatest(api_id, mobj_id);
82 rep.setData(javaApiStatusRepList); 87 rep.setData(javaApiStatusRepList);
83 } catch (Exception e) { 88 } catch (Exception e) {
  89 + log.warn("querylatesthis failed apiId :{} mobjId:{}", api_id, mobj_id, e);
84 rep.setCode(400); 90 rep.setCode(400);
85 rep.setMessage(e.getMessage()); 91 rep.setMessage(e.getMessage());
86 } 92 }
@@ -106,6 +112,7 @@ public class JavaAppInfoCtrl { @@ -106,6 +112,7 @@ public class JavaAppInfoCtrl {
106 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisByTime(api_id, mobj_id, start_time, end_time, page); 112 List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisByTime(api_id, mobj_id, start_time, end_time, page);
107 rep.setData(javaApiStatusRepList); 113 rep.setData(javaApiStatusRepList);
108 } catch (Exception e) { 114 } catch (Exception e) {
  115 + log.warn("queryhis failed apiId :{} mobjId:{} start_time:{} endTime:{} ,page:{} ", api_id, mobj_id, start_time, end_time, page, e);
109 rep.setCode(400); 116 rep.setCode(400);
110 rep.setMessage(e.getMessage()); 117 rep.setMessage(e.getMessage());
111 } 118 }
@@ -95,18 +95,23 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { @@ -95,18 +95,23 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService {
95 page * PaginationContants.PAGE_COMMON_OFFSET_PERIOD); 95 page * PaginationContants.PAGE_COMMON_OFFSET_PERIOD);
96 List<JavaApiStatusRep> repList = new ArrayList<JavaApiStatusRep>(); 96 List<JavaApiStatusRep> repList = new ArrayList<JavaApiStatusRep>();
97 97
98 - for (JavaApiStaticsModel req : modelList) { 98 + for (JavaApiStaticsModel model : modelList) {
99 JavaApiStatusRep rep = new JavaApiStatusRep(); 99 JavaApiStatusRep rep = new JavaApiStatusRep();
100 - rep.setServiceId(req.getServiceId());  
101 - rep.setMObjectId(req.getMObjectId());  
102 - rep.setStatus(req.getStatus()); 100 + rep.setServiceId(model.getServiceId());
  101 + rep.setMObjectId(model.getMObjectId());
  102 + rep.setStatus(model.getStatus());
103 103
104 - rep.setEndTime(req.getEndTime());  
105 - rep.setStartTime(req.getStartTime());  
106 - rep.setCostTime(req.getCostTime());  
107 - rep.setException(req.getException()); 104 + rep.setEndTime(model.getEndTime());
  105 + rep.setStartTime(model.getStartTime());
  106 + rep.setCostTime(model.getCostTime());
  107 + rep.setException(model.getException());
  108 + rep.setResponse(model.getResponse());
108 109
  110 + rep.setMPort(model.getMPort());
  111 + rep.setMIp(model.getMIp());
  112 + rep.setMName(model.getMName());
109 113
  114 + rep.setTime(model.getTime());
110 repList.add(rep); 115 repList.add(rep);
111 } 116 }
112 117
@@ -13,10 +13,18 @@ public class JavaApiStaticsModel { @@ -13,10 +13,18 @@ public class JavaApiStaticsModel {
13 private Integer mObjectId; 13 private Integer mObjectId;
14 private Integer status; 14 private Integer status;
15 private String exception; 15 private String exception;
  16 + private String response;
  17 +
16 private String startTime; 18 private String startTime;
17 private String endTime; 19 private String endTime;
18 private int costTime; 20 private int costTime;
19 21
  22 + private String mIp;
  23 + private String mPort;
  24 + private String mName;
  25 +
  26 + private String time;
  27 +
20 @Override 28 @Override
21 public String toString() { 29 public String toString() {
22 return ReflectionToStringBuilder.toString(this); 30 return ReflectionToStringBuilder.toString(this);
@@ -13,8 +13,13 @@ public class JavaApiStatusRep { @@ -13,8 +13,13 @@ public class JavaApiStatusRep {
13 private Integer mObjectId; 13 private Integer mObjectId;
14 private Integer status; 14 private Integer status;
15 private String exception; 15 private String exception;
  16 + private String response;
16 private String startTime; 17 private String startTime;
17 private String endTime; 18 private String endTime;
18 private int costTime; 19 private int costTime;
  20 + private String mIp;
  21 + private String mPort;
  22 + private String mName;
19 23
  24 + private String time;
20 } 25 }