Selaa lähdekoodia

知识库添加使用量和收藏量字段

lihai 5 vuotta sitten
vanhempi
commit
f8e37ab22a

+ 25 - 7
CallCenterApi/CallCenterApi.DAL/T_RepositoryInformation.cs

38
         {
38
         {
39
             StringBuilder strSql = new StringBuilder();
39
             StringBuilder strSql = new StringBuilder();
40
             strSql.Append("insert into T_RepositoryInformation(");
40
             strSql.Append("insert into T_RepositoryInformation(");
41
-            strSql.Append("F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID)");
41
+            strSql.Append("F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID,F_UseNum,F_CollectionNum)");
42
             strSql.Append(" values (");
42
             strSql.Append(" values (");
43
-            strSql.Append("@F_CategoryId,@F_Title,@F_Content,@F_Description,@F_Url,@F_KeyWords,@F_ClickCount,@F_ISPass,@F_ISSubmitAudit,@F_Expand1,@F_Expand2,@F_IntExpand1,@F_CreateOn,@F_CreateBy,@F_AuditID)");
43
+            strSql.Append("@F_CategoryId,@F_Title,@F_Content,@F_Description,@F_Url,@F_KeyWords,@F_ClickCount,@F_ISPass,@F_ISSubmitAudit,@F_Expand1,@F_Expand2,@F_IntExpand1,@F_CreateOn,@F_CreateBy,@F_AuditID,@F_UseNum,@F_CollectionNum)");
44
             strSql.Append(";select @@IDENTITY");
44
             strSql.Append(";select @@IDENTITY");
45
             SqlParameter[] parameters = {
45
             SqlParameter[] parameters = {
46
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
46
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
57
                     new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
57
                     new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
58
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
58
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
59
                     new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
59
                     new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
60
-                    new SqlParameter("@F_AuditID", SqlDbType.Int,4)};
60
+                    new SqlParameter("@F_AuditID", SqlDbType.Int,4),
61
+                    new SqlParameter("@F_UseNum", SqlDbType.Int,4),
62
+                    new SqlParameter("@F_CollectionNum", SqlDbType.Int,4)};
61
             parameters[0].Value = model.F_CategoryId;
63
             parameters[0].Value = model.F_CategoryId;
62
             parameters[1].Value = model.F_Title;
64
             parameters[1].Value = model.F_Title;
63
             parameters[2].Value = model.F_Content;
65
             parameters[2].Value = model.F_Content;
73
             parameters[12].Value = model.F_CreateOn;
75
             parameters[12].Value = model.F_CreateOn;
74
             parameters[13].Value = model.F_CreateBy;
76
             parameters[13].Value = model.F_CreateBy;
75
             parameters[14].Value = model.F_AuditID;
77
             parameters[14].Value = model.F_AuditID;
78
+            parameters[15].Value = model.F_UseNum;
79
+            parameters[16].Value = model.F_CollectionNum;
76
 
80
 
77
             object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
81
             object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
78
             if (obj == null)
82
             if (obj == null)
106
             strSql.Append("F_CreateOn=@F_CreateOn,");
110
             strSql.Append("F_CreateOn=@F_CreateOn,");
107
             strSql.Append("F_CreateBy=@F_CreateBy,");
111
             strSql.Append("F_CreateBy=@F_CreateBy,");
108
             strSql.Append("F_AuditID=@F_AuditID");
112
             strSql.Append("F_AuditID=@F_AuditID");
113
+            strSql.Append("F_UseNum=@F_UseNum");
114
+            strSql.Append("F_CollectionNum=@F_CollectionNum");
109
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
115
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
110
             SqlParameter[] parameters = {
116
             SqlParameter[] parameters = {
111
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
117
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
123
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
129
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
124
                     new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
130
                     new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
125
                     new SqlParameter("@F_AuditID", SqlDbType.Int,4),
131
                     new SqlParameter("@F_AuditID", SqlDbType.Int,4),
132
+                    new SqlParameter("@F_UseNum", SqlDbType.Int,4),
133
+                    new SqlParameter("@F_CollectionNum", SqlDbType.Int,4),
126
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)};
134
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)};
127
             parameters[0].Value = model.F_CategoryId;
135
             parameters[0].Value = model.F_CategoryId;
128
             parameters[1].Value = model.F_Title;
136
             parameters[1].Value = model.F_Title;
139
             parameters[12].Value = model.F_CreateOn;
147
             parameters[12].Value = model.F_CreateOn;
140
             parameters[13].Value = model.F_CreateBy;
148
             parameters[13].Value = model.F_CreateBy;
141
             parameters[14].Value = model.F_AuditID;
149
             parameters[14].Value = model.F_AuditID;
142
-            parameters[15].Value = model.F_RepositoryId;
150
+            parameters[15].Value = model.F_UseNum;
151
+            parameters[16].Value = model.F_CollectionNum;
152
+            parameters[17].Value = model.F_RepositoryId;
143
 
153
 
144
             int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
154
             int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
145
             if (rows > 0)
155
             if (rows > 0)
203
         {
213
         {
204
 
214
 
205
             StringBuilder strSql = new StringBuilder();
215
             StringBuilder strSql = new StringBuilder();
206
-            strSql.Append("select  top 1 F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID from T_RepositoryInformation ");
216
+            strSql.Append("select  top 1 F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID,F_UseNum,F_CollectionNum from T_RepositoryInformation ");
207
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
217
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
208
             SqlParameter[] parameters = {
218
             SqlParameter[] parameters = {
209
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
219
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
295
                 {
305
                 {
296
                     model.F_AuditID = int.Parse(row["F_AuditID"].ToString());
306
                     model.F_AuditID = int.Parse(row["F_AuditID"].ToString());
297
                 }
307
                 }
308
+                if (row["F_UseNum"] != null && row["F_UseNum"].ToString() != "")
309
+                {
310
+                    model.F_UseNum = int.Parse(row["F_UseNum"].ToString());
311
+                }
312
+                if (row["F_CollectionNum"] != null && row["F_CollectionNum"].ToString() != "")
313
+                {
314
+                    model.F_CollectionNum = int.Parse(row["F_CollectionNum"].ToString());
315
+                }
298
             }
316
             }
299
             return model;
317
             return model;
300
         }
318
         }
305
         public DataSet GetList(string strWhere)
323
         public DataSet GetList(string strWhere)
306
         {
324
         {
307
             StringBuilder strSql = new StringBuilder();
325
             StringBuilder strSql = new StringBuilder();
308
-            strSql.Append("select F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID ");
326
+            strSql.Append("select F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID,F_UseNum,F_CollectionNum ");
309
             strSql.Append(" FROM T_RepositoryInformation ");
327
             strSql.Append(" FROM T_RepositoryInformation ");
310
             if (strWhere.Trim() != "")
328
             if (strWhere.Trim() != "")
311
             {
329
             {
325
             {
343
             {
326
                 strSql.Append(" top " + Top.ToString());
344
                 strSql.Append(" top " + Top.ToString());
327
             }
345
             }
328
-            strSql.Append(" F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID ");
346
+            strSql.Append(" F_RepositoryId,F_CategoryId,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_ClickCount,F_ISPass,F_ISSubmitAudit,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_AuditID,F_UseNum,F_CollectionNum ");
329
             strSql.Append(" FROM T_RepositoryInformation ");
347
             strSql.Append(" FROM T_RepositoryInformation ");
330
             if (strWhere.Trim() != "")
348
             if (strWhere.Trim() != "")
331
             {
349
             {

+ 190 - 39
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/WebChat/ChatMessagesController.cs

18
     {
18
     {
19
         BLL.T_Chat_IM_ReplyList bll_Rep = new BLL.T_Chat_IM_ReplyList();
19
         BLL.T_Chat_IM_ReplyList bll_Rep = new BLL.T_Chat_IM_ReplyList();
20
         BLL.T_Chat_IM_OperationRecords bll_Record = new BLL.T_Chat_IM_OperationRecords();
20
         BLL.T_Chat_IM_OperationRecords bll_Record = new BLL.T_Chat_IM_OperationRecords();
21
-        //BLL.T_RepositoryInformation bll_Info = new BLL.T_RepositoryInformation();
21
+        BLL.T_RepositoryInformation bll_Knowledge = new BLL.T_RepositoryInformation();
22
 
22
 
23
         #region 快速回复
23
         #region 快速回复
24
 
24
 
27
         /// </summary>
27
         /// </summary>
28
         /// <param name="keyword"></param>
28
         /// <param name="keyword"></param>
29
         /// <returns></returns>
29
         /// <returns></returns>
30
+        [Authority]
30
         public ActionResult GetReplyList(string keyword)
31
         public ActionResult GetReplyList(string keyword)
31
         {
32
         {
33
+            string usercode = User.UserData["F_UserCode"];
32
             DataTable dt = new DataTable();
34
             DataTable dt = new DataTable();
35
+            string strpageindex = RequestString.GetQueryString("page");
36
+            int pageindex = 1;
37
+            string strpagesize = RequestString.GetQueryString("pagesize");
38
+            int pagesize = 10;
39
+            int recordCount = 0;
40
+
41
+            var list_Record = bll_Record.GetModelList($"F_CreateBy = '{usercode}' AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum'").ToList();
42
+
33
             // 分词关键字
43
             // 分词关键字
34
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
44
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
35
             string[] sArrayKey = keyWords.Trim().Split(',');
45
             string[] sArrayKey = keyWords.Trim().Split(',');
47
                 sql = sb.ToString();
57
                 sql = sb.ToString();
48
                 sql += ")";
58
                 sql += ")";
49
             }
59
             }
50
-
51
-            string strpageindex = RequestString.GetQueryString("page");
52
-            int pageindex = 1;
53
-            string strpagesize = RequestString.GetQueryString("pagesize");
54
-            int pagesize = 10;
60
+            
55
             if (strpageindex.Trim() != "")
61
             if (strpageindex.Trim() != "")
56
                 pageindex = Convert.ToInt32(strpageindex);
62
                 pageindex = Convert.ToInt32(strpageindex);
57
             if (strpagesize.Trim() != "")
63
             if (strpagesize.Trim() != "")
58
                 pagesize = Convert.ToInt32(strpagesize);
64
                 pagesize = Convert.ToInt32(strpagesize);
59
-            int recordCount = 0;
60
-            dt = BLL.PagerBLL.GetListPager(
65
+            // 关键词不为空,且分词后为空时,相当于没有搜索到信息(下面是相反的条件)
66
+            if (!(!string.IsNullOrEmpty(keyword) && string.IsNullOrEmpty(keyWords)))
67
+            {
68
+                dt = BLL.PagerBLL.GetListPager(
61
                 "T_Chat_IM_ReplyList",
69
                 "T_Chat_IM_ReplyList",
62
                 "F_Id",
70
                 "F_Id",
63
                 "F_Id,(SELECT F_Name FROM dbo.T_Chat_IM_ReplyClass WHERE F_Id = F_ClassId) AS ReplyClassName,F_ReplyContent,F_CreateTime",
71
                 "F_Id,(SELECT F_Name FROM dbo.T_Chat_IM_ReplyClass WHERE F_Id = F_ClassId) AS ReplyClassName,F_ReplyContent,F_CreateTime",
67
                 pageindex,
75
                 pageindex,
68
                 true,
76
                 true,
69
                 out recordCount);
77
                 out recordCount);
78
+            }
70
 
79
 
80
+            dt.Columns.Add("IsCollection", typeof(bool));   //收藏
81
+            foreach (DataRow dr in dt.Rows)
82
+            {
83
+                int CollectionNum = list_Record.Where(r => r.F_ReplyId == int.Parse(dr["F_Id"].ToString())).Count();
84
+                dr["IsCollection"] = CollectionNum > 0 ? true : false;
85
+            }
71
             var obj = new
86
             var obj = new
72
             {
87
             {
73
                 rows = dt,
88
                 rows = dt,
80
         }
95
         }
81
 
96
 
82
         /// <summary>
97
         /// <summary>
83
-        /// 发送
98
+        /// 发送 - 快速回复
84
         /// </summary>
99
         /// </summary>
85
         /// <param name="id"></param>
100
         /// <param name="id"></param>
86
         /// <returns></returns>
101
         /// <returns></returns>
112
         }
127
         }
113
 
128
 
114
         /// <summary>
129
         /// <summary>
115
-        /// 收藏
130
+        /// 收藏/取消收藏
116
         /// </summary>
131
         /// </summary>
117
         /// <param name="id"></param>
132
         /// <param name="id"></param>
118
         /// <returns></returns>
133
         /// <returns></returns>
120
         [Authority]
135
         [Authority]
121
         public ActionResult CollectionReply(int id = 0)
136
         public ActionResult CollectionReply(int id = 0)
122
         {
137
         {
138
+            string usercode = User.UserData["F_UserCode"];
123
             if (id <= 0)
139
             if (id <= 0)
124
                 return Error("参数错误");
140
                 return Error("参数错误");
125
             var model = bll_Rep.GetModel(id);
141
             var model = bll_Rep.GetModel(id);
126
             if (model == null)
142
             if (model == null)
127
                 return Error("操作失败");
143
                 return Error("操作失败");
128
-            model.F_CollectionNum += 1;
129
-            bool b = bll_Rep.Update(model);
130
-            if (b)
144
+
145
+            // 收藏是否存在
146
+            string sql = $"SELECT COUNT(1) FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
147
+            bool isCollection = DbHelperSQL.Exists(sql);
148
+            if (isCollection)
131
             {
149
             {
132
-                var model_Collection = new Model.T_Chat_IM_OperationRecords();
133
-                model_Collection.F_ReplyId = id;
134
-                model_Collection.F_TableName = "T_Chat_IM_ReplyList";   //表名
135
-                model_Collection.F_TableField = "F_CollectionNum";      //对应字段 收藏数 F_CollectionNum
136
-                model_Collection.F_CollectionNum = 1;
137
-                model_Collection.F_CreateBy = User.UserData["F_UserCode"];
138
-                model_Collection.F_CreateTime = DateTime.Now;
139
-                bll_Record.Add(model_Collection);
140
-                return Success("收藏成功");
150
+                // 已存在,取消收藏
151
+                model.F_CollectionNum -= 1;
152
+                bool b = bll_Rep.Update(model);
153
+                if (b)
154
+                {
155
+                    // 删除收藏记录
156
+                    string sql_Records = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
157
+                    var obj = DbHelperSQL.ExecuteSql(sql_Records);
158
+                    return Success("取消收藏成功");
159
+                }
160
+                else
161
+                    return Success("取消收藏失败");
141
             }
162
             }
142
             else
163
             else
143
-                return Success("收藏失败");
164
+            {
165
+                // 不存在,收藏
166
+                model.F_CollectionNum += 1;
167
+                bool b = bll_Rep.Update(model);
168
+                if (b)
169
+                {
170
+                    // 删除收藏记录
171
+                    string sql_Records = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
172
+                    var obj = DbHelperSQL.ExecuteSql(sql_Records);
173
+                    // 添加收藏
174
+                    var model_Collection = new Model.T_Chat_IM_OperationRecords();
175
+                    model_Collection.F_ReplyId = id;
176
+                    model_Collection.F_TableName = "T_Chat_IM_ReplyList";   //表名
177
+                    model_Collection.F_TableField = "F_CollectionNum";      //对应字段 收藏数 F_CollectionNum
178
+                    model_Collection.F_CollectionNum = 1;
179
+                    model_Collection.F_CreateBy = User.UserData["F_UserCode"];
180
+                    model_Collection.F_CreateTime = DateTime.Now;
181
+                    bll_Record.Add(model_Collection);
182
+                    return Success("收藏成功");
183
+                }
184
+                else
185
+                    return Success("收藏失败");
186
+            }
144
         }
187
         }
145
 
188
 
146
         /// <summary>
189
         /// <summary>
147
-        /// 取消收藏
190
+        /// 取消收藏 - 不用
148
         /// </summary>
191
         /// </summary>
149
         /// <param name="id"></param>
192
         /// <param name="id"></param>
150
         /// <returns></returns>
193
         /// <returns></returns>
162
             bool b = bll_Rep.Update(model);
205
             bool b = bll_Rep.Update(model);
163
             if (b)
206
             if (b)
164
             {
207
             {
165
-                // 删除发送,收藏记录
208
+                // 删除收藏记录
166
                 string sql = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
209
                 string sql = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_Chat_IM_ReplyList' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
167
                 var obj = DbHelperSQL.ExecuteSql(sql);
210
                 var obj = DbHelperSQL.ExecuteSql(sql);
168
-                return Success("收藏成功");
211
+                return Success("取消收藏成功");
169
             }
212
             }
170
             else
213
             else
171
-                return Success("收藏失败");
214
+                return Success("取消收藏失败");
172
         }
215
         }
173
         #endregion
216
         #endregion
174
 
217
 
181
         /// <returns></returns>
224
         /// <returns></returns>
182
         public ActionResult GetKnowledgeList(string keyword)
225
         public ActionResult GetKnowledgeList(string keyword)
183
         {
226
         {
227
+            string usercode = User.UserData["F_UserCode"];
184
             DataTable dt = new DataTable();
228
             DataTable dt = new DataTable();
185
             // 分词关键字
229
             // 分词关键字
186
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
230
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
189
             foreach (string key in sArrayKey)
233
             foreach (string key in sArrayKey)
190
             {
234
             {
191
                 if (key.Trim() != "")
235
                 if (key.Trim() != "")
192
-                    sql += " or F_Title like '%" + key + "%'";
236
+                    sql += " or F_Title like '%" + key + "%' or F_Content like '%" + key + "%'";
193
             }
237
             }
194
             if (!string.IsNullOrEmpty(sql))
238
             if (!string.IsNullOrEmpty(sql))
195
             {
239
             {
216
             if (strpagesize.Trim() != "")
260
             if (strpagesize.Trim() != "")
217
                 pagesize = Convert.ToInt32(strpagesize);
261
                 pagesize = Convert.ToInt32(strpagesize);
218
             int recordCount = 0;
262
             int recordCount = 0;
219
-            dt = BLL.PagerBLL.GetListPager(
220
-                "T_RepositoryInformation",
221
-                "F_RepositoryId",
222
-                "F_CategoryId,(SELECT F_CategoryName FROM dbo.T_RepositoryCategory WHERE F_CategoryId = T_RepositoryInformation.F_CategoryId) AS CategoryName,F_Title,F_Content,F_Description,F_CreateOn",
223
-                sql,
224
-                "ORDER BY F_RepositoryId desc",
225
-                pagesize,
226
-                pageindex,
227
-                true,
228
-                out recordCount);
263
+
264
+            var list_Record = bll_Record.GetModelList($"F_CreateBy = '{usercode}' AND F_TableName = 'T_RepositoryInformation' AND F_TableField = 'F_CollectionNum'").ToList();
265
+            
266
+            // 关键词不为空,且分词后为空时,相当于没有搜索到信息(下面是相反的条件)
267
+            if (!(!string.IsNullOrEmpty(keyword) && string.IsNullOrEmpty(keyWords)))
268
+            {
269
+                dt = BLL.PagerBLL.GetListPager(
270
+                    "T_RepositoryInformation",
271
+                    "F_RepositoryId",
272
+                    "F_CategoryId,(SELECT F_CategoryName FROM dbo.T_RepositoryCategory WHERE F_CategoryId = T_RepositoryInformation.F_CategoryId) AS CategoryName,F_Title,F_Content,F_Description,F_CreateOn",
273
+                    sql,
274
+                    "ORDER BY F_RepositoryId desc",
275
+                    pagesize,
276
+                    pageindex,
277
+                    true,
278
+                    out recordCount);
279
+            }
280
+
281
+            dt.Columns.Add("IsCollection", typeof(bool));   //收藏
282
+            foreach (DataRow dr in dt.Rows)
283
+            {
284
+                int CollectionNum = list_Record.Where(r => r.F_ReplyId == int.Parse(dr["F_Id"].ToString())).Count();
285
+                dr["IsCollection"] = CollectionNum > 0 ? true : false;
286
+            }
229
 
287
 
230
             var obj = new
288
             var obj = new
231
             {
289
             {
237
             return Content(obj.ToJson());
295
             return Content(obj.ToJson());
238
 
296
 
239
         }
297
         }
298
+
299
+        /// <summary>
300
+        /// 发送 知识库
301
+        /// </summary>
302
+        /// <param name="id"></param>
303
+        /// <returns></returns>
304
+        [HttpPost]
305
+        [Authority]
306
+        public ActionResult SendKnowledge(int id = 0)
307
+        {
308
+            if (id <= 0)
309
+                return Error("参数错误");
310
+            var model = bll_Knowledge.GetModel(id);
311
+            if (model == null)
312
+                return Error("操作失败");
313
+            model.F_UseNum += 1;
314
+            bool b = bll_Knowledge.Update(model);
315
+            if (b)
316
+            {
317
+                var model_Collection = new Model.T_Chat_IM_OperationRecords();
318
+                model_Collection.F_ReplyId = id;
319
+                model_Collection.F_TableName = "T_RepositoryInformation";   //表名
320
+                model_Collection.F_TableField = "F_UseNum";             //对应字段 使用数 F_UseNum
321
+                model_Collection.F_CollectionNum = 1;
322
+                model_Collection.F_CreateBy = User.UserData["F_UserCode"];
323
+                model_Collection.F_CreateTime = DateTime.Now;
324
+                bll_Record.Add(model_Collection);
325
+                return Success("发送成功");
326
+            }
327
+            else
328
+                return Success("发送失败");
329
+        }
330
+
331
+        /// <summary>
332
+        /// 收藏/取消收藏
333
+        /// </summary>
334
+        /// <param name="id"></param>
335
+        /// <returns></returns>
336
+        [HttpPost]
337
+        [Authority]
338
+        public ActionResult CollectionKnowledge(int id = 0)
339
+        {
340
+            string usercode = User.UserData["F_UserCode"];
341
+            if (id <= 0)
342
+                return Error("参数错误");
343
+            var model = bll_Knowledge.GetModel(id);
344
+            if (model == null)
345
+                return Error("操作失败");
346
+
347
+            // 收藏是否存在
348
+            string sql = $"SELECT COUNT(1) FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_RepositoryInformation' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
349
+            bool isCollection = DbHelperSQL.Exists(sql);
350
+            if (isCollection)
351
+            {
352
+                // 已存在,取消收藏
353
+                model.F_CollectionNum -= 1;
354
+                bool b = bll_Knowledge.Update(model);
355
+                if (b)
356
+                {
357
+                    // 删除收藏记录
358
+                    string sql_Records = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_RepositoryInformation' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
359
+                    var obj = DbHelperSQL.ExecuteSql(sql_Records);
360
+                    return Success("取消收藏成功");
361
+                }
362
+                else
363
+                    return Success("取消收藏失败");
364
+            }
365
+            else
366
+            {
367
+                // 不存在,收藏
368
+                model.F_CollectionNum += 1;
369
+                bool b = bll_Knowledge.Update(model);
370
+                if (b)
371
+                {
372
+                    // 删除收藏记录
373
+                    string sql_Records = $"DELETE FROM dbo.T_Chat_IM_OperationRecords WHERE 1=1 AND F_TableName = 'T_RepositoryInformation' AND F_TableField = 'F_CollectionNum' AND F_ReplyId = {id} AND F_CreateBy = '{usercode}'";
374
+                    var obj = DbHelperSQL.ExecuteSql(sql_Records);
375
+                    // 添加收藏
376
+                    var model_Collection = new Model.T_Chat_IM_OperationRecords();
377
+                    model_Collection.F_ReplyId = id;
378
+                    model_Collection.F_TableName = "T_RepositoryInformation";   //表名
379
+                    model_Collection.F_TableField = "F_CollectionNum";      //对应字段 收藏数 F_CollectionNum
380
+                    model_Collection.F_CollectionNum = 1;
381
+                    model_Collection.F_CreateBy = User.UserData["F_UserCode"];
382
+                    model_Collection.F_CreateTime = DateTime.Now;
383
+                    bll_Record.Add(model_Collection);
384
+                    return Success("收藏成功");
385
+                }
386
+                else
387
+                    return Success("收藏失败");
388
+            }
389
+        }
390
+
240
         #endregion
391
         #endregion
241
 
392
 
242
         #region 工单查询
393
         #region 工单查询
243
 
394
 
244
         #endregion
395
         #endregion
245
 
396
 
246
-        #region 通话记录查询
397
+        #region 客户档案查询
247
 
398
 
248
         #endregion
399
         #endregion
249
     }
400
     }

+ 19 - 0
CallCenterApi/CallCenterApi.Model/T_RepositoryInformation.cs

26
         private DateTime? _f_createon;
26
         private DateTime? _f_createon;
27
         private int? _f_createby;
27
         private int? _f_createby;
28
         private int? _f_auditid;
28
         private int? _f_auditid;
29
+        private int? _f_usenum = 0;
30
+        private int? _f_collectionnum = 0;
29
         /// <summary>
31
         /// <summary>
30
         /// 知识库条目id
32
         /// 知识库条目id
31
         /// </summary>
33
         /// </summary>
154
             set { _f_auditid = value; }
156
             set { _f_auditid = value; }
155
             get { return _f_auditid; }
157
             get { return _f_auditid; }
156
         }
158
         }
159
+
160
+        /// <summary>
161
+        /// 使用数 - 在线客服
162
+        /// </summary>
163
+        public int? F_UseNum
164
+        {
165
+            set { _f_usenum = value; }
166
+            get { return _f_usenum; }
167
+        }
168
+        /// <summary>
169
+        /// 收藏数 - 在线客服
170
+        /// </summary>
171
+        public int? F_CollectionNum
172
+        {
173
+            set { _f_collectionnum = value; }
174
+            get { return _f_collectionnum; }
175
+        }
157
         #endregion Model
176
         #endregion Model
158
 
177
 
159
     }
178
     }

+ 2 - 0
CallCenterCommon/CallCenter.WebChatServer/App.config

21
     <!--客户ip是黑名单-->
21
     <!--客户ip是黑名单-->
22
     <add key="black" value="当前状态异常,请电话联系!"/>
22
     <add key="black" value="当前状态异常,请电话联系!"/>
23
     
23
     
24
+    <!--智能机器人回复 - 客服不在线时-->
25
+    <add key="busy_robotreply" value="对不起,我已经很努力了,未能找到。请试试其他信息吧"/>
24
     <!--提示欢迎词(默认)-->
26
     <!--提示欢迎词(默认)-->
25
     <add key="welcome" value="你好,见到你很开心"/>
27
     <add key="welcome" value="你好,见到你很开心"/>
26
     <!--提示欢迎词时间间隔(秒)-->
28
     <!--提示欢迎词时间间隔(秒)-->

+ 1 - 1
CallCenterCommon/CallCenter.WebChatServer/ChatServer.cs

358
                                     // 客服不在线时,启动 智能机器人IM
358
                                     // 客服不在线时,启动 智能机器人IM
359
                                     string strContent = cs.GetSmartRobotByKey(msg.msg);
359
                                     string strContent = cs.GetSmartRobotByKey(msg.msg);
360
                                     if (string.IsNullOrEmpty(strContent))
360
                                     if (string.IsNullOrEmpty(strContent))
361
-                                        strContent = "抱歉,我已经很努力了,请试试其他信息吧";
361
+                                        strContent = ConfigurationManager.AppSettings["busy_robotreply"];
362
                                     Thread.Sleep(500);
362
                                     Thread.Sleep(500);
363
                                     ChatClass.Message cusrecmsg = new ChatClass.Message();
363
                                     ChatClass.Message cusrecmsg = new ChatClass.Message();
364
                                     cusrecmsg.action = "cusreceive";
364
                                     cusrecmsg.action = "cusreceive";

+ 3 - 4
CallCenterCommon/CallCenter.WebChatServer/keywords_baidu.dic

1
 你好
1
 你好
2
-物业
3
-快速
4
 开发
2
 开发
5
 系统
3
 系统
6
 新闻
4
 新闻
7
 呼叫系统
5
 呼叫系统
8
 呼叫
6
 呼叫
9
-简介
7
+商丘简介
8
+商丘12345
10
 支付
9
 支付
11
 产品
10
 产品
12
-公司
11
+加一
13
 地址
12
 地址
14
 咨询
13
 咨询

+ 9 - 0
项目其他/sql/T_RepositoryInformation添加字段.sql

1
+
2
+ALTER TABLE T_RepositoryInformation ADD [F_UseNum] INT DEFAULT(0)
3
+EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ʹÓÃÊý' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_RepositoryInformation', @level2type=N'COLUMN',@level2name=N'F_UseNum'
4
+GO
5
+
6
+
7
+ALTER TABLE T_RepositoryInformation ADD [F_CollectionNum] INT DEFAULT(0)
8
+EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ÊÕ²ØÊý' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_RepositoryInformation', @level2type=N'COLUMN',@level2name=N'F_CollectionNum'
9
+GO