Selaa lähdekoodia

交办工单、催办、督办。发送短信;用户表的F_Telephone字段 可以发送多个

liyuanyuan 4 vuotta sitten
vanhempi
commit
b939c40f94

+ 57 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/SMSController.cs

@@ -44,6 +44,63 @@ namespace CallCenterApi.Interface.Controllers
44 44
             return strbul.ToString().ToLower (); ;
45 45
         }
46 46
 
47
+/// <summary>
48
+/// 发送短信用的是这个20210906
49
+/// </summary>
50
+/// <param name="userId"></param>
51
+/// <param name="msg"></param>
52
+/// <param name="count"></param>
53
+/// <param name="mobiles"></param>
54
+/// <param name="templetid"></param>
55
+/// <param name="templet"></param>
56
+/// <param name="workorderid"></param>
57
+/// <returns></returns>
58
+        public static bool AddSmS(int userId, string msg, string content, string mobiles, string templetid
59
+           ,  string workorderid = "")
60
+        {
61
+            bool res = false;
62
+ 
63
+            string sign = Md5(cpcode + msg + mobiles + "" + templetid + key);
64
+            var dic = new SortedDictionary<string, string>
65
+            {
66
+                {"cpcode", cpcode},
67
+                {"msg", msg},
68
+                {"mobiles", mobiles},
69
+                {"excode", ""},
70
+                {"templetid",templetid},
71
+                {"sign", sign},
72
+            };
73
+            //序列化参数
74
+            var jsonParam = JsonConvert.SerializeObject(dic);
75
+
76
+            var responseString = HttpMethods.HttpPostNew(Smsurl, jsonParam, "application/json;charset=UTF-8");
77
+            JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
78
+            string access_token = jo["resultcode"].ToString();
79
+            string taskid = jo["taskid"].ToString();
80
+            if (access_token == "0")
81
+            {
82
+                Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
83
+                dModel.CallerNum = mobiles.Trim();
84
+                dModel.Content = content.Trim();
85
+                dModel.RecvModemIMEI = taskid;
86
+                dModel.F_Name = workorderid;
87
+                dModel.State = 0;
88
+                dModel.F_UserID = userId;
89
+                dModel.RecvTime = DateTime.Now;
90
+                int b = new BLL.T_SMS_RecvSMS().Add(dModel);
91
+                if (b > 0)
92
+                {
93
+                    return true;
94
+                }
95
+                else
96
+                {
97
+                    return false;
98
+                }
99
+            }
100
+            return res;
101
+        }
102
+
103
+
47 104
         public static  string   SendSms(string  msg,string mobiles,string templetid,string excode = "")
48 105
         {
49 106
             bool n=false ;

+ 206 - 14
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/YCWorkOrderController.cs

@@ -238,8 +238,38 @@ namespace CallCenterApi.Interface.Controllers.workorder
238 238
                         modelT_Bus_WorkOrder1.F_MainDeptId = deptinfo.F_DeptId;//承办单位
239 239
                         workorderBLL.Update(modelT_Bus_WorkOrder1);
240 240
                         #endregion
241
+                        #region 发送短信提醒
242
+                        string mcontent = "你有新工单:" + modelT_Bus_WorkOrder.F_WorkOrderId + ",请及时查收处理。";
243
+                        string workorderid = modelT_Bus_WorkOrder.F_WorkOrderId;
241 244
 
242
-                        //  SMSController.AddSmS(userId, "交办了这条工单", "交办了这条工单", "110", "交办的模板id");
245
+                        DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '" + deptinfo.F_DeptId + "' ").Tables[0];
246
+                        List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
247
+
248
+                        foreach (string item in _lists)
249
+                        {
250
+                            if (!string.IsNullOrEmpty(item))
251
+                            {
252
+
253
+                                if (item.Contains(","))
254
+                                {
255
+                                    string[] strlist = item.Split(',');
256
+
257
+                                    foreach (string item1 in strlist)
258
+                                    {
259
+                                        bool n1 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item1, "269418", workorderid);
260
+                                    }
261
+
262
+                                }
263
+                                else
264
+                                {
265
+                                    bool n2 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item, "269418", workorderid);
266
+                                }
267
+                            }
268
+                        }
269
+
270
+
271
+
272
+                        #endregion
243 273
                         #region 操作记录表--交办
244 274
 
245 275
                         var msgss = userinfo + " 登记并交办了工单,承办单位:" + deptinfo.F_DeptName;
@@ -312,7 +342,38 @@ namespace CallCenterApi.Interface.Controllers.workorder
312 342
                             }
313 343
                             newids += modelT_Bus_WorkOrder1.F_WorkOrderId + ",";
314 344
 
315
-                            // SMSController.AddSmS(userId, "交办了这条工单", "交办了这条工单", "110", "交办的模板id");
345
+                            #region 发送短信提醒  一个部门下会有多个用户的电话
346
+                            string mcontent = "你有新工单:" + modelT_Bus_WorkOrder1.F_WorkOrderId + ",请及时查收处理。";
347
+                            string workorderid = modelT_Bus_WorkOrder1.F_WorkOrderId;
348
+
349
+                            DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '"+ deptinfo.F_DeptId+ "' ").Tables[0];
350
+                            List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
351
+
352
+                            foreach (string item in _lists)
353
+                            {
354
+                                if (!string.IsNullOrEmpty(item))
355
+                                {
356
+                                    if (item.Contains(","))
357
+                                    {
358
+                                        string[] strlist = item.Split(',');
359
+
360
+                                        foreach (string item1 in strlist)
361
+                                        {
362
+                                            bool n1 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item1, "269418", workorderid);
363
+                                        }
364
+
365
+                                    }
366
+                                    else
367
+                                    {
368
+                                        bool n2 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item, "269418", workorderid);
369
+                                    }
370
+                                }
371
+                            }
372
+
373
+                          
374
+                            #endregion
375
+
376
+
316 377
                         }
317 378
                         newids = newids.Trim(','); deptname = deptname.Trim(',');
318 379
                         var msgs = "";
@@ -2683,7 +2744,35 @@ namespace CallCenterApi.Interface.Controllers.workorder
2683 2744
                         workorderBLL.Update(modelT_Bus_WorkOrder1);
2684 2745
                         #endregion
2685 2746
 
2686
-                      //  SMSController.AddSmS(userId, "交办了这条工单", "交办了这条工单", "110", "交办的模板id");
2747
+                        #region 发送短信提醒
2748
+                        string mcontent = "你有新工单:" + modelT_Bus_WorkOrder.F_WorkOrderId + ",请及时查收处理。";
2749
+                        string workorderid = modelT_Bus_WorkOrder.F_WorkOrderId;
2750
+                        DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '" + deptinfo.F_DeptId + "' ").Tables[0];
2751
+                        List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
2752
+
2753
+                        foreach (string item in _lists)
2754
+                        {
2755
+                            if (!string.IsNullOrEmpty(item))
2756
+                            {
2757
+                                if (item.Contains(","))
2758
+                                {
2759
+                                    string[] strlist = item.Split(',');
2760
+
2761
+                                    foreach (string item1 in strlist)
2762
+                                    {
2763
+                                        bool n1 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item1, "269418", workorderid);
2764
+                                    }
2765
+
2766
+                                }
2767
+                                else
2768
+                                {
2769
+                                    bool n2 = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item, "269418", workorderid);
2770
+                                }
2771
+                            }
2772
+
2773
+                        }
2774
+                     
2775
+                        #endregion
2687 2776
                         #region 操作记录表--交办
2688 2777
 
2689 2778
                         var msgss = userinfo + " 登记并交办了工单,承办单位:" + deptinfo.F_DeptName;
@@ -2729,8 +2818,39 @@ namespace CallCenterApi.Interface.Controllers.workorder
2729 2818
                             modelT_Bus_AssignedInfo.F_IsStandard = 0;
2730 2819
                             assignBLL.Add(modelT_Bus_AssignedInfo);
2731 2820
 
2821
+                            #region 发送短信提醒
2822
+                            string mcontent = "你有新工单:" + modelT_Bus_WorkOrder1.F_WorkOrderId + ",请及时查收处理。";
2823
+                            string workorderid = modelT_Bus_WorkOrder1.F_WorkOrderId;
2824
+
2825
+                            DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '" + deptinfo.F_DeptId + "' ").Tables[0];
2826
+                            List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
2827
+
2828
+                            foreach (string item in _lists)
2829
+                            {
2830
+                                if (!string.IsNullOrEmpty(item))
2831
+                                {
2832
+                                    if (item.Contains(","))
2833
+                                    {
2834
+                                        string[] strlist = item.Split(',');
2835
+
2836
+                                        foreach (string item1 in strlist)
2837
+                                        {
2838
+                                            bool n = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item1, "269418", workorderid);
2839
+                                        }
2840
+
2841
+                                    }
2842
+                                    else
2843
+                                    {
2844
+                                        bool n = SMSController.AddSmS(userModel.F_UserId, workorderid, mcontent, item, "269418", workorderid);
2845
+                                    }
2846
+                                }
2847
+                            }
2848
+
2849
+                       
2732 2850
                             #endregion
2733
-                           
2851
+
2852
+                            #endregion
2853
+
2734 2854
                             if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_State == 1)
2735 2855
                             {
2736 2856
                                 #region 保存工单信息
@@ -2756,7 +2876,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
2756 2876
                             }
2757 2877
                             newids += modelT_Bus_WorkOrder1.F_WorkOrderId + ",";
2758 2878
 
2759
-                           // SMSController.AddSmS(userId, "交办了这条工单", "交办了这条工单", "110", "交办的模板id");
2879
+                           
2760 2880
                         }
2761 2881
                         newids = newids.Trim(','); deptname = deptname.Trim(',');
2762 2882
                         var msgs = "";
@@ -5342,7 +5462,40 @@ namespace CallCenterApi.Interface.Controllers.workorder
5342 5462
                         modelT_Bus_RemindRecord.F_CreateUser = userModel.F_UserCode;
5343 5463
                         modelT_Bus_RemindRecord.F_CreateTime = DateTime.Now;
5344 5464
                         new BLL.T_Bus_RemindRecord().Add(modelT_Bus_RemindRecord);
5345
-                      //  SMSController.AddSmS(userId, "催办了这条工单", "催办了这条工单", "110", "催办的模板id");
5465
+                   
5466
+                        #region 发送短信提醒
5467
+                        int depid = (int)modelT_Bus_AssignedInfo.F_MainDeptId;
5468
+                    
5469
+                        string mcontent = "你有督办工单:" + modelT_Bus_WorkOrder.F_WorkOrderId + ",请及时查收处理。";
5470
+                        string mworkorderid = modelT_Bus_WorkOrder.F_WorkOrderId;
5471
+                        DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '" + depid + "' ").Tables[0];
5472
+                        List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
5473
+
5474
+                        foreach (string item in _lists)
5475
+                        {
5476
+                            if (!string.IsNullOrEmpty(item))
5477
+                            {
5478
+                                if (item.Contains(","))
5479
+                                {
5480
+                                    string[] strlist = item.Split(',');
5481
+
5482
+                                    foreach (string item1 in strlist)
5483
+                                    {
5484
+                                        bool n = SMSController.AddSmS(userModel.F_UserId, mworkorderid, mcontent, item1, "269420", mworkorderid);
5485
+                                    }
5486
+
5487
+                                }
5488
+                                else
5489
+                                {
5490
+                                    bool n = SMSController.AddSmS(userModel.F_UserId, mworkorderid, mcontent, item, "269420", mworkorderid);
5491
+                                }
5492
+                            }
5493
+                        }
5494
+
5495
+                      //  bool n = SMSController.AddSmS(userModel.F_UserId, mworkorderid, mcontent, deptinfo.F_DeptPhone, "269420", mworkorderid);
5496
+
5497
+                        #endregion
5498
+
5346 5499
 
5347 5500
                     }
5348 5501
                     else if (type == 2)
@@ -5354,7 +5507,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
5354 5507
                             oldrecord.F_Content = overseeopinion;
5355 5508
                             oldrecord.F_CreateTime = DateTime.Now;
5356 5509
                             remindBLL.Update(oldrecord);
5357
-                         //   SMSController.AddSmS(userId, "督办了这条工单", "督办了这条工单", "110", "督办的模板id");
5510
+                     
5358 5511
 
5359 5512
                         }
5360 5513
                         else
@@ -5371,7 +5524,45 @@ namespace CallCenterApi.Interface.Controllers.workorder
5371 5524
                             modelT_Bus_RemindRecord.F_CreateUser = userModel.F_UserCode;
5372 5525
                             modelT_Bus_RemindRecord.F_CreateTime = DateTime.Now;
5373 5526
                             new BLL.T_Bus_RemindRecord().Add(modelT_Bus_RemindRecord);
5374
-                           // SMSController.AddSmS(userId, "催办了这条工单", "催办了这条工单", "110", "催办的模板id");
5527
+                           
5528
+
5529
+
5530
+                            #region 发送短信提醒
5531
+                            int depid = (int)modelT_Bus_AssignedInfo.F_MainDeptId;
5532
+                         
5533
+                            string mcontent = "你有催办工单:" + modelT_Bus_WorkOrder.F_WorkOrderId + ",请及时查收处理。";
5534
+                            string mworkorderid = modelT_Bus_WorkOrder.F_WorkOrderId;
5535
+                            DataTable userlist = new BLL.T_Sys_UserAccount().GetList("  F_DeptId= '" + depid + "' ").Tables[0];
5536
+                            List<string> _lists = userlist.AsEnumerable().Select(t => t.Field<string>("F_Telephone")).ToList();
5537
+
5538
+                            
5539
+                            foreach (string item in _lists)
5540
+                            {
5541
+                                if (!string.IsNullOrEmpty(item))
5542
+                                {
5543
+                                    if (item.Contains(","))
5544
+                                    {
5545
+                                        string[] strlist = item.Split(',');
5546
+
5547
+                                        foreach (string item1 in strlist)
5548
+                                        {
5549
+                                            bool n = SMSController.AddSmS(userModel.F_UserId, mworkorderid, mcontent, item1, "270565", mworkorderid);
5550
+                                        }
5551
+
5552
+                                    }
5553
+                                    else
5554
+                                    {
5555
+                                        bool n = SMSController.AddSmS(userModel.F_UserId, mworkorderid, mcontent, item, "270565", workorderid);
5556
+                                    }
5557
+                                }
5558
+                            }
5559
+
5560
+                            #endregion
5561
+
5562
+
5563
+
5564
+
5565
+
5375 5566
                         }
5376 5567
                     }
5377 5568
                     #endregion
@@ -5379,9 +5570,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
5379 5570
                     #region 插入操作记录
5380 5571
                     string typename = "督办";
5381 5572
                     if (type == 2) { typename = "催办"; }
5382
-                    //if (type == 1 && state == 0) { typename = "提交督办"; }
5383
-                    //if (type == 1 && state == 1) { typename = "督办"; }
5384
-                    //if (type == 1 && state == 2) { typename = "退回督办"; }
5573
+                   
5385 5574
                     Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
5386 5575
                     oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
5387 5576
                     oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
@@ -5445,8 +5634,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
5445 5634
                     return Error("办理时限不能小于当前时间");
5446 5635
                 }
5447 5636
 
5448
-                //if (modelT_Bus_WorkOrder.F_WorkState == 7)
5449
-                //if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit)
5637
+     
5450 5638
                 if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit)
5451 5639
                 {
5452 5640
                     using (TransactionScope trans = new TransactionScope())
@@ -5490,6 +5678,11 @@ namespace CallCenterApi.Interface.Controllers.workorder
5490 5678
                         workorderBLL.Update(modelT_Bus_WorkOrder);
5491 5679
                         #endregion
5492 5680
 
5681
+
5682
+                    
5683
+
5684
+
5685
+
5493 5686
                         #region 插入操作记录
5494 5687
                         Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
5495 5688
                         oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
@@ -5498,7 +5691,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
5498 5691
 
5499 5692
                         string deptname = "";
5500 5693
                         #region 20191021调整为多个承办单位时调整
5501
-                        //var deptinfo = new BLL.T_Sys_Department().GetModel(modelT_Bus_AssignedInfo.F_MainDeptId.Value);
5502 5694
                         var deptinfo = new BLL.T_Sys_Department().GetModel(maindeptid);
5503 5695
                         if (deptinfo != null) { deptname = deptinfo.F_DeptName; }
5504 5696
                         #endregion

+ 65 - 0
CallCenterCommon/CallCenter.Utility/Http/HttpMethods.cs

@@ -13,6 +13,71 @@ namespace CallCenter.Utility
13 13
     public class HttpMethods
14 14
     {
15 15
         #region POST
16
+
17
+        /// <summary>
18
+        /// HTTP POST方式请求数据
19
+        /// </summary>
20
+        /// <param name="url">URL.</param>
21
+        /// <param name="param">POST的数据</param>
22
+        /// <returns></returns>
23
+        public static string HttpPostNew(string url, string param = null, string contentType = "application/x-www-form-urlencoded")
24
+        {
25
+            HttpWebRequest request;
26
+
27
+            //如果是发送HTTPS请求  
28
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
29
+            {
30
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
31
+                request = WebRequest.Create(url) as HttpWebRequest;
32
+                request.ProtocolVersion = HttpVersion.Version10;
33
+            }
34
+            else
35
+            {
36
+                request = WebRequest.Create(url) as HttpWebRequest;
37
+            }
38
+
39
+            request.Method = "POST";
40
+            request.ContentType = contentType;
41
+            request.Accept = "*/*";
42
+            request.Timeout = 15000;
43
+            request.AllowAutoRedirect = false;
44
+
45
+
46
+
47
+            StreamWriter requestStream = null;
48
+            WebResponse response = null;
49
+            string responseStr = null;
50
+
51
+            try
52
+            {
53
+                requestStream = new StreamWriter(request.GetRequestStream());
54
+                requestStream.Write(param);
55
+                requestStream.Close();
56
+
57
+                response = request.GetResponse();
58
+                if (response != null)
59
+                {
60
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
61
+                    responseStr = reader.ReadToEnd();
62
+                    reader.Close();
63
+                }
64
+            }
65
+            catch (Exception ex)
66
+            {
67
+                LogFactory.GetLogger("HttpPost").Error(url + "\r\n" + param + "\r\n" + ex.ToString());
68
+            }
69
+            finally
70
+            {
71
+                request = null;
72
+                requestStream = null;
73
+                response = null;
74
+            }
75
+
76
+            return responseStr;
77
+        }
78
+
79
+
80
+
16 81
         /// <summary>
17 82
         /// HTTP POST方式请求数据
18 83
         /// </summary>

+ 0 - 0
伊川这是最新的.txt