1550076451 месяцев назад: 11
Родитель
Сommit
2f46e7f0f4
15 измененных файлов с 375 добавлено и 302 удалено
  1. 3 2
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config
  2. 5 22
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/AddressBookController.cs
  3. 2 1
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/HomeController.cs
  4. 120 7
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/PushMessageController.cs
  5. 2 1
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs
  6. 2 2
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkorderAppController.cs
  7. 29 10
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs
  8. 7 0
      codegit/CallCenterCommon/CallCenter.QuartzService/CallCenter.QuartzService.csproj
  9. 27 0
      codegit/CallCenterCommon/CallCenter.QuartzService/FeiShuTask.cs
  10. 1 1
      codegit/CallCenterCommon/CallCenter.QuartzService/QuartzJob.cs
  11. 30 183
      codegit/CallCenterCommon/CallCenter.QuartzService/QuartzWorker.cs
  12. 1 21
      codegit/CallCenterCommon/CallCenter.QuartzService/SMSService.cs
  13. 46 46
      codegit/CallCenterCommon/CallCenter.QuartzService/SMSTask.cs
  14. 89 5
      codegit/CallCenterCommon/CallCenter.Utility/FeiShuiHelper.cs
  15. 11 1
      codegit/CallCenterCommon/CallCenter.Utility/RedisHelper.cs

+ 3 - 2
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

@@ -55,7 +55,8 @@
55 55
   <add key="AccessKeySecret" value="elRaejiGbEEp3SMy9uNNR2QkLd9ZjF" />
56 56
 
57 57
  
58
-  <add key="FeiShui_AppId" value="cli_a7242e417af7900c" />
58
+  <add key="FeiShui_AppId" value="cli_a74fe60168fc900c" />
59 59
   
60
-  <add key="FeiShui_AppSecret" value="QJIWfIUKJjVLZgEl5JqxoguOYlnCphV5" />
60
+  <add key="FeiShui_AppSecret" value="WNtLBLOmwkZtFm4AakJHihyo2fS0dwBe" />
61
+  <add key="FeiShuiUrgent" value="120" />
61 62
 </appSettings>

+ 5 - 22
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/AddressBookController.cs

@@ -320,31 +320,14 @@ namespace CallCenterApi.Interface.Controllers
320 320
                 string sql = "F_IsDelete=0 ";
321 321
                 if (!string.IsNullOrEmpty(keywords))
322 322
                 {
323
-                    var dept = new BLL.T_Sys_Department().GetModelList("F_DeptName like '%" + keywords + "%'").FirstOrDefault();
324
-
325
-                    if (dept != null)
326
-                    {
327
-                        if (dptid == 1)
328
-                            dptid = dept.F_DeptId;
329
-                        else
330
-                        {
331
-                            sql += $"  and ( F_Name like '%" + keywords.Trim() + "%'or F_Telephone like '%" + keywords.Trim() + "%'or F_Mobile like '%" + keywords.Trim() + "%'or F_ElseMobile like '%" + keywords.Trim() + "%'or F_Department like '%" + keywords.Trim() + "%' ) ";
332
-                        }
333 323
 
334
-                    }
335
-                    else
336
-                    {
337
-                        sql += $"  and ( F_Name like '%" + keywords.Trim() + "%'or F_Telephone like '%" + keywords.Trim() + "%'or F_Mobile like '%" + keywords.Trim() + "%'or F_ElseMobile like '%" + keywords.Trim() + "%'or F_Department like '%" + keywords.Trim() + "%' ) ";
338
-                    }
339
-                  
340
-                }
341
-                Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(dptid);
342
-                if (dptid > 0)
343
-                {
324
+                   sql += $"  and ( F_Name like '%" + keywords.Trim() + "%'or F_Telephone like '%"
325
+                     + keywords.Trim() + "%'or F_Mobile like '%" + keywords.Trim() + "%'or F_ElseMobile like '%"
326
+                     + keywords.Trim()
327
+                     + "%'or F_Department like '%" + keywords.Trim() + "%' " +
328
+                     " ) ";
344 329
 
345
-                    sql += " and F_DepartmentId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '" + deptModel.F_DeptCode + "%') ";
346 330
                 }
347
-                
348 331
                 var modelList = bll.GetAPPList(sql + " order by code asc").Tables[0];
349 332
                  if (pageindex* pagesize<modelList .Rows .Count )
350 333
                 {

+ 2 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/HomeController.cs

@@ -209,7 +209,8 @@ namespace CallCenterApi.Interface.Controllers
209 209
         }
210 210
         public ActionResult SendMessage(string mobile,string msg)
211 211
         {
212
-            var result= FeiShuiHelper.SendMsg(mobile, msg);
212
+          var result= FeiShuiHelper.SendMsg("1", "2", "3", "4", "5", "6", "7",
213
+                        mobile, msg);
213 214
             return Content(result);
214 215
         }
215 216
 

+ 120 - 7
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/PushMessageController.cs

@@ -30,6 +30,7 @@ namespace CallCenterApi.Interface.Controllers
30 30
         private static String APPID =Configs.GetValue("APPID");
31 31
         private static String APPKEY = Configs.GetValue("APPKEY");
32 32
         private static String MASTERSECRET = Configs.GetValue("MASTERSECRET");
33
+        private static String FeiShuiUrgent = Configs.GetValue("FeiShuiUrgent");
33 34
         private BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
34 35
         public class AppClientListDto
35 36
         {
@@ -46,6 +47,74 @@ namespace CallCenterApi.Interface.Controllers
46 47
             /// </summary>
47 48
             public string usercode { get; set; }
48 49
         }
50
+        public ActionResult PushFeiShuiMessagePush()
51
+        {
52
+            var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("  F_WoID in(select F_ID from  T_Bus_WorkOrder where F_IsDelete = 0 and F_State in(1, 3, 5)) and F_IsUsed = 0 and F_WoState in (1,3,5)");
53
+            string msg = "";
54
+            if (modellist != null)
55
+            {
56
+                foreach (var it in modellist)
57
+                {
58
+                    //  var modellitlast = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID = " + it.F_Id + "and F_IsUsed =0     and( F_Push=0  or  F_Push=1 )order by F_ID desc").FirstOrDefault();
59
+                    if (it == null)
60
+                        continue;
61
+                    System.TimeSpan time = DateTime.Now - DateTime.Parse(it.F_CreateTime.ToString());
62
+                    var usercount = new BLL.T_Sys_UserAccount().GetModel(it.F_NextUser);
63
+                    int Urgent = 120;
64
+                    if (!string .IsNullOrEmpty(FeiShuiUrgent))
65
+                    {
66
+                        try
67
+                        {
68
+                            Urgent = int.Parse(FeiShuiUrgent);
69
+                        }
70
+                        catch
71
+                        { }
72
+                    }
73
+                    
74
+
75
+                    string Title = "工单处理提醒";
76
+                    string count = "";
77
+                    if (it.F_WoState == 1)
78
+                    {
79
+                        count = "你有工单待指派";
80
+                    }
81
+                    else if (it.F_WoState == 3)
82
+                    {
83
+                        count = "你有工单待处理";
84
+                    }
85
+                    else if (it.F_WoState == 5)
86
+                    {
87
+                        count = "你有工单待指派";
88
+                    }
89
+                    if (usercount == null)
90
+                        continue;
91
+                    var model = new BLL.T_Bus_WorkOrder().GetModel((int )it.F_WoID);
92
+                    if (model!=null )
93
+                    {
94
+                        if (time.TotalMinutes >= Urgent)
95
+                        {
96
+                            msg = new PushMessageController().
97
+                     PushFeiShui(model, "工单处理提醒", count, usercount.F_UserCode, model.F_Id,1);
98
+                        }
99
+                        else
100
+                        {
101
+                            msg = new PushMessageController().
102
+                     PushFeiShui(model, "工单处理提醒", count, usercount.F_UserCode, model.F_Id);
103
+                        }
104
+                      
105
+                    }
106
+                   
107
+
108
+                }
109
+            }
110
+            var obj = new
111
+            {
112
+                state = "success",
113
+                message = "成功",
114
+                pushResult = msg
115
+            };
116
+            return Content(obj.ToJson()); ;
117
+        }
49 118
         public ActionResult PushMessagePush()
50 119
         {
51 120
             var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("  F_WoID in(select F_ID from  T_Bus_WorkOrder where F_IsDelete = 0 and F_State in(1, 3, 5)) and F_IsUsed = 0 and F_WoState in (1,3,5)");
@@ -77,7 +146,7 @@ namespace CallCenterApi.Interface.Controllers
77 146
                     }
78 147
                     if (usercount == null)
79 148
                         continue;
80
-                    msg = Push(Title, count, usercount.F_UserCode);
149
+                    msg = Push(Title, count, usercount.F_UserCode,it.F_WoID);
81 150
                   
82 151
                 }
83 152
             }
@@ -141,7 +210,7 @@ namespace CallCenterApi.Interface.Controllers
141 210
                             }
142 211
                             else
143 212
                             {
144
-                                 msg = Push(Title, count, usercount.F_UserCode);
213
+                                 msg = Push(Title, count, usercount.F_UserCode, it.F_WoID);
145 214
                               
146 215
                                 if (msg != "")
147 216
                                     AddLimLog(it, a + 1);
@@ -166,7 +235,7 @@ namespace CallCenterApi.Interface.Controllers
166 235
                                 continue;
167 236
                             else
168 237
                             {
169
-                                msg = Push(Title, count, usercount.F_UserCode);
238
+                                msg = Push(Title, count, usercount.F_UserCode, it.F_WoID);
170 239
 
171 240
                                 if (msg != "")
172 241
                                     AddLimLog(it, a + 1);
@@ -174,7 +243,7 @@ namespace CallCenterApi.Interface.Controllers
174 243
                         }
175 244
                         catch
176 245
                         {
177
-                            msg = Push(Title, count, usercount.F_UserCode);
246
+                            msg = Push(Title, count, usercount.F_UserCode, it.F_WoID);
178 247
 
179 248
                             if (msg != "")
180 249
                                 AddLimLog(it, 2);
@@ -319,18 +388,62 @@ namespace CallCenterApi.Interface.Controllers
319 388
             return Content(obj.ToJson()); ;
320 389
             //  return pushResult; ;
321 390
         }
322
-        public string  Push(string Title, string count,string usercode)
391
+        public string PushFeiShui(Model.T_Bus_WorkOrder model,string Title, string count, string usercode, long WoID = 0,int type=0)
323 392
         {
324 393
             //  int userId = CurrentUser.UserData.F_UserId;
325 394
             //   Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
326
-           
327 395
 
328
-          
396
+            string pushResult = "";
397
+
329 398
             var userModel = new BLL.T_Sys_UserAccount().GetModel(usercode);
330 399
             if (userModel != null)
331 400
             {
401
+                string products = "";
402
+                if (!string .IsNullOrEmpty(model.F_ProductDate))
403
+                {
404
+                    products = model.F_ProductDate;
405
+                }
406
+                if (!string.IsNullOrEmpty(model.F_BatchNumber))
407
+                {
408
+                    if (!string .IsNullOrEmpty(products))
409
+                       products +="-"+ model.F_BatchNumber;
410
+                    else
411
+                        products = model.F_BatchNumber;
412
+                }
413
+                if (!string.IsNullOrEmpty(model.F_BatchNumber))
414
+                {
415
+                    if (!string.IsNullOrEmpty(products))
416
+                        products += "-" + model.F_ProductName;
417
+                    else
418
+                        products = model.F_ProductName;
419
+                }
420
+                
332 421
                 usercode = userModel.F_UserCode;
422
+                if (!string.IsNullOrEmpty(userModel.F_Mobile))
423
+                {
424
+                    try
425
+                    {
426
+                        pushResult = FeiShuiHelper.SendMsg(Title, model.F_WorkOrderId, model.F_CusName,
427
+                       model.F_CusPhone, model.F_AddRess, products, model.F_QualityProblem,
428
+                       userModel.F_Mobile, count, WoID);
429
+                    }
430
+                    catch
431
+                    { }
432
+                   
433
+                }
333 434
             }
435
+           
436
+            return pushResult; ;
437
+        }
438
+        public string  Push(string Title, string count,string usercode,long WoID = 0)
439
+        {
440
+            //  int userId = CurrentUser.UserData.F_UserId;
441
+            //   Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
442
+           
443
+
444
+          
445
+            var userModel = new BLL.T_Sys_UserAccount().GetModel(usercode);
446
+          
334 447
             var clientidStr = RedisHelper.StringGet("clientidlist");
335 448
             var list = new List<AppClientListDto>();
336 449
             if (clientidStr != null)

+ 2 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -3656,7 +3656,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
3656 3656
                 var modellitlast = new BLL.T_Wo_WorkOrderItem_New().GetModel(itemid);
3657 3657
                 if (modellitlast!=null )
3658 3658
                 {
3659
-                    string msg = new PushMessageController().Push("工单处理提醒", "你有工单待" + optnext, touser);
3659
+                    string msg = new PushMessageController().Push("工单处理提醒", "你有工单待" + optnext, touser, model.F_Id);
3660
+                    string feishuimsg = new PushMessageController().PushFeiShui(model, "工单处理提醒", "你有工单待" + optnext, touser, model.F_Id);
3660 3661
                 }
3661 3662
                 #endregion
3662 3663
                 return true;

+ 2 - 2
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkorderAppController.cs

@@ -1987,8 +1987,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
1987 1987
                 var modellitlast = new BLL.T_Wo_WorkOrderItem_New().GetModel(itemid);
1988 1988
                 if (modellitlast != null)
1989 1989
                 {
1990
-                    string msg = new PushMessageController().Push("工单处理提醒", "你有工单待" + optnext, touser);
1991
-                  
1990
+                    string msg = new PushMessageController().Push("工单处理提醒", "你有工单待" + optnext, touser, model.F_Id);
1991
+                    string feishuimsg = new PushMessageController().PushFeiShui(model,"工单处理提醒", "你有工单待" + optnext, touser, model.F_Id);
1992 1992
                 }
1993 1993
                 #endregion
1994 1994
                 return true;

+ 29 - 10
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

@@ -1,10 +1,11 @@
1
-using CallCenter.Utility;
1
+using CallCenter.QuartzService;
2
+using CallCenter.Utility;
2 3
 using CallCenterApi.Common;
3 4
 using CallCenterApi.Interface.Controllers;
4 5
 using CallCenterApi.Interface.Models.Common;
5 6
 using System;
6 7
 using System.Collections.Generic;
7
-
8
+using System.Threading.Tasks;
8 9
 using System.Web;
9 10
 using System.Web.Mvc;
10 11
 using System.Web.Routing;
@@ -15,22 +16,40 @@ namespace CallCenterApi.Interface
15 16
 {
16 17
     public class MvcApplication : System.Web.HttpApplication
17 18
     {
18
-      
19
-     
19
+
20
+        private static QuartzWorker _worker;
20 21
         protected void Application_Start()
21 22
         {
22 23
             AreaRegistration.RegisterAllAreas();
23 24
             RouteConfig.RegisterRoutes(RouteTable.Routes);
24 25
             //clq 增加异常日志记录 自定义 HandleErrorAttribute
25 26
             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
26
-       
27
+            Task.Run(() =>
28
+            {
29
+                //IIS直接更新dll有可能end事件晚于start事件,因此延迟1分钟启动定时任务
30
+                Task.Delay(TimeSpan.FromMinutes(1)).Wait();
31
+                _worker = new QuartzWorker(65365);
32
+                _worker.AddWork(new FeiShuTask());
33
+                _worker.Start();
34
+
35
+            }).ContinueWith(p =>
36
+            {
37
+                //System.Diagnostics.Debug.WriteLine(DateTime.Now);
38
+            });
39
+          
27 40
 
28 41
         }
29
-    
30
-    
31
-       
32
-    
33
-      
42
+
43
+
44
+        protected void Application_End()
45
+        {
46
+            if (_worker != null)
47
+            {
48
+                _worker.Stop();
49
+            }
50
+        }
51
+
52
+
34 53
         protected void Application_AuthenticateRequest(object sender, EventArgs e)
35 54
         {
36 55
             HttpApplication app = (HttpApplication)sender;

+ 7 - 0
codegit/CallCenterCommon/CallCenter.QuartzService/CallCenter.QuartzService.csproj

@@ -67,6 +67,7 @@
67 67
   </ItemGroup>
68 68
   <ItemGroup>
69 69
     <Compile Include="Common.cs" />
70
+    <Compile Include="FeiShuTask.cs" />
70 71
     <Compile Include="log\Log.cs" />
71 72
     <Compile Include="log\LogFactory.cs" />
72 73
     <Compile Include="ProjectInstaller.cs">
@@ -105,6 +106,12 @@
105 106
       <SubType>Designer</SubType>
106 107
     </EmbeddedResource>
107 108
   </ItemGroup>
109
+  <ItemGroup>
110
+    <ProjectReference Include="..\CallCenter.Utility\CallCenter.Utility.csproj">
111
+      <Project>{4DA219CC-911E-4C81-BB0B-DF5183FD50FF}</Project>
112
+      <Name>CallCenter.Utility</Name>
113
+    </ProjectReference>
114
+  </ItemGroup>
108 115
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
109 116
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
110 117
        Other similar extension points exist, see Microsoft.Common.targets.

+ 27 - 0
codegit/CallCenterCommon/CallCenter.QuartzService/FeiShuTask.cs

@@ -0,0 +1,27 @@
1
+
2
+using CallCenter.Utility;
3
+using Quartz;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.IO;
7
+using System.Linq;
8
+using System.Text;
9
+
10
+namespace CallCenter.QuartzService
11
+{
12
+
13
+    public  class FeiShuTask : QuartzJob
14
+    {
15
+        public FeiShuTask()
16
+        {
17
+            CronExpression = "0 0/10 * * * ?";
18
+            DoWork += task;
19
+        }
20
+        public void task(object sender, EventArgs e)
21
+
22
+        {
23
+            var Dataurl = HttpMethods.HttpGet("http://10.1.9.26:8046//PushMessage/PushFeiShuiMessagePush");
24
+            
25
+        }
26
+    }
27
+}

+ 1 - 1
codegit/CallCenterCommon/CallCenter.QuartzService/QuartzJob.cs

@@ -12,7 +12,7 @@ namespace CallCenter.QuartzService
12 12
         /// <summary>
13 13
         /// Cron表达式,可设置多个
14 14
         /// </summary>
15
-        public List<string> CronExpressionList;
15
+        public string CronExpression;
16 16
 
17 17
         /// <summary>
18 18
         /// 任务ID

+ 30 - 183
codegit/CallCenterCommon/CallCenter.QuartzService/QuartzWorker.cs

@@ -1,217 +1,64 @@
1
-
2
-using Quartz;
1
+using System.Collections.Specialized;
3 2
 using Quartz.Impl;
4 3
 using Quartz.Impl.Triggers;
5
-using System;
6
-using System.Collections.Generic;
7
-using System.Collections.Specialized;
8
-using System.Linq;
9
-using System.Text;
4
+using Quartz;
10 5
 
11 6
 namespace CallCenter.QuartzService
12 7
 {
13 8
     public class QuartzWorker
14 9
     {
15
-        public Log log = LogFactory.GetLogger("定时");
16
-        public QuartzWorker()
17
-        {
18
-
19
-        }
20
-        /// <summary>
21
-        /// 初始化IScheduler
22
-        /// </summary>
23
-        /// <returns></returns>
24
-        public IScheduler GetScheduler()
10
+        readonly IScheduler _scheduler;
11
+        public QuartzWorker(int port)
25 12
         {
26
-            IScheduler _scheduler = null;
27
-            try
28
-            {
29
-                var properties = new NameValueCollection();
30
-                //properties["quartz.scheduler.instanceName"] = "RemoteServerSchedulerClient";
31
-                // 设置线程池
32
-                properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
33
-                properties["quartz.threadPool.threadCount"] = "10";
34
-                properties["quartz.threadPool.threadPriority"] = "Normal";
35
-
36
-                // 远程输出配置
37
-                properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
38
-                properties["quartz.scheduler.exporter.port"] = "556";
39
-                properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
40
-                properties["quartz.scheduler.exporter.channelType"] = "tcp";
41
-
42
-                var schedulerFactory = new StdSchedulerFactory(properties);
43
-                _scheduler = schedulerFactory.GetScheduler();
44
-            }
45
-            catch (Exception ex)
46
-            {
47
-                log.Info("QuartzWorker初始化失败,失败原因:" + ex.ToString());
48
-            }
49
-
50
-            return _scheduler;
13
+            var properties = new NameValueCollection();
14
+            //properties["quartz.scheduler.instanceName"] = "RemoteServerSchedulerClient";
15
+            // 设置线程池
16
+            properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
17
+            properties["quartz.threadPool.threadCount"] = "5";
18
+            properties["quartz.threadPool.threadPriority"] = "Normal";
19
+
20
+            // 远程输出配置
21
+            properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
22
+            properties["quartz.scheduler.exporter.port"] = port.ToString();
23
+            properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
24
+            properties["quartz.scheduler.exporter.channelType"] = "tcp";
25
+
26
+            var schedulerFactory = new StdSchedulerFactory(properties);
27
+            _scheduler = schedulerFactory.GetScheduler();
51 28
         }
52 29
 
53 30
         /// <summary>
54 31
         /// 添加一个任务
55 32
         /// </summary>
56 33
         /// <param name="job"></param>
57
-        public bool AddWork(QuartzJob job, IScheduler _scheduler)
34
+        public void AddWork(QuartzJob job)
58 35
         {
59 36
             var type = job.GetType();
60
-            var jobName = "job_" + job.jobID;
61
-            var jobGroup = "group_" + job.jobID;
62
-
63
-            bool bl = false;
64
-            try
65
-            {
66
-                JobKey jk = new JobKey(jobName, jobGroup);
67
-                if (_scheduler.GetJobDetail(jk) == null)
68
-                {
69
-                    // 创建一个工作
70
-                    var jobDetail = new JobDetailImpl(jobName, jobGroup, type, true, true);
71
-                    // 创建一个触发器
72
-                    Quartz.Collection.HashSet<ITrigger> triggerSet = new Quartz.Collection.HashSet<ITrigger>();
73
-                    var cronExpressionList = job.CronExpressionList;
74
-                    for (int i = 0; i < cronExpressionList.Count; i++)
75
-                    {
76
-                        var triggerName = "trigger_" + job.jobID + "_" + (i + 1);
77
-                        //触发器名称必须不同,否则最终只会添加一个触发器
78
-                        triggerSet.Add(new CronTriggerImpl(triggerName, jobGroup, jobName, jobGroup, cronExpressionList[i]));
79
-
80
-                        log.Info(triggerName + "已新增,规则:" + cronExpressionList[i]);
81
-                    }
82
-                    _scheduler.ScheduleJob(jobDetail, triggerSet, false);
83
-
84
-                    //启动任务
85
-                    if (!_scheduler.IsStarted)
86
-                    {
87
-                        Start(_scheduler);
88
-                    }
89
-                    else
90
-                    {
91
-                        _scheduler.ResumeJob(jk);
92
-                    }
93
-                    log.Info("启动任务:" + jobName);
94
-                }
95
-                else
96
-                {
97
-                    Update(job, _scheduler);
98
-                }
99
-
100
-                bl = true;
101
-            }
102
-            catch (Exception ex)
103
-            {
104
-                log.Info("添加任务失败,失败原因:" + ex.ToString());
105
-            }
106
-
107
-            return bl;
37
+            // 创建一个工作
38
+            var jobName = "JobName_" + type;
39
+            var jobGroup = "JobGroup_" + type;
40
+            var jobDetail = new JobDetailImpl(jobName, jobGroup, type, true, true);
41
+            // 创建一个触发器
42
+            var trigger = new CronTriggerImpl("trigger" + jobName, "triggergroup" + jobName, jobName, jobGroup, job.CronExpression);
43
+            _scheduler.AddJob(jobDetail, true);
44
+            _scheduler.ScheduleJob(trigger);
108 45
         }
109 46
 
110 47
         /// <summary>
111 48
         /// 开始运行
112 49
         /// </summary>
113
-        public void Start(IScheduler _scheduler)
50
+        public void Start()
114 51
         {
115 52
             _scheduler.Start();
116
-            log.Info("QuartzWorker已启动");
117 53
         }
118 54
 
119 55
         /// <summary>
120 56
         /// 停止运行
121 57
         /// </summary>
122
-        public void Stop(IScheduler _scheduler)
58
+        public void Stop()
123 59
         {
124 60
             _scheduler.Shutdown(true);
125
-            log.Info("QuartzWorker已停止");
126
-
127
-        }
128
-
129
-        /// <summary>
130
-        /// 暂停所有定时任务
131
-        /// </summary>
132
-        public void PauseAll(IScheduler _scheduler)
133
-        {
134
-            _scheduler.PauseAll();
135
-            log.Info("暂停所有定时任务");
136
-        }
137
-
138
-        /// <summary>
139
-        /// 重新启动所有定时任务
140
-        /// </summary>
141
-        public void ResumeAll(IScheduler _scheduler)
142
-        {
143
-            _scheduler.ResumeAll();
144
-            log.Info("重新启动所有定时任务");
145
-        }
146
-
147
-        /// <summary>
148
-        /// 修改任务触发器
149
-        /// </summary>
150
-        public void Update(QuartzJob job, IScheduler _scheduler)
151
-        {
152
-            var jobName = "job_" + job.jobID;
153
-            var jobGroup = "group_" + job.jobID;
154
-
155
-            try
156
-            {
157
-                var cronExpressionList = job.CronExpressionList;
158
-                JobKey jk = new JobKey(jobName, jobGroup);
159
-                List<ITrigger> list = _scheduler.GetTriggersOfJob(jk).ToList();
160
-                for (int i = 0; i < list.Count; i++)
161
-                {
162
-
163
-                    TriggerKey tk = list[i].Key;
164
-                    _scheduler.PauseTrigger(tk);
165
-                    _scheduler.UnscheduleJob(tk);
166
-
167
-                }
168
-
169
-                Quartz.Collection.HashSet<ITrigger> triggerSet = new Quartz.Collection.HashSet<ITrigger>();
170
-                for (int i = 0; i < cronExpressionList.Count; i++)
171
-                {
172
-                    var triggerName = "trigger_" + job.jobID + "_" + (i + 1);
173
-
174
-                    var trigger = new CronTriggerImpl(triggerName, jobGroup, jobName, jobGroup, cronExpressionList[i]);
175
-
176
-                    triggerSet.Add(trigger);
177
-
178
-                    log.Info(triggerName + "已修改,规则:" + cronExpressionList[i]);
179
-                }
180
-
181
-                _scheduler.ScheduleJob(_scheduler.GetJobDetail(jk), triggerSet, true);
182
-            }
183
-            catch (Exception ex)
184
-            {
185
-                log.Info(jobName + "修改失败,原因:" + ex.ToString());
186
-            }
187
-        }
188
-
189
-        /// <summary>
190
-        /// 移除任务
191
-        /// </summary>
192
-        public void Delete(QuartzJob job, IScheduler _scheduler)
193
-        {
194
-            var jobName = "job_" + job.jobID;
195
-            var jobGroup = "group_" + job.jobID;
196
-
197
-            try
198
-            {
199
-                JobKey jk = new JobKey(jobName, jobGroup);
200
-
201
-                foreach (var tri in _scheduler.GetTriggersOfJob(jk))
202
-                {
203
-                    _scheduler.PauseTrigger(tri.Key);
204
-                    _scheduler.UnscheduleJob(tri.Key);
205
-                }
206
-
207
-                _scheduler.DeleteJob(jk);
208 61
 
209
-                log.Info(jobName + "已移除");
210
-            }
211
-            catch (Exception ex)
212
-            {
213
-                log.Info(jobName + "移除失败,原因:" + ex.ToString());
214
-            }
215 62
         }
216 63
     }
217 64
 }

+ 1 - 21
codegit/CallCenterCommon/CallCenter.QuartzService/SMSService.cs

@@ -13,27 +13,7 @@ namespace CallCenter.QuartzService
13 13
 
14 14
         Log log = LogFactory.GetLogger("服务");
15 15
 
16
-        protected override void OnStart(string[] args)
17
-        {
18
-            QuartzWorker qw = new QuartzWorker();
19
-            Quartz.IScheduler _scheduler = qw.GetScheduler();
20
-            List<string> crns = new List<string>();
21
-            crns.Add(ConfigurationManager.AppSettings["t_crns"]);
22
-
23
-            SMSTask qj = new SMSTask();
24
-            qj.jobID = 0;
25
-            qj.CronExpressionList = crns;
26
-
27
-            bool bl = qw.AddWork(qj, _scheduler);
28
-            if (bl)
29
-            {
30
-                log.Warn("服务开启成功");
31
-            }
32
-            else
33
-            {
34
-                log.Warn("服务开启失败");
35
-            }
36
-        }
16
+       
37 17
 
38 18
         public void Shutdown()
39 19
         {

+ 46 - 46
codegit/CallCenterCommon/CallCenter.QuartzService/SMSTask.cs

@@ -9,59 +9,59 @@ namespace CallCenter.QuartzService
9 9
     {
10 10
         public SMSTask()
11 11
         {
12
-            DoWork += SMSTask_DoWork;
12
+          //  DoWork += SMSTask_DoWork;
13 13
         }
14 14
 
15
-        private void SMSTask_DoWork(object sender, EventArgs e)
16
-        {
17
-            Quartz.IJobExecutionContext it = sender as Quartz.IJobExecutionContext;
18
-            var _scheduler = it.Scheduler;
19
-            var jobDetail = it.JobDetail;
15
+        //private void SMSTask_DoWork(object sender, EventArgs e)
16
+        //{
17
+        //    Quartz.IJobExecutionContext it = sender as Quartz.IJobExecutionContext;
18
+        //    var _scheduler = it.Scheduler;
19
+        //    var jobDetail = it.JobDetail;
20 20
 
21
-            string name = it.JobDetail.Key.Name;
22
-            int id = Int32.Parse(name.Split('_')[1]);
21
+        //    string name = it.JobDetail.Key.Name;
22
+        //    int id = Int32.Parse(name.Split('_')[1]);
23 23
 
24
-            Log log = LogFactory.GetLogger("执行");
25
-            QuartzWorker qw = new QuartzWorker();
24
+        //    Log log = LogFactory.GetLogger("执行");
25
+        //    QuartzWorker qw = new QuartzWorker();
26 26
 
27
-            try
28
-            {
29
-                log.Warn("主任务执行");
27
+        //    try
28
+        //    {
29
+        //        log.Warn("主任务执行");
30 30
 
31
-                Common com = new Common();
31
+        //        Common com = new Common();
32 32
 
33
-                lock (this)
34
-                {
35
-                    string url = ConfigurationManager.AppSettings["smsurl"];
36
-                    if (!string.IsNullOrEmpty(url))
37
-                    {
38
-                        string strzxUrl = url + "/SMSZXZB/ExecSendByJob";
39
-                        string zxresult = com.HttpGet(strzxUrl, "count=" + ConfigurationManager.AppSettings["t_count"]);
40
-                        JObject zxrt = JsonConvert.DeserializeObject<JObject>(zxresult);
41
-                        if (zxrt != null && zxrt["state"].ToString() == "success")
42
-                        {
43
-                            JObject jsrt = JsonConvert.DeserializeObject<JObject>(zxrt["data"].ToString());
44
-                            if (jsrt["suc"].ToString() != "" && jsrt["err"].ToString() != "")
45
-                            {
46
-                                log.Error("发送成功手机号:" + jsrt["suc"].ToString() + "\r\n" + "发送失败手机号:" + jsrt["err"].ToString());
47
-                            }
48
-                        }
49
-                        else
50
-                        {
51
-                            log.Error("主任务执行失败,失败原因:" + zxrt["message"].ToString());
52
-                        }
53
-                    }
54
-                    else
55
-                    {
56
-                        log.Warn("接口地址不存在");
57
-                    }
58
-                }
59
-            }
60
-            catch (Exception ex)
61
-            {
33
+        //        lock (this)
34
+        //        {
35
+        //            string url = ConfigurationManager.AppSettings["smsurl"];
36
+        //            if (!string.IsNullOrEmpty(url))
37
+        //            {
38
+        //                string strzxUrl = url + "/SMSZXZB/ExecSendByJob";
39
+        //                string zxresult = com.HttpGet(strzxUrl, "count=" + ConfigurationManager.AppSettings["t_count"]);
40
+        //                JObject zxrt = JsonConvert.DeserializeObject<JObject>(zxresult);
41
+        //                if (zxrt != null && zxrt["state"].ToString() == "success")
42
+        //                {
43
+        //                    JObject jsrt = JsonConvert.DeserializeObject<JObject>(zxrt["data"].ToString());
44
+        //                    if (jsrt["suc"].ToString() != "" && jsrt["err"].ToString() != "")
45
+        //                    {
46
+        //                        log.Error("发送成功手机号:" + jsrt["suc"].ToString() + "\r\n" + "发送失败手机号:" + jsrt["err"].ToString());
47
+        //                    }
48
+        //                }
49
+        //                else
50
+        //                {
51
+        //                    log.Error("主任务执行失败,失败原因:" + zxrt["message"].ToString());
52
+        //                }
53
+        //            }
54
+        //            else
55
+        //            {
56
+        //                log.Warn("接口地址不存在");
57
+        //            }
58
+        //        }
59
+        //    }
60
+        //    catch (Exception ex)
61
+        //    {
62 62
 
63
-                log.Warn("主任务执行失败,失败原因:" + ex.ToString());
64
-            }
65
-        }
63
+        //        log.Warn("主任务执行失败,失败原因:" + ex.ToString());
64
+        //    }
65
+        //}
66 66
     }
67 67
 }

+ 89 - 5
codegit/CallCenterCommon/CallCenter.Utility/FeiShuiHelper.cs

@@ -1,4 +1,5 @@
1 1
 using Newtonsoft.Json;
2
+using Newtonsoft.Json.Linq;
2 3
 using System;
3 4
 using System.Collections.Generic;
4 5
 using System.IO;
@@ -68,6 +69,7 @@ namespace CallCenter.Utility
68 69
             }
69 70
             return result;
70 71
         }
72
+
71 73
         //通过手机号获取用户id
72 74
         private static string GetUserid(string mobile)
73 75
         {
@@ -87,7 +89,7 @@ namespace CallCenter.Utility
87 89
                 if (resultobj.code != "0")
88 90
                 {
89 91
                     LogFactory.GetLogger("GetUserid").Error(resultobj.msg);
90
-                    result = resultobj.msg;
92
+                    result = "";
91 93
                 }
92 94
                 else
93 95
                 {
@@ -97,11 +99,15 @@ namespace CallCenter.Utility
97 99
             }
98 100
             return result;
99 101
         }
102
+
100 103
         //发送消息
101
-        public static string SendMsg(string mobile,string msg)
104
+        public static string SendMsg(string title,
105
+            string workrodercode, string name, string phone,
106
+            string address, string products, string description,
107
+            string mobile, string msg, long WoID = 0,int type=0)
102 108
         {
103 109
             string userid = GetUserid(mobile);
104
-            if (string.IsNullOrEmpty(mobile))
110
+            if (string.IsNullOrEmpty(userid))
105 111
                 return "";
106 112
             Guid guid = Guid.NewGuid();
107 113
             string uuid = guid.ToString();
@@ -113,7 +119,18 @@ namespace CallCenter.Utility
113 119
             //param.Add("uuid", uuid);
114 120
 
115 121
             var postData = new { receive_id = userid, msg_type = "post",
116
-                content = "{\"zh_cn\":{\"title\":\""+ msg + "\",\"content\":[[{\"tag\":\"text\",\"text\":\"地址 :\"},{\"tag\":\"a\",\"href\":\"http://www.feishu.cn\",\"text\":\"超链接\"}]]}}",
122
+                content = "{\"zh_cn\":{\"title\":\""+ title + 
123
+                "\",\"content\":[[{\"tag\":\"text\",\"text\":\"工单编号:"+ workrodercode + "\"}]," +
124
+                "[{\"tag\":\"text\",\"text\":\"投诉人姓名:" + name + "\"}]," +
125
+                "[{\"tag\":\"text\",\"text\":\"投诉人手机号:" + phone + "\"}]," +
126
+                "[{\"tag\":\"text\",\"text\":\"投诉人地址:" + address + "\"}]," +
127
+                "[{\"tag\":\"text\",\"text\":\"产品地址:" + products + "\"}]," +
128
+                "[{\"tag\":\"text\",\"text\":\"问题描述:" + description + "\"}]," +
129
+                 "[{\"tag\":\"text\",\"text\":\"\"}]," +
130
+                "[{\"tag\":\"text\",\"text\":\"点击查看详情 :\"},{\"tag\":\"a\",\"href\":\"https://applink.feishu.cn/client/web_app/open?appId=" + app_id + "&wid=" + WoID+"\",\"text\":\"[查看详情链接]\"}]," +
131
+                "[{\"tag\":\"text\",\"text\":\"\"}]," +
132
+                "[{\"tag\":\"a\",\"href\":\"https://applink.feishu.cn/client/web_app/open?appId="+ app_id + "\",\"text\":\"[进入售后平台]\"}]" +
133
+                "]}}",
117 134
                 uuid = uuid,
118 135
             };
119 136
             var strresult = SendPostRequest
@@ -128,6 +145,23 @@ namespace CallCenter.Utility
128 145
                 }
129 146
                 else
130 147
                 {
148
+                    //"message_id"
149
+                   //加急短信
150
+                    JObject jo = (JObject)JsonConvert.DeserializeObject(resultobj["data"].ToJson());
151
+                    if (jo != null)
152
+                    {
153
+                        if (type==1)
154
+                        {
155
+                            string message_id = jo["message_id"].ToString();
156
+                            if (!string.IsNullOrEmpty(message_id))
157
+                            {
158
+                                var user_id_list = new { user_id_list = new string[] { userid } };
159
+                                var message = SendPatchRequest
160
+         ("https://open.feishu.cn/open-apis/im/v1/messages/" + message_id + "/urgent_sms?user_id_type=user_id", user_id_list);
161
+                                return message;
162
+                            }
163
+                        }
164
+                    }
131 165
                     result =  resultobj.ToJson() ;
132 166
                 }
133 167
             }
@@ -210,7 +244,57 @@ namespace CallCenter.Utility
210 244
 
211 245
             return result;
212 246
         }
213
-        public static string SendPostRequest(string url, object data)
247
+        public static string SendPatchRequest(string url, object data)
248
+        {
249
+            string authToken = GetTenantAccessToken();
250
+            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
251
+            request.Method = "PATCH"; // 指定 PATCH 方法
252
+            request.ContentType = "application/json; charset=utf-8";
253
+            request.Headers.Add("Authorization", $"Bearer {authToken}");
254
+
255
+            // 如需忽略 SSL 证书验证(仅测试环境)
256
+            // ServicePointManager.ServerCertificateValidationCallback = 
257
+            //     (sender, cert, chain, sslPolicyErrors) => true;
258
+
259
+            try
260
+            {
261
+                // 序列化请求数据
262
+                string json = JsonConvert.SerializeObject(data);
263
+                byte[] payload = Encoding.UTF8.GetBytes(json);
264
+
265
+                // 写入请求体
266
+                request.ContentLength = payload.Length;
267
+                using (Stream stream = request.GetRequestStream())
268
+                {
269
+                    stream.Write(payload, 0, payload.Length);
270
+                }
271
+
272
+                // 获取响应
273
+                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
274
+                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
275
+                {
276
+                    return reader.ReadToEnd();
277
+                }
278
+            }
279
+            catch (WebException ex)
280
+            {
281
+                // 处理错误响应
282
+                if (ex.Response is HttpWebResponse errorResponse)
283
+                {
284
+                    using (Stream errorStream = errorResponse.GetResponseStream())
285
+                    using (StreamReader reader = new StreamReader(errorStream, Encoding.UTF8))
286
+                    {
287
+                        string errorContent = reader.ReadToEnd();
288
+                        throw new Exception($"HTTP Error {(int)errorResponse.StatusCode}: {errorContent}");
289
+                    }
290
+                }
291
+                throw new Exception("Network error: " + ex.Message);
292
+            }
293
+        }
294
+    
295
+
296
+
297
+      public static string SendPostRequest(string url, object data)
214 298
         {
215 299
             string authToken = GetTenantAccessToken();
216 300
             // 创建请求对象

+ 11 - 1
codegit/CallCenterCommon/CallCenter.Utility/RedisHelper.cs

@@ -17,7 +17,17 @@ namespace CallCenter.Utility
17 17
         {
18 18
             if (redis == null || !redis.IsConnected)
19 19
             {
20
-                redis = ConnectionMultiplexer.Connect(Configs.GetValue("Redis_Server") + ":" + Configs.GetValue("Redis_Port"));
20
+                var config = new ConfigurationOptions
21
+                {
22
+                    AbortOnConnectFail = false,
23
+                    AllowAdmin = true,
24
+                    ConnectTimeout = 15000,
25
+                    SyncTimeout = 5000,
26
+                    ResponseTimeout = 15000,
27
+                    Password = Configs.GetValue("Redis_Password"),//Redis数据库密码
28
+                    EndPoints = { Configs.GetValue("Redis_Server") + ":" + Configs.GetValue("Redis_Port") }// connectionString 为IP:Port 如”192.168.2.110:6379”
29
+                };
30
+                redis = ConnectionMultiplexer.Connect(config);
21 31
                 //redis = ConnectionMultiplexer.Connect("192.168.4.18, abortConnect=false");
22 32
 
23 33
                 database = redis.GetDatabase(int.Parse(Configs.GetValue("Redis_Defaultdatabase")));