package com.hxzk.util; import com.hxzk.deo.TbWarning; import com.hxzk.pojo.TbSmsLog; import com.hxzk.pojo.TbSmsReminder; import com.hxzk.service.SmsLogService; import com.hxzk.service.TbSmsReminderService; import com.hxzk.service.WarningService; 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 org.springframework.stereotype.Component; import java.sql.SQLOutput; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; @Component public class MyThreadTask implements Runnable { private String SecretId = "AKIDrjZOI4e6KLZu9FAsSRN8eOwSt52lbMBz"; private String SecretKey = "xnRtHUL3YqdMyOLVSBjKkz1pQoxujS4d"; private WarningService warningService; private TbSmsReminderService smsReminderService; private SmsLogService smsLogService; public MyThreadTask(WarningService warningService,TbSmsReminderService smsReminderService,SmsLogService smsLogService) { this.warningService = warningService; this.smsReminderService = smsReminderService; this.smsLogService = smsLogService; } @Override public void run() { try { while (true) { //获取当前定义的短信提示类型 List smsReminders = smsReminderService.findAllSMSReminder(); List ids = new ArrayList<>(); //循环短信提示(根据类型)查找需要发送短信的告警 for (int i = 0 ; i< smsReminders.size();i++){ String type = smsReminders.get(i).getSmstype(); //拿着当前type 在数据库中查询在之前6秒和现在满足告警条件的数据 List a = warningService.findNowAll(type); for (int j = 0 ; j