zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
        }
        
    }
 
 
}