Commit b9b5efe4 authored by shiyu's avatar shiyu

短信发送

parent b9a930a7
......@@ -114,6 +114,11 @@ public interface CommConsts {
*/
public final static String SPECIAL_PERFORMANCE_URL = "/pages/saleSpecialList/index";
/**
* 小程序首页
*/
public final static String HOMEPAGE_URL = "/pages/home/index";
/**
* 消息跳转专场拍品详情
......
......@@ -11,6 +11,7 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.RedisUtils;
import com.wwdz.ch.core.util.StringArrayExcelReadListener;
import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.StringUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
......@@ -46,8 +47,8 @@ public class SendMsgFromExcelJob {
@Value("${spring.profiles.active}")
private String env;
// 每年8月13日晚上19点执行一次
@Scheduled(cron = "0 0 19 13 8 ?")
// 每年8月14日晚上19点执行一次
@Scheduled(cron = "0 20 19 14 8 ?")
public void executeTask() {
if ("dev".equals(env)) {
logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行给指定类目用户发送通知任务<<<<<<<<<<<<<<<<<<<<<");
......@@ -60,7 +61,7 @@ public class SendMsgFromExcelJob {
}
logger.info(">>>>>>>>>>>> sendMsgFromExcel 开始执行 <<<<<<<<<<<<");
try {
String key = "cq:sendMsgFromExcel:081319";
String key = "cqsh:sendMsgFromExcel:081419";
Date now = new Date();
if (redisUtils.hasKey(key)) {
String msg = "给指定类目用户发送通知任务正在重复执行";
......@@ -68,7 +69,7 @@ public class SendMsgFromExcelJob {
logger.info(">>>>>>>>>>>> sendMsgFromExcel 已经执行过了 <<<<<<<<<<<<");
return;
}
String fileName = "瓷器短信表.xlsx";
String fileName = "两个类目.xlsx";
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
StringArrayExcelReadListener listener = new StringArrayExcelReadListener();
ExcelReader reader = EasyExcelFactory.read(inputStream, listener).build();
......@@ -78,20 +79,29 @@ public class SendMsgFromExcelJob {
List<String> head = listener.getHead();
logger.info("excel title = {}", head);
List<List<String>> dataList = listener.getData();
logger.info(">>>>>>>>>> 瓷器类目 excel 读取数据 : {} 条", dataList.size());
dataList.stream().forEach(row -> {
String phone = row.get(0);
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + 32 + "&k=sms");
logger.info(">>>>>>>>>> 紫砂陶瓷-书画篆刻类目 excel 读取数据 : {} 条", dataList.size());
String url = wxAppletApi.getUrlLink(CommConsts.HOMEPAGE_URL,"");
dataList.parallelStream().forEach(row -> {
if (row != null) {
String name = row.get(0);
String phone = row.get(1);
String msg = null;
//发短信
String msg = "巧手裁云·神毫绘莲|景德镇瓷器专场开始啦,请前往"+ url + "查看";
if ("紫砂陶瓷".equals(name)) {
msg = "巧手裁云·神毫绘莲|景德镇瓷器专场开始啦,请前往"+ url + "查看";
} else if ("书画篆刻".equals(name)) {
msg = "如是画苑·中美协画家专场开始啦,请前往"+ url + "查看";
}
if (StringUtils.hasLength(msg)) {
aliSmsSender.sendSms(phone, msg);
logger.info("手机号: {}, 瓷器类目, 发送短信成功", phone);
logger.info("手机号: {}, msg: {}, 发送短信成功", phone, msg);
}
}
});
String successMsg = "给指定类目用户发送通知执行完成";
//发短信
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + 32 + "&k=sms");
String msg = "巧手裁云·神毫绘莲|景德镇瓷器专场开始啦,请前往"+ url + "查看";
aliSmsSender.sendSms("15757185512", msg);
aliSmsSender.sendSms("15757185512", successMsg);
redisUtils.set(key, now, 3600 * 24);
logger.info(">>>>>>>>>>>> sendMsgFromExcel 发送通知给指定用户定时任务执行完成 <<<<<<<<<<<<");
} catch (Exception e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment