package com.shlanbao.tzsc.pms.equ.overhaul.tools;
|
|
|
import com.google.gson.Gson;
|
import com.shlanbao.tzsc.base.mapping.EqpRequestRecord;
|
import org.directwebremoting.Browser;
|
import org.directwebremoting.ScriptSessions;
|
import org.directwebremoting.ServerContextFactory;
|
|
|
public class DwrPush {
|
|
/**
|
* 推送信息到任意页面
|
*
|
* @param url
|
* 除去项目根路径外的action路径名,以"/"开头
|
* @param functionName
|
* 前台页面JS函数名
|
* @param message
|
* 需要推送的信息
|
* @author pushMsgToAnyJSP(String url, final String functionName,final Object... message)
|
* */
|
public static void pushMsgToAnyJSP(String url, final String functionName,final EqpRequestRecord rb) {
|
try {
|
String contextPath = "/GF_LBDWS";
|
String page = contextPath + url;
|
Browser.withPage(page,new Runnable() {
|
public void run() {
|
//将对象转成字符串
|
if (rb==null) {
|
ScriptSessions.addFunctionCall(functionName);
|
}else {
|
Gson gson = new Gson();
|
String json = gson.toJson(rb);
|
//JSON json=new JSONArray().fromObject(rb);
|
String jsonstr = json.toString();
|
ScriptSessions.addFunctionCall(functionName, jsonstr);
|
}
|
}
|
});
|
} catch (Exception e) {
|
/*System.out.println("维修呼叫推送页面未打开 !!!!");*/
|
e.printStackTrace();
|
}
|
|
}
|
|
|
}
|