|
|
@@ -3,9 +3,11 @@ package com.goafanti.common.task;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
@@ -13,6 +15,7 @@ import javax.annotation.Resource;
|
|
|
import javax.mail.MessagingException;
|
|
|
|
|
|
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;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@@ -23,9 +26,12 @@ 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.NoticeMapper;
|
|
|
+import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.enums.PatentCategoryStatus;
|
|
|
import com.goafanti.common.error.BusinessException;
|
|
|
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.utils.LoggerUtils;
|
|
|
@@ -43,6 +49,8 @@ public class PatentTask {
|
|
|
private PatentNewService patentNewService;
|
|
|
@Resource
|
|
|
private AdminService adminService;
|
|
|
+ @Autowired
|
|
|
+ private NoticeMapper noticeMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -65,6 +73,7 @@ public class PatentTask {
|
|
|
LoggerUtils.debug(getClass(), "====================开始检查专利提醒==================");
|
|
|
try {
|
|
|
List<PatentNew> l=patentNewService.AllselectStartPatentNew();
|
|
|
+ List<Notice> nlist=new ArrayList<>();
|
|
|
for (PatentNew p : l) {
|
|
|
Calendar cst =Calendar.getInstance();
|
|
|
Calendar ced =Calendar.getInstance();
|
|
|
@@ -79,18 +88,29 @@ public class PatentTask {
|
|
|
ted.add(Calendar.YEAR,y);
|
|
|
//计算相差日期
|
|
|
int count = (int) ((ted.getTimeInMillis()-ced.getTimeInMillis()) / (1000*3600*24));
|
|
|
+ Notice n =new Notice();
|
|
|
+ n.setId(UUID.randomUUID().toString());
|
|
|
+ n.setNoticeType(NoticeStatus.ORDER_NO.getCode());
|
|
|
+ n.setCreateTime(new Date());
|
|
|
+ n.setReaded(0);//未读
|
|
|
+ n.setAid("1");
|
|
|
if (count>=0&&count<=90) {
|
|
|
Admin a=adminService.selectByPrimaryKey(p.getAid());
|
|
|
//设置如果找不到用户则提醒
|
|
|
+ String str2="aid="+p.getAid()+",名称="+p.getName()+",email="+p.getEmail();;
|
|
|
+ n.setContent(str2);
|
|
|
if(a==null) {
|
|
|
- EmailBo emailBo = new EmailBo( "专利提醒失败", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统", "专利提醒失败,aid="+p.getAid());
|
|
|
- try {
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
- } catch (UnsupportedEncodingException | MessagingException e1) {
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
+ EmailBo emailBo = new EmailBo( "专利提醒失败【账号】", AFTConstants.ADMIN_EMAIL,"超管", "平台", "系统",str2 );
|
|
|
+ SendEmailUtil.getInstance().send(emailBo);
|
|
|
+ nlist.add(n);
|
|
|
continue;
|
|
|
- }
|
|
|
+ }else if (!SendEmailUtil.isEmail(p.getEmail())) {
|
|
|
+ EmailBo emailBo = new EmailBo( "专利提醒失败【邮件】", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统",str2);
|
|
|
+ SendEmailUtil.getInstance().send(emailBo);
|
|
|
+ nlist.add(n);
|
|
|
+ continue;
|
|
|
+
|
|
|
+ }
|
|
|
//计算出年费金额,然后存入数据库
|
|
|
BigDecimal money=countMoney(y,p.getType());
|
|
|
if(StringUtils.isNotBlank(p.getEmail())){
|
|
|
@@ -106,14 +126,19 @@ public class PatentTask {
|
|
|
PatentNewLog pl=new PatentNewLog();
|
|
|
String str=StrToString("专利提醒",p.getEmail(), p.getApplicant(), a.getName(),p.getName(), p.getPatentNo(),
|
|
|
money.toString(), DateFormatUtils.format(ted, "yyyy-MM-dd"));
|
|
|
- System.out.println(str.toString());
|
|
|
- pl.setContent(str.toString());
|
|
|
+ pl.setContent(str);
|
|
|
pl.setCreateTime(new Date());
|
|
|
pl.setPid(p.getId());
|
|
|
patentNewService.addPatenNewLog(pl);
|
|
|
-
|
|
|
+ n.setAid(p.getAid());
|
|
|
+ n.setContent(str);
|
|
|
+ nlist.add(n);
|
|
|
+ Thread.sleep(2000);
|
|
|
}
|
|
|
}
|
|
|
+ if (!nlist.isEmpty()) {
|
|
|
+ noticeMapper.insertBatch(nlist);
|
|
|
+ }
|
|
|
List<PatentNew> ls=patentNewService.AllselectEndPatentNew();
|
|
|
for (PatentNew p : ls) {
|
|
|
Calendar cst =Calendar.getInstance();
|
|
|
@@ -136,11 +161,11 @@ public class PatentTask {
|
|
|
} catch (Exception e) {
|
|
|
LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
|
|
|
EmailBo emailBo = new EmailBo( "专利提醒失败", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统", "专利提醒失败");
|
|
|
- try {
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
- } catch (UnsupportedEncodingException | MessagingException e1) {
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
+ try {
|
|
|
+ SendEmailUtil.getInstance().send(emailBo);
|
|
|
+ } catch (UnsupportedEncodingException | MessagingException e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
@@ -152,7 +177,6 @@ public class PatentTask {
|
|
|
private String StrToString(String name, String email, String applicant, String adminName, String pantentName,
|
|
|
String pantentNo, String money, String format) {
|
|
|
StringBuilder str =new StringBuilder("");
|
|
|
-// str.append("专利提醒+"+p.getEmail()+"+"+ p.getApplicant()+"+"+ "科德集团"+"+"+ a.getName()+"+"+p.getName()+"+"+p.getPatentNo()+"+"+ money.toString()+"+"+ DateFormatUtils.format(ted, "yyyy-MM-dd"));
|
|
|
str.append(name).append(":").append("邮箱:").append(email).append(",授权公司:").append(applicant).append(",录入人:").append(adminName)
|
|
|
.append(",专利名称:").append(pantentName).append (",专利编号:").append(pantentNo).append(",金额:").append(money).append(",时间:").append(format);
|
|
|
return str.toString();
|
|
|
@@ -197,6 +221,10 @@ public class PatentTask {
|
|
|
|
|
|
return new BigDecimal(money);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param htmlStr
|
|
|
* @return
|