| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.*; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dao.SmsConfigMapper; |
| | | import com.doumee.dao.business.dao.SmsEmailMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.SmsEmailService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private EmayService emayService; |
| | | @Autowired |
| | | private SmsConfigMapper smsConfigMapper; |
| | | |
| | | @Value("${debug_model}") |
| | | private boolean debugModel; |
| | |
| | | )>=3){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,超出发送次数,请稍后重试!"); |
| | | } |
| | | |
| | | String code = Constants.getRandom6Num(); |
| | | |
| | | String content = systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode()+"验证码为:"+code+",此验证码有效为3分钟。请勿泄露"; |
| | | |
| | | // boolean result= emayService.sendSingleSms(smsEmail.getPhone(),content); |
| | | emayService.sendSmsByHk(smsEmail.getPhone(),content); |
| | | // if(!result){ |
| | | // throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,短信验证码发送失败,请稍后重试!"); |
| | | // } |
| | | |
| | | smsEmail.setRemark(code); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |
| | | smsEmail.setStatus(Constants.ZERO); |
| | | smsEmail.setType(Constants.ZERO); |
| | | smsEmail.setTitle("短信验证码"); |
| | | smsEmail.setContent(content); |
| | | smsEmail.setObjType(Constants.ZERO+""); |
| | | smsEmailMapper.insert(smsEmail); |
| | | |
| | | return smsEmail.getId(); |
| | | SmsConfig smsConfig = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getObjType, |
| | | SmsConstants.inventCode).last(" limit 1 ")); |
| | | //开启短信通知 |
| | | if(Objects.nonNull(smsConfig) || Constants.equalsInteger(smsConfig.getStatus(),Constants.ZERO)){ |
| | | if(StringUtils.isNotBlank(smsConfig.getContent())){ |
| | | String content = smsConfig.getContent().replace("{验证码}",code); |
| | | emayService.sendSmsByHk(smsEmail.getPhone(),content); |
| | | smsEmail.setRemark(code); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |
| | | smsEmail.setStatus(Constants.ZERO); |
| | | smsEmail.setType(Constants.ZERO); |
| | | smsEmail.setTitle("短信验证码"); |
| | | smsEmail.setContent(content); |
| | | smsEmail.setObjType(Constants.ZERO+""); |
| | | smsEmailMapper.insert(smsEmail); |
| | | return smsEmail.getId(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | QueryWrapper<SmsEmail> wrapper = new QueryWrapper<>(smsEmail); |
| | | return smsEmailMapper.selectCount(wrapper); |
| | | } |
| | | @Override |
| | | public void sendWaitingSmsNotice(){ |
| | | LambdaQueryWrapper<SmsEmail> wrapper = new LambdaQueryWrapper<SmsEmail>() |
| | | .eq(SmsEmail::getIsdeleted,Constants.ZERO) |
| | | .eq(SmsEmail::getStatus,Constants.TWO); |
| | | List<SmsEmail> smsEmails = smsEmailMapper.selectList(wrapper); |
| | | if(smsEmails!=null && smsEmails.size()>0){ |
| | | for(SmsEmail model : smsEmails){ |
| | | if(model.getPhone() == null){ |
| | | model.setStatus(Constants.THREE);//发送失败 |
| | | model.setRemark("手机号为空,取消任务发送!"); |
| | | }else{ |
| | | try { |
| | | emayService.sendSmsByHk(model.getPhone(),model.getContent()); |
| | | model.setStatus(Constants.ONE);//发送成功 |
| | | model.setRemark("短信任务发送成功"); |
| | | }catch (Exception e){ |
| | | model.setStatus(Constants.THREE);//发送失败 |
| | | model.setRemark("短信任务发送失败!"+e.getMessage()); |
| | | } |
| | | } |
| | | model.setEditDate(new Date()); |
| | | smsEmailMapper.updateById(model); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 访客申请业务短信通知 |
| | |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | auditUser,SmsConstants.platformBook,content,visits.getId()); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public static void sendVisitReportTimeOutSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , |
| | | SmsConfigMapper smsConfigMapper, |
| | | String objCode, String msg,List<String> mobiles){ |
| | | try{ |
| | | SmsConfig smsConfig = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getCode, |
| | | objCode).last(" limit 1 ")); |
| | | //开启短信通知 |
| | | if(Objects.nonNull(smsConfig) || Constants.equalsInteger(smsConfig.getStatus(),Constants.ZERO)){ |
| | | String content = systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode() + smsConfig.getContent(); |
| | | //超时特殊处理 |
| | | if(smsConfig.getCode().equals(SmsConstants.visitReportingContent.visitReportingTimeOutSignOutNum)){ |
| | | //今日还有{未签离数量}个访客报备车辆未离场,请前往PC端查看详细信息。 |
| | | content = content.replace("{未签离数量}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | mobiles,SmsConstants.visitReport,content,0); |
| | | return; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void sendVisitTimeOutSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , |
| | | SmsConfigMapper smsConfigMapper, |
| | | String objCode, String msg,List<String> mobiles){ |
| | | try{ |
| | | SmsConfig smsConfig = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getCode, |
| | | objCode).last(" limit 1 ")); |
| | | //开启短信通知 |
| | | if(Objects.nonNull(smsConfig) || Constants.equalsInteger(smsConfig.getStatus(),Constants.ZERO)){ |
| | | String content = systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode() + smsConfig.getContent(); |
| | | //超时特殊处理 |
| | | if(smsConfig.getCode().equals(SmsConstants.visitContent.visitTimeOutSignOutNum)){ |
| | | //今日还有{未签离数量}个访客报备车辆未离场,请前往PC端查看详细信息。 |
| | | content = content.replace("{未签离数量}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | mobiles,SmsConstants.visit,content,0); |
| | | return; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | smsEmail.setObjId(objId); |
| | | smsEmailMapper.insert(smsEmail); |
| | | emayService.sendSmsByHk(phone,content); |
| | | |
| | | |
| | | } |
| | | } |
| | | |