fei.wang
2024-04-15 61747a14819075bf6da2c1597b6c22e22e026686
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package com.flow.quartz;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.flow.mapper.ManagerMapper;
import com.flow.pojo.Card;
import com.flow.pojo.Company;
import com.flow.pojo.Duanxinlog;
import com.flow.pojo.Manager;
import com.flow.service.CardService;
import com.flow.service.CompanyService;
import com.flow.service.DuanxinlogService;
import com.flow.util.DESUtil;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
 
public class MyJob2 {
    private String SecretId = "AKIDrjZOI4e6KLZu9FAsSRN8eOwSt52lbMBz";
    private String SecretKey = "xnRtHUL3YqdMyOLVSBjKkz1pQoxujS4d";
    @Autowired
    CardService cardService;
    @Autowired
    CompanyService companyService;
    @Autowired
    ManagerMapper managerMapper;
 
    @Autowired
    DuanxinlogService duanxinlogService;
    public MyJob2() {
    }
 
    private void execute1() throws Exception {
        List<Company> companies = this.companyService.findLength();
 
        for(int i = 0; i < companies.size(); ++i) {
            TimeUnit.SECONDS.sleep(10L);
            String GsMc = ((Company)companies.get(i)).getCompanyname();
            String GsPhone = DESUtil.decrypt(((Company)companies.get(i)).getPhone(), DESUtil.key);
            System.out.println(GsPhone);
            List<Card> cardList = this.cardService.findDaoQi(GsMc);
            System.out.println(cardList);
            String cardNum = "";
            if (cardList.size() == 0) {
                break;
            }
 
            for(int j = 0; j < cardList.size(); ++j) {
                if (j == cardList.size() - 1) {
                    cardNum = cardNum + ((Card)cardList.get(j)).getCardnumber();
                } else {
                    cardNum = cardNum + ((Card)cardList.get(j)).getCardnumber() + ";";
                }
            }
 
            try {
                Credential cred = new Credential(this.SecretId, this.SecretKey);
                HttpProfile httpProfile = new HttpProfile();
                httpProfile.setEndpoint("sms.tencentcloudapi.com");
                ClientProfile clientProfile = new ClientProfile();
                clientProfile.setHttpProfile(httpProfile);
                SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile);
                SendSmsRequest req = new SendSmsRequest();
                String[] phoneNumberSet1 = new String[]{GsPhone};
                QueryWrapper sms = new QueryWrapper();
                sms.eq("none", "0");
                sms.eq("smsreception", "1");
                List<Manager> managerList = (managerMapper).selectList(sms);
                for (int s=0;s<managerList.size();s++){
//                        System.out.println(managerList.get(s).getPhone());
//                        phoneNumberSet1[s] = managerList.get(s).getPhone();
                    String[] phoneNumberSet12  = {managerList.get(s).getPhone()};
                    System.out.println(phoneNumberSet12);
                    req.setPhoneNumberSet(phoneNumberSet12);
 
                    req.setSmsSdkAppId("1400838975");
                    req.setSignName("北京华星北斗智控");
                    req.setTemplateId("1908206");
 
//                    String[] templateParamSet1 = {String.valueOf(+num11 / 24 / 60 / 60 / 1000)};
                    String[] templateParamSet1 = new String[]{cardNum, "150MB"};
                    req.setTemplateParamSet(templateParamSet1);
                    // 返回的resp是一个SendSmsResponse的实例,与请求对象对应
                    SendSmsResponse resp = client.SendSms(req);
                }
                req.setPhoneNumberSet(phoneNumberSet1);
                req.setSmsSdkAppId("1400838975");
                req.setSignName("北京华星北斗智控");
                req.setTemplateId("1908206");
                String[] templateParamSet1 = new String[]{cardNum, "150MB"};
                req.setTemplateParamSet(templateParamSet1);
                SendSmsResponse resp = client.SendSms(req);
                System.out.println(SendSmsResponse.toJsonString(resp));
                Duanxinlog duanxinlog = new Duanxinlog();
                duanxinlog.setIdentification(cardList.get(i).getCardnumber());
                duanxinlog.setReceiver(cardList.get(i).getCompany());
                duanxinlog.setNumber(GsPhone);
//                duanxinlog.setContent("尊敬的用户,您好!您有服务器将于"+cardList.get(i).getEnddate()+"到期,为避免影响您的正常使用请及时续费,您可登录华星智控公司物联网管理平台查询详情续费,如有疑问可咨询我公司客服人员,祝您生活愉快!");
                this.duanxinlogService.addDuanxinlog(duanxinlog);
            } catch (TencentCloudSDKException var15) {
                System.out.println(var15.toString());
            }
        }
 
    }
}