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 19 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
20 20 import org.springframework.context.annotation.Bean;
21 21 import org.springframework.context.annotation.Configuration;
  22 +import org.springframework.scheduling.annotation.EnableAsync;
22 23 import org.springframework.stereotype.Controller;
23 24 import tk.mybatis.spring.annotation.MapperScan;
24 25  
... ... @@ -29,6 +30,7 @@ import java.util.Map;
29 30  
30 31 @SpringBootApplication
31 32 @MapperScan(basePackages = {"com.cnlive.shenhe.mapper"})
  33 +@EnableAsync
32 34 public class ShenheApplication extends SpringBootServletInitializer {
33 35 /**
34 36 * url的前缀
... ...
src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
... ... @@ -16,6 +16,7 @@ import org.slf4j.Logger;
16 16 import org.slf4j.LoggerFactory;
17 17 import org.springframework.beans.factory.annotation.Autowired;
18 18 import org.springframework.beans.factory.annotation.Value;
  19 +import org.springframework.scheduling.annotation.Async;
19 20 import org.springframework.scheduling.annotation.Scheduled;
20 21 import org.springframework.stereotype.Component;
21 22 import tk.mybatis.mapper.entity.Example;
... ... @@ -29,6 +30,7 @@ import java.util.Map;
29 30 * @author Administrator
30 31 */
31 32 @Component
  33 +@Async
32 34 public class LiveApplyJob {
33 35  
34 36 private static Logger logger = LoggerFactory.getLogger(LiveApplyJob.class);
... ... @@ -49,6 +51,9 @@ public class LiveApplyJob {
49 51 @Value("${email_send_URL}")
50 52 private String email_send_URL;
51 53  
  54 + @Value("${mobile_send_URL}")
  55 + private String mobile_send_URL;
  56 +
52 57 @Autowired
53 58 SitesService sitesService;
54 59 @Autowired
... ... @@ -95,6 +100,7 @@ public class LiveApplyJob {
95 100 String url = email_send_URL;
96 101 List<ShyEmail> shyEmailList = emailService.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY);
97 102 logger.info("直播申请邮件通知开始,共" + shyLiveApplyList.size() + "个申请,每个申请通知" + shyEmailList.size() + "个邮箱");
  103 + int i = 0;
98 104 for (ShyLiveapply liveApply : shyLiveApplyList) {
99 105 logger.info("当前发送邮件的直播申请id为:" + liveApply.getId());
100 106 //初始化通知状态
... ... @@ -117,15 +123,15 @@ public class LiveApplyJob {
117 123 String emailAddr = shyEmail.getEmail();
118 124 String title = liveApply.getSpid_desc() + "新直播开播申请";
119 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 133 HttpUtil httpUtil = HttpUtil.init();
128   - httpUtil.setParamMap(params);
  134 + httpUtil.setParamMap(emailparams);
129 135 try {
130 136 Map<String, String> post = httpUtil.post(url);
131 137 logger.info("当前发送邮件用户为:" + emailAddr + ",发送邮件的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));
... ... @@ -133,12 +139,14 @@ public class LiveApplyJob {
133 139 if (result == null) {
134 140 noticeState = CommonConst.NOTICE_FAIL;
135 141 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result为空");
  142 + i += 1;
136 143 break;
137 144 }
138 145 Integer code = result.getInteger("errorCode");
139 146 if (code != 0) {
140 147 noticeState = CommonConst.NOTICE_FAIL;
141 148 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,result返回消息为:").append(result.getString("errorMessage"));
  149 + i += 1;
142 150 break;
143 151 } else {
144 152 noticeState = CommonConst.NOTICE_SUCCESS;
... ... @@ -148,8 +156,26 @@ public class LiveApplyJob {
148 156 logger.info("异常结果为:{}", e.getMessage());
149 157 noticeState = CommonConst.NOTICE_FAIL;
150 158 noticeMsg.append("\n").append(dateTime).append(" 邮件服务器调用失败,服务器报错了");
  159 + i += 1;
151 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 180 liveApply.setEmail_notice_state(noticeState);
155 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 7 import org.slf4j.Logger;
8 8 import org.slf4j.LoggerFactory;
9 9 import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.scheduling.annotation.Async;
10 11 import org.springframework.scheduling.annotation.Scheduled;
11 12 import org.springframework.stereotype.Component;
12 13  
... ... @@ -16,6 +17,7 @@ import java.util.List;
16 17 * @author Administrator
17 18 */
18 19 @Component
  20 +@Async
19 21 public class VideosJob {
20 22  
21 23 private static Logger logger = LoggerFactory.getLogger(VideosJob.class);
... ... @@ -49,8 +51,8 @@ public class VideosJob {
49 51 * 机审 、未审核 、抽帧完成 进行送审
50 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 56 ShyVideos shyVideos = new ShyVideos();
55 57 //审核类型为机审
56 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 97 email_app_id=769_jetja50p18
98 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 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 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 103 qn_bucket=cnlivetest
... ...
src/main/resources/application-prod.properties
... ... @@ -91,6 +91,7 @@ live_url=http://bc.cnlive.com/bokong/activity/activityShenHe
91 91 email_app_id=769_jetja50p18
92 92 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
93 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 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 97 email_app_id=769_jetja50p18
98 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 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 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 103 qn_bucket=cnlivetest
... ...
src/main/resources/application.properties
... ... @@ -22,6 +22,8 @@ server.tomcat.uri-encoding=UTF-8
22 22 spring.http.encoding.charset=UTF-8
23 23 spring.http.encoding.enabled=true
24 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 28 mybatis.mapper-locations=classpath:mapper/*.xml
27 29 mybatis.type-aliases-package=com.cnlive.shenhe.entity
28 30 \ No newline at end of file
... ...