package com.flow.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.flow.mapper.*; import com.flow.pojo.*; import com.flow.service.DuanxinlogService; import com.flow.service.TbFuwuqiService; import com.flow.util.DESUtil; import com.flow.util.result; import com.flow.util.resultutil; import com.github.pagehelper.PageInfo; import com.tencentcloudapi.common.Credential; 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.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @RestController @RequestMapping({"/hxzk"}) @Component public class DuanxinlogController { private String SecretId = "AKIDrjZOI4e6KLZu9FAsSRN8eOwSt52lbMBz"; private String SecretKey = "xnRtHUL3YqdMyOLVSBjKkz1pQoxujS4d"; @Autowired DuanxinlogService duanxinlogService; @Autowired CardMapper cardMapper; @Autowired TbFuwuqiMapper tbFuwuqiMapper; @Autowired DuanxinlogMapper duanxinlogMapper; @Autowired TbFuwuqiService tbFuwuqiService; @Autowired CompanyMapper companyMapper; @Autowired ManagerMapper managerMapper; @GetMapping({"findDuanxinlog"}) result> findDuanxinlog(Integer page, Integer limit) { PageInfo cz = this.duanxinlogService.FindDuanxinlog(page, limit); return resultutil.returnSuccess(cz.getTotal(), cz.getList()); } @PostMapping({"DeleteDuanxinlog"}) public ModelAndView DeleteManager(String num) { this.duanxinlogService.DeleteDuanxinlog(num); ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("/page/Duanxinlog.jsp"); return modelAndView; } /* * 函数名 : smsfuwuqi * 说明 : 服务器 查询所有服务器数据 根据公司名称查询电话 使用当前时间减去结束时间 使用号码查询短信表取出发送日期,如果当前日期大于发送日期 发送短信 * 返回值 : 无 * 作者 : 王飞 // * 日期 : 2024年2月28日 */ // @EnableScheduling // @Scheduled(cron = "*/10 * * * * ?")//测试10一次 // @Scheduled(cron = "0 46 17 * * ?") @Scheduled(cron = "0 0 */1 * * ?")//一小时执行一次 public void smsfuwuqi() throws Exception { System.out.println("服务器定时器执行============》》》》》》》》》》》》》》》》"); QueryWrapper queryWrapper1 = new QueryWrapper(); queryWrapper1.eq("none", "0"); List fuwuqiList = (tbFuwuqiMapper).selectList(queryWrapper1); for (int i = 0; i < fuwuqiList.size(); i++) { QueryWrapper queryWrapper3 = new QueryWrapper(); queryWrapper3.eq("none", "0"); queryWrapper3.eq("companyName", fuwuqiList.get(i).getCompany()); Company companyList = (companyMapper).selectOne(queryWrapper3); SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); Date endDay = date2.parse(fuwuqiList.get(i).getEnddate());//结束时间 Long starTime = date.getTime(); Long endTime = endDay.getTime(); Long num11 = endTime - starTime;//时间戳 //不足一天的算作一天,因此在到期天数上加1 if (+num11 / 24 / 60 / 60 / 1000 == 19 | +num11 / 24 / 60 / 60 / 1000 == 9 | +num11 / 24 / 60 / 60 / 1000 == 4 | +num11 / 24 / 60 / 60 / 1000 == 0) { String dispatchDate = this.duanxinlogService.userdate(fuwuqiList.get(i).getServername()); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String dtext = formatter.format(date); if (dispatchDate == null || !dtext.equals(dispatchDate)) { // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 Credential cred = new Credential(SecretId, SecretKey); // 实例化一个http选项,可选的,没有特殊需求可以跳过 HttpProfile httpProfile = new HttpProfile(); httpProfile.setEndpoint("sms.tencentcloudapi.com"); // 实例化一个client选项,可选的,没有特殊需求可以跳过 ClientProfile clientProfile = new ClientProfile(); clientProfile.setHttpProfile(httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 SendSmsRequest req = new SendSmsRequest(); // String[] phoneNumberSet1 = {"18701153496"}; String[] phoneNumberSet1 = {DESUtil.decrypt(companyList.getLoginphone(), DESUtil.key)}; QueryWrapper sms = new QueryWrapper(); sms.eq("none", "0"); sms.eq("smsreception", "1"); List managerList = (managerMapper).selectList(sms); for (int s=0;s cardList = (cardMapper).selectList(queryWrapper); for (int i = 0; i < cardList.size(); i++) { QueryWrapper queryWrapper3 = new QueryWrapper(); queryWrapper3.eq("none", "0"); queryWrapper3.eq("companyName", cardList.get(i).getCompany()); Company companyList = new Company(); companyList = (companyMapper).selectOne(queryWrapper3); if (companyList == null) { QueryWrapper queryWrapper4 = new QueryWrapper(); queryWrapper4.eq("none", "0"); queryWrapper4.eq("companyabbname", cardList.get(i).getCompany()); companyList = (companyMapper).selectOne(queryWrapper4); } SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); Date endDay = date2.parse(cardList.get(i).getEnddate());//结束时间 Long starTime = date.getTime(); Long endTime = endDay.getTime(); Long num11 = endTime - starTime;//时间戳 if (+num11 / 24 / 60 / 60 / 1000 == 19 | +num11 / 24 / 60 / 60 / 1000 == 9 | +num11 / 24 / 60 / 60 / 1000 == 4 | +num11 / 24 / 60 / 60 / 1000 == 0) { String dispatchDate = this.duanxinlogService.userdate(cardList.get(i).getCardnumber()); // String dispatchDate = this.duanxinlogService.userdate(cardList.get(i).getCardnumber()); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String dtext = formatter.format(date); if (dispatchDate == null || !dtext.equals(dispatchDate)) { String randomNumber = new String(); // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 Credential cred = new Credential(SecretId, SecretKey); // 实例化一个http选项,可选的,没有特殊需求可以跳过 HttpProfile httpProfile = new HttpProfile(); httpProfile.setEndpoint("sms.tencentcloudapi.com"); // 实例化一个client选项,可选的,没有特殊需求可以跳过 ClientProfile clientProfile = new ClientProfile(); clientProfile.setHttpProfile(httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 SendSmsRequest req = new SendSmsRequest(); // String[] phoneNumberSet1 = {cardList.get(i).getCardnumber()}; String[] phoneNumberSet1 = {DESUtil.decrypt(companyList.getLoginphone(), DESUtil.key)}; // String[] phoneNumberSet1 = {"18701153496"}; QueryWrapper sms = new QueryWrapper(); sms.eq("none", "0"); sms.eq("smsreception", "1"); List managerList = (managerMapper).selectList(sms); for (int s=0;s