Просмотр исходного кода

Merge branch 'test' of jishutao/kede-server into prod

anderx лет назад: 5
Родитель
Сommit
e58d1f40dc

+ 13 - 1
src/main/java/com/goafanti/common/model/Notice.java

@@ -53,7 +53,19 @@ public class Notice {
 	 */
 	private Integer year;
 	
-	
+	public Notice() {};
+//	Readed(0);//未读
+//	 n.setAid("1");
+//	 n.setNoticeType(NoticeStatus.TASK_PATENT_ERROR.getCode());
+//	 n
+	public Notice(String id,Date createTime,Integer readed,String aid,Integer noticeType,String content) {
+		this.id=id;
+		this.createTime=createTime;
+		this.readed=readed;
+		this.aid=aid;
+		this.noticeType=noticeType;
+		this.content=content;
+	};
 
 	public Integer getYear() {
 		return year;

+ 36 - 54
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -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(), "=====================专利提醒结束======================");

+ 11 - 2
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -4,14 +4,20 @@ import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.UUID;
+
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 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.model.Notice;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.SendEmailUtil;
@@ -26,6 +32,8 @@ public class ReleaseUserTask {
 	private CustomerService customerServiceImpl;
 	@Resource
 	private UserService userServiceImpl;
+	@Autowired
+	private NoticeMapper	noticeMapper;
 	
 	int pointsDataLimit=50;
 	
@@ -85,15 +93,16 @@ public class ReleaseUserTask {
 			if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);*/
 
 		} catch (Exception e) {
+			Notice n =new Notice(UUID.randomUUID().toString(),new Date(),0,"1",NoticeStatus.TASK_PATENT_ERROR.getCode(),"==============客户释放失败================");
+			 noticeMapper.insert(n);
 			EmailBo emailBo = new EmailBo( "释放客户失败",  AFTConstants.ADMIN_EMAIL,  "超管", "平台",  "系统", "释放客户失败");
 			try {
 				SendEmailUtil.getInstance().send(emailBo);
 			} catch (UnsupportedEncodingException | MessagingException e1) {
 				e1.printStackTrace();
 			}
-			LoggerUtils.error(getClass(), "=============================================");
+			LoggerUtils.error(getClass(), "====================客户释放失败=================");
 			LoggerUtils.error(getClass(), "客户释放失败", e);
-			LoggerUtils.error(getClass(), "=============================================");
 		}
 		LoggerUtils.debug(getClass(), "==============客户释放完成============");
 	}

+ 2 - 2
src/main/java/com/goafanti/common/utils/SendEmailUtil.java

@@ -63,7 +63,7 @@ public class SendEmailUtil {
         props.setProperty("mail.smtp.socketFactory.fallback", "false");// 注意是字符串的true,不是boolean类型的true
 		// 这一套是465端口
 		props.setProperty("mail.smtp.host", HOST);// 设置服务器地址
-		//props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);// 设置协议
+		props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);// 设置协议
 		props.setProperty("mail.smtp.port", PORT);// 设置端口
 		props.put("mail.smtp.auth", "true");// 注意是字符串的true,不是boolean类型的true
 
@@ -145,7 +145,7 @@ public class SendEmailUtil {
 	
 	
 	public static void main(String[] args) {
-		  EmailBo emailBo = new EmailBo( "专利提醒失败",  "mentos287@dingtalk.com",  "超管", "平台",  "系统", "专利提醒失败");
+		  EmailBo emailBo = new EmailBo( "专利提醒失败",  "312518615@qq.com",  "超管", "平台",  "系统", "专利提醒失败");
 				try {
 					SendEmailUtil.getInstance().send(emailBo);
 				} catch (UnsupportedEncodingException | MessagingException e) {

+ 2 - 1
src/main/java/com/goafanti/personnel/bo/OutPersonnelListBo.java

@@ -364,7 +364,8 @@ public class OutPersonnelListBo {
 	}
 	public Integer getWorkingYear() {
 		if (this.workingYear==null&& this.entryTime!=null) {
-			return getAgeByBirth(this.entryTime);
+			int wy=getAgeByBirth(this.entryTime);
+			return 0<wy?0:wy;
 		}
 		return workingYear;
 	}

+ 10 - 6
src/main/java/com/goafanti/personnel/service/impl/PersonnelServiceImpl.java

@@ -451,13 +451,17 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		m.setWelfareAnnexUrl(i.getAnnexUrl());
 		m.setWelfareAnnexName(i.getAnnexName());
 		m.setWelfareRemarks(i.getRemarks());
-		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
-		if (pm==null||pm.getId()==null) {
-			personnelMidMapper.insertSelective(m);
-		}else {
-			personnelMidMapper.updateByPrimaryKeySelective(m);
-			
+		if (m.getInsuranceStartTime()!=null||m.getFundStartTime()!=null||m.getEmployerStartTime()!=null||
+				m.getWelfareAnnexUrl()!=null||m.getWelfareRemarks()!=null) {
+			PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
+			if (pm==null||pm.getId()==null) {
+				personnelMidMapper.insertSelective(m);
+			}else {
+				personnelMidMapper.updateByPrimaryKeySelective(m);
+				
+			}
 		}
+		
 		return 1;
 	}
 }