duhongyu il y a 5 ans
Parent
commit
9985a0f51e

Fichier diff supprimé car celui-ci est trop grand
+ 19 - 5
CallCenterApi/CallCenterApi.DAL/T_Bus_WorkOrder.cs


+ 88 - 3
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/SMSController.cs

@@ -2,19 +2,104 @@
2 2
 using CallCenterApi.Common;
3 3
 using CallCenterApi.DB;
4 4
 using CallCenterApi.Interface.Controllers.Base;
5
+using Newtonsoft.Json;
6
+using Newtonsoft.Json.Linq;
5 7
 using System;
6 8
 using System.Collections.Generic;
9
+using System.Collections.Specialized;
7 10
 using System.Data;
11
+using System.IO;
8 12
 using System.Linq;
13
+using System.Net;
14
+using System.Security.Cryptography;
15
+using System.Text;
9 16
 using System.Web;
10 17
 using System.Web.Mvc;
11 18
 
19
+
12 20
 namespace CallCenterApi.Interface.Controllers
13 21
 {
14 22
     public class SMSController : BaseController
15 23
     {
24
+      
25
+        private static string Smsurl = "http://rcsapi.wo.cn:8000/umcinterface/sendtempletmsg";
26
+        static string cpcode = "AAAOFV";
27
+        static string key = "2e12579ba6a6576f8980b628b8008247";
28
+        /// <summary>
29
+        /// MD5加密
30
+        /// </summary>
31
+        /// <param name="txt"></param>
32
+        /// <returns></returns>
33
+        public static string Md5(string txt)
34
+        {
35
+            byte[] sor = Encoding.UTF8.GetBytes(txt);
36
+            MD5 md5 = MD5.Create();
37
+            byte[] result = md5.ComputeHash(sor);
38
+            StringBuilder strbul = new StringBuilder(40);
39
+            for (int i = 0; i < result.Length; i++)
40
+            {
41
+                //加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
42
+                strbul.Append(result[i].ToString("x2"));
43
+            }
44
+            return strbul.ToString().ToLower (); ;
45
+        }
46
+        public static  bool  SendSms(string  msg,string mobiles,string templetid,string excode = "")
47
+        {
48
+            bool n=false ;
49
+            string sign = Md5(cpcode + msg + mobiles + excode + templetid + key);
50
+            var dic = new SortedDictionary<string, string>
51
+            {
52
+                {"cpcode", cpcode},
53
+                {"msg", msg},
54
+                {"mobiles", mobiles},
55
+                {"excode", excode},
56
+                {"templetid",templetid},
57
+                {"sign", sign},
58
+            };
59
+            //序列化参数
60
+            var jsonParam = JsonConvert.SerializeObject(dic);
61
+            //发送请求
62
+            var request = (HttpWebRequest)WebRequest.Create(Smsurl);
63
+            request.Method = "POST";
64
+            request.ContentType = "application/json;charset=UTF-8";
65
+            var byteData = Encoding.UTF8.GetBytes(jsonParam);
66
+            var length = byteData.Length;
67
+            request.ContentLength = length;
68
+            var writer = request.GetRequestStream();
69
+            writer.Write(byteData, 0, length);
70
+            writer.Close();
71
+            //接收数据
72
+            var response = (HttpWebResponse)request.GetResponse();
73
+            var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd();
74
+            JObject jo = (JObject)JsonConvert.DeserializeObject(responseString );
75
+            string access_token = jo["resultcode"].ToString();
76
+            if (access_token == "0")
77
+                n = true;
78
+            return n;
79
+        }
80
+        public static bool   AddSmS(int userId,string count ,string msg, string mobiles, string templetid)
81
+        {
82
+        
83
+            bool n = SendSms(msg, mobiles, templetid);
84
+            if (n ==false )
85
+                return n;
86
+            Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
87
+            dModel.CallerNum = mobiles.Trim();
88
+            dModel.Content = count.Trim();
89
+            dModel.State = 0;
90
+            dModel.F_UserID = userId;
91
+            dModel.RecvTime = DateTime.Now;
92
+            int b = new BLL.T_SMS_RecvSMS().Add(dModel);
93
+            if (b > 0)
94
+            {
95
+                return true;
96
+            }
97
+            else
98
+            {
99
+                return false;
100
+            }
101
+        }
16 102
         #region 接收短信
17
-
18 103
         [Authority]
19 104
         /// <summary>
20 105
         /// 获取接收短信列表
@@ -79,7 +164,6 @@ namespace CallCenterApi.Interface.Controllers
79 164
             return Content(obj.ToJson());
80 165
 
81 166
         }
82
-
83 167
         [Authority]
84 168
         /// <summary>
85 169
         /// 新增接收短信
@@ -88,7 +172,6 @@ namespace CallCenterApi.Interface.Controllers
88 172
         public ActionResult AddRecv(string tel, string cont)
89 173
         {
90 174
             Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
91
-
92 175
             dModel.CallerNum = tel.Trim();
93 176
             dModel.Content = cont.Trim();
94 177
             dModel.State = 0;
@@ -638,6 +721,8 @@ namespace CallCenterApi.Interface.Controllers
638 721
             }
639 722
             return msg;
640 723
         }
724
+
725
+      
641 726
         #endregion
642 727
     }
643 728
 }

+ 113 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -7405,6 +7405,119 @@ namespace CallCenterApi.Interface.Controllers.workorder
7405 7405
                 return Error("权限不足");
7406 7406
             }
7407 7407
         }
7408
+        /// <summary>
7409
+        /// 工单提醒
7410
+        /// </summary>
7411
+        /// <param name="workordercode"></param>
7412
+        /// <param name="deptid"></param>
7413
+        /// <param name="type"></param>
7414
+        /// <returns></returns>
7415
+        public ActionResult SendSms(string workordercode,int deptid,int type=0)
7416
+        {
7417
+            if (deptid <= 0)
7418
+                return Error("请选择部门");
7419
+            int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
7420
+            string msg = "";
7421
+            var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId=" + deptid + "and F_DeleteFlag=0");
7422
+            if (user !=null )
7423
+            {
7424
+                foreach (var it  in user)
7425
+                {
7426
+                    if (!string .IsNullOrEmpty (it .F_Mobile))
7427
+                    {
7428
+                        string count = "";
7429
+                        string templetid = "";
7430
+                        if (type ==0)
7431
+                        {
7432
+                            templetid = "26157";
7433
+                            count = "您有新的工单,请及时查收处理,工单编号" + workordercode;
7434
+                        }
7435
+                        else   if (type == 1)
7436
+                        {
7437
+                            templetid = "26155";
7438
+                            count = "您有工单正在被督办,请及时处理,工单编号" + workordercode;
7439
+                        }
7440
+                        else
7441
+                        {
7442
+                            templetid = "26154";
7443
+                            count = "您有紧急工单,请及时处理,工单编号" + workordercode;
7444
+                        }
7445
+
7446
+                        bool n = SMSController.AddSmS(userId, count, workordercode, it.F_Mobile, templetid);
7447
+                        if (n == false)
7448
+                            msg += it.F_UserName + "发送短信失败。";
7449
+                    }
7450
+                }
7451
+                if (msg != "")
7452
+                    return Error(msg);
7453
+                else
7454
+                    return Success("发送成功");
7455
+            }
7456
+            else
7457
+            {
7458
+                return Error("暂无人员");
7459
+            }
7460
+        }
7461
+        /// <summary>
7462
+        /// 办理结果通知
7463
+        /// </summary>
7464
+        /// <param name="msg1"></param>
7465
+        /// <param name="msg2"></param>
7466
+        /// <param name="msg3"></param>
7467
+        /// <param name="msg4"></param>
7468
+        /// <param name="mobile"></param>
7469
+        /// <returns></returns>
7470
+        public ActionResult SmsHand(string msg1 , string msg2 , string msg3,string msg4,string mobile)
7471
+        {
7472
+            
7473
+            int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
7474
+            string msg = msg1+","+ msg2 + "," + msg3 + "," + msg4;
7475
+
7476
+            string count = "尊敬的市民,您于" + msg1 + "反映的" + msg2 + "问题,工单号:" + msg3 + ",处理结果如下:" + msg4 + "。如有异议,请您再次致电12345,感谢您的支持。";
7477
+
7478
+
7479
+            bool n = SMSController.AddSmS(userId, count, msg, mobile, "26213");
7480
+            if (n)
7481
+                return Success("发送成功");
7482
+            else
7483
+                return Error ("发送失败");
7484
+        }
7485
+     
7486
+       public ActionResult SmsOverTime()
7487
+         {
7488
+          
7489
+           var workorder = new BLL.T_Bus_WorkOrder().GetModelList("F_IsDelete=0 and  F_WorkState in (2,4) and (F_IsSms!=1 or  F_IsSms is null)");
7490
+            if (workorder != null)
7491
+            {
7492
+                foreach (var it in workorder)
7493
+                {
7494
+                    System.TimeSpan time = DateTime.Parse(it.F_LimitTime.ToString()) - DateTime.Now ;
7495
+                    if (time.TotalHours <=6)
7496
+                    {
7497
+                       
7498
+                        var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId=" + it.F_MainDeptId  + "and F_DeleteFlag=0");
7499
+                        if (user != null)
7500
+                        {
7501
+                            foreach (var iv  in user)
7502
+                            {
7503
+                                if (!string.IsNullOrEmpty(iv.F_Mobile))
7504
+                                {
7505
+                                    string count = " 您有工单6小时后超期,请及时处理,工单号" + it.F_WorkOrderId;
7506
+                                    bool n = SMSController.AddSmS(0, count, it.F_WorkOrderId, iv.F_Mobile, "26147");
7507
+                                      if (n )
7508
+                                    {
7509
+                                        it.F_IsSms = 1;
7510
+                                        bool t = new BLL.T_Bus_WorkOrder().Update(it);
7511
+                                    }
7512
+                                }
7513
+                            }
7514
+                        }
7515
+                    }
7516
+                }
7517
+            }
7518
+            return Success("发送成功");
7519
+        }
7520
+       
7408 7521
 
7409 7522
         /// <summary>
7410 7523
         /// 收回工单

+ 9 - 0
CallCenterApi/CallCenterApi.Model/T_Bus_WorkOrder.cs

@@ -74,6 +74,7 @@ namespace CallCenterApi.Model
74 74
         private int?  _f_noticeid;
75 75
         private int? _f_isstandard;
76 76
         private string _f_standardids;
77
+        private int? _f_issms;
77 78
 
78 79
         /// <summary>
79 80
         /// 
@@ -589,6 +590,14 @@ namespace CallCenterApi.Model
589 590
             set { _f_isstandard = value; }
590 591
             get { return _f_isstandard; }
591 592
         }
593
+        /// <summary>
594
+        /// 是否发送短信0否1是
595
+        /// </summary>
596
+        public int? F_IsSms
597
+        {
598
+            set { _f_issms = value; }
599
+            get { return _f_issms; }
600
+        }
592 601
         #endregion Model
593 602
 
594 603
     }

+ 55 - 0
Push/Program.cs

@@ -0,0 +1,55 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Net;
6
+using System.Text;
7
+using System.Threading;
8
+using System.Threading.Tasks;
9
+using Newtonsoft.Json;
10
+
11
+namespace Push
12
+{
13
+    class Program
14
+    {
15
+        public class PushTime
16
+        {
17
+            public DateTime time;
18
+            public int morning;
19
+            public int Afternoon;
20
+        }
21
+        private PushTime time = new PushTime();
22
+        static void Main(string[] args)
23
+        {
24
+            Console.OutputEncoding = System.Text.Encoding.UTF8;
25
+            Environment.SetEnvironmentVariable("needDetails", "true");
26
+            Console.OutputEncoding = System.Text.Encoding.UTF8;
27
+            Environment.SetEnvironmentVariable("needDetails", "true");
28
+            System.Console.WriteLine("Hello Push!");
29
+            Thread t = new Thread(new ThreadStart(SetCensusURL));
30
+            t.Start();
31
+        }
32
+        private static void SetCensusURL()
33
+        {
34
+            int n = 0;
35
+            while (true)
36
+            {
37
+                Thread.Sleep(60 * 1000);
38
+                n += 1;
39
+                WebClient web = new WebClient();
40
+                web.Encoding = Encoding.UTF8;
41
+
42
+                try
43
+                {
44
+                    string seturl = "http://192.168.8.20:1001/WorkOrder/SmsOverTime";
45
+                    string Dataurl = web.DownloadString(seturl);//这一句话就能请求到数据了
46
+                    System.Console.WriteLine(Dataurl);
47
+                }
48
+                catch
49
+                {
50
+                }
51
+            }
52
+        }
53
+    }
54
+}
55
+

+ 8 - 0
PushMessage.cs

@@ -0,0 +1,8 @@
1
+using System;
2
+
3
+public class Class1
4
+{
5
+	public Class1()
6
+	{
7
+	}
8
+}