zhao_js
2024-01-04 6898a19dcf7f52a1f93f8775cdfafc1685b4ee97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using CommonUtil;
using CommonUtil.Web;
using Operater.DAL;
using Quartz;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
 
namespace ScheduledTasks.Handle
{
    public class SmsWarningHandle : IJob
    {
        public async Task Execute(IJobExecutionContext context)
        {
            await Synchronize(context);
        }
        public static async Task Synchronize(IJobExecutionContext context)
        {
            try
            {
                //查询超过3分钟未审核的
                string searchSql = $"select count(1) as count from sms_send where sendstatus=0 and isshowsend=0 and TIMESTAMPDIFF(MINUTE, now(),createtime)>3";
                DataTable shDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql);
                int shCount = int.Parse(shDt.Rows[0]["count"].ToString());
                if (shCount > 0)
                {//发预警
                    string warStr = "您有待审核的任务\n>类型:待审核\n>数量:" + shCount + "\n>查看:[点击处理](https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7a9a40880081340d&redirect_uri=https%3A%2F%2Fsms.ushopvip.com%2Fpages%2Fad_page%2Ftrans&response_type=code&scope=snsapi_base&state=gzh#wechat_redirect)";
                    SendQwGroup.SendMessage(warStr);
 
                }
                //查询长时间未发送成功
                searchSql = $"select count(1) as count from sms_send where isshowsend=0 and wantsendtime>now() and sendstatus=0 and TIMESTAMPDIFF(MINUTE, now(),wantsendtime)>5";
                DataTable wfDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql);
                int wfCount = int.Parse(wfDt.Rows[0]["count"].ToString());
                if (wfCount > 0)
                {//发预警
                    string warStr = "长时间未发送完成任务\n>类型:任务异常\n>数量:" + wfCount;
                    SendQwGroup.SendMessage(warStr);
                }
            }
            catch (Exception e)
            {
                LogUtil.Info(e.ToString(), "短信预警error");
                Console.WriteLine($"短信预警error", e.ToString());
            }
        }
    }
}