| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; |
| | | 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.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.SmsConstants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.PlatformBooksMapper; |
| | | import com.doumee.dao.business.PlatformJobMapper; |
| | | import com.doumee.dao.business.SmsConfigMapper; |
| | | import com.doumee.dao.business.SmsEmailMapper; |
| | | 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 com.doumee.service.business.third.EmayService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 短信邮件信息表Service实现 |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private EmayService emayService; |
| | | @Autowired |
| | | private SmsConfigMapper smsConfigMapper; |
| | | |
| | | @Value("${debug_model}") |
| | | private boolean debugModel; |
| | | |
| | | public static void isCaptcheValide(SmsEmailMapper smsEmailMapper, String phone, String captche) { |
| | | public static void isCaptcheValide(com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper, String phone, String captche) { |
| | | SmsEmail model = smsEmailMapper.selectOne(new QueryWrapper<SmsEmail>().lambda() |
| | | .eq(SmsEmail::getType, Constants.ZERO) |
| | | .eq(SmsEmail::getPhone, phone) |
| | |
| | | smsEmailMapper.updateById(model); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Integer create(SmsEmail smsEmail) { |
| | | smsEmailMapper.insert(smsEmail); |
| | |
| | | )>=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); |
| | | if(!result){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,短信验证码发送失败,请稍后重试!"); |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 访客申请业务短信通知 |
| | | * @param systemDictDataBiz |
| | | * @param emayService |
| | | * @param smsEmailMapper |
| | | * @param smsConfigMapper |
| | | * @param visitsMapper |
| | | * @param objId |
| | | * @param objCode |
| | | * @param msg |
| | | * @param auditUser |
| | | */ |
| | | public static void sendVisitSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | VisitsMapper visitsMapper, Integer objId, String objCode, String msg, List<String> auditUser){ |
| | | 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(); |
| | | Visits visits = visitsMapper.selectById(objId); |
| | | if(Objects.nonNull(visits)){ |
| | | if(objCode.equals(SmsConstants.visitContent.visitAuditSuccess)){ |
| | | //您的【访客申请】已经审批通过,请于{预约入园开始时间}前往门卫室访客机签到入园,如有疑问,请联系被访人 |
| | | content = content.replace("{预约入园开始时间}",DateUtil.getFomartDate(visits.getStarttime(),"yyyy-MM-dd HH:mm")); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visit,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitContent.visitAuditFail)){ |
| | | //您的【访客申请】已被驳回,驳回原因为:{驳回原因}。如有疑问,请联系被访人。 |
| | | content = content.replace("{驳回原因}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visit,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitContent.visitTimeOutSignOut)){ |
| | | //您的【访客申请】已于{到期时间}到期,请及时离场并前往门卫室访客机签离,如有疑问,请联系被访人 |
| | | content = content.replace("{到期时间}",DateUtil.getFomartDate(visits.getEndtime(),"yyyy-MM-dd HH:mm")); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visit,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitContent.visitTimeOutSignOutNum)) { |
| | | //今日还有{未签离数量}个访客未签离,请前往PC端查看详细信息。 |
| | | content = content.replace("{未签离数量}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visit,content,visits.getId()); |
| | | }else{ |
| | | //您有一条【车辆入园申请】需要处理,详细信息请前往微信公众号查看。 |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | auditUser,SmsConstants.platformBook,content,visits.getId()); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 访客报备业务短信通知 |
| | | * @param systemDictDataBiz |
| | | * @param emayService |
| | | * @param smsEmailMapper |
| | | * @param smsConfigMapper |
| | | * @param visitsMapper |
| | | * @param objId |
| | | * @param objCode |
| | | * @param msg |
| | | * @param auditUser |
| | | */ |
| | | public static void sendVisitReportSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | VisitsMapper visitsMapper, Integer objId, String objCode, String msg, List<String> auditUser){ |
| | | 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(); |
| | | Visits visits = visitsMapper.selectById(objId); |
| | | if(Objects.nonNull(visits)){ |
| | | if(objCode.equals(SmsConstants.visitReportingContent.visitReportingAuditSuccess)){ |
| | | // 您的【访客报备】已经审批通过,请通知访客于{预约入园开始时间}后乘坐{车牌号}入园,如有疑问,请联系被访人。 |
| | | content = content.replace("{预约入园开始时间}",DateUtil.getFomartDate(visits.getStarttime(),"yyyy-MM-dd HH:mm")) |
| | | .replace("{车牌号}",visits.getCarNos()); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visitReport,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitReportingContent.visitReportingAuditFail)){ |
| | | //您的【访客报备】已被驳回,驳回原因为:{驳回原因}。如有疑问,请联系审批人。 |
| | | content = content.replace("{驳回原因}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visitReport,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitReportingContent.visitReportingTimeOutSignOut)){ |
| | | //您的【访客报备】已于{预约入园结束时间}到期,请及时离场,如有疑问,请联系被访人 |
| | | content = content.replace("{预约入园结束时间}",DateUtil.getFomartDate(visits.getEndtime(),"yyyy-MM-dd HH:mm")); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visitReport,content,visits.getId()); |
| | | }else if(objCode.equals(SmsConstants.visitReportingContent.visitReportingTimeOutSignOutNum)) { |
| | | //今日还有{未签离数量}个访客报备车辆未离场,请前往PC端查看详细信息。 |
| | | content = content.replace("{未签离数量}",msg); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(visits.getPhone().split(",")),SmsConstants.visitReport,content,visits.getId()); |
| | | }else{ |
| | | //您有一条【车辆入园申请】需要处理,详细信息请前往微信公众号查看。 |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | auditUser,SmsConstants.platformBook,content,visits.getId()); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 隐患随手拍 |
| | | * @param systemDictDataBiz |
| | | * @param emayService |
| | | * @param smsEmailMapper |
| | | * @param smsConfigMapper |
| | | * @param hiddenDangerMapper |
| | | * @param objId |
| | | * @param objCode |
| | | * @param auditUser |
| | | */ |
| | | public static void sendHiddenDangerSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | HiddenDangerMapper hiddenDangerMapper, Integer objId, String objCode, List<String> auditUser){ |
| | | 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(); |
| | | HiddenDanger hiddenDanger = hiddenDangerMapper.selectById(objId); |
| | | //您有一条【隐患随手拍-消防隐患】需要处理,详细信息请前往微信公众号查看 |
| | | //您提交的【隐患随手拍-消防隐患】已经处理完毕,详细信息请前往微信公众号查看。 |
| | | if(Objects.nonNull(hiddenDanger)){ |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | auditUser,SmsConstants.platformBook,content,hiddenDanger.getId()); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用车申请 短信通知配置 |
| | | * 用车申请 |
| | | * @param systemDictDataBiz |
| | | * @param emayService |
| | | * @param smsEmailMapper |
| | | * @param smsConfigMapper |
| | | * @param carUseBookMapper |
| | | * @param objId |
| | | * @param objCode |
| | | * @param msg |
| | | * @param userList |
| | | */ |
| | | public static void sendCarUseSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | CarUseBookMapper carUseBookMapper, Integer objId, String objCode, String msg, List<String> userList){ |
| | | //您有一条【用车申请】需要处理,详细信息请前往微信公众号查看。 |
| | | 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(); |
| | | CarUseBook carUseBook = carUseBookMapper.selectById(objId); |
| | | if(Objects.nonNull(carUseBook)){ |
| | | if(objCode.equals(SmsConstants.carUseBookContent.carUseBookAuditSuccess)){ |
| | | //您的【用车申请】已经审批通过,出发时间为{提交的出发时间},请按时用车。如用车计划有变,请及时联系派车员。 |
| | | content = content.replace("{提交的出发时间}",DateUtil.getFomartDate(carUseBook.getStartTime(),"yyyy-MM-dd HH:mm")); |
| | | }else if(objCode.equals(SmsConstants.carUseBookContent.carUseBookAuditFail) || objCode.equals(SmsConstants.carUseBookContent.carUseBookCancel)){ |
| | | //您的【用车申请】已被驳回,驳回原因为:{驳回原因}。如有疑问,请联系派车员。 |
| | | content = content.replace("{驳回原因}",msg); |
| | | //您的【用车申请】已被取消,取消原因为:{取消原因}。如有疑问,请联系派车员。 |
| | | content = content.replace("{取消原因}",msg); |
| | | } |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | userList,SmsConstants.carUse,content,carUseBook.getId()); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 物流车预约 短信通知配置 |
| | | * @param emayService |
| | | * @param smsEmailMapper |
| | | * @param smsConfigMapper |
| | |
| | | * @param msg |
| | | * @param auditUser |
| | | */ |
| | | public static void sendPlatformBookSms(SystemDictDataBiz systemDictDataBiz,EmayService emayService ,SmsEmailMapper smsEmailMapper ,SmsConfigMapper smsConfigMapper, |
| | | PlatformBooksMapper platformBooksMapper,Integer objId,String objCode,String msg,List<String> auditUser){ |
| | | public static void sendPlatformBookSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | PlatformBooksMapper platformBooksMapper, Integer objId, String objCode, String msg, List<String> auditUser){ |
| | | try{ |
| | | SmsConfig smsConfig = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getCode, |
| | | objCode).last(" limit 1 ")); |
| | |
| | | if(Objects.nonNull(platformBooks)){ |
| | | if(objCode.equals(SmsConstants.platformBookContent.platformBookAuditSuccess)){ |
| | | //您的【车辆入园申请】已经审批通过,入园时间为{入园时间},请提前30分钟前往现场签到。如计划有变,请及时联系审核人员。 |
| | | content = content.replace("{入园时间}",DateUtil.getDate(platformBooks.getArriveDate(),"yyyy-MM-dd HH:mm")); |
| | | content = content.replace("{入园时间}",DateUtil.getFomartDate(platformBooks.getArriveDate(),"yyyy-MM-dd HH:mm")); |
| | | sendBusinessSms(emayService,smsEmailMapper, |
| | | Arrays.asList(platformBooks.getDriverPhone().split(",")),SmsConstants.platformBook,content,platformBooks.getId()); |
| | | }else if(objCode.equals(SmsConstants.platformBookContent.platformBookAuditFail) || objCode.equals(SmsConstants.platformBookContent.platformBookCancel)){ |
| | |
| | | * @param objCode |
| | | * @param platformName |
| | | */ |
| | | public static void sendPlatformJobSms(SystemDictDataBiz systemDictDataBiz,EmayService emayService , SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | PlatformJobMapper platformJobMapper, Integer objId, String objCode, String platformName,String newPlatformName){ |
| | | public static void sendPlatformJobSms(SystemDictDataBiz systemDictDataBiz, EmayService emayService , com.doumee.dao.business.dao.SmsEmailMapper smsEmailMapper , SmsConfigMapper smsConfigMapper, |
| | | PlatformJobMapper platformJobMapper, Integer objId, String objCode, String platformName, String newPlatformName){ |
| | | //platformJobNewJob {车牌号}车主您好,您有一个新的运输任务,详细信息请前往微信公众号查看。 |
| | | //platformJobStopJob {车牌号}车主您好,您的运输任务已被取消,详细信息请前往微信公众号查看。 |
| | | //platformJobCallIn {车牌号}车主您好,请在10分钟内,前往园区等待区等待叫号作业。 |
| | |
| | | smsEmail.setObjType(objType); |
| | | smsEmail.setObjId(objId); |
| | | smsEmailMapper.insert(smsEmail); |
| | | emayService.sendSingleSms(phone,content); |
| | | |
| | | emayService.sendSmsByHk(phone,content); |
| | | } |
| | | } |
| | | |