|
|
@@ -15,10 +15,16 @@ import javax.mail.MessagingException;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
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.enums.PatentCategoryStatus;
|
|
|
+import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.PatentNew;
|
|
|
import com.goafanti.common.model.PatentNewLog;
|
|
|
@@ -31,8 +37,8 @@ import com.goafanti.report.bo.marketingESBo;
|
|
|
|
|
|
|
|
|
|
|
|
-@Component
|
|
|
-//@Controller
|
|
|
+//@Component
|
|
|
+@RestController
|
|
|
public class PatentTask {
|
|
|
@Resource
|
|
|
private PatentNewService patentNewService;
|
|
|
@@ -54,10 +60,11 @@ public class PatentTask {
|
|
|
|
|
|
|
|
|
|
|
|
- @Scheduled(cron = "0 0 0 * * ?")
|
|
|
-// @RequestMapping(value = "/open/patentRemind", method = RequestMethod.GET)
|
|
|
+// @Scheduled(cron = "0 0 0 * * ?")
|
|
|
+ @RequestMapping(value = "/open/patentRemind", method = RequestMethod.GET)
|
|
|
public void patentRemind() {
|
|
|
- LoggerUtils.debug(getClass(), "开始检查专利提醒");
|
|
|
+ LoggerUtils.debug(getClass(), "====================开始检查专利提醒==================");
|
|
|
+ try {
|
|
|
List<PatentNew> l=patentNewService.AllselectStartPatentNew();
|
|
|
for (PatentNew p : l) {
|
|
|
Calendar cst =Calendar.getInstance();
|
|
|
@@ -74,33 +81,24 @@ public class PatentTask {
|
|
|
//计算相差日期
|
|
|
int count = (int) ((ted.getTimeInMillis()-ced.getTimeInMillis()) / (1000*3600*24));
|
|
|
if (count>=0&&count<=90) {
|
|
|
- String content = null;
|
|
|
Admin a=adminService.selectByPrimaryKey(p.getAid());
|
|
|
//计算出年费金额,然后存入数据库
|
|
|
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"));
|
|
|
- try {
|
|
|
+ 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);
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
- } catch (MessagingException e) {
|
|
|
- LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
}
|
|
|
p.setPatentAmount(money);
|
|
|
p.setStatus(1);//提醒中
|
|
|
p.setYears(y);
|
|
|
patentNewService.updatePatenNew(p);
|
|
|
PatentNewLog pl=new PatentNewLog();
|
|
|
- pl.setContent(getTextFromHtml(content));
|
|
|
+ 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.setCreateTime(new Date());
|
|
|
pl.setPid(p.getId());
|
|
|
patentNewService.addPatenNewLog(pl);
|
|
|
@@ -126,11 +124,34 @@ public class PatentTask {
|
|
|
patentNewService.updatePatenNew(p);
|
|
|
}
|
|
|
}
|
|
|
+ throw new BusinessException("测试");
|
|
|
+ } catch (Exception e) {
|
|
|
+ LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
|
|
|
+ EmailBo emailBo = new EmailBo( "专利提醒失败", AFTConstants.ADMIN_EMAIL, "超管", "平台", "系统", "专利提醒失败");
|
|
|
+ try {
|
|
|
+ SendEmailUtil.getInstance().send(emailBo);
|
|
|
+ } catch (UnsupportedEncodingException | MessagingException e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
LoggerUtils.debug(getClass(), "=====================专利提醒结束======================");
|
|
|
}
|
|
|
|
|
|
|
|
|
+ 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();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param 年份
|