|
|
@@ -9,10 +9,20 @@ import javax.annotation.Resource;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import com.aliyuncs.DefaultAcsClient;
|
|
|
+import com.aliyuncs.IAcsClient;
|
|
|
+import com.aliyuncs.exceptions.ClientException;
|
|
|
+import com.aliyuncs.exceptions.ServerException;
|
|
|
+import com.aliyuncs.profile.DefaultProfile;
|
|
|
+import com.aliyuncs.profile.IClientProfile;
|
|
|
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsRequest;
|
|
|
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsResponse;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.patent.bo.PatentExpireBO;
|
|
|
@@ -22,6 +32,12 @@ import com.goafanti.patent.service.PatentInfoService;
|
|
|
public class PatentTask {
|
|
|
@Resource
|
|
|
private PatentInfoService patentInfoService;
|
|
|
+
|
|
|
+ @Value(value = "${accessKey}")
|
|
|
+ private String accessKey = null;
|
|
|
+
|
|
|
+ @Value(value = "${accessSecret}")
|
|
|
+ private String accessSecret = null;
|
|
|
|
|
|
private static final String LEAP_DAY = "02-29";
|
|
|
|
|
|
@@ -37,11 +53,12 @@ public class PatentTask {
|
|
|
List<PatentExpireBO> peb = patentInfoService.selectExpireRecord();
|
|
|
if (null != peb && peb.size() > 0) {
|
|
|
for (PatentExpireBO p : peb) {
|
|
|
- if (StringUtils.isNotBlank(p.getMobile()) && StringUtils.isNumeric(p.getMobile())
|
|
|
+ String mobile = p.getMobile();
|
|
|
+ if (StringUtils.isNotBlank(mobile) && StringUtils.isNumeric(mobile)
|
|
|
&& null != p.getPatentApplicationDate()) {
|
|
|
try {
|
|
|
if (disposeExprire(p)) {
|
|
|
- // TODO 发送短信
|
|
|
+ sendMessage(mobile);
|
|
|
}
|
|
|
} catch (ParseException e) {
|
|
|
}
|
|
|
@@ -78,5 +95,26 @@ public class PatentTask {
|
|
|
return DateUtils.parseDate((Integer.parseInt(DateFormatUtils.format(s, AFTConstants.YYYY)) + 5) + "-"
|
|
|
+ DateFormatUtils.format(s, AFTConstants.MMDD), AFTConstants.YYYYMMDD);
|
|
|
}
|
|
|
+
|
|
|
+ private void sendMessage(String mobile){
|
|
|
+ IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecret);
|
|
|
+ try {
|
|
|
+ DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
|
|
|
+ } catch (ClientException e1) {
|
|
|
+ }
|
|
|
+ IAcsClient client = new DefaultAcsClient(profile);
|
|
|
+ SingleSendSmsRequest request = new SingleSendSmsRequest();
|
|
|
+ try {
|
|
|
+ request.setSignName("阿凡提信息科技");// {\"code\":\""+mobileVerifyCode+"\"}
|
|
|
+ request.setTemplateCode("SMS_37845022");
|
|
|
+ //request.setParamString("{\"code\":\"" + mobileVerifyCode + "\",\"product\":\"阿凡提信息科技\"}");
|
|
|
+ request.setRecNum(mobile);
|
|
|
+ SingleSendSmsResponse httpResponse = client.getAcsResponse(request);
|
|
|
+ } catch (ServerException e) {
|
|
|
+ LoggerUtils.fmtError(getClass(), e, "服务器端手机短信异常:%s", e.getMessage());
|
|
|
+ } catch (ClientException e) {
|
|
|
+ LoggerUtils.fmtError(getClass(), e, "客户端手机短信异常:%s", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|