|
|
@@ -1,6 +1,7 @@
|
|
|
package com.goafanti.common.task;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -9,21 +10,33 @@ import javax.annotation.Resource;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
-import org.junit.Test;
|
|
|
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.model.PatentCost;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
+import com.goafanti.patent.bo.PatentAnnualFeeTaskBo;
|
|
|
import com.goafanti.patent.bo.PatentExpireBo;
|
|
|
+import com.goafanti.patent.service.PatentCostService;
|
|
|
import com.goafanti.patent.service.PatentInfoService;
|
|
|
|
|
|
@Component
|
|
|
public class PatentTask {
|
|
|
@Resource
|
|
|
private PatentInfoService patentInfoService;
|
|
|
+ @Resource
|
|
|
+ private PatentCostService patentCostService;
|
|
|
|
|
|
@Value(value = "${accessKey}")
|
|
|
private String accessKey = null;
|
|
|
@@ -36,57 +49,43 @@ public class PatentTask {
|
|
|
private static final String LEAP_DAY_ADD = "03-01";
|
|
|
|
|
|
/**
|
|
|
- * "0 0 6 * * ?" 每天上午6点触发一次
|
|
|
+ * "0 0 0 * * ?" 每天0点触发一次
|
|
|
*/
|
|
|
|
|
|
@Scheduled(cron = "0 0 0 * * ?")
|
|
|
public void exprireRun() {
|
|
|
LoggerUtils.debug(getClass(), "开始检查专利到期");
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ disposeExprireRecord(now);// 短信
|
|
|
+ disposeAnnualFee(now);// 年费状态
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disposeExprireRecord(Calendar now) {
|
|
|
List<PatentExpireBo> peb = patentInfoService.selectExpireRecord();
|
|
|
if (null != peb && peb.size() > 0) {
|
|
|
- //List<PatentCost> list = new ArrayList<PatentCost>();
|
|
|
for (PatentExpireBo p : peb) {
|
|
|
String mobile = p.getMobile();
|
|
|
- Date patentApplicationDate = p.getPatentApplicationDate();
|
|
|
if (StringUtils.isNotBlank(mobile) && StringUtils.isNumeric(mobile)
|
|
|
- && null != patentApplicationDate) {
|
|
|
- Calendar now = Calendar.getInstance();
|
|
|
+ && null != p.getPatentApplicationDate()) {
|
|
|
try {
|
|
|
if (disposeExprire(p, now)) {
|
|
|
//sendMessage(p);
|
|
|
- return;
|
|
|
}
|
|
|
-
|
|
|
} catch (ParseException e) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- /*List<PatentAnnualFeeTaskBo> af = patentInfoService.findAnnualFeeTaskBo();
|
|
|
- PatentCost cost = null;*/
|
|
|
- /*if (disposeExprireDate(patentApplicationDate, now.getTime())){
|
|
|
- cost = new PatentCost();
|
|
|
- cost.setId(p.getCostId());
|
|
|
- cost.setAnnualFeeState(PatentAnnualFeeStatus.);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private Boolean disposeExprire(PatentExpireBo peb, Calendar now) throws ParseException {
|
|
|
Date addYear = disposeAddYear(peb.getPatentApplicationDate());// 申请日5年后
|
|
|
if (addYear.getTime() - now.getTime().getTime() >= 0) {
|
|
|
- now.add(Calendar.MONTH, +3);//提前三个月
|
|
|
+ now.add(Calendar.MONTH, +3);// 提前三个月
|
|
|
return disposeExprireDate(peb.getPatentApplicationDate(), now.getTime());
|
|
|
}
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test(){
|
|
|
- Calendar now = Calendar.getInstance();
|
|
|
- now.add(Calendar.MONTH, -3);
|
|
|
- System.out.println(DateFormatUtils.format(now.getTime(), AFTConstants.MMDD));
|
|
|
- }
|
|
|
|
|
|
private Boolean disposeExprireDate(Date apd, Date now) {
|
|
|
String sApd = DateFormatUtils.format(apd, AFTConstants.MMDD);
|
|
|
@@ -108,7 +107,29 @@ public class PatentTask {
|
|
|
+ DateFormatUtils.format(s, AFTConstants.MMDD), AFTConstants.YYYYMMDD);
|
|
|
}
|
|
|
|
|
|
- /*private void sendMessage(PatentExpireBo p) {
|
|
|
+ private void disposeAnnualFee(Calendar now) {
|
|
|
+ List<PatentAnnualFeeTaskBo> af = patentInfoService.findAnnualFeeTaskBo();
|
|
|
+ if (af.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<PatentCost> list = new ArrayList<>();
|
|
|
+ for (PatentAnnualFeeTaskBo bo : af) {
|
|
|
+ PatentCost cost = null;
|
|
|
+ if (disposeExprireDate(bo.getPatentApplicationDate(), now.getTime())) {
|
|
|
+ cost = new PatentCost();
|
|
|
+ cost.setId(bo.getId());
|
|
|
+ list.add(cost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ patentCostService.batchUpdateByPrimaryKey(list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unused")
|
|
|
+ private void sendMessage(PatentExpireBo p) {
|
|
|
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecret);
|
|
|
try {
|
|
|
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
|
|
|
@@ -128,6 +149,6 @@ public class PatentTask {
|
|
|
} catch (ClientException e) {
|
|
|
LoggerUtils.fmtError(getClass(), e, "客户端手机短信异常:%s", e.getMessage());
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
}
|