|
|
@@ -1,6 +1,5 @@
|
|
|
package com.goafanti.common.task;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
@@ -10,9 +9,7 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.mail.SendFailedException;
|
|
|
|
|
|
-import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
@@ -21,20 +18,16 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.goafanti.admin.service.AdminService;
|
|
|
-import com.goafanti.common.bo.EmailBo;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
-import com.goafanti.common.dao.UserMapper;
|
|
|
import com.goafanti.common.enums.NoticeStatus;
|
|
|
-import com.goafanti.common.enums.PatentCategoryStatus;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.Notice;
|
|
|
-import com.goafanti.common.model.PatentNew;
|
|
|
import com.goafanti.common.model.PatentNewLog;
|
|
|
-import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.utils.AsyncUtils;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.SendEmailUtil;
|
|
|
+import com.goafanti.patent.bo.PatentNewBo;
|
|
|
import com.goafanti.patent.service.PatentNewService;
|
|
|
|
|
|
|
|
|
@@ -49,8 +42,6 @@ public class PatentTask {
|
|
|
@Resource
|
|
|
private AdminService adminService;
|
|
|
@Autowired
|
|
|
- private UserMapper userMapper;
|
|
|
- @Autowired
|
|
|
private AsyncUtils asyncUtils;
|
|
|
|
|
|
|
|
|
@@ -79,26 +70,14 @@ public class PatentTask {
|
|
|
public void patentRemind() {
|
|
|
LoggerUtils.debug(getClass(), "====================开始检查专利提醒==================");
|
|
|
try {
|
|
|
- List<PatentNew> l = patentNewService.AllselectStartPatentNew();
|
|
|
+ List<PatentNewBo> l = patentNewService.AllselectStartPatentNew();
|
|
|
List<Notice> nlist = new ArrayList<>();
|
|
|
List<PatentNewLog> logList = new ArrayList<>();
|
|
|
- for (PatentNew p : l) {
|
|
|
- //因为改成数据关联字段修改
|
|
|
- String userName ="";
|
|
|
+ for (PatentNewBo p : l) {
|
|
|
|
|
|
- if (p.getUid()!=null) {
|
|
|
- User u =userMapper.selectByPrimaryKey(p.getUid());
|
|
|
- if (u!=null) {
|
|
|
- userName=u.getNickname();
|
|
|
- }else {
|
|
|
- userName=p.getApplicant();
|
|
|
- }
|
|
|
- }else {
|
|
|
- userName=p.getApplicant();
|
|
|
- }
|
|
|
// 申请时间
|
|
|
- Calendar sq = Calendar.getInstance();
|
|
|
- sq.setTime(p.getApplyDate());
|
|
|
+ Calendar end = Calendar.getInstance();
|
|
|
+ end.setTime(p.getEndDate());
|
|
|
Integer status = 0;
|
|
|
// 当前时间
|
|
|
Calendar now = Calendar.getInstance();
|
|
|
@@ -108,17 +87,8 @@ public class PatentTask {
|
|
|
now.clear(Calendar.MINUTE);
|
|
|
now.clear(Calendar.SECOND);
|
|
|
Date date=new Date();
|
|
|
- // 提醒
|
|
|
- Calendar ted = Calendar.getInstance();
|
|
|
- // 先获取到目前多少天数,再计算出年限
|
|
|
- int d = (int) ((now.getTimeInMillis() - sq.getTimeInMillis()) / (1000 * 3600 * 24));
|
|
|
- int y = d / 365;
|
|
|
- if (d % 365 > 0)
|
|
|
- y++;
|
|
|
- ted.setTime(sq.getTime());
|
|
|
- ted.add(Calendar.YEAR, y);
|
|
|
// 计算相差日期
|
|
|
- int count = (int) ((ted.getTimeInMillis() - now.getTimeInMillis()) / (1000 * 3600 * 24));
|
|
|
+ int count = (int) ((end.getTimeInMillis() - now.getTimeInMillis()) / (1000 * 3600 * 24));
|
|
|
Notice n = new Notice();
|
|
|
n.setId(UUID.randomUUID().toString());
|
|
|
n.setCreateTime(date);
|
|
|
@@ -153,7 +123,7 @@ public class PatentTask {
|
|
|
Admin a = adminService.selectByPrimaryKey(p.getAid());
|
|
|
StringBuffer str2 = new StringBuffer();
|
|
|
str2.append("专利编号=").append(p.getPatentNo()).append("名称=").append(p.getName()).append(",email=")
|
|
|
- .append(p.getEmail());
|
|
|
+ .append(p.getEmail().trim());
|
|
|
n.setContent(str2.toString());
|
|
|
if (a == null) {
|
|
|
str2.append(",aid=").append(p.getAid()).append(",找不到管理员。");
|
|
|
@@ -177,27 +147,9 @@ public class PatentTask {
|
|
|
nlist.add(n2);
|
|
|
continue;
|
|
|
} else {
|
|
|
- // 计算出年费金额,然后存入数据库
|
|
|
- BigDecimal money = countMoney(y, p.getType());
|
|
|
-
|
|
|
- EmailBo emailBo = new EmailBo("专利提醒", p.getEmail().trim(),userName, "科德集团", a.getName(),
|
|
|
- p.getName(), p.getPatentNo(), money.toString(), DateFormatUtils.format(ted, "yyyy-MM-dd"),status);
|
|
|
- n.setNoticeType(NoticeStatus.TASK_PATENT_REMIND.getCode());
|
|
|
- String title = "专利提醒成功!";
|
|
|
- p.setStatus(status);// 提醒中
|
|
|
- try {
|
|
|
- asyncUtils.patentSend(emailBo);
|
|
|
- } catch (SendFailedException e) {
|
|
|
- // 如果邮件发送失败提醒
|
|
|
- n.setNoticeType(NoticeStatus.TASK_PATENT_ERROR.getCode());
|
|
|
- title = "提醒失败!对方邮箱不存在或者拒收!";
|
|
|
- p.setStatus(0);
|
|
|
- }
|
|
|
- p.setPatentAmount(money);
|
|
|
- p.setYears(y);
|
|
|
- patentNewService.updatePatenNew(p);
|
|
|
+ String title = "提醒失败!对方邮箱不存在或者拒收!";
|
|
|
PatentNewLog pl = new PatentNewLog();
|
|
|
- String str = StrToString(title, p.getEmail().trim(), userName ,p.getName(),date,status);
|
|
|
+ String str = StrToString(title, p.getEmail().trim(), p.getUserName() ,p.getName(),date,status);
|
|
|
pl.setContent(str);
|
|
|
pl.setCreateTime(new Date());
|
|
|
pl.setPid(p.getId());
|
|
|
@@ -265,44 +217,7 @@ public class PatentTask {
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param 年份
|
|
|
- * @param 分类
|
|
|
- * @return 金额
|
|
|
- */
|
|
|
-
|
|
|
- private static BigDecimal countMoney(Integer y, Integer type) {
|
|
|
- int money=0;
|
|
|
- if (type==PatentCategoryStatus.INVENTION.getCode()) {
|
|
|
- if (y>0&&y<4) {
|
|
|
- money=900;
|
|
|
- }else if (y>3&&y<7) {
|
|
|
- money=1200;
|
|
|
- }else if (y>6&&y<10) {
|
|
|
- money=2000;
|
|
|
- }else if (y>9&&y<13) {
|
|
|
- money=4000;
|
|
|
- }else if (y>12&&y<16) {
|
|
|
- money=6000;
|
|
|
- }else if (y>15&&y<21) {
|
|
|
- money=8000;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (y>0&&y<4) {
|
|
|
- money=600;
|
|
|
- }else if (y>3&&y<6) {
|
|
|
- money=900;
|
|
|
- }else if (y>5&&y<9) {
|
|
|
- money=1200;
|
|
|
- }else if (y>8&&y<11) {
|
|
|
- money=2000;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return new BigDecimal(money);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -334,31 +249,5 @@ public class PatentTask {
|
|
|
htmlStr = delHTMLTag(htmlStr);
|
|
|
htmlStr = htmlStr.replaceAll(" ", "");
|
|
|
return htmlStr;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- // 申请时间一月份是0。
|
|
|
- Calendar sq = Calendar.getInstance();
|
|
|
- sq.set(2020, 7, 29);
|
|
|
- System.out.println(DateUtils.formatDate(sq.getTime(), AFTConstants.YYYYMMDD));
|
|
|
- // 当前时间
|
|
|
- Calendar now = Calendar.getInstance();
|
|
|
- now.setTime(new Date());
|
|
|
- now.set(Calendar.MILLISECOND, 0);
|
|
|
- // 提醒
|
|
|
- Calendar ted = Calendar.getInstance();
|
|
|
- // 先获取到目前多少天数,再计算出年限
|
|
|
- int d = (int) ((now.getTimeInMillis() - sq.getTimeInMillis()) / (1000 * 3600 * 24));
|
|
|
- System.out.println(d);
|
|
|
- int y = d / 365;
|
|
|
- if (d % 365 > 0)y++;
|
|
|
- System.out.println(y);
|
|
|
- ted.setTime(sq.getTime());
|
|
|
- ted.add(Calendar.YEAR, y);
|
|
|
- System.out.println(DateUtils.formatDate(ted.getTime(), AFTConstants.YYYYMMDD));
|
|
|
- // 计算相差日期
|
|
|
- int count = (int) ((ted.getTimeInMillis() - now.getTimeInMillis()) / (1000 * 3600 * 24));
|
|
|
- System.out.println(count);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|