|
|
@@ -1,8 +1,6 @@
|
|
|
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;
|
|
|
@@ -12,31 +10,26 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
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;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
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.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;
|
|
|
import com.goafanti.common.utils.SendEmailUtil;
|
|
|
-import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.patent.service.PatentNewService;
|
|
|
|
|
|
|
|
|
@@ -89,59 +82,53 @@ public class PatentTask {
|
|
|
//计算相差日期
|
|
|
int count = (int) ((ted.getTimeInMillis()-ced.getTimeInMillis()) / (1000*3600*24));
|
|
|
Notice n =new Notice();
|
|
|
- n.setId(UUID.randomUUID().toString());
|
|
|
- n.setCreateTime(new Date());
|
|
|
- n.setReaded(0);//未读
|
|
|
- n.setAid("1");
|
|
|
- n.setNoticeType(NoticeStatus.TASK_PATENT_ERROR.getCode());
|
|
|
+ n.setId(UUID.randomUUID().toString());
|
|
|
+ n.setCreateTime(new Date());
|
|
|
+ n.setReaded(0);//未读
|
|
|
+ n.setAid("1");
|
|
|
+ n.setNoticeType(NoticeStatus.TASK_PATENT_ERROR.getCode());
|
|
|
if (count>=0&&count<=90) {
|
|
|
Admin a=adminService.selectByPrimaryKey(p.getAid());
|
|
|
- //设置如果找不到用户则提醒
|
|
|
+ //设置如果找不到用户则提醒管理员
|
|
|
String str2="名称="+p.getName()+",email="+p.getEmail();;
|
|
|
n.setContent(str2);
|
|
|
if(a==null) {
|
|
|
- EmailBo emailBo = new EmailBo( "专利提醒失败【账号】", AFTConstants.ADMIN_EMAIL,"超管", "平台", "系统",str2 );
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
n.setContent(str2+",aid="+p.getAid());
|
|
|
nlist.add(n);
|
|
|
continue;
|
|
|
}else if (!SendEmailUtil.isEmail(p.getEmail())) {
|
|
|
- EmailBo emailBo = new EmailBo( "专利提醒失败【邮件】", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统",str2);
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
n.setContent(str2+",管理员="+a.getName());
|
|
|
- if (SendEmailUtil.isEmail(a.getEmail())) {
|
|
|
- emailBo = new EmailBo( "专利提醒失败【邮件】", a.getEmail(),"超管", "平台", "系统",str2 );
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
- }
|
|
|
+ nlist.add(n);
|
|
|
+ //再发一条给管理员
|
|
|
+ n.setAid(a.getId());
|
|
|
nlist.add(n);
|
|
|
continue;
|
|
|
-
|
|
|
+ }else {
|
|
|
+ //计算出年费金额,然后存入数据库
|
|
|
+ BigDecimal money=countMoney(y,p.getType());
|
|
|
+ ted.setTime(cst.getTime());
|
|
|
+ ted.add(Calendar.YEAR, y);
|
|
|
+ EmailBo emailBo = new EmailBo("专利提醒",p.getEmail(), p.getApplicant(), "科德集团", a.getName(),p.getName(), p.getPatentNo(), money.toString(), DateFormatUtils.format(ted, "yyyy-MM-dd"));
|
|
|
+ SendEmailUtil.getInstance().patentSend(emailBo);
|
|
|
+ p.setPatentAmount(money);
|
|
|
+ p.setStatus(1);//提醒中
|
|
|
+ p.setYears(y);
|
|
|
+ patentNewService.updatePatenNew(p);
|
|
|
+ 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"));
|
|
|
+ pl.setContent(str);
|
|
|
+ pl.setCreateTime(new Date());
|
|
|
+ pl.setPid(p.getId());
|
|
|
+ patentNewService.addPatenNewLog(pl);
|
|
|
+ n.setAid(p.getAid());
|
|
|
+ n.setContent(str);
|
|
|
+ n.setNoticeType(NoticeStatus.TASK_PATENT_REMIND.getCode());
|
|
|
+ nlist.add(n);
|
|
|
}
|
|
|
- //计算出年费金额,然后存入数据库
|
|
|
- BigDecimal money=countMoney(y,p.getType());
|
|
|
- if(StringUtils.isNotBlank(p.getEmail())){
|
|
|
- ted.setTime(cst.getTime());
|
|
|
- ted.add(Calendar.YEAR, y);
|
|
|
- EmailBo emailBo = new EmailBo("专利提醒",p.getEmail(), p.getApplicant(), "科德集团", a.getName(),p.getName(), p.getPatentNo(), money.toString(), DateFormatUtils.format(ted, "yyyy-MM-dd"));
|
|
|
- SendEmailUtil.getInstance().patentSend(emailBo);
|
|
|
- }
|
|
|
- p.setPatentAmount(money);
|
|
|
- p.setStatus(1);//提醒中
|
|
|
- p.setYears(y);
|
|
|
- patentNewService.updatePatenNew(p);
|
|
|
- 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"));
|
|
|
- pl.setContent(str);
|
|
|
- pl.setCreateTime(new Date());
|
|
|
- pl.setPid(p.getId());
|
|
|
- patentNewService.addPatenNewLog(pl);
|
|
|
- n.setAid(p.getAid());
|
|
|
- n.setContent(str);
|
|
|
- n.setNoticeType(NoticeStatus.TASK_PATENT_REMIND.getCode());
|
|
|
- nlist.add(n);
|
|
|
- Thread.sleep(2000);
|
|
|
+
|
|
|
}
|
|
|
+ Thread.sleep(2000);
|
|
|
}
|
|
|
if (!nlist.isEmpty()) {
|
|
|
noticeMapper.insertBatch(nlist);
|
|
|
@@ -160,21 +147,16 @@ public class PatentTask {
|
|
|
ted.add(Calendar.YEAR,y);
|
|
|
//计算相差日期
|
|
|
int count = (int) ((ted.getTimeInMillis()-ced.getTimeInMillis()) / (1000*3600*24));
|
|
|
- if (count>276) {
|
|
|
+ if (count>200) {
|
|
|
p.setStatus(0);//恢复待提醒
|
|
|
patentNewService.updatePatenNew(p);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
|
|
|
- EmailBo emailBo = new EmailBo( "专利提醒失败", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统", "专利提醒失败");
|
|
|
- try {
|
|
|
- SendEmailUtil.getInstance().send(emailBo);
|
|
|
- } catch (UnsupportedEncodingException | MessagingException e1) {
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
+ Notice n =new Notice(UUID.randomUUID().toString(),new Date(),0,"1",NoticeStatus.TASK_PATENT_ERROR.getCode(),"==============专利提醒失败================");
|
|
|
+ noticeMapper.insert(n);
|
|
|
e.printStackTrace();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
LoggerUtils.debug(getClass(), "=====================专利提醒结束======================");
|