浏览代码

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

lihai 5 年之前
父节点
当前提交
f8e37ab22a

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

@@ -38,9 +38,9 @@ namespace CallCenterApi.DAL
38 38
         {
39 39
             StringBuilder strSql = new StringBuilder();
40 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 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 44
             strSql.Append(";select @@IDENTITY");
45 45
             SqlParameter[] parameters = {
46 46
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
@@ -57,7 +57,9 @@ namespace CallCenterApi.DAL
57 57
                     new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
58 58
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
59 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 63
             parameters[0].Value = model.F_CategoryId;
62 64
             parameters[1].Value = model.F_Title;
63 65
             parameters[2].Value = model.F_Content;
@@ -73,6 +75,8 @@ namespace CallCenterApi.DAL
73 75
             parameters[12].Value = model.F_CreateOn;
74 76
             parameters[13].Value = model.F_CreateBy;
75 77
             parameters[14].Value = model.F_AuditID;
78
+            parameters[15].Value = model.F_UseNum;
79
+            parameters[16].Value = model.F_CollectionNum;
76 80
 
77 81
             object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
78 82
             if (obj == null)
@@ -106,6 +110,8 @@ namespace CallCenterApi.DAL
106 110
             strSql.Append("F_CreateOn=@F_CreateOn,");
107 111
             strSql.Append("F_CreateBy=@F_CreateBy,");
108 112
             strSql.Append("F_AuditID=@F_AuditID");
113
+            strSql.Append("F_UseNum=@F_UseNum");
114
+            strSql.Append("F_CollectionNum=@F_CollectionNum");
109 115
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
110 116
             SqlParameter[] parameters = {
111 117
                     new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
@@ -123,6 +129,8 @@ namespace CallCenterApi.DAL
123 129
                     new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
124 130
                     new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
125 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 134
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)};
127 135
             parameters[0].Value = model.F_CategoryId;
128 136
             parameters[1].Value = model.F_Title;
@@ -139,7 +147,9 @@ namespace CallCenterApi.DAL
139 147
             parameters[12].Value = model.F_CreateOn;
140 148
             parameters[13].Value = model.F_CreateBy;
141 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 154
             int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
145 155
             if (rows > 0)
@@ -203,7 +213,7 @@ namespace CallCenterApi.DAL
203 213
         {
204 214
 
205 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 217
             strSql.Append(" where F_RepositoryId=@F_RepositoryId");
208 218
             SqlParameter[] parameters = {
209 219
                     new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
@@ -295,6 +305,14 @@ namespace CallCenterApi.DAL
295 305
                 {
296 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 317
             return model;
300 318
         }
@@ -305,7 +323,7 @@ namespace CallCenterApi.DAL
305 323
         public DataSet GetList(string strWhere)
306 324
         {
307 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 327
             strSql.Append(" FROM T_RepositoryInformation ");
310 328
             if (strWhere.Trim() != "")
311 329
             {
@@ -325,7 +343,7 @@ namespace CallCenterApi.DAL
325 343
             {
326 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 347
             strSql.Append(" FROM T_RepositoryInformation ");
330 348
             if (strWhere.Trim() != "")
331 349
             {

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

@@ -18,7 +18,7 @@ namespace CallCenterApi.Interface.Controllers.WebChat
18 18
     {
19 19
         BLL.T_Chat_IM_ReplyList bll_Rep = new BLL.T_Chat_IM_ReplyList();
20 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 23
         #region 快速回复
24 24
 
@@ -27,9 +27,19 @@ namespace CallCenterApi.Interface.Controllers.WebChat
27 27
         /// </summary>
28 28
         /// <param name="keyword"></param>
29 29
         /// <returns></returns>
30
+        [Authority]
30 31
         public ActionResult GetReplyList(string keyword)
31 32
         {
33
+            string usercode = User.UserData["F_UserCode"];
32 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 44
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
35 45
             string[] sArrayKey = keyWords.Trim().Split(',');
@@ -47,17 +57,15 @@ namespace CallCenterApi.Interface.Controllers.WebChat
47 57
                 sql = sb.ToString();
48 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 61
             if (strpageindex.Trim() != "")
56 62
                 pageindex = Convert.ToInt32(strpageindex);
57 63
             if (strpagesize.Trim() != "")
58 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 69
                 "T_Chat_IM_ReplyList",
62 70
                 "F_Id",
63 71
                 "F_Id,(SELECT F_Name FROM dbo.T_Chat_IM_ReplyClass WHERE F_Id = F_ClassId) AS ReplyClassName,F_ReplyContent,F_CreateTime",
@@ -67,7 +75,14 @@ namespace CallCenterApi.Interface.Controllers.WebChat
67 75
                 pageindex,
68 76
                 true,
69 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 86
             var obj = new
72 87
             {
73 88
                 rows = dt,
@@ -80,7 +95,7 @@ namespace CallCenterApi.Interface.Controllers.WebChat
80 95
         }
81 96
 
82 97
         /// <summary>
83
-        /// 发送
98
+        /// 发送 - 快速回复
84 99
         /// </summary>
85 100
         /// <param name="id"></param>
86 101
         /// <returns></returns>
@@ -112,7 +127,7 @@ namespace CallCenterApi.Interface.Controllers.WebChat
112 127
         }
113 128
 
114 129
         /// <summary>
115
-        /// 收藏
130
+        /// 收藏/取消收藏
116 131
         /// </summary>
117 132
         /// <param name="id"></param>
118 133
         /// <returns></returns>
@@ -120,31 +135,59 @@ namespace CallCenterApi.Interface.Controllers.WebChat
120 135
         [Authority]
121 136
         public ActionResult CollectionReply(int id = 0)
122 137
         {
138
+            string usercode = User.UserData["F_UserCode"];
123 139
             if (id <= 0)
124 140
                 return Error("参数错误");
125 141
             var model = bll_Rep.GetModel(id);
126 142
             if (model == null)
127 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 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 189
         /// <summary>
147
-        /// 取消收藏
190
+        /// 取消收藏 - 不用
148 191
         /// </summary>
149 192
         /// <param name="id"></param>
150 193
         /// <returns></returns>
@@ -162,13 +205,13 @@ namespace CallCenterApi.Interface.Controllers.WebChat
162 205
             bool b = bll_Rep.Update(model);
163 206
             if (b)
164 207
             {
165
-                // 删除发送,收藏记录
208
+                // 删除收藏记录
166 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 210
                 var obj = DbHelperSQL.ExecuteSql(sql);
168
-                return Success("收藏成功");
211
+                return Success("取消收藏成功");
169 212
             }
170 213
             else
171
-                return Success("收藏失败");
214
+                return Success("取消收藏失败");
172 215
         }
173 216
         #endregion
174 217
 
@@ -181,6 +224,7 @@ namespace CallCenterApi.Interface.Controllers.WebChat
181 224
         /// <returns></returns>
182 225
         public ActionResult GetKnowledgeList(string keyword)
183 226
         {
227
+            string usercode = User.UserData["F_UserCode"];
184 228
             DataTable dt = new DataTable();
185 229
             // 分词关键字
186 230
             string keyWords = KeywordSpliterHelper.DoGetKeyword(keyword);
@@ -189,7 +233,7 @@ namespace CallCenterApi.Interface.Controllers.WebChat
189 233
             foreach (string key in sArrayKey)
190 234
             {
191 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 238
             if (!string.IsNullOrEmpty(sql))
195 239
             {
@@ -216,16 +260,30 @@ namespace CallCenterApi.Interface.Controllers.WebChat
216 260
             if (strpagesize.Trim() != "")
217 261
                 pagesize = Convert.ToInt32(strpagesize);
218 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 288
             var obj = new
231 289
             {
@@ -237,13 +295,106 @@ namespace CallCenterApi.Interface.Controllers.WebChat
237 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 391
         #endregion
241 392
 
242 393
         #region 工单查询
243 394
 
244 395
         #endregion
245 396
 
246
-        #region 通话记录查询
397
+        #region 客户档案查询
247 398
 
248 399
         #endregion
249 400
     }

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

@@ -26,6 +26,8 @@ namespace CallCenterApi.Model
26 26
         private DateTime? _f_createon;
27 27
         private int? _f_createby;
28 28
         private int? _f_auditid;
29
+        private int? _f_usenum = 0;
30
+        private int? _f_collectionnum = 0;
29 31
         /// <summary>
30 32
         /// 知识库条目id
31 33
         /// </summary>
@@ -154,6 +156,23 @@ namespace CallCenterApi.Model
154 156
             set { _f_auditid = value; }
155 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 176
         #endregion Model
158 177
 
159 178
     }

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

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

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

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

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

@@ -1,14 +1,13 @@
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

@@ -0,0 +1,9 @@
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