Browse Source

公告通讯录

zhaozhiqiang 3 years ago
parent
commit
0dae27c62d

+ 3 - 0
RMYY_CallCenter_Api.Bll/RMYY_CallCenter_Api.Bll.csproj

@@ -61,6 +61,9 @@
61 61
     <Compile Include="T_Hos_WorkOrderItem.cs" />
62 62
     <Compile Include="T_Mat_WorkOrder.cs" />
63 63
     <Compile Include="T_Mat_WorkOrderItem.cs" />
64
+    <Compile Include="T_Msg_Chat.cs" />
65
+    <Compile Include="T_Msg_Chat_Map.cs" />
66
+    <Compile Include="T_Msg_NoticeInfo.cs" />
64 67
     <Compile Include="T_Sys_Accessories.cs" />
65 68
     <Compile Include="T_Sys_Department.cs" />
66 69
     <Compile Include="T_Sys_DictionaryBase.cs" />

+ 3 - 0
RMYY_CallCenter_Api.Dal/RMYY_CallCenter_Api.Dal.csproj

@@ -61,6 +61,9 @@
61 61
     <Compile Include="T_Hos_WorkOrderItem.cs" />
62 62
     <Compile Include="T_Mat_WorkOrder.cs" />
63 63
     <Compile Include="T_Mat_WorkOrderItem.cs" />
64
+    <Compile Include="T_Msg_Chat.cs" />
65
+    <Compile Include="T_Msg_Chat_Map.cs" />
66
+    <Compile Include="T_Msg_NoticeInfo.cs" />
64 67
     <Compile Include="T_Sys_Accessories.cs" />
65 68
     <Compile Include="T_Sys_Department.cs" />
66 69
     <Compile Include="T_Sys_DictionaryBase.cs" />

+ 26 - 0
RMYY_CallCenter_Api.Dal/T_Sys_GongDan.cs

@@ -181,7 +181,33 @@ namespace RMYY_CallCenter_Api.Dal
181 181
                 return null;
182 182
             }
183 183
         }
184
+        /// <summary>
185
+        /// 根据名称获取对象实体
186
+        /// </summary>
187
+        /// <param name="F_GDId"></param>
188
+        /// <returns></returns>
189
+        public RMYY_CallCenter_Api.Model.T_Sys_GongDan GetModelbyname(string F_Name)
190
+        {
191
+
192
+            StringBuilder strSql = new StringBuilder();
193
+            strSql.Append("select  top 1 F_GDId,F_ParentID,F_Name,F_Remark,F_Sort,F_CreateTime,F_TypeId,F_ImgUrl from T_Sys_GongDan with(nolock)");
194
+            strSql.Append(" where F_Name=@F_Name");
195
+            SqlParameter[] parameters = {
196
+                    new SqlParameter("@F_Name", SqlDbType.VarChar,100)
197
+            };
198
+            parameters[0].Value = F_Name;
184 199
 
200
+            RMYY_CallCenter_Api.Model.T_Sys_GongDan model = new RMYY_CallCenter_Api.Model.T_Sys_GongDan();
201
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
202
+            if (ds.Tables[0].Rows.Count > 0)
203
+            {
204
+                return DataRowToModel(ds.Tables[0].Rows[0]);
205
+            }
206
+            else
207
+            {
208
+                return null;
209
+            }
210
+        }
185 211
 
186 212
         /// <summary>
187 213
         /// 得到一个对象实体

+ 3 - 0
RMYY_CallCenter_Api.Model/RMYY_CallCenter_Api.Model.csproj

@@ -60,6 +60,9 @@
60 60
     <Compile Include="T_Hos_WorkOrderItem.cs" />
61 61
     <Compile Include="T_Mat_WorkOrder.cs" />
62 62
     <Compile Include="T_Mat_WorkOrderItem.cs" />
63
+    <Compile Include="T_Msg_Chat.cs" />
64
+    <Compile Include="T_Msg_Chat_Map.cs" />
65
+    <Compile Include="T_Msg_NoticeInfo.cs" />
63 66
     <Compile Include="T_Sys_Accessories.cs" />
64 67
     <Compile Include="T_Sys_Department.cs" />
65 68
     <Compile Include="T_Sys_DictionaryBase.cs" />

+ 4 - 0
RMYY_CallCenter_Api.Utility/RMYY_CallCenter_Api.Utility.csproj

@@ -76,6 +76,7 @@
76 76
     <Compile Include="Helper\EnumHelper.cs" />
77 77
     <Compile Include="Helper\FileHelper.cs" />
78 78
     <Compile Include="Helper\HttpHelper.cs" />
79
+    <Compile Include="Helper\HttpHelperay.cs" />
79 80
     <Compile Include="Helper\ImageHelper.cs" />
80 81
     <Compile Include="Helper\LogHelper.cs" />
81 82
     <Compile Include="Helper\NPOIHelper.cs" />
@@ -85,11 +86,14 @@
85 86
     <Compile Include="Helper\ConfigHelper.cs" />
86 87
     <Compile Include="Extention\Json.cs" />
87 88
     <Compile Include="Properties\AssemblyInfo.cs" />
89
+    <Compile Include="RequestString.cs" />
88 90
     <Compile Include="Time\DateTimeConvert.cs" />
89 91
     <Compile Include="Tree\Tree.cs" />
90 92
     <Compile Include="Tree\TreeModel.cs" />
91 93
     <Compile Include="Tree\TreeSelect.cs" />
92 94
     <Compile Include="Tree\TreeSelectModel.cs" />
95
+    <Compile Include="TypeConverter.cs" />
96
+    <Compile Include="ValidateString.cs" />
93 97
   </ItemGroup>
94 98
   <ItemGroup>
95 99
     <None Include="packages.config" />

+ 481 - 0
RMYY_CallCenter_Api/Controllers/IndexController.cs

@@ -1,4 +1,5 @@
1 1
 using RMYY_CallCenter_Api.DB;
2
+using RMYY_CallCenter_Api.Models.Input;
2 3
 using RMYY_CallCenter_Api.Utility;
3 4
 using System;
4 5
 using System.Collections.Generic;
@@ -12,6 +13,10 @@ namespace RMYY_CallCenter_Api.Controllers
12 13
     public class IndexController : BaseController
13 14
     {
14 15
         private Bll.T_Sys_Menu menbll = new Bll.T_Sys_Menu();
16
+        private Bll.T_Sys_Role rolebll = new Bll.T_Sys_Role();
17
+        private Bll.T_Msg_Chat bllchat = new Bll.T_Msg_Chat();
18
+        private Bll.T_Msg_Chat_Map bllmap = new Bll.T_Msg_Chat_Map();
19
+        private readonly Bll.T_Sys_UserAccount userAccount = new Bll.T_Sys_UserAccount();
15 20
         // GET: Index
16 21
         /// <summary>
17 22
         /// 获取当前用户
@@ -216,6 +221,482 @@ namespace RMYY_CallCenter_Api.Controllers
216 221
             return Content(obj.ToJson());
217 222
         }
218 223
 
224
+        #region 及时通讯
225
+
226
+        #region 模仿微信聊天(暂时不用)
227
+        /// <summary>
228
+        /// 即时聊天 - 角色信息
229
+        /// </summary>
230
+        /// <param name="pageIndex"></param>
231
+        /// <param name="pageSize"></param>
232
+        /// <param name="code"></param>
233
+        /// <param name="name"></param>
234
+        /// <returns></returns>
235
+        public ActionResult GetRoleList()
236
+        {
237
+            //var dtCache = CacheHelper.Get<DataTable>($"RoleList");
238
+            var dtCache = RedisHelper.StringGet("RoleList");
239
+            if (dtCache != null)
240
+            {
241
+                return Success("获取成功", dtCache.ToString().ToObject<DataTable>());
242
+            }
243
+            DataTable dt = new DataTable();
244
+            dt = rolebll.GetAllList().Tables[0];
245
+            //CacheHelper.Insert($"RoleList", dt, 10);
246
+            RedisHelper.StringSet("RoleList", dt.ToJson(), new TimeSpan(0, 10, 0));
247
+            return Success("获取成功", dt);
248
+        }
249
+
250
+        /// <summary>
251
+        /// 即时聊天 - 坐席人员
252
+        /// </summary>
253
+        /// <param name="pageIndex"></param>
254
+        /// <param name="pageSize"></param>
255
+        /// <param name="code"></param>
256
+        /// <param name="name"></param>
257
+        /// <returns></returns>
258
+        public ActionResult GetUserListByRoleId(int roleid, string keyword)
259
+        {
260
+            DataTable dt = new DataTable();
261
+            //取得前天日期
262
+            DateTime start = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString() + " 00:00:00");
263
+
264
+            string sql1 = "SELECT FromUserId,COUNT(1)AS counts FROM T_Msg_Chat_Map WHERE ToUserId = " + User.F_UserId + " AND ISNULL(IsRead,0) = 0 AND CreateDate > '" + start + "' group by FromUserId order by FromUserId";
265
+            var dt1 = DbHelperSQL.Query(sql1).Tables[0];
266
+            //缓存
267
+            //var dtCache = CacheHelper.Get<DataTable>($"UserList{roleid}");
268
+            var objCache = RedisHelper.StringGet($"UserList{roleid}");
269
+            if (objCache != null)
270
+            {
271
+                var dtCache = objCache.ToString().ToObject<DataTable>();
272
+                #region 提示统计
273
+                if (!string.IsNullOrEmpty(keyword))
274
+                {
275
+                    dtCache = ToDataTable1(dtCache.Select("F_UserName LIKE '%" + keyword + "%' OR F_UserCode LIKE '%" + keyword + "%'"));
276
+                }
277
+                foreach (DataRow dr in dtCache.Rows)
278
+                {
279
+                    var list = dt1.Select(" FromUserId=" + dr["F_UserId"]);
280
+                    dr["counts"] = list.Count() > 0 ? list[0]["counts"].ToString() : "0";
281
+                }
282
+                #endregion                
283
+                return Success("获取成功", dtCache);
284
+            }
285
+            //实时查询
286
+            var sql = " F_DeleteFlag=0 ";
287
+            if (roleid != 0)
288
+            {
289
+                sql += " and F_RoleId = " + roleid + "";
290
+            }
291
+            string sqldt = "SELECT F_UserId,F_UserCode,F_UserName,F_RoleId,F_SexFlag,F_See FROM T_Sys_UserAccount WHERE " + sql + " ";
292
+            dt = DbHelperSQL.Query(sqldt).Tables[0];
293
+
294
+            #region 提示统计
295
+            dt.Columns.Add("counts", typeof(string)); //统计
296
+            //string sql1 = "SELECT FromUserId,COUNT(1)AS counts FROM T_Msg_Chat_Map WHERE ToUserId = " + User.F_UserId + " AND ISNULL(IsRead,0) = 0 AND CreateDate > '" + start + "' group by FromUserId order by FromUserId";
297
+            //var dt1 = DbHelperSQL.Query(sql1).Tables[0];
298
+            foreach (DataRow dr in dt.Rows)
299
+            {
300
+                var list = dt1.Select(" FromUserId=" + dr["F_UserId"]);
301
+                dr["counts"] = list.Count() > 0 ? list[0]["counts"].ToString() : "0";
302
+            }
303
+            //缓存保存
304
+            //CacheHelper.Insert($"UserList{roleid}", dt, 10);
305
+            RedisHelper.StringSet($"UserList{roleid}", dt.ToJson(), new TimeSpan(0, 10, 0));
306
+            if (!string.IsNullOrEmpty(keyword))
307
+            {
308
+                dt = ToDataTable1(dt.Select("F_UserName LIKE '%" + keyword + "%' OR F_UserCode LIKE '%" + keyword + "%'"));
309
+            }
310
+            #endregion
311
+            return Success("获取成功", dt);
312
+        }
313
+
314
+        /// <summary>
315
+        /// 即时聊天 - 获取最新通讯(获取双方记录【聊天】)
316
+        /// </summary>
317
+        /// <returns></returns>
318
+        public ActionResult GetChatList(int fromuserId)
319
+        {
320
+            DataTable dt = null;
321
+            int recordCount = 0;
322
+            //取得前天日期
323
+            DateTime start = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString() + " 00:00:00");
324
+            //接收坐席Id
325
+
326
+            if (fromuserId > 0)
327
+            {
328
+                //条件(最近3天的记录)
329
+                string sql = " ISNULL(a.IsDelete,0) = 0 AND ISNULL(c.F_DeleteFlag,0) = 0 "; // AND ISNULL(b.IsRead,0) = 0
330
+                if (fromuserId > 0)
331
+                {
332
+                    sql += " and (b.FromUserId = " + fromuserId + " or b.ToUserId = " + fromuserId + ") ";
333
+                }
334
+                if (User.F_UserId > 0)
335
+                {
336
+                    sql += " and (b.ToUserId = " + User.F_UserId + " or b.FromUserId = " + User.F_UserId + ") ";
337
+                }
338
+                if (start != null)
339
+                {
340
+                    sql += " and b.CreateDate > '" + start + "' ";
341
+                }
342
+                //查询(聊天记录)
343
+                string sql1 = "SELECT a.Id,a.FromUserId,a.Content,a.IsToAll,a.CreateDate,c.F_UserName FROM dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = a.FromUserId WHERE " + sql + " ORDER BY a.CreateDate ASC";
344
+                dt = DbHelperSQL.Query(sql1).Tables[0];
345
+                recordCount = dt.Rows.Count;
346
+
347
+                //修改(设置已读)
348
+                string sqlwhere = " ISNULL(IsRead,0) = 0 ";
349
+                if (fromuserId > 0)
350
+                {
351
+                    sqlwhere += " and FromUserId = " + fromuserId + " ";
352
+                }
353
+                if (User.F_UserId > 0)
354
+                {
355
+                    sqlwhere += " and ToUserId = " + User.F_UserId + " ";
356
+                }
357
+                string sqlwhere1 = "UPDATE dbo.T_Msg_Chat_Map SET IsRead = 1 WHERE " + sqlwhere + " ";
358
+                DbHelperSQL.ExecuteSql(sqlwhere1);
359
+
360
+            }
361
+            var obj = new
362
+            {
363
+                rows = dt,
364
+                total = recordCount
365
+            };
366
+            return Content(obj.ToJson());
367
+        }
368
+        #endregion
369
+
370
+        #region 及时通讯 - 通讯列表
371
+        /// <summary>
372
+        /// 即时通讯 - 获取通讯列表
373
+        /// </summary>
374
+        /// <returns></returns>
375
+        public ActionResult GetChatListSearch()
376
+        {
377
+            DataTable dt = new DataTable();
378
+            int fromid = RequestString.GetInt("fromid", 0);
379
+            int isread = RequestString.GetInt("isread", -1);
380
+            string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("strstarttime"));
381
+            string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("strendtime"));
382
+            string strpageindex = RequestString.GetQueryString("page");
383
+            int pageindex = 1;
384
+            string strpagesize = RequestString.GetQueryString("pagesize");
385
+            int pagesize = 10;
386
+
387
+            //接收坐席Id
388
+
389
+            string sql = " and ISNULL(a.IsDelete,0) = 0 AND ISNULL(c.F_DeleteFlag,0) = 0 ";
390
+
391
+
392
+
393
+            #region 权限设置
394
+            //管理员,坐席班长
395
+            if (User.F_RoleCode == "GLY" || User.F_RoleCode == "DDZG" || User.F_RoleCode == "ZXBZ")
396
+            {
397
+                //
398
+            }
399
+            else
400
+            {
401
+                sql += " and (b.ToUserId = " + User.F_UserId + " OR b.FromUserId = " + User.F_UserId + ") ";
402
+            }
403
+            #endregion
404
+
405
+            if (fromid > 0)
406
+            {
407
+                sql += " and (b.FromUserId = " + fromid + " or b.ToUserId = " + fromid + ") ";
408
+            }
409
+            if (isread != -1)
410
+            {
411
+                sql += " and ISNULL(b.IsRead,0) = " + isread + " ";
412
+            }
413
+            if (!string.IsNullOrEmpty(strstarttime))
414
+            {
415
+                sql += " and datediff(day,b.CreateDate,'" + strstarttime + "')<=0 ";
416
+            }
417
+            if (!string.IsNullOrEmpty(strendtime))
418
+            {
419
+                sql += " and datediff(day,b.CreateDate,'" + strendtime + "')>=0 ";
420
+            }
421
+            if (strpageindex.Trim() != "")
422
+            {
423
+                pageindex = Convert.ToInt32(strpageindex);
424
+            }
425
+            if (strpagesize.Trim() != "")
426
+            {
427
+                pagesize = Convert.ToInt32(strpagesize);
428
+            }
429
+            int recordCount = 0;
430
+            var col = "a.Id,b.FromUserId,b.ToUserId,a.Content,a.IsToAll,a.CreateDate,b.IsRead,c.F_UserName,c.F_UserCode,c.F_RoleId,d.F_UserName AS ToUserName,d.F_UserCode AS ToUserCode,d.F_RoleId AS ToRoleId";
431
+            dt = Bll.PagerBll.GetListPager(
432
+                    " dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = b.FromUserId LEFT JOIN dbo.T_Sys_UserAccount d ON d.F_UserId = b.ToUserId ",
433
+                    "b.Id",
434
+                    col,
435
+                    sql,
436
+                    " ORDER BY a.CreateDate ASC",
437
+                    pagesize,
438
+                    pageindex,
439
+                    true,
440
+                    out recordCount);
441
+
442
+            var obj = new
443
+            {
444
+                rows = dt,
445
+                total = recordCount
446
+            };
447
+            return Content(obj.ToJson());
448
+        }
449
+        #endregion
450
+
451
+        /// <summary>
452
+        /// 即时聊天 - 保存最新通讯
453
+        /// </summary>
454
+        /// <returns></returns>
455
+        public ActionResult SaveChatInfo(ChatInput input)
456
+        {
457
+            //发送坐席Id
458
+
459
+            var model = new Model.T_Msg_Chat();
460
+            var modelmap = new Model.T_Msg_Chat_Map();
461
+            model.Content = input.Content;          //必填
462
+            model.VoiceUrl = input.VoiceUrl;
463
+            model.FromUserId = User.F_UserId;
464
+            model.ToUserId = input.ToUserId;
465
+            model.ToRoleId = input.ToRoleId;
466
+            //如果用户和角色都为0,则发送所有人
467
+            if (input.ToUserId == 0 && input.ToRoleId == 0)
468
+            {
469
+                input.IsToAll = 1;
470
+            }
471
+            model.IsToAll = input.IsToAll;
472
+            int chatId = bllchat.Add(model);
473
+            if (chatId > 0)
474
+            {
475
+                modelmap.ChatId = chatId;
476
+                modelmap.FromUserId = User.F_UserId;
477
+                //群发聊天          
478
+                if (input.IsToAll > 0)
479
+                {
480
+                    var userList = userAccount.DataTableToList(userAccount.GetList(" F_DeleteFlag=0 ").Tables[0]);
481
+                    foreach (var u in userList)
482
+                    {
483
+                        modelmap.ToUserId = u.F_UserId;
484
+                        bllmap.Add(modelmap);
485
+                    }
486
+                    return Success("发送成功");
487
+                }
488
+                //角色聊天
489
+                if (input.ToRoleId > 0 && input.ToUserId == 0)
490
+                {
491
+                    var userList = userAccount.DataTableToList(userAccount.GetList(" F_DeleteFlag=0 AND F_RoleId=" + input.ToRoleId + " ").Tables[0]);
492
+                    foreach (var u in userList)
493
+                    {
494
+                        modelmap.ToUserId = u.F_UserId;
495
+                        bllmap.Add(modelmap);
496
+                    }
497
+                    return Success("发送成功");
498
+                }
499
+                //私人聊天
500
+                modelmap.ToUserId = input.ToUserId;
501
+                //关闭之前所有的信息
502
+                string sqlwhere1 = "UPDATE dbo.T_Msg_Chat_Map SET IsRead = 1 WHERE FromUserId = " + input.ToUserId + " or ToUserId = " + User.F_UserId + " ";
503
+                DbHelperSQL.ExecuteSql(sqlwhere1);
504
+                //后添加新的信息
505
+                bllmap.Add(modelmap);
506
+                return Success("发送成功");
507
+            }
508
+            return Error("发送失败");
509
+        }
510
+
511
+        /// <summary>
512
+        /// 即时通讯 - 获取最新通讯(单方查看)
513
+        /// </summary>
514
+        /// <param name="isread">0未读1已读2全部</param>
515
+        /// <returns></returns>
516
+        public ActionResult GetChatLists(int top, int fromid, int isread = 0)
517
+        {
518
+            DataTable dt = null;
519
+            int recordCount = 0;
520
+            //接收坐席Id
521
+
522
+            string sql = " ISNULL(a.IsDelete,0) = 0 AND ISNULL(c.F_DeleteFlag,0) = 0 "; // AND ISNULL(b.IsRead,0) = 0
523
+            if (top <= 0)
524
+            {
525
+                top = 50;
526
+            }
527
+            if (fromid > 0)
528
+            {
529
+                //sql += " and ISNULL(b.FromUserId,0) = " + fromid + " ";
530
+                sql += " and (b.FromUserId = " + fromid + " or b.ToUserId = " + fromid + ") ";
531
+                sql += " and (b.ToUserId = " + User.F_UserId + " or b.FromUserId = " + User.F_UserId + ") ";
532
+            }
533
+            else
534
+            {
535
+                sql += " and b.ToUserId = " + User.F_UserId + " ";
536
+            }
537
+            if (isread != 2)
538
+            {
539
+                sql += " and ISNULL(b.IsRead,0) = " + isread + " ";
540
+            }
541
+            //查询(聊天记录)
542
+            string sql1 = "SELECT TOP " + top + " a.Id,b.FromUserId,b.ToUserId,a.Content,a.IsToAll,a.CreateDate,b.IsRead,c.F_UserName,c.F_RoleId,c.F_SexFlag,c.F_See FROM dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = a.FromUserId WHERE " + sql + " ORDER BY a.CreateDate ASC";
543
+            dt = DbHelperSQL.Query(sql1).Tables[0];
544
+            recordCount = dt.Rows.Count;
545
+
546
+            var obj = new
547
+            {
548
+                rows = dt,
549
+                total = recordCount
550
+            };
551
+            return Content(obj.ToJson());
552
+        }
553
+
554
+        /// <summary>
555
+        /// 即时通讯 - 获取最新通讯数量(单方查看)
556
+        /// </summary>
557
+        /// <param name="isread">0未读1已读2全部</param>
558
+        /// <returns></returns>
559
+        public ActionResult GetChatCount(int top)
560
+        {
561
+            DataTable dt = null;
562
+            int recordCount = 0;
563
+            //接收坐席Id
564
+
565
+            if (top <= 0)
566
+            {
567
+                top = 50;
568
+            }
569
+            string sql = " ISNULL(a.IsDelete,0) = 0 AND ISNULL(c.F_DeleteFlag,0) = 0 "; // AND ISNULL(b.IsRead,0) = 0
570
+            sql += " and b.ToUserId = " + User.F_UserId + " and ISNULL(b.IsRead,0) = 0 ";
571
+            //查询(聊天记录)
572
+            string sql1 = "SELECT TOP " + top + " a.Id FROM dbo.T_Msg_Chat a WITH (NOLOCK) RIGHT JOIN dbo.T_Msg_Chat_Map b WITH (NOLOCK) ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c WITH (NOLOCK) ON c.F_UserId = a.FromUserId WHERE " + sql + " ORDER BY a.CreateDate ASC";
573
+            dt = DbHelperSQL.Query(sql1).Tables[0];
574
+            recordCount = dt.Rows.Count;
575
+
576
+            var obj = new
577
+            {
578
+                rows = "",
579
+                total = recordCount
580
+            };
581
+            return Content(obj.ToJson());
582
+        }
583
+
584
+        /// <summary>
585
+        /// 即时通讯 - 获取最新通讯信息(单方查看)
586
+        /// </summary>
587
+        /// <param name="id"></param>
588
+        /// <param name="User.F_UserId"></param>
589
+        /// <returns></returns>
590
+        public ActionResult GetChatInfoById(int id)
591
+        {
592
+            if (id <= 0)
593
+            {
594
+                return Error("参数出错");
595
+            }
596
+            DataTable dt = null;
597
+            string cid = string.Empty, content = string.Empty, createDate = string.Empty, userName = string.Empty, isread = string.Empty, roleId = string.Empty;
598
+            //接收坐席Id
599
+
600
+            string sql = " ISNULL(a.IsDelete,0) = 0 AND ISNULL(c.F_DeleteFlag,0) = 0 "; // AND ISNULL(b.IsRead,0) = 0
601
+            if (User.F_UserId > 0)
602
+            {
603
+                sql += " and b.ToUserId = " + User.F_UserId + " ";
604
+            }
605
+            if (id > 0)
606
+            {
607
+                sql += " and a.Id = " + id + " ";
608
+            }
609
+            //查询(聊天记录)
610
+            string sql1 = "SELECT a.Id,a.FromUserId,a.Content,a.IsToAll,a.CreateDate,b.IsRead,c.F_UserName,c.F_RoleId FROM dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = a.FromUserId WHERE " + sql + " ORDER BY a.CreateDate ASC";
611
+            dt = DbHelperSQL.Query(sql1).Tables[0];
612
+            if (dt.Rows.Count > 0)
613
+            {
614
+                cid = dt.Rows[0]["Id"].ToString();
615
+                content = dt.Rows[0]["Content"].ToString();
616
+                createDate = dt.Rows[0]["CreateDate"].ToString();
617
+                userName = dt.Rows[0]["F_UserName"].ToString();
618
+                roleId = dt.Rows[0]["F_RoleId"].ToString();
619
+                isread = dt.Rows[0]["IsRead"].ToString();
620
+            }
621
+
622
+            //修改(设置已读)
623
+            string sqlwhere = " ISNULL(IsRead,0) = 0 ";
624
+            if (User.F_UserId > 0)
625
+            {
626
+                sqlwhere += " and ToUserId = " + User.F_UserId + " ";
627
+            }
628
+            if (id > 0)
629
+            {
630
+                sqlwhere += " and ChatId = " + id + " ";
631
+            }
632
+            string sqlwhere1 = "UPDATE dbo.T_Msg_Chat_Map SET IsRead = 1 WHERE " + sqlwhere + " ";
633
+            DbHelperSQL.ExecuteSql(sqlwhere1);
634
+
635
+            var obj = new
636
+            {
637
+                id = cid,
638
+                username = userName,
639
+                content = content,
640
+                createdate = createDate,
641
+                roleId = roleId,
642
+                isread = isread
643
+            };
644
+            return Content(obj.ToJson());
645
+        }
646
+
647
+        /// <summary>
648
+        /// 即时通讯 - 关闭通讯信息(单方查看)
649
+        /// </summary>
650
+        /// <param name="id"></param>
651
+        /// <param name="User.F_UserId"></param>
652
+        /// <returns></returns>
653
+        public ActionResult CloseChat(int id)
654
+        {
655
+            //接收坐席Id
656
+
657
+            int recordCount = 0;
658
+            //修改(设置已读)
659
+            string sqlwhere = " ISNULL(IsRead,0) = 0 ";
660
+            if (User.F_UserId > 0)
661
+            {
662
+                sqlwhere += " and ToUserId = " + User.F_UserId + " ";
663
+            }
664
+            if (id > 0)
665
+            {
666
+                sqlwhere += " and ChatId = " + id + " ";
667
+            }
668
+            string sqlwhere1 = "UPDATE dbo.T_Msg_Chat_Map SET IsRead = 1 WHERE " + sqlwhere + " ";
669
+            int n = DbHelperSQL.ExecuteSql(sqlwhere1);
670
+            if (n > 0)
671
+            {
672
+                recordCount = n;
673
+            }
674
+
675
+            var obj = new
676
+            {
677
+                rows = "",
678
+                total = recordCount
679
+            };
680
+            return Content(obj.ToJson());
681
+        }
682
+
683
+        /// <summary>
684
+        /// DataRow转成DataTable
685
+        /// </summary>
686
+        /// <param name="rows"></param>
687
+        /// <returns></returns>
688
+        public DataTable ToDataTable1(DataRow[] rows)
689
+        {
690
+            if (rows == null || rows.Length == 0) return null;
691
+            DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
692
+            foreach (DataRow row in rows)
693
+            {
694
+                tmp.ImportRow(row); // 将DataRow添加到DataTable中
695
+            }
696
+            return tmp;
697
+        }
698
+
699
+        #endregion
219 700
 
220 701
     }
221 702
 }

+ 38 - 0
RMYY_CallCenter_Api/Controllers/System/KnowledgeController.cs

@@ -250,6 +250,44 @@ namespace RMYY_CallCenter_Api.Controllers.System
250 250
             }  
251 251
             return treelist;
252 252
         }
253
+        /// <summary>
254
+        /// 导入知识库
255
+        /// </summary>
256
+        /// <returns></returns>
257
+        public ActionResult Excelmodelinfo()
258
+        {
259
+            NPOIHelper npoi = new NPOIHelper();
260
+            if (Request.Files.Count <= 0)
261
+                throw new Exception("请选中的Excel文件!");
262
+            var a = Request.Files[0];
263
+            var dtExcel = npoi.ExcelToTable(Request.Files[0], 0);
264
+            foreach (DataRow item in dtExcel.Rows)
265
+            {
266
+                Model.T_Sys_Knowledge kmodel = new Model.T_Sys_Knowledge();
267
+                if (item["工单类型"].ToString() != "")
268
+                {
269
+                    //根据工单类型名称获取工单类型编号
270
+                    var getmodelbyname = new Bll.T_Sys_GongDan().GetModelbyname(item["工单类型"].ToString());
271
+                    var tid = getmodelbyname.F_TypeId;
272
+                    //Model.T_Sys_GongDan tmodel = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(tid));
273
+                    kmodel.F_TypeId = Convert.ToInt32(tid);// int.Parse(item["工单类型"].ToString().Trim());
274
+                     kmodel.F_TypeName = item["工单类型"].ToString();//工单类型名称
275
+                }
276
+                else
277
+                    kmodel.F_TypeId = 0;
253 278
 
279
+                kmodel.F_Title = item["标题"].ToString();
280
+                kmodel.F_KeyWords = item["关键字"].ToString();
281
+                kmodel.F_Content = item["内容"].ToString();
282
+                kmodel.F_Description = item["描述"].ToString();
283
+                kmodel.F_Files ="";
284
+                kmodel.F_CreateCode = User.F_UserCode;
285
+                kmodel.F_CreateTime = DateTime.Now;
286
+                kmodel.F_CreateName = User.F_UserName;
287
+                kmodel.F_IsDel = 0;
288
+                int b = new Bll.T_Sys_Knowledge().Add(kmodel);
289
+            }
290
+            return Success("导入成功");
291
+        }
254 292
     }
255 293
 }

+ 17 - 11
RMYY_CallCenter_Api/Controllers/WorepairController.cs

@@ -1056,19 +1056,25 @@ namespace RMYY_CallCenter_Api.Controllers
1056 1056
             #endregion
1057 1057
             ///完成工单统计 日 周 月 起止日期
1058 1058
             #region 定义起止时间
1059
-            //默认天
1060
-            stime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
1061
-            etime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
1062
-            if (isweek == 1)//周
1059
+            if (string.IsNullOrEmpty(stime) || string.IsNullOrEmpty(stime))
1063 1060
             {
1064
-                stime = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).ToString("yyyy-MM-dd") + " 00:00:00";  //本周周一
1065
-                etime = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).AddDays(6).ToString("yyyy-MM-dd") + " 23:59:59";  //本周周日
1066
-            }
1067
-            else//月
1068
-            {
1069
-                stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).ToString("yyyy-MM-dd") + " 00:00:00";  //本月月初
1070
-                etime = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1).AddDays(6).ToString("yyyy-MM-dd") + " 23:59:59";  //本月月末
1061
+                if (isweek == 0)//默认天
1062
+                {
1063
+                    stime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
1064
+                    etime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
1065
+                }
1066
+                else if (isweek == 1)//周
1067
+                {
1068
+                    stime = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).ToString("yyyy-MM-dd") + " 00:00:00";  //本周周一
1069
+                    etime = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).AddDays(6).ToString("yyyy-MM-dd") + " 23:59:59";  //本周周日
1070
+                }
1071
+                else//月
1072
+                {
1073
+                    stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).ToString("yyyy-MM-dd") + " 00:00:00";  //本月月初
1074
+                    etime = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1).AddDays(6).ToString("yyyy-MM-dd") + " 23:59:59";  //本月月末
1075
+                }
1071 1076
             }
1077
+           
1072 1078
             #endregion
1073 1079
             #region T_Con_WorkOrder  工单类型:1健康咨询,2投诉建议,3外聘专家咨询,4家庭预约上门,5静脉置管维护
1074 1080
             ///健康咨询完成工单数量 1

+ 2 - 0
RMYY_CallCenter_Api/RMYY_CallCenter_Api.csproj

@@ -131,6 +131,7 @@
131 131
     <Compile Include="Controllers\CallTel\CallrecordsController.cs" />
132 132
     <Compile Include="Controllers\CarManage\T_Car_MessageController.cs" />
133 133
     <Compile Include="Controllers\CarManage\T_Car_WorkOrderController.cs" />
134
+    <Compile Include="Controllers\information\NoticeController.cs" />
134 135
     <Compile Include="Controllers\System\AddressBookController.cs" />
135 136
     <Compile Include="Controllers\System\KnowledgeController.cs" />
136 137
     <Compile Include="Controllers\System\SeatGroupController.cs" />
@@ -177,6 +178,7 @@
177 178
     <Compile Include="Models\Filter\FilterSysConfig.cs" />
178 179
     <Compile Include="Models\Filter\FilterUserAccount.cs" />
179 180
     <Compile Include="Models\FormsPrincipal.cs" />
181
+    <Compile Include="Models\Input\ChatInput.cs" />
180 182
     <Compile Include="Models\Input\Con_WorkOrderInput.cs" />
181 183
     <Compile Include="Models\Input\DictionaryInput.cs" />
182 184
     <Compile Include="Models\Input\T_WowoRepair_Baseinput.cs" />