Commit 0389e938dcd9f30d8f5c3658683dfb625404f1b2

Authored by 王言钊
1 parent 92da8342

新增邮箱通知状态修改定时任务

src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
@@ -81,15 +81,17 @@ public class LiveApplyJob { @@ -81,15 +81,17 @@ public class LiveApplyJob {
81 } 81 }
82 82
83 /** 83 /**
84 - * 直播申请邮件通知 84 + * 直播申请邮件通知 五分钟一次
  85 + * 检测未通知的邮箱进行通知
85 */ 86 */
86 @Scheduled(fixedRate = 5 * 60 * 1000) 87 @Scheduled(fixedRate = 5 * 60 * 1000)
87 - public void liveApplyNotice() { 88 + public void autoLiveApplyEmailNotice() {
88 Example example = new Example(ShyLiveapply.class); 89 Example example = new Example(ShyLiveapply.class);
89 Criteria criteria = example.createCriteria(); 90 Criteria criteria = example.createCriteria();
  91 + //审核通过的
90 criteria.andEqualTo("shenhe_state", CommonConst.AUDIT_SUCCESS); 92 criteria.andEqualTo("shenhe_state", CommonConst.AUDIT_SUCCESS);
91 - //状态不等于已通知  
92 - criteria.andNotEqualTo("email_notice_state", CommonConst.NOTICE_SUCCESS); 93 + //状态等于未通知
  94 + criteria.andEqualTo("email_notice_state", CommonConst.NOTICE_INTT);
93 List<ShyLiveapply> shyLiveApplyList = shyLiveApplyMapper.selectByExample(example); 95 List<ShyLiveapply> shyLiveApplyList = shyLiveApplyMapper.selectByExample(example);
94 if (shyLiveApplyList.size() > 0) { 96 if (shyLiveApplyList.size() > 0) {
95 //开发者对应的id,与app_key相对应 97 //开发者对应的id,与app_key相对应
@@ -100,13 +102,11 @@ public class LiveApplyJob { @@ -100,13 +102,11 @@ public class LiveApplyJob {
100 String url = email_send_URL; 102 String url = email_send_URL;
101 List<ShyEmail> shyEmailList = emailService.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY); 103 List<ShyEmail> shyEmailList = emailService.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY);
102 logger.info("直播申请邮件通知开始,共" + shyLiveApplyList.size() + "个申请,每个申请通知" + shyEmailList.size() + "个邮箱"); 104 logger.info("直播申请邮件通知开始,共" + shyLiveApplyList.size() + "个申请,每个申请通知" + shyEmailList.size() + "个邮箱");
103 - int i = 0;  
104 for (ShyLiveapply liveApply : shyLiveApplyList) { 105 for (ShyLiveapply liveApply : shyLiveApplyList) {
105 logger.info("当前发送邮件的直播申请id为:" + liveApply.getId()); 106 logger.info("当前发送邮件的直播申请id为:" + liveApply.getId());
106 //初始化通知状态 107 //初始化通知状态
107 Integer noticeState = liveApply.getEmail_notice_state(); 108 Integer noticeState = liveApply.getEmail_notice_state();
108 //初始化通知消息 109 //初始化通知消息
109 - //String noticeMsg = liveApply.getEmail_notice_msg();  
110 StringBuilder noticeMsg = new StringBuilder(liveApply.getEmail_notice_msg()); 110 StringBuilder noticeMsg = new StringBuilder(liveApply.getEmail_notice_msg());
111 //显示spid简称 111 //显示spid简称
112 ShySites shySites = sitesService.findspidDescByspid(liveApply.getSp_id()); 112 ShySites shySites = sitesService.findspidDescByspid(liveApply.getSp_id());
@@ -124,7 +124,7 @@ public class LiveApplyJob { @@ -124,7 +124,7 @@ public class LiveApplyJob {
124 String emailAddr = shyEmail.getEmail(); 124 String emailAddr = shyEmail.getEmail();
125 String title = liveApply.getSpid_desc() + "新直播开播申请"; 125 String title = liveApply.getSpid_desc() + "新直播开播申请";
126 String templateId = "4017"; 126 String templateId = "4017";
127 - Map<String, String> emailparams = new HashMap<>(); 127 + Map<String, String> emailparams = new HashMap<>(16);
128 emailparams.put("appId", appId); 128 emailparams.put("appId", appId);
129 emailparams.put("emailAddr", emailAddr); 129 emailparams.put("emailAddr", emailAddr);
130 emailparams.put("title", title); 130 emailparams.put("title", title);
@@ -140,14 +140,12 @@ public class LiveApplyJob { @@ -140,14 +140,12 @@ public class LiveApplyJob {
140 if (result == null) { 140 if (result == null) {
141 noticeState = CommonConst.NOTICE_FAIL; 141 noticeState = CommonConst.NOTICE_FAIL;
142 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result为空"); 142 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result为空");
143 - i += 1;  
144 break; 143 break;
145 } 144 }
146 Integer code = result.getInteger("errorCode"); 145 Integer code = result.getInteger("errorCode");
147 if (code != 0) { 146 if (code != 0) {
148 noticeState = CommonConst.NOTICE_FAIL; 147 noticeState = CommonConst.NOTICE_FAIL;
149 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result返回消息为:").append(result.getString("errorMessage")); 148 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result返回消息为:").append(result.getString("errorMessage"));
150 - i += 1;  
151 break; 149 break;
152 } else { 150 } else {
153 noticeState = CommonConst.NOTICE_SUCCESS; 151 noticeState = CommonConst.NOTICE_SUCCESS;
@@ -157,30 +155,8 @@ public class LiveApplyJob { @@ -157,30 +155,8 @@ public class LiveApplyJob {
157 logger.info("异常结果为:{}", e.getMessage()); 155 logger.info("异常结果为:{}", e.getMessage());
158 noticeState = CommonConst.NOTICE_FAIL; 156 noticeState = CommonConst.NOTICE_FAIL;
159 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,服务器报错了"); 157 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,服务器报错了");
160 - i += 1;  
161 break; 158 break;
162 } 159 }
163 - //String taskId = "003_09";  
164 - //String signatureId = "0";  
165 - //Map<String, String> mobileparams = new HashMap<>(16);  
166 - //mobileparams.put("appId", appId);  
167 - //mobileparams.put("mobile", liveApply.getMobile());  
168 - //mobileparams.put("content", content.toString());  
169 - //mobileparams.put("taskId", taskId);  
170 - //mobileparams.put("signatureId", signatureId);  
171 - //httpUtil.setParamMap(mobileparams);  
172 - //if (i > shyEmailList.size() * 2) {  
173 - // Map<String, String> post = httpUtil.post(mobile_send_URL);  
174 - // logger.info("当前发送短信用户为:" + liveApply.getMobile() + ",发送短信的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));  
175 - // JSONObject result = JSONObject.parseObject(post.get("result"));  
176 - // Integer code = result.getInteger("errorCode");  
177 - // if (code == 0) {  
178 - // noticeState = CommonConst.NOTICE_SUCCESS;  
179 - // noticeMsg.append(noticeMsg).append("\n").append(dateTime).append("短信手机号").append(liveApply.getMobile()).append("(").append(liveApply.getSender()).append(")发送成功").toString();  
180 - // i = 0;  
181 - // }  
182 - // break;  
183 - //}  
184 } 160 }
185 liveApply.setEmail_notice_state(noticeState); 161 liveApply.setEmail_notice_state(noticeState);
186 liveApply.setEmail_notice_msg(noticeMsg.toString()); 162 liveApply.setEmail_notice_msg(noticeMsg.toString());
@@ -190,6 +166,29 @@ public class LiveApplyJob { @@ -190,6 +166,29 @@ public class LiveApplyJob {
190 } 166 }
191 167
192 /** 168 /**
  169 + * 每个小时执行一次,定时修改直播申请库中的邮箱通知状态
  170 + * 检测邮箱通知失败状态的邮箱状态改为未通知状态
  171 + */
  172 + @Scheduled(fixedRate = 60 * 60 * 1000)
  173 + public void autoLiveApplyEmailNoticeStateModify() {
  174 + Example example = new Example(ShyLiveapply.class);
  175 + Criteria criteria = example.createCriteria();
  176 + //审核通过的
  177 + criteria.andEqualTo("shenhe_state", CommonConst.AUDIT_SUCCESS);
  178 + //状态等于通知失败的
  179 + criteria.andEqualTo("email_notice_state", CommonConst.NOTICE_FAIL);
  180 + List<ShyLiveapply> shyLiveApplyList = shyLiveApplyMapper.selectByExample(example);
  181 + logger.info("邮箱通知失败的修改数量:{}", shyLiveApplyList.size());
  182 + for (ShyLiveapply shyLiveapply : shyLiveApplyList) {
  183 + if (CommonUtils.isNotNull(shyLiveapply)) {
  184 + //修改为未通知 继续发送
  185 + shyLiveapply.setEmail_notice_state(CommonConst.NOTICE_INTT);
  186 + liveApplyService.updateShyLiveApply(shyLiveapply);
  187 + }
  188 + }
  189 + }
  190 +
  191 + /**
193 * 自动退领 192 * 自动退领
194 * 每天0点执行 193 * 每天0点执行
195 */ 194 */
src/main/java/com/cnlive/shenhe/job/VideosJob.java
@@ -49,10 +49,10 @@ public class VideosJob { @@ -49,10 +49,10 @@ public class VideosJob {
49 /** 49 /**
50 * 定时向易盾发送视频抽帧图片进行检测 50 * 定时向易盾发送视频抽帧图片进行检测
51 * 机审 、未审核 、抽帧完成 进行送审 51 * 机审 、未审核 、抽帧完成 进行送审
52 - * 每天8点到23点执行,每分钟一次 52 + * 每天8点到23点执行,每分钟一次
53 */ 53 */
54 @Scheduled(cron = "0 0/3 8-23 * * ? ") 54 @Scheduled(cron = "0 0/3 8-23 * * ? ")
55 - public void videoFilter(){ 55 + public void videoFilter() {
56 ShyVideos shyVideos = new ShyVideos(); 56 ShyVideos shyVideos = new ShyVideos();
57 //审核类型为机审 57 //审核类型为机审
58 shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE); 58 shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);