Browse Source

订单任务修改

Signed-off-by: anderx <312518615@qq.com>
anderx 5 years ago
parent
commit
fc96147eb9

+ 1 - 1
src/main/java/com/goafanti/common/bo/EmailBo.java

@@ -64,7 +64,7 @@ public class EmailBo {
 		this.addressee = addressee;
 		this.deptname = deptname;
 		this.sender = sender;
-		setPatentFormat( addressee, sender, patentName, patentNo, amount, date);
+		this.content=setPatentFormat( addressee, sender, patentName, patentNo, amount, date);
 		
 		
 	}

+ 2 - 0
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -144,6 +144,8 @@ public class AFTConstants {
 	/** 领取员工上线 **/
 	public static final Integer USER_RCEIVE_MAX= 9;
 	
+	public static final String ADMIN_EMAIL= "anderx@dingtalk.com";
+	
 	
 	public static final String DEFAULT_CONTACT_TYPE="0";
 	

+ 6 - 0
src/main/java/com/goafanti/common/task/OrderDunTask.java

@@ -120,6 +120,12 @@ public class OrderDunTask {
 		}
   		LoggerUtils.debug(logger, "======================新催款任务轮询结束===================");
   		} catch (Exception e) {
+  			EmailBo emailBo = new EmailBo( "催款处理失败",  AFTConstants.ADMIN_EMAIL,  "超管", "平台",  "系统", "催款处理失败");
+			try {
+				SendEmailUtil.getInstance().send(emailBo);
+			} catch (UnsupportedEncodingException | MessagingException e1) {
+				e1.printStackTrace();
+			}
   			LoggerUtils.error(getClass(), "=============================================");
 			LoggerUtils.error(getClass(), "新催款的信息处理失败", e);
 			LoggerUtils.error(getClass(), "=============================================");

+ 40 - 19
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -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 年份

+ 13 - 0
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -1,13 +1,20 @@
 package com.goafanti.common.task;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import javax.annotation.Resource;
+import javax.mail.MessagingException;
+
 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.model.User;
 import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.common.utils.SendEmailUtil;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.customer.service.CustomerService;
@@ -74,6 +81,12 @@ public class ReleaseUserTask {
 			if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);*/
 
 		} catch (Exception e) {
+			EmailBo emailBo = new EmailBo( "释放客户失败",  AFTConstants.ADMIN_EMAIL,  "超管", "平台",  "系统", "释放客户失败");
+			try {
+				SendEmailUtil.getInstance().send(emailBo);
+			} catch (UnsupportedEncodingException | MessagingException e1) {
+				e1.printStackTrace();
+			}
 			LoggerUtils.error(getClass(), "=============================================");
 			LoggerUtils.error(getClass(), "客户释放失败", e);
 			LoggerUtils.error(getClass(), "=============================================");

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

@@ -89,7 +89,6 @@ public class SendEmailUtil {
 		// Session session = getSession();
 		// Instantiate a message
 		Message msg = new MimeMessage(session);
-
 		// Set message attributes
 		msg.setFrom(new InternetAddress(MimeUtility.encodeText(AUTH_USER_NICKNAME) +"<" +  FROM + ">"));
 //		msg.setFrom(new InternetAddress(FROM));
@@ -143,4 +142,9 @@ public class SendEmailUtil {
         return m.matches();
     }
 	
+	
+	public static void main(String[] args) {
+		
+	}
+	
 }

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

@@ -88,7 +88,6 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 	
 	@Override
 	public int addPersonnel(InputPersonnelBo i) {
-		personnelMidMapper.insertSelective(new PersonnelMid(i.getId()));
 		return personnelDossierMapper.insertSelective(i);
 	}
 
@@ -126,7 +125,13 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		m.setId(i.getId());
 		m.setEmergencyContact(pc.getEmergencyContact());
 		m.setEmergencyMobile(pc.getEmergencyMobile());
-		personnelMidMapper.updateByPrimaryKeySelective(m);
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getId());
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(m);
+		}else {
+			personnelMidMapper.updateByPrimaryKeySelective(m);
+			
+		}
 		
 		return 1;
 	}
@@ -153,7 +158,13 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		p.setId(i.getPdId());
 		p.setPromotionRemarks(i.getPromotionRemarks());
 		p.setPromotionTime(i.getPromotionTime());
-		personnelMidMapper.updateByPrimaryKeySelective(p);
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(p);
+		}else {
+			personnelMidMapper.updateByPrimaryKeySelective(p);
+			
+		}
 		return 1;
 	}
 
@@ -174,7 +185,13 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		p.setId(i.getPdId());
 		p.setContractStartTime(i.getStartTime());
 		p.setContractEndTime(i.getEndTime());
-		personnelMidMapper.updateByPrimaryKeySelective(p);
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(p);
+		}else {
+			personnelMidMapper.updateByPrimaryKeySelective(p);
+			
+		}
 		return 1;
 	}
 
@@ -198,7 +215,13 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		PersonnelMid p=new PersonnelMid();
 		p.setId(i.getPdId());
 		p.setQuitTime(i.getEffectTime());
-		personnelMidMapper.updateByPrimaryKeySelective(p);
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(p);
+		}else {
+			personnelMidMapper.updateByPrimaryKeySelective(p);
+			
+		}
 		return 1;
 	}
 
@@ -428,7 +451,13 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 		m.setWelfareAnnexUrl(i.getAnnexUrl());
 		m.setWelfareAnnexName(i.getAnnexName());
 		m.setWelfareRemarks(i.getRemarks());
-		personnelMidMapper.updateByPrimaryKeySelective(m);
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(m);
+		}else {
+			personnelMidMapper.updateByPrimaryKeySelective(m);
+			
+		}
 		return 1;
 	}
 }