|
|
@@ -2,8 +2,10 @@ package com.cnd3b.websocketcontroller.message;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cnd3b.common.Controller;
|
|
|
+import com.cnd3b.common.data.SQLFactory;
|
|
|
import com.cnd3b.common.parameter.parameter;
|
|
|
import com.cnd3b.utility.Encryption;
|
|
|
+import p2.util.P2Exception;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
@@ -25,15 +27,15 @@ public class message extends Controller {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String sendTextMessage() {
|
|
|
+ public String sendTextMessage() throws P2Exception {
|
|
|
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()));
|
|
|
+ messageObject.put("fdatetime", getDateTime_Str());
|
|
|
+ messageObject.put("fmessageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
|
|
|
|
|
|
/**
|
|
|
* 创建发送方信息
|
|
|
@@ -64,15 +66,15 @@ public class message extends Controller {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String sendFileMessage() {
|
|
|
+ public String sendFileMessage() throws P2Exception {
|
|
|
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()));
|
|
|
+ messageObject.put("fdatetime", getDateTime_Str());
|
|
|
+ messageObject.put("fmessageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
|
|
|
|
|
|
/**
|
|
|
* 创建发送方信息
|
|
|
@@ -95,11 +97,11 @@ public class message extends Controller {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发送文件消息
|
|
|
+ * 发送数据消息
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String sendDataMessage() {
|
|
|
+ public String sendDataMessage() throws P2Exception {
|
|
|
long timdialogid = content.getLong("timdialogid");//对话框ID
|
|
|
long ownertable = content.getLong("ownertable");//数据表
|
|
|
long ownerid = content.getLong("ownerid");//数据ID
|
|
|
@@ -108,8 +110,8 @@ public class message extends Controller {
|
|
|
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()));
|
|
|
+ messageObject.put("fdatetime", getDateTime_Str());
|
|
|
+ messageObject.put("fmessageid", new Encryption().Encode_MD5(siteid + userid + Calendar.getInstance().getTimeInMillis()));
|
|
|
|
|
|
/**
|
|
|
* 创建发送方信息
|
|
|
@@ -136,7 +138,27 @@ public class message extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 消息持久化
|
|
|
+ *
|
|
|
+ * @param messageObject
|
|
|
+ */
|
|
|
private void saveMessage(JSONObject messageObject) {
|
|
|
-
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "即时通讯群消息插入");
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("fnotes", "null");
|
|
|
+ sqlFactory.addParameter("timdialogid", messageObject.getLong("timdialogid"));
|
|
|
+ sqlFactory.addParameter("tenterprise_userid", userid);
|
|
|
+ sqlFactory.addParameter("fmessageobj", messageObject.toJSONString());
|
|
|
+ sqlFactory.addParameter("fmessageid", messageObject.getString("messageid"));
|
|
|
+ sqlFactory.addParameter("fmessagetype", messageObject.getString("ftype"));
|
|
|
+ if ("data".equals(messageObject.getString("ftype"))) {
|
|
|
+ sqlFactory.addParameter("ownerid", messageObject.getJSONObject("data").getString("ownerid"));
|
|
|
+ sqlFactory.addParameter("ownertable", messageObject.getJSONObject("data").getString("ownertable"));
|
|
|
+ } else {
|
|
|
+ sqlFactory.addParameter("ownerid", "null");
|
|
|
+ sqlFactory.addParameter("ownertable", "null");
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlFactory.getSQL());
|
|
|
}
|
|
|
}
|