Authored by FengRuwei

历史查询

... ... @@ -159,18 +159,40 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper {
long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end")));
long costTime = (endTime - startTime);
String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));
javaApiStaticsModel.setStartTime(DateFormatUtil.parseLongToTimeStr(startTime));
javaApiStaticsModel.setEndTime(DateFormatUtil.parseLongToTimeStr(endTime));
javaApiStaticsModel.setCostTime((int) costTime);
int a_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("api_id"))).intValue();
int m_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("mobj_id"))).intValue();
javaApiStaticsModel.setServiceId(a_id);
javaApiStaticsModel.setMObjectId(m_id);
String m_ip = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_ip"));
String m_port = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_port"));
String m_name = (String) series.getValues().get(0).get(series.getColumns().indexOf("mobj_name"));
javaApiStaticsModel.setMIp(m_ip);
javaApiStaticsModel.setMPort(m_port);
javaApiStaticsModel.setMName(m_name);
String time = (String) series.getValues().get(0).get(series.getColumns().indexOf("time"));
javaApiStaticsModel.setTime(DateFormatUtil.displayFormat(time));
if (is_exception == true) {
javaApiStaticsModel.setStatus(0);
String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));
javaApiStaticsModel.setException(exception);
} else
} else {
javaApiStaticsModel.setStatus(1);
String response = (String) series.getValues().get(0).get(series.getColumns().indexOf("response"));
javaApiStaticsModel.setResponse(response);
}
list.add(javaApiStaticsModel);
}
return list;
... ...
... ... @@ -5,6 +5,8 @@ import com.monitor.javaserver.service.IJavaApiStatusService;
import com.monitor.model.request.JavaApiStatusReq;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.JavaApiStatusRep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
... ... @@ -22,6 +24,7 @@ import java.util.List;
@RequestMapping("javaApiStatus")
public class JavaAppInfoCtrl {
Logger log = LoggerFactory.getLogger(JavaAppInfoCtrl.class);
@Autowired
IJavaApiStatusService javaApiStatusService;
... ... @@ -34,6 +37,7 @@ public class JavaAppInfoCtrl {
JavaApiStatusRep javaApiStatusRep = javaApiStatusService.getJavaApiStatus(req);
rep.setData(javaApiStatusRep);
} catch (Exception e) {
log.warn("queryOne failed req :{} ", req, e);
rep.setCode(400);
rep.setMessage(e.getMessage());
}
... ... @@ -51,6 +55,7 @@ public class JavaAppInfoCtrl {
List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusList(list);
rep.setData(javaApiStatusRepList);
} catch (Exception e) {
log.warn("query failed req :{} ", req, e);
rep.setCode(400);
rep.setMessage(e.getMessage());
}
... ... @@ -81,6 +86,7 @@ public class JavaAppInfoCtrl {
List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisLatest(api_id, mobj_id);
rep.setData(javaApiStatusRepList);
} catch (Exception e) {
log.warn("querylatesthis failed apiId :{} mobjId:{}", api_id, mobj_id, e);
rep.setCode(400);
rep.setMessage(e.getMessage());
}
... ... @@ -106,6 +112,7 @@ public class JavaAppInfoCtrl {
List<JavaApiStatusRep> javaApiStatusRepList = javaApiStatusService.getJavaApiStatusHisByTime(api_id, mobj_id, start_time, end_time, page);
rep.setData(javaApiStatusRepList);
} catch (Exception e) {
log.warn("queryhis failed apiId :{} mobjId:{} start_time:{} endTime:{} ,page:{} ", api_id, mobj_id, start_time, end_time, page, e);
rep.setCode(400);
rep.setMessage(e.getMessage());
}
... ...
... ... @@ -95,18 +95,23 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService {
page * PaginationContants.PAGE_COMMON_OFFSET_PERIOD);
List<JavaApiStatusRep> repList = new ArrayList<JavaApiStatusRep>();
for (JavaApiStaticsModel req : modelList) {
for (JavaApiStaticsModel model : modelList) {
JavaApiStatusRep rep = new JavaApiStatusRep();
rep.setServiceId(req.getServiceId());
rep.setMObjectId(req.getMObjectId());
rep.setStatus(req.getStatus());
rep.setServiceId(model.getServiceId());
rep.setMObjectId(model.getMObjectId());
rep.setStatus(model.getStatus());
rep.setEndTime(req.getEndTime());
rep.setStartTime(req.getStartTime());
rep.setCostTime(req.getCostTime());
rep.setException(req.getException());
rep.setEndTime(model.getEndTime());
rep.setStartTime(model.getStartTime());
rep.setCostTime(model.getCostTime());
rep.setException(model.getException());
rep.setResponse(model.getResponse());
rep.setMPort(model.getMPort());
rep.setMIp(model.getMIp());
rep.setMName(model.getMName());
rep.setTime(model.getTime());
repList.add(rep);
}
... ...
... ... @@ -13,10 +13,18 @@ public class JavaApiStaticsModel {
private Integer mObjectId;
private Integer status;
private String exception;
private String response;
private String startTime;
private String endTime;
private int costTime;
private String mIp;
private String mPort;
private String mName;
private String time;
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
... ...
... ... @@ -13,8 +13,13 @@ public class JavaApiStatusRep {
private Integer mObjectId;
private Integer status;
private String exception;
private String response;
private String startTime;
private String endTime;
private int costTime;
private String mIp;
private String mPort;
private String mName;
private String time;
}
... ...