|
|
@@ -21,11 +21,11 @@ import com.goafanti.patent.service.PatentInfoService;
|
|
|
@Component
|
|
|
public class PatentTask {
|
|
|
@Resource
|
|
|
- private PatentInfoService patentInfoService;
|
|
|
-
|
|
|
- private static final String LEAP_DAY = "02-29";
|
|
|
-
|
|
|
- private static final String LEAP_DAY_ADD = "03-01";
|
|
|
+ private PatentInfoService patentInfoService;
|
|
|
+
|
|
|
+ private static final String LEAP_DAY = "02-29";
|
|
|
+
|
|
|
+ private static final String LEAP_DAY_ADD = "03-01";
|
|
|
|
|
|
/**
|
|
|
* "0 0 10 * * ?" 每天上午10点触发一次
|
|
|
@@ -37,11 +37,11 @@ public class PatentTask {
|
|
|
List<PatentExpireBO> peb = patentInfoService.selectExpireRecord();
|
|
|
if (null != peb && peb.size() > 0) {
|
|
|
for (PatentExpireBO p : peb) {
|
|
|
- if (!StringUtils.isBlank(p.getFirstMobile()) && StringUtils.isNumeric(p.getFirstMobile())
|
|
|
+ if (StringUtils.isNotBlank(p.getMobile()) && StringUtils.isNumeric(p.getMobile())
|
|
|
&& null != p.getPatentApplicationDate()) {
|
|
|
- try {
|
|
|
- if (disposeExprire(p)){
|
|
|
- //TODO 发送短信
|
|
|
+ try {
|
|
|
+ if (disposeExprire(p)) {
|
|
|
+ // TODO 发送短信
|
|
|
}
|
|
|
} catch (ParseException e) {
|
|
|
}
|
|
|
@@ -49,38 +49,34 @@ public class PatentTask {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private Boolean disposeExprire(PatentExpireBO peb) throws ParseException{
|
|
|
- Date addYear = disposeAddYear(peb.getPatentApplicationDate());//申请日5年后
|
|
|
+
|
|
|
+ private Boolean disposeExprire(PatentExpireBO peb) throws ParseException {
|
|
|
+ Date addYear = disposeAddYear(peb.getPatentApplicationDate());// 申请日5年后
|
|
|
Calendar now = Calendar.getInstance();
|
|
|
- if (addYear.getTime() - now.getTime().getTime() >= 0){
|
|
|
+ if (addYear.getTime() - now.getTime().getTime() >= 0) {
|
|
|
return disposeExprireDate(peb.getPatentApplicationDate(), now.getTime());
|
|
|
}
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
-
|
|
|
- private Boolean disposeExprireDate(Date apd, Date now){
|
|
|
- String sApd = DateFormatUtils.format(apd, AFTConstants.YYYYMMDD).substring(5,9);
|
|
|
- String sNow = DateFormatUtils.format(now, AFTConstants.YYYYMMDD).substring(5,9);
|
|
|
- if (LEAP_DAY.equals(sApd)){
|
|
|
- if (LEAP_DAY_ADD.equals(sNow)){
|
|
|
+
|
|
|
+ private Boolean disposeExprireDate(Date apd, Date now) {
|
|
|
+ String sApd = DateFormatUtils.format(apd, AFTConstants.MMDD);
|
|
|
+ String sNow = DateFormatUtils.format(now, AFTConstants.MMDD);
|
|
|
+ if (LEAP_DAY.equals(sApd)) {
|
|
|
+ if (LEAP_DAY_ADD.equals(sNow)) {
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
} else {
|
|
|
- if (sApd.equals(sNow)){
|
|
|
+ if (sApd.equals(sNow)) {
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
}
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
-
|
|
|
- private Date disposeAddYear(Date s) throws ParseException{
|
|
|
- String d = DateFormatUtils.format(s, AFTConstants.YYYYMMDD);
|
|
|
- String suffix = d.substring(4, 9);
|
|
|
- int year = Integer.parseInt(d.substring(0, 3));
|
|
|
- int expireYear = year + 5;
|
|
|
- String expireDate = expireYear + suffix;
|
|
|
- return DateUtils.parseDate(expireDate, AFTConstants.YYYYMMDD);
|
|
|
+
|
|
|
+ private Date disposeAddYear(Date s) throws ParseException {
|
|
|
+ return DateUtils.parseDate((Integer.parseInt(DateFormatUtils.format(s, AFTConstants.YYYY)) + 5) + "-"
|
|
|
+ + DateFormatUtils.format(s, AFTConstants.MMDD), AFTConstants.YYYYMMDD);
|
|
|
}
|
|
|
|
|
|
}
|