BindPushJob.java
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//package com.sincere.quartz.job;
//
//import com.sincere.common.dto.smartCampus.BindPushDto;
//import com.sincere.common.dto.smartCampus.ParentDto;
//import com.sincere.common.enums.PushTypeEnums;
//import com.sincere.common.util.DateUtils;
//import com.sincere.quartz.feign.ScFeign;
//import com.sincere.quartz.model.ShortMsg;
//import com.sincere.quartz.service.SmsService;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * 用户注册激活提醒
// * @author chen
// * @version 1.0
// * @date 2019/12/10 0010 8:31
// */
//@Service
//public class BindPushJob {
//
// private Logger logger = LoggerFactory.getLogger(BindPushJob.class);
//
//
// @Autowired
// ScFeign scFeign;
//
// @Autowired
// SmsService smsService;
//
// private static Map<String , String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误
//
// @Scheduled(cron = "0 0-59 * * * ? ")
// public void bindPush(){
// Date nowDate = new Date();
// List<BindPushDto> schoolList = scFeign.selectBindPushSchool();
// for(BindPushDto school : schoolList){
// if(school.getBeginDate().compareTo(nowDate) <= 0 && school.getEndDate().compareTo(nowDate) >= 0){
// String lastDate = intervalDaysMap.get(school.getSchoolId()+"_"+school.getType());
// if(StringUtils.isBlank(lastDate)){
// //下发推送
// bindPush(school,nowDate);
// }else {
// int day = DateUtils.getDateDifference(nowDate,DateUtils.string2Date(lastDate,DateUtils.format1),"day") ;
// if(day == school.getIntervalDays() + 1) {
// //下发推送
// bindPush(school,nowDate);
// }
// }
// }
// }
// }
//
// private void bindPush(BindPushDto bindPushDto , Date nowDate){
// if(bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate,DateUtils.format4))){
// intervalDaysMap.put(bindPushDto.getSchoolId()+"_"+bindPushDto.getType(),DateUtils.date2String(nowDate,DateUtils.format1));
// //未关注
// List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId());
// logger.info(bindPushDto.getSchoolName()+"未关注人数"+unFollowList.size());
// for(ParentDto parentDto : unFollowList){
// sendMessage(parentDto,bindPushDto.getMsg());
// }
// //未绑定
// List<ParentDto> unBindList =scFeign.selectNotBind(bindPushDto.getSchoolId(),getThirdType(bindPushDto.getType()));
// logger.info(bindPushDto.getSchoolName()+"未绑定人数"+unBindList.size());
// for(ParentDto parentDto : unBindList){
// sendMessage(parentDto,bindPushDto.getMsg());
// }
// }
// }
//
// private void sendMessage(ParentDto parentDto , String message){
// //手机号为空
// if(StringUtils.isNotBlank(parentDto.getMobile())){
// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
// ShortMsg shortMsg = new ShortMsg();
// shortMsg.setTableName("smsNew"+tableSuffix);
// shortMsg.setSchoolId(parentDto.getSchoolId());
// shortMsg.setMobile(parentDto.getMobile());
// shortMsg.setMsg(message);
// smsService.insertSMS(shortMsg);
// logger.info("----学校Id---"+parentDto.getSchoolId() + "----手机号----"+parentDto.getMobile()+"---"+message);
// }
// }
//
// // 0是企业号,1是钉钉
// private int getThirdType(int type){
// if(type == 0){
// return PushTypeEnums.QIYEHAO.getType() ;
// }else {
// return PushTypeEnums.DING.getType() ;
// }
// }
//
//}