Commit a2b43c864abdd847016fe7233b704f26b490ac0e

Authored by 王言钊
2 parents 49b0fd31 5d0a5ca1

Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
#	src/main/java/com/cnlive/shenhe/job/VideosJob.java
src/main/java/com/cnlive/shenhe/ShenheApplication.java
@@ -19,6 +19,7 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF @@ -19,6 +19,7 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF
19 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 19 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
20 import org.springframework.context.annotation.Bean; 20 import org.springframework.context.annotation.Bean;
21 import org.springframework.context.annotation.Configuration; 21 import org.springframework.context.annotation.Configuration;
  22 +import org.springframework.scheduling.annotation.EnableAsync;
22 import org.springframework.stereotype.Controller; 23 import org.springframework.stereotype.Controller;
23 import tk.mybatis.spring.annotation.MapperScan; 24 import tk.mybatis.spring.annotation.MapperScan;
24 25
@@ -29,6 +30,7 @@ import java.util.Map; @@ -29,6 +30,7 @@ import java.util.Map;
29 30
30 @SpringBootApplication 31 @SpringBootApplication
31 @MapperScan(basePackages = {"com.cnlive.shenhe.mapper"}) 32 @MapperScan(basePackages = {"com.cnlive.shenhe.mapper"})
  33 +@EnableAsync
32 public class ShenheApplication extends SpringBootServletInitializer { 34 public class ShenheApplication extends SpringBootServletInitializer {
33 /** 35 /**
34 * url的前缀 36 * url的前缀
src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
@@ -16,6 +16,7 @@ import org.slf4j.Logger; @@ -16,6 +16,7 @@ import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory; 16 import org.slf4j.LoggerFactory;
17 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.beans.factory.annotation.Value; 18 import org.springframework.beans.factory.annotation.Value;
  19 +import org.springframework.scheduling.annotation.Async;
19 import org.springframework.scheduling.annotation.Scheduled; 20 import org.springframework.scheduling.annotation.Scheduled;
20 import org.springframework.stereotype.Component; 21 import org.springframework.stereotype.Component;
21 import tk.mybatis.mapper.entity.Example; 22 import tk.mybatis.mapper.entity.Example;
@@ -29,6 +30,7 @@ import java.util.Map; @@ -29,6 +30,7 @@ import java.util.Map;
29 * @author Administrator 30 * @author Administrator
30 */ 31 */
31 @Component 32 @Component
  33 +@Async
32 public class LiveApplyJob { 34 public class LiveApplyJob {
33 35
34 private static Logger logger = LoggerFactory.getLogger(LiveApplyJob.class); 36 private static Logger logger = LoggerFactory.getLogger(LiveApplyJob.class);
@@ -49,6 +51,9 @@ public class LiveApplyJob { @@ -49,6 +51,9 @@ public class LiveApplyJob {
49 @Value("${email_send_URL}") 51 @Value("${email_send_URL}")
50 private String email_send_URL; 52 private String email_send_URL;
51 53
  54 + @Value("${mobile_send_URL}")
  55 + private String mobile_send_URL;
  56 +
52 @Autowired 57 @Autowired
53 SitesService sitesService; 58 SitesService sitesService;
54 @Autowired 59 @Autowired
@@ -95,6 +100,7 @@ public class LiveApplyJob { @@ -95,6 +100,7 @@ public class LiveApplyJob {
95 String url = email_send_URL; 100 String url = email_send_URL;
96 List<ShyEmail> shyEmailList = emailService.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY); 101 List<ShyEmail> shyEmailList = emailService.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY);
97 logger.info("直播申请邮件通知开始,共" + shyLiveApplyList.size() + "个申请,每个申请通知" + shyEmailList.size() + "个邮箱"); 102 logger.info("直播申请邮件通知开始,共" + shyLiveApplyList.size() + "个申请,每个申请通知" + shyEmailList.size() + "个邮箱");
  103 + int i = 0;
98 for (ShyLiveapply liveApply : shyLiveApplyList) { 104 for (ShyLiveapply liveApply : shyLiveApplyList) {
99 logger.info("当前发送邮件的直播申请id为:" + liveApply.getId()); 105 logger.info("当前发送邮件的直播申请id为:" + liveApply.getId());
100 //初始化通知状态 106 //初始化通知状态
@@ -117,15 +123,15 @@ public class LiveApplyJob { @@ -117,15 +123,15 @@ public class LiveApplyJob {
117 String emailAddr = shyEmail.getEmail(); 123 String emailAddr = shyEmail.getEmail();
118 String title = liveApply.getSpid_desc() + "新直播开播申请"; 124 String title = liveApply.getSpid_desc() + "新直播开播申请";
119 String templateId = "4017"; 125 String templateId = "4017";
120 - Map<String, String> params = new HashMap<>();  
121 - params.put("appId", appId);  
122 - params.put("emailAddr", emailAddr);  
123 - params.put("title", title);  
124 - params.put("content", content);  
125 - params.put("templateId", templateId);  
126 - params.put("sign", OpenUtil.sign(params, appKey)); 126 + Map<String, String> emailparams = new HashMap<>();
  127 + emailparams.put("appId", appId);
  128 + emailparams.put("emailAddr", emailAddr);
  129 + emailparams.put("title", title);
  130 + emailparams.put("content", content);
  131 + emailparams.put("templateId", templateId);
  132 + emailparams.put("sign", OpenUtil.sign(emailparams, appKey));
127 HttpUtil httpUtil = HttpUtil.init(); 133 HttpUtil httpUtil = HttpUtil.init();
128 - httpUtil.setParamMap(params); 134 + httpUtil.setParamMap(emailparams);
129 try { 135 try {
130 Map<String, String> post = httpUtil.post(url); 136 Map<String, String> post = httpUtil.post(url);
131 logger.info("当前发送邮件用户为:" + emailAddr + ",发送邮件的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result")); 137 logger.info("当前发送邮件用户为:" + emailAddr + ",发送邮件的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));
@@ -133,12 +139,14 @@ public class LiveApplyJob { @@ -133,12 +139,14 @@ public class LiveApplyJob {
133 if (result == null) { 139 if (result == null) {
134 noticeState = CommonConst.NOTICE_FAIL; 140 noticeState = CommonConst.NOTICE_FAIL;
135 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result为空"); 141 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result为空");
  142 + i += 1;
136 break; 143 break;
137 } 144 }
138 Integer code = result.getInteger("errorCode"); 145 Integer code = result.getInteger("errorCode");
139 if (code != 0) { 146 if (code != 0) {
140 noticeState = CommonConst.NOTICE_FAIL; 147 noticeState = CommonConst.NOTICE_FAIL;
141 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result返回消息为:").append(result.getString("errorMessage")); 148 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result返回消息为:").append(result.getString("errorMessage"));
  149 + i += 1;
142 break; 150 break;
143 } else { 151 } else {
144 noticeState = CommonConst.NOTICE_SUCCESS; 152 noticeState = CommonConst.NOTICE_SUCCESS;
@@ -148,8 +156,26 @@ public class LiveApplyJob { @@ -148,8 +156,26 @@ public class LiveApplyJob {
148 logger.info("异常结果为:{}", e.getMessage()); 156 logger.info("异常结果为:{}", e.getMessage());
149 noticeState = CommonConst.NOTICE_FAIL; 157 noticeState = CommonConst.NOTICE_FAIL;
150 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,服务器报错了"); 158 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,服务器报错了");
  159 + i += 1;
151 break; 160 break;
152 } 161 }
  162 + //String taskId = "003_01";
  163 + //String signatureId = "0";
  164 + //Map<String, String> mobileparams = new HashMap<>(16);
  165 + //mobileparams.put("appId", appId);
  166 + //mobileparams.put("mobile", liveApply.getMobile());
  167 + //mobileparams.put("content", content);
  168 + //mobileparams.put("taskId", taskId);
  169 + //mobileparams.put("signatureId", signatureId);
  170 + //httpUtil.setParamMap(mobileparams);
  171 + //if (i > 4) {
  172 + // Map<String, String> post = httpUtil.post(mobile_send_URL);
  173 + // logger.info("当前发送短信用户为:" + liveApply.getMobile() + ",发送短信的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));
  174 + // noticeState = CommonConst.NOTICE_SUCCESS;
  175 + // noticeMsg = noticeMsg + "\n" + dateTime + "短信手机号" + liveApply.getMobile() + "(" + liveApply.getSender() + ")发送成功";
  176 + // i = 0;
  177 + // break;
  178 + //}
153 } 179 }
154 liveApply.setEmail_notice_state(noticeState); 180 liveApply.setEmail_notice_state(noticeState);
155 liveApply.setEmail_notice_msg(noticeMsg.toString()); 181 liveApply.setEmail_notice_msg(noticeMsg.toString());
src/main/java/com/cnlive/shenhe/job/VideosJob.java
@@ -7,6 +7,7 @@ import com.cnlive.shenhe.utils.CommonConstStates; @@ -7,6 +7,7 @@ import com.cnlive.shenhe.utils.CommonConstStates;
7 import org.slf4j.Logger; 7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.scheduling.annotation.Async;
10 import org.springframework.scheduling.annotation.Scheduled; 11 import org.springframework.scheduling.annotation.Scheduled;
11 import org.springframework.stereotype.Component; 12 import org.springframework.stereotype.Component;
12 13
@@ -16,6 +17,7 @@ import java.util.List; @@ -16,6 +17,7 @@ import java.util.List;
16 * @author Administrator 17 * @author Administrator
17 */ 18 */
18 @Component 19 @Component
  20 +@Async
19 public class VideosJob { 21 public class VideosJob {
20 22
21 private static Logger logger = LoggerFactory.getLogger(VideosJob.class); 23 private static Logger logger = LoggerFactory.getLogger(VideosJob.class);
@@ -49,8 +51,8 @@ public class VideosJob { @@ -49,8 +51,8 @@ public class VideosJob {
49 * 机审 、未审核 、抽帧完成 进行送审 51 * 机审 、未审核 、抽帧完成 进行送审
50 * 每天8点到23点执行,每分钟一次 52 * 每天8点到23点执行,每分钟一次
51 */ 53 */
52 - @Scheduled(cron = "0 0/1 8-23 * * ? ")  
53 - public void videoFilter() { 54 + @Scheduled(cron = "0 0/3 8-23 * * ? ")
  55 + public void videoFilter(){
54 ShyVideos shyVideos = new ShyVideos(); 56 ShyVideos shyVideos = new ShyVideos();
55 //审核类型为机审 57 //审核类型为机审
56 shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE); 58 shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);
src/main/resources/application-dev.properties
@@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe @@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe
97 email_app_id=769_jetja50p18 97 email_app_id=769_jetja50p18
98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  100 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
100 101
101 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 qn_bucket=cnlivetest 103 qn_bucket=cnlivetest
src/main/resources/application-prod.properties
@@ -91,6 +91,7 @@ live_url=http://bc.cnlive.com/bokong/activity/activityShenHe @@ -91,6 +91,7 @@ live_url=http://bc.cnlive.com/bokong/activity/activityShenHe
91 email_app_id=769_jetja50p18 91 email_app_id=769_jetja50p18
92 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 92 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
93 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 93 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  94 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
94 95
95 96
96 qn_bucket=mam-sxzg-82 97 qn_bucket=mam-sxzg-82
src/main/resources/application-test.properties
@@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe @@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe
97 email_app_id=769_jetja50p18 97 email_app_id=769_jetja50p18
98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  100 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
100 101
101 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 qn_bucket=cnlivetest 103 qn_bucket=cnlivetest
src/main/resources/application.properties
@@ -22,6 +22,8 @@ server.tomcat.uri-encoding=UTF-8 @@ -22,6 +22,8 @@ server.tomcat.uri-encoding=UTF-8
22 spring.http.encoding.charset=UTF-8 22 spring.http.encoding.charset=UTF-8
23 spring.http.encoding.enabled=true 23 spring.http.encoding.enabled=true
24 spring.http.encoding.force=true 24 spring.http.encoding.force=true
  25 +#\u914D\u7F6EScheduled\u5B9A\u65F6\u4EFB\u52A1\u4E3A\u591A\u7EBF\u7A0B
  26 +spring.task.scheduling.pool.size=8
25 27
26 mybatis.mapper-locations=classpath:mapper/*.xml 28 mybatis.mapper-locations=classpath:mapper/*.xml
27 mybatis.type-aliases-package=com.cnlive.shenhe.entity 29 mybatis.type-aliases-package=com.cnlive.shenhe.entity
28 \ No newline at end of file 30 \ No newline at end of file