use of com.creditease.uav.helpers.url.BASE64DecoderUrl in project uavstack by uavorg.
the class GodEyeRestService method noitifyView.
@POST
@Path("notify/view/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyView(String data, @Suspended AsyncResponse response) throws Exception {
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
@SuppressWarnings("unchecked") Map<String, String> jsonParam = JSONHelper.toObject(data, Map.class);
String url = jsonParam.get("url");
String time;
if ("link".equals(jsonParam.get("type"))) {
byte[] d = new BASE64DecoderUrl().decodeBuffer(url);
url = new String(d, "utf-8");
time = url.substring(url.lastIndexOf("&") + 1);
} else {
String timeStr = url.substring(url.lastIndexOf("&") + 1);
time = String.valueOf(simpleDateFormat.parse(timeStr).getTime());
}
String ntfkey = url.substring(0, url.lastIndexOf("&"));
String loginUser = "";
HttpSession session = request.getSession(false);
if (null != session) {
loginUser = String.valueOf(session.getAttribute("apphub.gui.session.login.user.id"));
}
String log = "loginUser=[" + loginUser + "],type=[" + jsonParam.get("type") + "],ntfkey=[" + ntfkey + "],time=[" + time + "]";
if (!"".equals(ntfkey) && !"undefined".equals(ntfkey)) {
UAVHttpMessage message = new UAVHttpMessage();
message.putRequest("ncevent", ntfkey);
message.putRequest("time", time);
NoitifyViewCB callback = new NoitifyViewCB();
callback.setResponse(response);
callback.setLog(log);
doHttpPost("uav.app.godeye.notify.view.http.addr", "/nc/update", message, callback);
}
}
use of com.creditease.uav.helpers.url.BASE64DecoderUrl in project uavstack by uavorg.
the class GodEyeRestService method noitifyDescQuery.
/**
* 先获取第一条预警信息,条件:time,ntfkey 获取当前查看时间:如果有则取其时间范围内数据,没有则取time以后所有数据
*
* @param data
* @param response
* @throws Exception
*/
@SuppressWarnings("unchecked")
@POST
@Path("notify/q/desc/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyDescQuery(String data, @Suspended AsyncResponse response) throws Exception {
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Map<String, String> jsonParam = JSONHelper.toObject(data, Map.class);
String url = jsonParam.get("url");
Long time;
if ("link".equals(jsonParam.get("type"))) {
byte[] d = new BASE64DecoderUrl().decodeBuffer(url);
url = new String(d, "utf-8");
time = Long.valueOf(url.substring(url.lastIndexOf("&") + 1));
} else {
String timeStr = url.substring(url.lastIndexOf("&") + 1);
time = simpleDateFormat.parse(timeStr).getTime();
}
final String ntfkey = url.substring(0, url.lastIndexOf("&"));
HashMap<String, Object> requestWhere = new HashMap<String, Object>();
requestWhere.put("ntfkey", ntfkey);
requestWhere.put("firstrecord", "true");
requestWhere.put("time", time);
HashMap<String, Object> requestParam = new HashMap<String, Object>();
requestParam.put("where", requestWhere);
HashMap<String, Object> sort = new HashMap<String, Object>();
sort.put("values", "time");
sort.put("sortorder", "-1");
requestParam.put("sort", sort);
// 封装http请求数据
UAVHttpMessage message = new UAVHttpMessage();
message.putRequest("mgo.sql", JSONHelper.toString(requestParam));
message.putRequest("datastore.name", "MT_Notify");
message.putRequest("mgo.coll.name", "uav_notify");
NoitifyDescQueryCB callback = new NoitifyDescQueryCB();
callback.setResponse(response);
callback.setNtfkey(ntfkey);
callback.setTime(time);
doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
}
Aggregations