| | |
| | | import org.springblade.modules.sms.service.ISmsTemplateService; |
| | | import org.springblade.modules.sms.entity.SmsRecordEntity; |
| | | import org.springblade.modules.sms.service.ISmsRecordService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.task.entity.TaskPlaceSelfCheckEntity; |
| | | import org.springblade.modules.task.entity.TaskResidencePermitApplyEntity; |
| | | import org.springblade.modules.task.service.ITaskPlaceSelfCheckService; |
| | | import org.springblade.modules.task.service.ITaskResidencePermitApplyService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public Boolean sendVerificationCode(String phone) { |
| | | if (phone == null || phone.length() != 11) { |
| | | logger.error("手机号格式错误"); |
| | | return false; |
| | | } |
| | | |
| | | if (redisTemplate.exists(SMS_VALIDATE_PHONE_NUM + phone)) { |
| | | logger.error("同一个手机号一分钟内只能发送一条记录"); |
| | | return false; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param templateId |
| | | * @param residenceId |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * @param templateId |
| | | * @param placeSelfCheckId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Boolean sendRectificationNotice(Long templateId, Long placeSelfCheckId) { |
| | | |
| | | Sms serviceOne = iSmsService.getOne(Wrappers.<Sms>lambdaQuery().eq(Sms::getStatus, 2)); |
| | | if (serviceOne == null) { |
| | | logger.error("未找到状态为2的Sms服务"); |
| | | return false; |
| | | } |
| | | SmsTemplateEntity smsTemplateEntity = iSmsTemplateService.getOne(Wrappers.<SmsTemplateEntity>lambdaQuery() |
| | | .eq(SmsTemplateEntity::getId, templateId)); |
| | | if (smsTemplateEntity == null) { |
| | | logger.error("未找到对应的短信模板"); |
| | | return false; |
| | | } |
| | | ITaskPlaceSelfCheckService bean = SpringUtils.getBean(ITaskPlaceSelfCheckService.class); |
| | | TaskPlaceSelfCheckEntity placeSelfCheckEntity = bean.getById(placeSelfCheckId); |
| | | IUserService userService = SpringUtils.getBean(IUserService.class); |
| | | UserVO userVO = userService.getuserById(placeSelfCheckEntity.getId()); |
| | | String phone = userVO.getPhone(); |
| | | //发送的手机号 |
| | | List<Map> phonesList = new ArrayList<>(); |
| | | Map phoneMap = new HashMap(); |
| | | phoneMap.put("phone", phone); |
| | | List<String> varList = new ArrayList<>(); |
| | | // 设置参数 |
| | | |
| | | varList.add(userVO.getName()); |
| | | varList.add(placeSelfCheckEntity.getPlaceName()); |
| | | phoneMap.put("varList", varList); |
| | | phonesList.add(phoneMap); |
| | | //短信内容 |
| | | String content = smsTemplateEntity.getContent(); |
| | | //发送时间 |
| | | LocalDateTime nowDateTime = LocalDateTime.now(); |
| | | String send_time = nowDateTime.format(SECOND_FORMATTER); |
| | | Map params = new HashMap(); |
| | | params.put("phones", phonesList); |
| | | //短信主题 |
| | | params.put("subject", "对外接口不同内容发送-动态模板"); |
| | | params.put("content", content); |
| | | //短信模板 |
| | | params.put("template_id", null); |
| | | // 发送时间 |
| | | params.put("send_time", send_time); |
| | | //优先级,高级=5,中级=3,低级=1 |
| | | params.put("priority", "1"); |
| | | //不同内容发送类型,1=动态模板发送,2=文件内容发送 |
| | | params.put("type", "1"); |
| | | //创建人主键 |
| | | params.put("sop_create_by", serviceOne.getSmsCode()); |
| | | //短信发送记录 |
| | | saveSmsRecord(phone, serviceOne, placeSelfCheckEntity.getPlaceName(), content); |
| | | Boolean aBoolean = sendSmsGet(serviceOne, params); |
| | | return aBoolean; |
| | | } |
| | | |
| | | /** |
| | | * 发送短信并获取发送结果。 |
| | | * |
| | | * @param serviceOne 用于发送短信的服务对象 |