Antiloveg 8 years ago
parent
commit
d7ed49c204

+ 4 - 1
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -5,6 +5,10 @@ public class AFTConstants {
 
 	public static final String	YYYYMMDD			= "yyyy-MM-dd";
 
+	public static final String	YYYY				= "yyyy";
+	
+	public static final String	MMDD				= "MM-dd";
+
 	public static final String	INITIALPASSWORD		= "123456";				// 初始密码
 
 	public static final String	SUPERADMIN			= "999999";				// 超级管理员
@@ -37,5 +41,4 @@ public class AFTConstants {
 
 	public static final int		CITYMAXNUM			= 999;
 
-
 }

+ 6 - 4
src/main/java/com/goafanti/common/mapper/PatentInfoMapper.xml

@@ -989,12 +989,14 @@
   </select>
   
   <select id="selectExpireRecord"  resultType="com.goafanti.patent.bo.PatentExpireBO">	
-  	select p.id, p.uid, p.patent_name as patentName, 
-  	       p.patent_application_date as patentApplicationDate, oi.first_mobile as firstMobile
+  	select 
+  		p.id, p.uid, p.patent_name as patentName, 
+  	    p.patent_application_date as patentApplicationDate, u.mobile
   	from patent_info p 
 		LEFT JOIN patent_cost pc on p.id = pc.pid
-		LEFT JOIN organization_identity oi on oi.uid = p.uid
-	where p.deleted_sign = 0 and p.patent_state in (12, 13)
+		LEFT JOIN user u on u.id = p.uid
+	where 
+		p.deleted_sign = 0 and p.patent_state in (12, 13)
 	and pc.annual_fee_state = 0
   </select>
   

+ 24 - 28
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -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);
 	}
 
 }

+ 7 - 7
src/main/java/com/goafanti/patent/bo/PatentExpireBO.java

@@ -26,9 +26,9 @@ public class PatentExpireBO {
 	private Date patentApplicationDate;
 	
 	/**
-	 * 第一联系人
+	 * 注册号码
 	 */
-	private String firstMobile;
+	private String mobile;
 
 	public String getId() {
 		return id;
@@ -62,14 +62,14 @@ public class PatentExpireBO {
 		this.patentApplicationDate = patentApplicationDate;
 	}
 
-	public String getFirstMobile() {
-		return firstMobile;
+	public String getMobile() {
+		return mobile;
 	}
 
-	public void setFirstMobile(String firstMobile) {
-		this.firstMobile = firstMobile;
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
 	}
-	
+
 	public String getPatentApplicationFormattedDate() {
 		if (this.patentApplicationDate == null) {
 			return null;