| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.flow.mapper.BangZhuMapper; |
| | | import com.flow.mapper.ManagerMapper; |
| | | import com.flow.pojo.Bangzhu; |
| | | import com.flow.pojo.Duanxinlog; |
| | | import com.flow.pojo.Manager; |
| | | import com.flow.service.BangZhuService; |
| | | import com.flow.service.DuanxinlogService; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class BangZhuServiceImpl extends ServiceImpl<BangZhuMapper, Bangzhu> implements BangZhuService { |
| | | private String SecretId = "AKIDrjZOI4e6KLZu9FAsSRN8eOwSt52lbMBz"; |
| | | private String SecretKey = "xnRtHUL3YqdMyOLVSBjKkz1pQoxujS4d"; |
| | | @Autowired |
| | | ManagerMapper managerMapper; |
| | | |
| | | @Autowired |
| | | DuanxinlogService duanxinlogService; |
| | | |
| | | public BangZhuServiceImpl() { |
| | | } |
| | | |
| | | public void addBang(Bangzhu bangzhu) { |
| | | public void addBang(Bangzhu bangzhu) throws TencentCloudSDKException { |
| | | 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[]{"15210640466"}; |
| | | // req.setPhoneNumberSet(phoneNumberSet1); |
| | | QueryWrapper sms = new QueryWrapper(); |
| | | sms.eq("none", "0"); |
| | | sms.eq("smsreception", "1"); |
| | | List<Manager> managerList = (managerMapper).selectList(sms); |
| | | String phone = new String(); |
| | | 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); |
| | | if (s+1==managerList.size()){ |
| | | phone+=managerList.get(s).getPhone(); |
| | | }else{ |
| | | phone+=managerList.get(s).getPhone()+","; |
| | | } |
| | | req.setSmsSdkAppId("1400838975"); |
| | | req.setSignName("北京华星北斗智控"); |
| | | req.setTemplateId("2127737"); |
| | | |
| | | String[] templateParamSet1 = {String.valueOf(bangzhu.getCompany())}; |
| | | |
| | | req.setTemplateParamSet(templateParamSet1); |
| | | // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 |
| | | SendSmsResponse resp = client.SendSms(req); |
| | | System.out.println(SendSmsResponse.toJsonString(resp)); |
| | | } |
| | | // req.setSmsSdkAppId("1400838975"); |
| | | // req.setSignName("北京华星北斗智控"); |
| | | // req.setTemplateId("2127736"); |
| | | // String[] templateParamSet1 = new String[]{cardNum}; |
| | | // req.setTemplateParamSet(templateParamSet1); |
| | | // SendSmsResponse resp = client.SendSms(req); |
| | | // System.out.println(SendSmsResponse.toJsonString(resp)); |
| | | Duanxinlog duanxinlog = new Duanxinlog(); |
| | | duanxinlog.setIdentification("留言短信提示"); |
| | | duanxinlog.setReceiver(bangzhu.getCompany()); |
| | | duanxinlog.setNumber(phone); |
| | | duanxinlog.setContent(bangzhu.getCompany()+"提交了问题工单,请及时处理。"); |
| | | this.duanxinlogService.addDuanxinlog(duanxinlog); |
| | | |
| | | ((BangZhuMapper)this.baseMapper).insert(bangzhu); |
| | | } |
| | | |