|
|
@@ -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
|
}
|