短信
This commit is contained in:
parent
38a7f6cbbc
commit
5ce785f545
@ -269,6 +269,24 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 极光短信包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.jpush.api</groupId>
|
||||||
|
<artifactId>jiguang-common</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.jpush.api</groupId>
|
||||||
|
<artifactId>jsms-client</artifactId>
|
||||||
|
<version>1.2.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 其他工具包 -->
|
<!-- 其他工具包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.ruoyi.common.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class CommonConfig {
|
||||||
|
|
||||||
|
@Value("${sms.appkey}")
|
||||||
|
private String smsAppkey;
|
||||||
|
|
||||||
|
@Value("${sms.secret}")
|
||||||
|
private String smsSecret;
|
||||||
|
|
||||||
|
public String getSmsAppkey() {
|
||||||
|
return smsAppkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSmsAppkey(String smsAppkey) {
|
||||||
|
this.smsAppkey = smsAppkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSmsSecret() {
|
||||||
|
return smsSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSmsSecret(String smsSecret) {
|
||||||
|
this.smsSecret = smsSecret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,204 @@
|
|||||||
|
package com.ruoyi.common.service.impl;
|
||||||
|
|
||||||
|
import cn.jiguang.common.resp.APIConnectionException;
|
||||||
|
import cn.jiguang.common.resp.APIRequestException;
|
||||||
|
import cn.jsms.api.common.SMSClient;
|
||||||
|
import cn.jsms.api.common.model.SMSPayload;
|
||||||
|
import com.ruoyi.common.config.CommonConfig;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SMSService {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger (this.getClass ());
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommonConfig commonConfig;
|
||||||
|
|
||||||
|
private SMSClient client;
|
||||||
|
|
||||||
|
private static int registerTempId = 148418; // 注册模板
|
||||||
|
private static int loginTempId = 148417; // 登录模板
|
||||||
|
private static int regSucId = 152215; // 注册成功模板
|
||||||
|
private static int addEmpId = 151527; // 添加员工模板
|
||||||
|
private static int resetEmpPsw = 151221; // 重置员工密码模板
|
||||||
|
private static int applyId = 151637; // 报名验证码模板
|
||||||
|
private static int patriarchLoginId = 152601; // 家长端登录验证码模板
|
||||||
|
private static int publicCodeId = 154801;// 通用的验证码模板
|
||||||
|
private static int birthTeacher = 199895; // 教师生日祝福模板
|
||||||
|
private static int warn = 199897;// 平台剩余日期提醒模板
|
||||||
|
|
||||||
|
// private static int TEMP_TYPE_NOTICE = 2; // 通知类
|
||||||
|
// private static int TEMP_TYPE_AD = 3; // 营销类
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init () {
|
||||||
|
client = new SMSClient (commonConfig.getSmsSecret (), commonConfig.getSmsAppkey ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @Title: sendRegisterSMS
|
||||||
|
* @Description: 发送生日祝福
|
||||||
|
*/
|
||||||
|
public void sendBirthTeacherSMS (String mobile) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (birthTeacher)
|
||||||
|
.build ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @param days
|
||||||
|
* @Title: sendRegisterSMS
|
||||||
|
* @Description: 平台剩余日期提醒
|
||||||
|
*/
|
||||||
|
public void sendWarnSMS (String mobile,String days) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (warn)
|
||||||
|
.addTempPara("days",days).build ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @param code
|
||||||
|
* @Title: sendRegisterSMS
|
||||||
|
* @Description: 发送注册验证码
|
||||||
|
*/
|
||||||
|
public void sendRegisterSMS (String mobile, String code) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (registerTempId)
|
||||||
|
.addTempPara ("code", code).build ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @param code
|
||||||
|
* @Title: sendLoginSMS
|
||||||
|
* @Description: 发送登录验证码
|
||||||
|
*/
|
||||||
|
public void sendLoginSMS (String mobile, String code) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (loginTempId)
|
||||||
|
.addTempPara ("code", code).build ();
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile 接收手机号
|
||||||
|
* @Title: sendRegSucSMS
|
||||||
|
* @Description: 发送注册成功短信
|
||||||
|
*/
|
||||||
|
public void sendRegSucSMS (String mobile) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (regSucId).build ();
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile 接收手机号
|
||||||
|
* @param password 密码
|
||||||
|
* @Title: sendAddEmpSMS
|
||||||
|
* @Description: 发送添加员工成功短信
|
||||||
|
*/
|
||||||
|
public void sendAddEmpSMS (String mobile, String password) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (addEmpId)
|
||||||
|
.addTempPara ("userName", mobile)
|
||||||
|
.addTempPara ("password", password)
|
||||||
|
.build ();
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @param password
|
||||||
|
* @Title: sendResetEmpPswSMS
|
||||||
|
* @Description: 重置员工密码短信
|
||||||
|
*/
|
||||||
|
public void sendResetEmpPswSMS (String mobile, String password) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (resetEmpPsw)
|
||||||
|
.addTempPara ("password", password)
|
||||||
|
.build ();
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mobile
|
||||||
|
* @param code
|
||||||
|
* @Title: sendLoginSMS
|
||||||
|
* @Description: 发送登录验证码
|
||||||
|
*/
|
||||||
|
public void sendApplySMS (String mobile, String code) {
|
||||||
|
SMSPayload payload = SMSPayload.newBuilder ().setMobileNumber (mobile).setTempId (applyId)
|
||||||
|
.addTempPara ("code", code).build ();
|
||||||
|
try {
|
||||||
|
client.sendTemplateSMS (payload);
|
||||||
|
} catch (APIRequestException e) {
|
||||||
|
logger.error ("Error response from JPush server. Should review and fix it. ", e);
|
||||||
|
|
||||||
|
} catch (APIConnectionException e) {
|
||||||
|
logger.error ("Connection error. Should retry later. ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setClient (SMSClient client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,17 @@
|
|||||||
package com.ruoyi.framework.task;
|
package com.ruoyi.framework.task;
|
||||||
|
|
||||||
|
import com.ruoyi.common.service.impl.SMSService;
|
||||||
import com.ruoyi.project.benyi.domain.BySchoolNews;
|
import com.ruoyi.project.benyi.domain.BySchoolNews;
|
||||||
import com.ruoyi.project.benyi.service.IBySchoolNewsService;
|
import com.ruoyi.project.benyi.service.IBySchoolNewsService;
|
||||||
import com.ruoyi.project.bysite.domain.ByNews;
|
import com.ruoyi.project.bysite.domain.ByNews;
|
||||||
import com.ruoyi.project.bysite.service.IByNewsService;
|
import com.ruoyi.project.bysite.service.IByNewsService;
|
||||||
import com.ruoyi.project.common.SchoolCommon;
|
import com.ruoyi.project.common.SchoolCommon;
|
||||||
import com.ruoyi.project.system.domain.BySchool;
|
import com.ruoyi.project.system.domain.BySchool;
|
||||||
|
import com.ruoyi.project.system.domain.ByTeacherJbxx;
|
||||||
import com.ruoyi.project.system.domain.SysDept;
|
import com.ruoyi.project.system.domain.SysDept;
|
||||||
import com.ruoyi.project.system.domain.SysUser;
|
import com.ruoyi.project.system.domain.SysUser;
|
||||||
import com.ruoyi.project.system.service.IBySchoolService;
|
import com.ruoyi.project.system.service.IBySchoolService;
|
||||||
|
import com.ruoyi.project.system.service.IByTeacherJbxxService;
|
||||||
import com.ruoyi.project.system.service.ISysDeptService;
|
import com.ruoyi.project.system.service.ISysDeptService;
|
||||||
import com.ruoyi.project.system.service.ISysUserService;
|
import com.ruoyi.project.system.service.ISysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -38,6 +41,10 @@ public class RyTask {
|
|||||||
private IBySchoolNewsService iBySchoolNewsService;
|
private IBySchoolNewsService iBySchoolNewsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IByNewsService iByNewsService;
|
private IByNewsService iByNewsService;
|
||||||
|
@Autowired
|
||||||
|
private IByTeacherJbxxService iByTeacherJbxxService;
|
||||||
|
@Autowired
|
||||||
|
private SMSService smsService;
|
||||||
|
|
||||||
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
|
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
|
||||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||||
@ -110,6 +117,16 @@ public class RyTask {
|
|||||||
iBySchoolNewsService.updateBySchoolNews(newBySchoolNews);
|
iBySchoolNewsService.updateBySchoolNews(newBySchoolNews);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (params.equals("birthteacher")) {
|
||||||
|
System.out.println("birthteacher");
|
||||||
|
List<ByTeacherJbxx> list = iByTeacherJbxxService.selectByTeacherBrithList(null);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
String phone = list.get(i).getUser().getUserName();
|
||||||
|
smsService.sendBirthTeacherSMS(phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println("执行有参方法:" + params);
|
System.out.println("执行有参方法:" + params);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,14 @@ public interface ByTeacherJbxxMapper
|
|||||||
*/
|
*/
|
||||||
public List<ByTeacherJbxx> selectByTeacherJbxxList(ByTeacherJbxx byTeacherJbxx);
|
public List<ByTeacherJbxx> selectByTeacherJbxxList(ByTeacherJbxx byTeacherJbxx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询教师基本信息列表
|
||||||
|
*
|
||||||
|
* @param byTeacherJbxx 教师基本信息
|
||||||
|
* @return 教师基本信息集合
|
||||||
|
*/
|
||||||
|
public List<ByTeacherJbxx> selectByTeacherBrithList(ByTeacherJbxx byTeacherJbxx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询教师基本信息列表
|
* 查询教师基本信息列表
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,14 @@ public interface IByTeacherJbxxService
|
|||||||
*/
|
*/
|
||||||
public List<ByTeacherJbxx> selectByTeacherJbxxList(ByTeacherJbxx byTeacherJbxx);
|
public List<ByTeacherJbxx> selectByTeacherJbxxList(ByTeacherJbxx byTeacherJbxx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询教师基本信息列表
|
||||||
|
*
|
||||||
|
* @param byTeacherJbxx 教师基本信息
|
||||||
|
* @return 教师基本信息集合
|
||||||
|
*/
|
||||||
|
public List<ByTeacherJbxx> selectByTeacherBrithList(ByTeacherJbxx byTeacherJbxx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询教师基本信息列表
|
* 查询教师基本信息列表
|
||||||
*
|
*
|
||||||
|
@ -43,6 +43,17 @@ public class ByTeacherJbxxServiceImpl implements IByTeacherJbxxService {
|
|||||||
return byTeacherJbxxMapper.selectByTeacherJbxxList(byTeacherJbxx);
|
return byTeacherJbxxMapper.selectByTeacherJbxxList(byTeacherJbxx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询教师基本信息列表
|
||||||
|
*
|
||||||
|
* @param byTeacherJbxx 教师基本信息
|
||||||
|
* @return 教师基本信息集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ByTeacherJbxx> selectByTeacherBrithList(ByTeacherJbxx byTeacherJbxx) {
|
||||||
|
return byTeacherJbxxMapper.selectByTeacherBrithList(byTeacherJbxx);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询教师基本信息列表
|
* 查询教师基本信息列表
|
||||||
*
|
*
|
||||||
|
@ -135,3 +135,8 @@ wx:
|
|||||||
appid: wx0370c4756118456a
|
appid: wx0370c4756118456a
|
||||||
secret: f57143e81f3c95b0d909d91b3116cc82
|
secret: f57143e81f3c95b0d909d91b3116cc82
|
||||||
domain: https://api.weixin.qq.com/sns/oauth2/access_token
|
domain: https://api.weixin.qq.com/sns/oauth2/access_token
|
||||||
|
|
||||||
|
#jiguang
|
||||||
|
sms:
|
||||||
|
appkey: 438b95319ada13c8c6ffacfe
|
||||||
|
secret: c77c8aded1dd8c2fb083ebd3
|
||||||
|
@ -70,6 +70,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
${dataScope}
|
${dataScope}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectByTeacherBrithList" parameterType="ByTeacherJbxx" resultMap="ByTeacherJbxxResult">
|
||||||
|
select t.id, t.userid, t.zjhm, t.csrq, t.byyx, t.zy, t.xl, t.xw, t.cjgzrq, t.zgzs, t.createuserid, t.createtime,
|
||||||
|
u.user_id, u.nick_name, u.user_name from by_teacher_jbxx t left join sys_user u on t.userid=u.user_id
|
||||||
|
where MONTH(t.csrq) = MONTH(NOW()) and DAY(t.csrq) = DAY(NOW()) and u.del_flag='0' and u.status='0'
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectByTeacherJbGroupXw" parameterType="ByTeacherJbxx" resultMap="ByTeacherJbxxResult">
|
<select id="selectByTeacherJbGroupXw" parameterType="ByTeacherJbxx" resultMap="ByTeacherJbxxResult">
|
||||||
select (CASE WHEN (select dict_label from sys_dict_data where dict_type='sys_jsxl' and dict_value=t.xl ) is null THEN '未设置' ELSE (select dict_label from sys_dict_data where dict_type='sys_jsxl' and dict_value=t.xl ) END )xl,count(*) byyx
|
select (CASE WHEN (select dict_label from sys_dict_data where dict_type='sys_jsxl' and dict_value=t.xl ) is null THEN '未设置' ELSE (select dict_label from sys_dict_data where dict_type='sys_jsxl' and dict_value=t.xl ) END )xl,count(*) byyx
|
||||||
from by_teacher_jbxx t
|
from by_teacher_jbxx t
|
||||||
|
Loading…
x
Reference in New Issue
Block a user