zhaozhiqiang %!s(int64=5) %!d(string=hace) años
padre
commit
62a830d027

+ 2 - 1
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.IRepositories/ImsgonlineRepository.cs

@@ -2,11 +2,12 @@
2 2
 using System.Collections.Generic;
3 3
 using System.Text;
4 4
 using MadRunFabric.Common;
5
-using MadRunFabric.Model.OnlineServiceApi;
5
+using MadRunFabric.Model.TestUserTypeApi;
6 6
 
7 7
 namespace TestUserTypeApi.IRepositories
8 8
 {
9 9
    public  interface ImsgonlineRepository : IRepository<T_Msg_Chat, string>
10 10
     {
11
+        IEnumerable<object> GetList(int pageindex, int pagesize, int isread, out int recordCount);
11 12
     }
12 13
 }

+ 11 - 2
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Model/Dto/T_Msg_Chat.cs

@@ -22,16 +22,25 @@ namespace TestUserTypeApi.Model.Dto
22 22
         /// <summary>
23 23
         /// 消息来源
24 24
         /// </summary>
25
-        public int fromuserid { get; set; }
25
+        public string  fromuserid { get; set; }
26 26
 
27 27
         /// <summary>
28 28
         /// 消息发送给谁
29 29
         /// </summary>
30
-        public int touserid { get; set; }
30
+        public string  touserid { get; set; }
31 31
 
32 32
         /// <summary>
33 33
         /// 是否删除
34 34
         /// </summary>
35 35
         public int isdelete { get; set; }
36
+        /// <summary>
37
+        /// 区分微信接口和网站接口
38
+        /// </summary>
39
+
40
+        public int isonetype { get; set; }
41
+        /// <summary>
42
+        /// 是否查看过 0未查看 1查看过
43
+        /// </summary>
44
+        public int isread { get; set; }
36 45
     }
37 46
 }

+ 1 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Model/Dto/T_Msg_Chat_Map.cs

@@ -33,5 +33,6 @@ namespace TestUserTypeApi.Model.Dto
33 33
         /// 是否删除
34 34
         /// </summary>
35 35
         public int isdelete { get; set; }
36
+
36 37
     }
37 38
 }

+ 6 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Model/Dto/TestPagerDto.cs

@@ -23,6 +23,12 @@ namespace TestUserTypeApi.Model.Dto
23 23
         /// 题目选项
24 24
         /// </summary>
25 25
         public string testoptions { get; set; }
26
+
27
+        /// <summary>
28
+        /// 题目类型
29
+        /// </summary>
30
+        public string tesquestionType { get; set; }
31
+
26 32
         /// <summary>
27 33
         /// 参考答案
28 34
         /// </summary>

+ 36 - 5
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Repositories/msgonlineRepository.cs

@@ -3,22 +3,53 @@ using System.Collections.Generic;
3 3
 using System.Text;
4 4
 using MadRunFabric.Common;
5 5
 using MadRunFabric.Common.Options;
6
-using MadRunFabric.Model.OnlineServiceApi;
6
+using MadRunFabric.Model.TestUserTypeApi;
7 7
 using Microsoft.Extensions.Logging;
8 8
 using Microsoft.Extensions.Options;
9 9
 using MongoDB.Driver;
10
-
10
+using TestUserTypeApi.IRepositories;
11
+using System.Linq;
11 12
 
12 13
 namespace TestUserTypeApi.Repositories
13 14
 {
14
-   public  class msgonlineRepository : BaseRepository<T_Msg_Chat, string>, IRepositories.ImsgonlineRepository
15
+   public  class msgonlineRepository : BaseRepository<T_Msg_Chat, string>, ImsgonlineRepository
15 16
     {
16 17
         protected readonly ILogger<BaseRepository<T_Msg_Chat, string>> _logger;
17
-        protected readonly IMongoCollection<T_Msg_Chat> _collection_MassageInfo;
18
+        protected readonly IMongoCollection<T_Msg_Chat> _collection_T_Msg_Chat;
19
+        protected readonly IMongoCollection<T_Msg_Chat_Map> _collection_T_Msg_Chat_Map;
18 20
         public msgonlineRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<T_Msg_Chat, string>> logger) : base(settings, logger)
19 21
         {
20
-            _collection_MassageInfo = _context.GetCollection<T_Msg_Chat>();
22
+            _collection_T_Msg_Chat_Map = _context.GetCollection<T_Msg_Chat_Map>();
23
+            _collection_T_Msg_Chat = _context.GetCollection<T_Msg_Chat>();
21 24
             _logger = logger;
22 25
         }
26
+       
27
+        public IEnumerable<object> GetList(int pageindex, int pagesize, int isread, out int recordCount)
28
+        {
29
+            var query =
30
+                 from chat in _collection.AsQueryable()
31
+                 join chatmap in _collection_T_Msg_Chat_Map.AsQueryable() on chat.id equals chatmap.chatid into chatDefa
32
+                 where chat.isdelete == 0
33
+                 select new TestUserTypeApi.Model.Dto.T_Msg_Chat
34
+                 {
35
+                     id = chat.id,
36
+                     Msgcontent = chat.Msgcontent,
37
+                     fromuserid = chat.fromuserid,//消息来源
38
+                     touserid   = chat.touserid,//发送给谁
39
+                     isonetype  = chat.isonetype,//1是微信接口进入的
40
+                     isdelete   = chat.isdelete,
41
+                     createtime  = chat.createtime,
42
+                     isread      = chatDefa != null && chatDefa.Count() > 0 ? chatDefa.First().isread : 0
43
+                 };
44
+            #region 查询条件
45
+            if (!string.IsNullOrEmpty(isread.ToString()))
46
+                query = query.Where(it => it.isread == isread);
47
+            query = query.Where(it => it.isread == 0);
48
+            #endregion
49
+            //var list = query.OrderByDescending(it => it.createtime);
50
+            recordCount = query.Count();
51
+            var list = query.Skip((pageindex - 1) * pagesize).Take(pagesize);
52
+            return list;
53
+        }
23 54
     }
24 55
 }

+ 1 - 1
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Repositories/msgonlinemapRepository.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
3 3
 using System.Text;
4 4
 using MadRunFabric.Common;
5 5
 using MadRunFabric.Common.Options;
6
-using MadRunFabric.Model.OnlineServiceApi;
6
+using MadRunFabric.Model.TestUserTypeApi;
7 7
 using Microsoft.Extensions.Logging;
8 8
 using Microsoft.Extensions.Options;
9 9
 using MongoDB.Driver;

+ 150 - 59
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi/Controllers/TestUserTypeController.cs

@@ -21,7 +21,8 @@ using System.ServiceModel;
21 21
 using System.Collections;
22 22
 using System.Net.Http;
23 23
 using System.Reflection;
24
-using MadRunFabric.Model.OnlineServiceApi;
24
+using com.pkuhit.iihip.sdk;
25
+using com.pkuhit.iihip.sdk.message;
25 26
 
26 27
 // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
27 28
 
@@ -101,7 +102,7 @@ namespace TestUserTypeApi.Controllers
101 102
             //    list = await _tsertuserRepository.Get(s => s.testtype == testtypeid);
102 103
             //}
103 104
             //排序字段
104
-            var sort = Builders<TestPager>.Sort.Descending("createdatatime");
105
+            var sort = Builders<TestPager>.Sort.Ascending("testcode");
105 106
             //根据条件查询集合
106 107
             var listApp = new List<FilterDefinition<TestPager>>();
107 108
             listApp.Add(Builders<TestPager>.Filter.Eq("isdelete", 0));
@@ -138,7 +139,14 @@ namespace TestUserTypeApi.Controllers
138 139
                 model.testcode = item.testcode;
139 140
                 model.testoptions = optioncenter;
140 141
                 model.testtype = item.testtype;
141
-                model.testtypename = ttps.Typename;
142
+                if (ttps != null)
143
+                {
144
+                    model.testtypename = ttps.Typename;
145
+                }
146
+                else
147
+                {
148
+                    model.testtypename = "";
149
+                }
142 150
                 //model.tesquestid = model.tesquestid;//选项编号
143 151
                 model.isdelete = item.isdelete;
144 152
                 listmodel.Add(model);
@@ -159,7 +167,7 @@ namespace TestUserTypeApi.Controllers
159 167
         {
160 168
 
161 169
             //排序字段
162
-            var sort = Builders<TestPager>.Sort.Descending("createdatatime");
170
+            var sort = Builders<TestPager>.Sort.Ascending("testcode");
163 171
             //根据条件查询集合
164 172
             var listApp = new List<FilterDefinition<TestPager>>();
165 173
             listApp.Add(Builders<TestPager>.Filter.Eq("isdelete", 0));
@@ -185,7 +193,11 @@ namespace TestUserTypeApi.Controllers
185 193
                 model.testcode = item.testcode;
186 194
                 model.optionlists = tqn;//选项集合信息
187 195
                 model.testtype = item.testtype;
188
-                model.testtypename = ttps.Typename;
196
+                if (ttps != null)
197
+                {
198
+                    model.testtypename = ttps.Typename;
199
+                }
200
+                
189 201
                 //model.tesquestid = model.tesquestid;//选项编号
190 202
                 model.isdelete = item.isdelete;
191 203
                 listmodel.Add(model);
@@ -462,7 +474,11 @@ namespace TestUserTypeApi.Controllers
462 474
                 model.id = item.id;
463 475
                 model.telcode = item.telcode;//电话号
464 476
                 model.testid = item.testid;//试卷表id
465
-                model.testname = tpser.testtitle;//试题名称
477
+                if (tpser != null)
478
+                {
479
+                    model.testname = tpser.testtitle;//试题名称
480
+                }
481
+                
466 482
                 model.testoptions = item.testoptions;//选项
467 483
                 model.grade = item.grade;//得分
468 484
                 model.testtype = item.testtype;//试卷类型
@@ -582,7 +598,11 @@ namespace TestUserTypeApi.Controllers
582 598
                 model.testcount = item.testcount;//答题数量
583 599
                 model.allgrade = item.allgrade;//总分数
584 600
                 model.testtype = item.testtype;//试卷类型
585
-                model.testtypename = ttps.Typename;//试卷类型名称
601
+                if (ttps != null)
602
+                {
603
+                    model.testtypename = ttps.Typename;//试卷类型名称
604
+                }
605
+               
586 606
                                                    // model.testid = item.testid;//问题id
587 607
 
588 608
                 listmodel.Add(model);
@@ -713,7 +733,18 @@ namespace TestUserTypeApi.Controllers
713 733
         {
714 734
             var model = await _ItestquestionRepository.Get(p => p.testid == testid);
715 735
             return Success("成功", model);
716
-        } 
736
+        }
737
+
738
+        /// <summary>
739
+        /// 根据id获取详情信息
740
+        /// </summary>
741
+        /// <returns></returns>
742
+        [HttpGet("gettestquestinfobyid")]
743
+        public async Task<IActionResult> Gettestquestinfobyid(string id)
744
+        {
745
+            var model = await _ItestquestionRepository.Get(p => p.id == id);
746
+            return Success("成功", model);
747
+        }
717 748
         #endregion
718 749
         #region 短信模块
719 750
         /// <summary>
@@ -906,50 +937,56 @@ namespace TestUserTypeApi.Controllers
906 937
             var str = tps.sendcenter;// "您好 !感谢您对我们医院的新人月支持请对我们的服质量给予评价1 满意;2不满意;3 表扬,回复数字即可。谢谢!顺祝生活愉快【郑州市第一人民医院】";//您好 !感谢您对我们医院的新人月支持请对我们的服质量给予评价1 满意;2不满意;3 表扬,回复数字即可。谢谢!顺祝生活愉快  
907 938
             //发送给哪个手机号
908 939
             var Mobile = tps.telcode;
909
-            //定时发送还是立即发送
910
-            var SendTime = tps.SendTime;
911
-            string result1 = HttpUtility.UrlEncode(str, Encoding.GetEncoding("GB2312"));
912
-            var ifsend = false;
913
-            var aaa = " ";
914
-            string url = "https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=" + Mobile + "&Content=" + result1 + "&Cell=&SendTime=";
915
-
916
-            //?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=13935966971&Content="+ result1 + "&Cell=&SendTime=
917
-
918
-            //Encoding encoding = Encoding.GetEncoding("GB2312");
919
-            //Encoding encoding = Encoding.GetEncoding("UTF-8");
920
-            Encoding encoding = Encoding.GetEncoding("GBK");
921
-            IDictionary<string, string> parameters = new Dictionary<string, string>();
922
-            parameters.Add("CorpID", "DYRMYY011170");
923
-            parameters.Add("Pwd", "xxk@80188");
924
-            parameters.Add("Mobile", Mobile);
925
-            parameters.Add("Content", result1);
926
-            parameters.Add("Cell", "");
927
-            parameters.Add("SendTime", SendTime.ToString());
928
-            HttpWebResponse response = PostHttps(url, parameters, encoding);
929
-            //打印返回值
930
-            Stream stream = response.GetResponseStream();   //获取响应的字符串流
931
-            StreamReader sr = new StreamReader(stream); //创建一个stream读取流
932
-
933
-            //返回的信息
934
-            string html = sr.ReadToEnd();
935
-
940
+            ////定时发送还是立即发送
941
+            //var SendTime = tps.SendTime;
942
+            //string result1 = HttpUtility.UrlEncode(str, Encoding.GetEncoding("GB2312"));
943
+            //var ifsend = false;
944
+            //var aaa = " ";
945
+            //string url = "https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=" + Mobile + "&Content=" + result1 + "&Cell=&SendTime=";
946
+
947
+            ////?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=13935966971&Content="+ result1 + "&Cell=&SendTime=
948
+
949
+            ////Encoding encoding = Encoding.GetEncoding("GB2312");
950
+            ////Encoding encoding = Encoding.GetEncoding("UTF-8");
951
+            //Encoding encoding = Encoding.GetEncoding("GBK");
952
+            //IDictionary<string, string> parameters = new Dictionary<string, string>();
953
+            //parameters.Add("CorpID", "DYRMYY011170");
954
+            //parameters.Add("Pwd", "xxk@80188");
955
+            //parameters.Add("Mobile", Mobile);
956
+            //parameters.Add("Content", result1);
957
+            //parameters.Add("Cell", "");
958
+            //parameters.Add("SendTime", SendTime.ToString());
959
+            //HttpWebResponse response = PostHttps(url, parameters, encoding);
960
+            ////打印返回值
961
+            //Stream stream = response.GetResponseStream();   //获取响应的字符串流
962
+            //StreamReader sr = new StreamReader(stream); //创建一个stream读取流
963
+
964
+            ////返回的信息
965
+            //string html = sr.ReadToEnd();
966
+            string html ="2";
936 967
             if (Convert.ToInt32(html) > 0)
937 968
             {
938
-                MassageInfo tp = new MassageInfo();
939
-                tp.telcode = tps.telcode;
940
-                tp.sendcenter = tps.sendcenter;
941
-                tp.senddate = DateTime.Now;
942
-                tp.isdelete = 0;
943
-                tp.replycenter = "";
944
-                var a = _IMassageInfoRepository.AddRetID(tp);
945
-                if (a.Result != null || a.Result != "")
946
-                {
947
-                    return Success("成功", a.Result);
948
-                }
949
-                else
969
+                string[] arrStr = tps.sendcenter.Split(',');
970
+                foreach (var item in arrStr)
950 971
                 {
951
-                    return Error("失败");
972
+                    MassageInfo tp = new MassageInfo();
973
+
974
+                    tp.telcode = tps.telcode;
975
+                    tp.sendcenter = tps.sendcenter;
976
+                    tp.senddate = DateTime.Now;
977
+                    tp.isdelete = 0;
978
+                    tp.replycenter = "";
979
+                    var a = _IMassageInfoRepository.AddRetID(tp);
952 980
                 }
981
+                return Success("成功");
982
+                //if (a.Result != null || a.Result != "")
983
+                //{
984
+                //    return Success("成功", a.Result);
985
+                //}
986
+                //else
987
+                //{
988
+                //    return Error("失败");
989
+                //}
953 990
             }
954 991
             else if (Convert.ToInt32(html) == -2)
955 992
             {
@@ -1304,7 +1341,7 @@ namespace TestUserTypeApi.Controllers
1304 1341
             return Success("成功", obj);
1305 1342
         }
1306 1343
         /// <summary>
1307
-        /// 添加聊天记录表信息
1344
+        ///网站接口进入 添加聊天记录表信息
1308 1345
         /// </summary>
1309 1346
         /// <param name="tps"></param>
1310 1347
         /// <returns></returns>
@@ -1315,6 +1352,7 @@ namespace TestUserTypeApi.Controllers
1315 1352
             tp.Msgcontent = tps.Msgcontent;//信息内容
1316 1353
             tp.fromuserid = tps.fromuserid;//消息来源
1317 1354
             tp.touserid = tps.touserid;//发送给谁
1355
+            tp.isonetype = 0;//0是网站接口进入的
1318 1356
             tp.isdelete = 0;
1319 1357
             tp.createtime = DateTime.Now;
1320 1358
             var a = _ImsgonlineRepository.AddRetID(tp);
@@ -1344,6 +1382,49 @@ namespace TestUserTypeApi.Controllers
1344 1382
             }
1345 1383
 
1346 1384
         }
1385
+
1386
+        /// <summary>
1387
+        /// 微信接口进入 添加聊天记录表信息
1388
+        /// </summary>
1389
+        /// <param name="tps"></param>
1390
+        /// <returns></returns>
1391
+        [HttpGet("whataddonlineservice")]
1392
+        public async Task<IActionResult> whatAddOnlineservice(Model.Dto.T_Msg_Chat tps)
1393
+        {
1394
+            T_Msg_Chat tp = new T_Msg_Chat();
1395
+            tp.Msgcontent = tps.Msgcontent;//信息内容
1396
+            tp.fromuserid = tps.fromuserid;//消息来源
1397
+            tp.touserid = tps.touserid;//发送给谁
1398
+            tp.isonetype =1;//1是微信接口进入的
1399
+            tp.isdelete = 0;
1400
+            tp.createtime = DateTime.Now;
1401
+            var a = _ImsgonlineRepository.AddRetID(tp);
1402
+            if (a.Result != null || a.Result != "")
1403
+            {
1404
+                T_Msg_Chat_Map tmp = new T_Msg_Chat_Map();
1405
+                tmp.chatid = a.Result;//聊天记录的编号
1406
+                tmp.fromuserid = tps.fromuserid;
1407
+                tmp.touserid = tps.touserid;
1408
+                tmp.isdelete = 0;
1409
+                tmp.isread = 0;//是否查看过
1410
+                tmp.createtime = DateTime.Now;
1411
+                var b = _ImsgonlinemapRepository.AddRetID(tmp);
1412
+                if (b.Result != null || b.Result != "")
1413
+                {
1414
+                    return Success("成功", a.Result);
1415
+                }
1416
+                else
1417
+                {
1418
+                    return Error("添加关联记录失败");
1419
+                }
1420
+
1421
+            }
1422
+            else
1423
+            {
1424
+                return Error("添加聊天记录失败");
1425
+            }
1426
+
1427
+        }
1347 1428
         /// <summary>
1348 1429
         /// 根据编号获取聊天记录信息详情
1349 1430
         /// </summary>
@@ -1360,36 +1441,45 @@ namespace TestUserTypeApi.Controllers
1360 1441
             return Success("成功", model);
1361 1442
         }
1362 1443
         /// <summary>
1363
-        /// 获取未读消息列表
1444
+        /// 获取未读消息列表 已读消息列表  
1364 1445
         /// </summary>
1365 1446
         /// <param name="PageIndex"></param>
1366 1447
         /// <param name="PageSize"></param>
1367 1448
         /// <returns></returns>
1368
-        [HttpGet("getListonlineservice")]
1369
-        public async Task<IActionResult> GetListOnlineservicemap(int PageIndex, int PageSize)
1449
+        [HttpGet("getlistonlineservicemap")]
1450
+        public async Task<IActionResult> GetListOnlineservicemap(int PageIndex, int PageSize,int isread)
1370 1451
         {
1371
-
1452
+            var a = _ImsgonlineRepository.GetList(PageIndex, PageSize,0,out int count);
1372 1453
             //排序字段
1373
-            var sort = Builders<T_Msg_Chat_Map>.Sort.Descending("createdatatime");
1454
+            var sort = Builders<T_Msg_Chat_Map>.Sort.Ascending("createdatatime");
1374 1455
             //根据条件查询集合
1375 1456
             var listApp = new List<FilterDefinition<T_Msg_Chat_Map>>();
1376 1457
             listApp.Add(Builders<T_Msg_Chat_Map>.Filter.Eq("isdelete", 0));
1377
-
1458
+            if (isread != null)
1459
+            {
1460
+                listApp.Add(Builders<T_Msg_Chat_Map>.Filter.Eq("isread", isread));//未读 已读 
1461
+            }
1462
+            else
1463
+            {
1464
+                listApp.Add(Builders<T_Msg_Chat_Map>.Filter.Eq("isread", 0));//未读
1465
+            }
1378 1466
             var filter = Builders<T_Msg_Chat_Map>.Filter.And(listApp);
1379 1467
 
1380 1468
             var list = await _ImsgonlinemapRepository.GetByPage(filter, PageIndex, PageSize, sort);
1381 1469
             var redCount = await _ImsgonlinemapRepository.CountAsync(filter);   //获取总数
1382
-            var listmodel = new List<T_Msg_Chat_Map>();
1470
+            var listmodel = new List<T_Msg_Chat>();
1383 1471
 
1384 1472
 
1385 1473
             foreach (var item in list)
1386 1474
             {
1387
-                var model = new T_Msg_Chat_Map();
1475
+                var mapmode = await _ImsgonlineRepository.GetSingle(p => p.id == item.chatid);
1476
+                var model = new T_Msg_Chat();
1388 1477
                 model.id = item.id;
1389
-                model.chatid = item.chatid;//聊天记录编号
1390
-                model.isread = item.isread;//是否阅读
1478
+                model.Msgcontent = mapmode.Msgcontent;//聊天内容
1391 1479
                 model.fromuserid = item.fromuserid;//消息来源
1480
+
1392 1481
                 model.touserid = item.touserid;//发送给谁
1482
+
1393 1483
                 model.createtime = item.createtime;//创建时间
1394 1484
                 model.isdelete = item.isdelete;//是否禁用
1395 1485
                 listmodel.Add(model);
@@ -1402,5 +1492,6 @@ namespace TestUserTypeApi.Controllers
1402 1492
             return Success("成功", obj);
1403 1493
         }
1404 1494
         #endregion
1495
+
1405 1496
     }
1406 1497
 }