Kaynağa Gözat

1:聊天记录查询新增过滤条件(文字及起始时间)
2:聊天记录保存时新增备注字段,默认等于文字消息内容
3:修复一键联系时重复生成对话框的错误

沈静伟 4 yıl önce
ebeveyn
işleme
ab4af7fe89

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/system/im/imdialog/SQL/即时通讯群历史消息查询.sql

@@ -1,2 +1,2 @@
 select fmessageobj as message from timdialogmessage t1
-where t1.siteid=$siteid$ and t1.timdialogid=$timdialogid$
+where t1.siteid=$siteid$ and t1.timdialogid=$timdialogid$ and $where$

+ 4 - 3
src/dsb/com/cnd3b/restcontroller/system/im/imdialog/SQL/根据用户ID查询一对一聊天对话框ID.sql

@@ -1,3 +1,4 @@
-select timdialogid from timdialogusers t1
-where t1.siteid=$siteid$ and fimdialogtype='ÆÕͨ' and exists(select *from timdialogusers where siteid=t1.siteid and timdialogid=t1.timdialogid and tenterprise_userid in $tenterprise_userid$ )
-group by timdialogid having count(0)=2
+select t1.timdialogid from timdialogusers t1
+inner join timdialog t2 on t1.siteid=t2.siteid and t1.timdialogid=t2.timdialogid
+where t1.siteid=$siteid$ and t1.fimdialogtype='ÆÕͨ' and exists(select *from timdialogusers where siteid=t1.siteid and timdialogid=t1.timdialogid and tenterprise_userid in $tenterprise_userid$ )
+group by t1.timdialogid having count(0)=2

+ 25 - 5
src/dsb/com/cnd3b/restcontroller/system/im/imdialog/imdialog.java

@@ -126,9 +126,30 @@ public class imdialog extends Controller {
          */
         String[] sortfield = {"t1.createdate desc"};
         String sort = getSort(sortfield, "t1.createdate desc");
+
+        /**
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.fnotes like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("begdate") && !"".equals(whereObject.getString("begdate"))) {
+                where.append(" and convert(varchar(10),t1.createdate,120)>=").append("'").append(whereObject.getString("begdate")).append("'");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and convert(varchar(10),t1.createdate,120)<=").append("'").append(whereObject.getString("enddate")).append("'");
+            }
+        }
+
         SQLFactory timdialogSQL = new SQLFactory(this, "即时通讯群历史消息查询", pageSize, pageNumber, sort);
         timdialogSQL.addParameter("siteid", siteid);
         timdialogSQL.addParameter("timdialogid", timdialogid);
+        timdialogSQL.addParameter("where", where);
         Rows rows = dbConnect.runSqlQuery(timdialogSQL.getSQL());
         for (Row row : rows) {
             String message = row.getString("message");
@@ -271,7 +292,7 @@ public class imdialog extends Controller {
      */
     public String closeSubject() throws D3bException, P2Exception {
         long timsubjectid = content.getLongValue("timsubjectid"); //话题ID 新增时默认传0
-        String status = dbConnect.runSqlUpdate("update timsubject set fisclose=1,closedate=getDate() where siteid='" + siteid + "' and timsubjectid='" + timsubjectid+"'");
+        String status = dbConnect.runSqlUpdate("update timsubject set fisclose=1,closedate=getDate() where siteid='" + siteid + "' and timsubjectid='" + timsubjectid + "'");
         if ("true".equals(status)) {
             return getSucReturnObject().toString();
         } else {
@@ -321,12 +342,11 @@ public class imdialog extends Controller {
     public String queryDialogUncloseSubject() {
         long timdialogid = content.getLongValue("timdialogid");
         Rows rows = dbConnect.runSqlQuery("select timsubjectid from timsubject where siteid='" + siteid + "' and timdialogid='" + timdialogid + "' and fisclose=0 order by timsubjectid desc");
-        if(!rows.isEmpty()){
+        if (!rows.isEmpty()) {
             long timsubjectid = rows.get(0).getLong("timsubjectid");
-            content.put("timsubjectid",timsubjectid);
+            content.put("timsubjectid", timsubjectid);
             return querySubject();
-        }
-        else {
+        } else {
             return getSucReturnObject().toString();
         }
     }

+ 5 - 5
src/dsb/com/cnd3b/websocketcontroller/message/message.java

@@ -60,7 +60,7 @@ public class message extends Controller {
                 }
             }
         }
-        saveMessage(messageObject);
+        saveMessage(messageObject, fmessage);
         return getSucReturnObject().toString();
     }
 
@@ -98,7 +98,7 @@ public class message extends Controller {
                 }
             }
         }
-        saveMessage(messageObject);
+        saveMessage(messageObject, "null");
         return getSucReturnObject().toString();
     }
 
@@ -143,7 +143,7 @@ public class message extends Controller {
                 }
             }
         }
-        saveMessage(messageObject);
+        saveMessage(messageObject, "null");
         return getSucReturnObject().toString();
     }
 
@@ -152,10 +152,10 @@ public class message extends Controller {
      *
      * @param messageObject
      */
-    private void saveMessage(JSONObject messageObject) {
+    private void saveMessage(JSONObject messageObject, String fnotes) {
         SQLFactory sqlFactory = new SQLFactory(this, "¼´Ê±Í¨Ñ¶ÈºÏûÏ¢²åÈë");
         sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("fnotes", "null");
+        sqlFactory.addParameter("fnotes", fnotes);
         sqlFactory.addParameter("timdialogid", messageObject.getLong("timdialogid"));
         sqlFactory.addParameter("tenterprise_userid", userid);
         sqlFactory.addParameter("fmessageobj", messageObject.toJSONString());