Procházet zdrojové kódy

代码整理、即时聊天、附件查询调整

沈静伟 před 4 roky
rodič
revize
7fd549c950

+ 53 - 68
src/dsb/com/cnd3b/common/Controller.java

@@ -9,12 +9,14 @@ import com.cnd3b.common.data.db.DBConnect;
 import com.cnd3b.common.data.db.DataPool;
 import com.cnd3b.common.parameter.parameter;
 import com.cnd3b.common.data.Row;
+import org.apache.poi.ss.formula.functions.T;
 import p2.p2server.P2Server;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.security.ConnectionKey;
 import p2.util.P2Exception;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.sql.Connection;
@@ -83,7 +85,7 @@ public class Controller extends BaseClass {
             userid = this.content.getLongValue("userid");
         } else if (this.content.containsKey("$accesstoken")) {
             $accesstoken = this.content.getString("$accesstoken");
-            if(parameter.tokenlist.containsKey($accesstoken)){
+            if (parameter.tokenlist.containsKey($accesstoken)) {
                 userid = parameter.tokenlist.get($accesstoken);
             }
         }
@@ -213,7 +215,6 @@ public class Controller extends BaseClass {
     }
 
 
-
     //userid:tuserrequestlogid
     public static HashMap<Long, Long> userRequestLogMap = new HashMap<>();
     //userid:count
@@ -450,6 +451,13 @@ public class Controller extends BaseClass {
         return rows;
     }
 
+    public Row getAttachmentUrl(long tattachmentid) {
+        SQLFactory docfactory = new SQLFactory("附件查询_ID");
+        docfactory.addParameter("siteid", siteid);
+        docfactory.addParameter("tattachmentid", tattachmentid);
+        return dbConnect.runSqlQuery(docfactory.getSQL()).getRow(0);
+    }
+
     public RowsMap getAttachmentUrl(String ownertable, String[] ownerids) {
         return getAttachmentUrl(ownertable, ownerids, "default");
     }
@@ -458,8 +466,8 @@ public class Controller extends BaseClass {
         return getAttachmentUrl(ownertable, ownerids, "default");
     }
 
-    public Rows getAttachmentUrl(String ownertable, String ownerids) {
-        return getAttachmentUrl(ownertable, ownerids, "default");
+    public Rows getAttachmentUrl(String ownertable, String ownerid) {
+        return getAttachmentUrl(ownertable, ownerid, "default");
     }
 
     public RowsMap getAttachmentUrl(String ownertable, ArrayList<String> ownerids, String ftype) {
@@ -475,11 +483,27 @@ public class Controller extends BaseClass {
         return dbConnect.runSqlQuery(docfactory.getSQL()).toRowsMap("ownerid");
     }
 
-    public Rows getAttachmentUrl(String ownertable, String ownerids, String ftype) {
+    public static HashMap<Long, String> headPicMap = new HashMap<>();
+    /**
+     * 获取用户头像
+     *
+     * @return
+     */
+    public String getHeadPic(long userid) {
+        if (!headPicMap.containsKey(userid)) {
+            Rows rows = getAttachmentUrl("tenterprise_users", String.valueOf(userid), "headportrait");
+            if (!rows.isEmpty()) {
+                headPicMap.put(userid, rows.get(0).getString("fobsurl_minimage"));
+            }
+        }
+        return headPicMap.getOrDefault(userid, "");
+    }
+
+    public Rows getAttachmentUrl(String ownertable, String ownerid, String ftype) {
         SQLFactory docfactory = new SQLFactory("附件查询");
         docfactory.addParameter("siteid", siteid);
         docfactory.addParameter("ownertable", ownertable);
-        docfactory.addParameter_in("ownerid", ownerids);
+        docfactory.addParameter_in("ownerid", ownerid);
         docfactory.addParameter("ftype", ftype);
         return dbConnect.runSqlQuery(docfactory.getSQL());
     }
@@ -569,68 +593,6 @@ public class Controller extends BaseClass {
         return datakey;
     }
 
-    //  public static HashMap<String,HashMap<String,Integer>>table_field_length_Map=new HashMap<>();
-
-//    /**
-//     * 文本字段验证
-//     *
-//     * @param fieldvalue
-//     * @return  true表示超出长度,false表示未超出长度
-//     */
-//    public void fieldValueCheck_Str(String fieldname, String fieldtitle, String fieldvalue)throws Exception {
-//        String[]split=fieldname.toUpperCase().split("[.]");
-//        String tablename=split[0];
-//       if(!table_field_length_Map.containsKey(tablename)){
-//            HashMap<String,Integer>map=new HashMap<>();
-//            Rows rows = dbConnect.runSqlQuery("select fieldname,length from ps_objectcols where objectname='"+tablename+"'");
-//            for(Row row:rows){
-//                map.put(row.getString("fieldname"),row.getInteger("length"));
-//            }
-//           table_field_length_Map.put(tablename,map);
-//       }
-//       int maxlength= table_field_length_Map.get(tablename).get(split[1])/2;
-//        if (fieldvalue!=null&&fieldvalue.length() >maxlength) {
-//            throw new Exception(fieldtitle + " 内容超过最大字数" + maxlength + "限制");
-//        }
-//    }
-//    /**
-//     * 文本字段验证
-//     *
-//     * @param fieldvalue
-//     * @return  true表示超出长度,false表示未超出长度
-//     */
-//    public void fieldValueCheck_Str(String fieldname, String fieldtitle, String fieldvalue,int length)throws Exception {
-//        String[]split=fieldname.toUpperCase().split("[.]");
-//        String tablename=split[0];
-//        if(!table_field_length_Map.containsKey(tablename)){
-//            HashMap<String,Integer>map=new HashMap<>();
-//            Rows rows = dbConnect.runSqlQuery("select fieldname,length from ps_objectcols where objectname='"+tablename+"'");
-//            for(Row row:rows){
-//                map.put(row.getString("fieldname"),row.getInteger("length"));
-//            }
-//            table_field_length_Map.put(tablename,map);
-//        }
-//        int maxlength= table_field_length_Map.get(tablename).get(split[1])/2;
-//        if (fieldvalue!=null&&(fieldvalue.length() >maxlength||fieldvalue.length()>length)) {
-//            throw new Exception(fieldtitle + " 内容超过最大字数" + maxlength + "限制");
-//        }
-//    }
-
-//    /**
-//     * 字段验证
-//     *
-//     * @param object
-//     * @param fieldname
-//     * @return 错误信息
-//     */
-//    public void isNumeric(JSONObject object, String fieldname, String fieldtitle) throws Exception{
-//        try {
-//            object.getFloatValue(fieldname);
-//        } catch (Exception e) {
-//            throw new Exception(fieldtitle + "为数值项,请填入正确的数值");
-//        }
-//    }
-
     public void p2ServerSystemPaoSetClose() {
         for (PaoSetRemote paoset : PaoSetRemoteList) {
             try {
@@ -641,4 +603,27 @@ public class Controller extends BaseClass {
         }
         PaoSetRemoteList.clear();
     }
+
+
+    public static HashMap<Long, ArrayList<Long>> imdialog_usermap = new HashMap<>();
+
+    /**
+     * 根据消息对话框ID获取用户id
+     *
+     * @param timdialogid
+     * @return
+     */
+    public ArrayList<Long> getUserIds(long timdialogid) {
+        if (!imdialog_usermap.containsKey(timdialogid)) {
+            Rows rows = dbConnect.runSqlQuery("select tenterprise_userid from timdialogusers where siteid='" + siteid + "' and timdialogid='" + timdialogid + "' and fisremove=0");
+            ArrayList<Long> list = new ArrayList<>();
+            for (Row row : rows) {
+                list.add(row.getLong("tenterprise_userid"));
+            }
+            imdialog_usermap.put(timdialogid, list);
+        }
+        return imdialog_usermap.get(timdialogid);
+    }
+
+
 }

+ 2 - 0
src/dsb/com/cnd3b/common/data/Rows.java

@@ -3,6 +3,7 @@ package com.cnd3b.common.data;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.cnd3b.utility.Math;
+import org.apache.poi.ss.formula.functions.T;
 import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
@@ -142,6 +143,7 @@ public class Rows extends ArrayList<Row> {
         return list;
     }
 
+
     public RowsMap toRowsMap(String fieldname) {
         RowsMap map = new RowsMap();
         for (Row row : this) {

+ 16 - 0
src/dsb/com/cnd3b/common/data/SQL/附件查询_ID.sql

@@ -0,0 +1,16 @@
+select siteid
+     , ownerid
+     , ownertable
+     , ftype
+     , REPLACE(fdocument, '.' + postfix, '') as fdocument
+     , tattachmentid
+     , postfix
+     , fobsurl as url
+     , fobsurl_minimage
+     , fobsurl_compressimage
+     , fobsurl_hls
+     , createdate
+     , contentlength
+from tattachment
+where siteid=$siteid$ and tattachmentid=$tattachmentid$
+order by tattachmentid

+ 6 - 0
src/dsb/com/cnd3b/common/parameter/parameter.java

@@ -1,12 +1,15 @@
 package com.cnd3b.common.parameter;
 
 import com.cnd3b.common.data.Row;
+import com.cnd3b.common.websocket.WebClientSocket;
 import p2.p2server.P2Server;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * 参数及全局数据表
@@ -49,6 +52,9 @@ public class parameter {
     public static HashMap<String, Date> registerpassword_date = new HashMap<>(16);
 
 
+    //websocket连接池
+    public static Map<Long, WebClientSocket> websocketClients = new ConcurrentHashMap<Long, WebClientSocket>();
+
     /**
      * 方法请求次数
      */

+ 157 - 115
src/dsb/com/cnd3b/common/websocket/WebClientSocket.java

@@ -2,6 +2,7 @@ package com.cnd3b.common.websocket;
 
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.BaseClass;
+import com.cnd3b.common.D3BReturnObject_Err;
 import com.cnd3b.common.data.Row;
 import com.cnd3b.common.parameter.parameter;
 
@@ -9,37 +10,50 @@ import javax.websocket.*;
 import javax.websocket.server.PathParam;
 import javax.websocket.server.ServerEndpoint;
 import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 //ws://127.0.0.1:8080/samex/webSocket/829fef9884bbf7f9fb9c51499d7b332f
 @ServerEndpoint("/webSocket/{accesstoken}")
 public class WebClientSocket extends BaseClass {
 
-    //websocket连接池
-    public static Map<Long, WebClientSocket> websocketClients = new ConcurrentHashMap<Long, WebClientSocket>();
     private Session session;
     //当前连接对象的账号ID
     private long userid;
     private Row userRow;
+    private String accesstoken;
 
+    /**
+     * 连接开启
+     *
+     * @param accesstoken
+     * @param session
+     * @throws IOException
+     */
     @OnOpen
     private void onOpen(@PathParam("accesstoken") String accesstoken, Session session) throws IOException {
         this.session = session;
+        this.accesstoken = accesstoken;
         if (parameter.tokenlist.containsKey(accesstoken)) {
             userid = parameter.tokenlist.get(accesstoken);
             userRow = parameter.userIdList.get(userid);
         } else {
-            sendMessage("请登陆!");
+            return;
         }
-        websocketClients.put(userid, this);
+        parameter.websocketClients.put(userid, this);
     }
 
+    /**
+     * 连接关闭
+     *
+     * @throws IOException
+     */
     @OnClose
     private void onClose() throws IOException {
-        websocketClients.remove(userid);
+        parameter.websocketClients.remove(userid);
     }
 
     /**
@@ -80,111 +94,150 @@ public class WebClientSocket extends BaseClass {
      * @param messageObject
      * @throws IOException
      */
+    /**
+     * 消息接收
+     *
+     * @param RequestContent
+     * @throws IOException
+     */
     @OnMessage
-    private void onMessage(String messageObject) throws IOException {
-        JSONObject mesageObj = messageCheck(messageObject);
-        if (mesageObj == null) {
+    private void onMessage(String RequestContent) throws IOException {
+        /**
+         * 验证请求正文是否为规范的SONObject格式
+         */
+        JSONObject requestcontent = null;
+        try {
+            requestcontent = JSONObject.parseObject(RequestContent);
+        } catch (Exception e) {
             return;
         }
-        long dialogid = mesageObj.getLong("dialogid");//对话框ID
         /**
-         * 消息处理
+         * 验证请求正文中是否包含必填的键值
          */
-        mesageObj = messageProcessing(mesageObj);
+        String[] mustkeys = {"classname", "method", "content"};
+        for (String mustkey : mustkeys) {
+            if (!requestcontent.containsKey(mustkey)) {
+                return;
+            }
+        }
         /**
-         * 消息发送
+         * 验证请求正文中的content是否为规范的SONObject格式
          */
-        sendMessageToDialog(mesageObj.toJSONString(), dialogid);
-    }
+        JSONObject content = new JSONObject();
+        try {
+            content = requestcontent.getJSONObject("content");
+        } catch (Exception e) {
+            return;
+        }
 
-    public JSONObject messageProcessing(JSONObject mesageObj) {
-        mesageObj.put("datetime", getDateTime_Str());
-        mesageObj.put("messageid", String.valueOf(userid) + Calendar.getInstance().getTimeInMillis());
         /**
-         * 创建发送方信息
+         * 验证正文中的token是否有效
          */
-        JSONObject sendfromObject = new JSONObject();
-        sendfromObject.put("userid", userid);
-        sendfromObject.put("siteid", userRow.getString("siteid"));
-        sendfromObject.put("username", userRow.getString("fname"));
-        mesageObj.put("sendfrom", sendfromObject);
+        String className = requestcontent.getString("classname");
 
-        /**
-         *  消息持久化,保存消息体mesageObj,字段:siteid,dialogid,userid,messageid,datetime,description,messagetype,mesageObj
-         */
+        parameter.requesttime.put(accesstoken, Calendar.getInstance().getTime());
 
-        return mesageObj;
-    }
+        String methodName = requestcontent.getString("method");
+        if (content.isEmpty()) {
+            content = new JSONObject();
+        }
+        content.put("$classname", className);
+        content.put("$method", methodName);
+        content.put("$accesstoken", accesstoken);
 
-    /**
-     * 消息格式检查
-     *
-     * @param messageObject
-     * @throws Exception
-     */
-    public JSONObject messageCheck(String messageObject) {
-        JSONObject mesageObj = null;
-        String errmsg = "";
+        String key = className + "." + methodName;
+        String result;
+        Object obj = null;
         try {
-            mesageObj = JSONObject.parseObject(messageObject);
+
+            long starttimes = Calendar.getInstance().getTimeInMillis();
+            /**
+             * 执行请求方法
+             */
+            Class clz = Class.forName("com.cnd3b.websocketcontroller." + className);
+            Constructor cla = clz.getDeclaredConstructor(JSONObject.class);
+            obj = cla.newInstance(content);
+            Method method = obj.getClass().getDeclaredMethod(methodName);
+            result = (String) method.invoke(obj);
+            long endtimes = Calendar.getInstance().getTimeInMillis();
+            saveCallMethodMsg(key, true, endtimes - starttimes);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className).toString();
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("类" + className + "实例化异常").toString();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("类" + className + "安全权限异常,可能该类为非public类").toString();
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className + "的" + methodName + "方法").toString();
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("类" + className + "的" + methodName + "方法参数不合法").toString();
+        } catch (InvocationTargetException e) {
+            Throwable targetException = e.getTargetException();
+            D3BReturnObject_Err d3BReturnObject_err = new D3BReturnObject_Err();
+            d3BReturnObject_err.setErrMsg(targetException.getMessage());
+            result = d3BReturnObject_err.toString();
         } catch (Exception e) {
-            errmsg = "不是有效的JSONObject消息格式";
-        }
-        if (!mesageObj.containsKey("dialogid") || mesageObj.getLongValue("dialogid") <= 0) {
-            errmsg = "dialogid缺失";
-        }
-        if (!mesageObj.containsKey("messagetype")) {
-            errmsg = "messagetype缺失";
-        }
-        String messagetype = mesageObj.getString("messagetype");
-        if (!Arrays.asList(new String[]{"text", "file", "data"}).contains(messagetype)) {
-            errmsg = "无效的messagetype";
-        }
-        if (!mesageObj.containsKey("description") || "".equals(mesageObj.getString("description"))) {
-            errmsg = "description缺失";
-        }
-        if (!mesageObj.containsKey("data")) {
-            errmsg = "data缺失";
-        }
-        JSONObject data = mesageObj.getJSONObject("data");
-        if ("text".equals(messagetype)) {
-            if (!data.containsKey("message") || "".equals(mesageObj.getString("message"))) {
-                errmsg = "text消息必须包含message";
-            }
-        } else if ("file".equals(messagetype)) {
-            if (!data.containsKey("ownertable") || "".equals(mesageObj.getString("ownertable"))) {
-                errmsg = "file消息必须包含ownertable";
-            }
-            if (!data.containsKey("ownerid") || "".equals(mesageObj.getString("ownerid"))) {
-                errmsg = "file消息必须包含ownerid";
-            }
-            if (!data.containsKey("serialnumber") || "".equals(mesageObj.getString("serialnumber"))) {
-                errmsg = "file消息必须包含serialnumber";
-            }
-            if (!data.containsKey("fobsurl") || "".equals(mesageObj.getString("fobsurl"))) {
-                errmsg = "file消息必须包含fobsurl";
-            }
-            if (!data.containsKey("fdocument") || "".equals(mesageObj.getString("fdocument"))) {
-                errmsg = "file消息必须包含fdocument";
-            }
-        } else if ("data".equals(messagetype)) {
-            if (!data.containsKey("type") || "".equals(mesageObj.getString("type"))) {
-                errmsg = "data消息必须包含type";
-            }
-            if (!data.containsKey("ownertable") || "".equals(mesageObj.getString("ownertable"))) {
-                errmsg = "data消息必须包含ownertable";
-            }
-            if (!data.containsKey("ownerid") || "".equals(mesageObj.getString("ownerid"))) {
-                errmsg = "data消息必须包含ownerid";
+            e.printStackTrace();
+            result = new D3BReturnObject_Err().setErrMsg("发生未知异常" + e.getMessage()).toString();
+        } finally {
+            if (obj != null) {
+                try {
+                    obj.getClass().getMethod("p2ServerSystemPaoSetClose").invoke(obj);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
         }
-        if (!"".equals(errmsg)) {
-            sendMessage(errmsg);
-            return null;
+        return;
+    }
+
+    /**
+     * 记录请求数
+     *
+     * @param key
+     * @param fromdb
+     * @param time
+     */
+    private void saveCallMethodMsg(String key, boolean fromdb, long time) {
+        long callmethodTimes = parameter.callmethodTimes.containsKey(key) ? parameter.callmethodTimes.get(key) : 0L;
+
+        //更新请求总数
+        parameter.callmethodTimes.put(key, callmethodTimes + 1L);
+
+        //最新请求时间
+        parameter.lastcallmethodtime.put(key, Calendar.getInstance().getTime());
+
+        //从缓存获取的次数
+        long callmethod_fromcacheTimes = parameter.callmethod_fromcacheTimes.containsKey(key) ? parameter.callmethod_fromcacheTimes.get(key) : 0L;
+        if (!fromdb) {
+            /**
+             * 方法请求从缓存获取次数
+             */
+            parameter.callmethod_fromcacheTimes.put(key, callmethod_fromcacheTimes + 1L);
+        } else {
+            /**
+             * 方法请求查询最新耗时
+             */
+            parameter.callmethodLastTimeLong.put(key, time);
+
+
+            long totaltimes = callmethodTimes - callmethod_fromcacheTimes;
+
+            /**
+             * 方法请求查询平均时间
+             */
+            long callmethodTimeLong = parameter.callmethodTimeLong.containsKey(key) ? parameter.callmethodTimeLong.get(key) : 0L;
+
+            parameter.callmethodTimeLong.put(key, (callmethodTimeLong * totaltimes + time) / (totaltimes + 1));
         }
-        return mesageObj;
     }
 
+
     @OnError
     private void onError(Session session, Throwable error) {
         error.printStackTrace();
@@ -192,38 +245,27 @@ public class WebClientSocket extends BaseClass {
 
 
     /**
-     * 对当前连接发送消息
+     * 对当前连接发送对话框消息
      *
      * @param message
      */
-    public void sendMessage(String message) {
-        session.getAsyncRemote().sendText(message);
+    public void sendDialogMessage(JSONObject message) {
+        JSONObject object = new JSONObject();
+        object.put("msgtype", "imdialog");
+        object.put("message", message);
+        session.getAsyncRemote().sendText(object.toJSONString());
     }
 
     /**
-     * 向指定的对象发送消息
+     * 对当前连接发送系统消息
      *
      * @param message
-     * @param toUserid
-     * @throws IOException
      */
-    public void sendMessageToUser(String message, long toUserid) throws IOException {
-        if (websocketClients.containsKey(toUserid)) {
-            websocketClients.get(toUserid).session.getAsyncRemote().sendText(message);
-        }
-    }
-
-    /**
-     * 向指定的d对话框发送消息
-     *
-     * @param message
-     * @param dialogid
-     * @throws IOException
-     */
-    public void sendMessageToDialog(String message, long dialogid) throws IOException {
-        for (WebClientSocket item : websocketClients.values()) {
-            item.session.getAsyncRemote().sendText(message);
-        }
+    public void sendSystemMessage(JSONObject message) {
+        JSONObject object = new JSONObject();
+        object.put("msgtype", "system");
+        object.put("message", message);
+        session.getAsyncRemote().sendText(object.toJSONString());
     }
 
 

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/customer/notice/notice.java

@@ -105,7 +105,7 @@ public class notice extends Controller {
                 row.put("fattachmentcount", 0);
             }
 
-            row.put("docinfos", map.get(tnoticeid));
+            row.put("attinfos", map.get(tnoticeid));
         }
         return getSucReturnObject().setDataByPaging(rows, sortfield).setFinalDo(DataPool.defaultdatalife, 1);
     }

+ 142 - 0
src/dsb/com/cnd3b/websocketcontroller/message/message.java

@@ -0,0 +1,142 @@
+package com.cnd3b.websocketcontroller.message;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.parameter.parameter;
+import com.cnd3b.utility.Encryption;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+
+public class message extends Controller {
+
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public message(JSONObject content) {
+        super(content);
+    }
+    //String fmessagetype = content.getString("fmessagetype");//消息类型,text,file,data,image
+
+    /**
+     * 发送文字消息
+     *
+     * @return
+     */
+    public String sendTextMessage() {
+        long timdialogid = content.getLong("timdialogid");//对话框ID
+        String fmessage = content.getString("fmessage");//消息
+
+        JSONObject messageObject = new JSONObject();
+        messageObject.put("timdialogid", timdialogid);
+        messageObject.put("ftype", "text");
+        messageObject.put("datetime", getDateTime_Str());
+        messageObject.put("messageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
+
+        /**
+         * 创建发送方信息
+         */
+        JSONObject sendfromObject = new JSONObject();
+        sendfromObject.put("userid", userid);
+        sendfromObject.put("siteid", siteid);
+        sendfromObject.put("username", username);
+        sendfromObject.put("headpic", getHeadPic(userid));
+        messageObject.put("sendfrom", sendfromObject);
+
+        JSONObject msgObject = new JSONObject();
+        msgObject.put("fcontent", fmessage);
+        messageObject.put("data", msgObject);
+
+        ArrayList<Long> userids = getUserIds(timdialogid);
+        for (long userid : userids) {
+            if (parameter.websocketClients.containsKey(userid)) {
+                parameter.websocketClients.get(userid).sendDialogMessage(messageObject);
+            }
+        }
+        saveMessage(messageObject);
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 发送文件消息
+     *
+     * @return
+     */
+    public String sendFileMessage() {
+        long timdialogid = content.getLong("timdialogid");//对话框ID
+        long tattachmentid = content.getLong("tattachmentid");//附件ID
+
+        JSONObject messageObject = new JSONObject();
+        messageObject.put("timdialogid", timdialogid);
+        messageObject.put("ftype", "file");
+        messageObject.put("datetime", getDateTime_Str());
+        messageObject.put("messageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
+
+        /**
+         * 创建发送方信息
+         */
+        JSONObject sendfromObject = new JSONObject();
+        sendfromObject.put("userid", userid);
+        sendfromObject.put("siteid", siteid);
+        sendfromObject.put("username", username);
+        messageObject.put("sendfrom", sendfromObject);
+        messageObject.put("data", getAttachmentUrl(tattachmentid));
+
+        ArrayList<Long> userids = getUserIds(timdialogid);
+        for (long userid : userids) {
+            if (parameter.websocketClients.containsKey(userid)) {
+                parameter.websocketClients.get(userid).sendDialogMessage(messageObject);
+            }
+        }
+        saveMessage(messageObject);
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 发送文件消息
+     *
+     * @return
+     */
+    public String sendDataMessage() {
+        long timdialogid = content.getLong("timdialogid");//对话框ID
+        long ownertable = content.getLong("ownertable");//数据表
+        long ownerid = content.getLong("ownerid");//数据ID
+        long ftype = content.getLong("ftype");//数据类型
+
+        JSONObject messageObject = new JSONObject();
+        messageObject.put("timdialogid", timdialogid);
+        messageObject.put("ftype", "data");
+        messageObject.put("datetime", getDateTime_Str());
+        messageObject.put("messageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
+
+        /**
+         * 创建发送方信息
+         */
+        JSONObject sendfromObject = new JSONObject();
+        sendfromObject.put("userid", userid);
+        sendfromObject.put("siteid", siteid);
+        sendfromObject.put("username", username);
+        messageObject.put("sendfrom", sendfromObject);
+
+        JSONObject msgObject = new JSONObject();
+        msgObject.put("ownertable", ownertable);
+        msgObject.put("ownerid", ownerid);
+        msgObject.put("ftype", ftype);
+        messageObject.put("data", msgObject);
+
+        ArrayList<Long> userids = getUserIds(timdialogid);
+        for (long userid : userids) {
+            if (parameter.websocketClients.containsKey(userid)) {
+                parameter.websocketClients.get(userid).sendDialogMessage(messageObject);
+            }
+        }
+        saveMessage(messageObject);
+        return getSucReturnObject().toString();
+    }
+
+    private void saveMessage(JSONObject messageObject) {
+
+    }
+}