use of com.creditease.agent.feature.notifycenter.task.PersistentTask in project uavstack by uavorg.
the class NCHttpHandler method handle.
@SuppressWarnings("unchecked")
@Override
public void handle(UAVHttpMessage data) {
String ntfkey = data.getRequest(NCConstant.NCEventParam);
long startTime_gui = DataConvertHelper.toLong(data.getRequest(NCConstant.NCEventTime), -1);
Map<String, String> ntfvalue = cm.getHash(NCConstant.STORE_REGION, NCConstant.STORE_KEY_NCINFO, ntfkey);
String argsValue = ntfvalue.get(ntfkey);
// no exist the cache value
if (argsValue == null) {
data.putResponse(UAVHttpMessage.ERR, "No Exist Cache for key[" + ntfkey + "]");
return;
}
Map<String, Object> ntfValue = JSONHelper.toObject(argsValue, Map.class);
long viewTime = DataConvertHelper.toLong(ntfValue.get(NCConstant.COLUMN_VIEWTIME), -1);
long startTime = DataConvertHelper.toLong(ntfValue.get(NCConstant.COLUMN_STARTTIME), -1);
// if the startTime_gui not equal startTime, means the event with the startTime_gui has been viewed
if (viewTime != -1 || startTime_gui != startTime) {
data.putResponse(UAVHttpMessage.RESULT, "Event[" + ntfkey + "](" + startTime + ") has been viewed");
return;
}
NotificationEvent event = new NotificationEvent("Viewed", "ViewTitle", "tempDescription");
ntfValue.put(NCConstant.COLUMN_STATE, StateFlag.VIEW.getStatFlag());
ntfValue.put(NCConstant.COLUMN_VIEWTIME, System.currentTimeMillis());
event.addArg(NCConstant.NTFKEY, ntfkey);
event.addArg(NCConstant.NTFVALUE, JSONHelper.toString(ntfValue));
event.addArg(NCConstant.NCFirstEvent, "false");
PersistentTask taskP = new PersistentTask(cName, feature);
taskP.put(NCConstant.NCEventParam, event);
qworker.put(taskP);
data.putResponse(UAVHttpMessage.RESULT, "OK");
}
use of com.creditease.agent.feature.notifycenter.task.PersistentTask in project uavstack by uavorg.
the class NCJudgementHandler method addPersistentTask.
/**
* 添加预警事件到持久化任务
*/
public void addPersistentTask(NotificationEvent event) {
PersistentTask taskP = new PersistentTask(cName, feature);
taskP.put(NCConstant.NCEventParam, event);
qworker.put(taskP);
}
Aggregations