Browse Source

定时任务处理

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

+ 10 - 0
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -81,6 +81,16 @@ public class PatentTask {
 			 int count = (int) ((ted.getTimeInMillis()-ced.getTimeInMillis()) / (1000*3600*24));
 			 if (count>=0&&count<=90) {
 					 Admin a=adminService.selectByPrimaryKey(p.getAid());
+					 //设置如果找不到用户则提醒
+					 if(a==null) {
+						 EmailBo emailBo = new EmailBo( "专利提醒失败",  AFTConstants.ADMIN_EMAIL,  "超管", "平台",  "系统", "专利提醒失败,aid="+p.getAid());
+							try {
+								SendEmailUtil.getInstance().send(emailBo);
+							} catch (UnsupportedEncodingException | MessagingException e1) {
+								e1.printStackTrace();
+							}
+							continue;
+					 }
 					 //计算出年费金额,然后存入数据库
 					 BigDecimal money=countMoney(y,p.getType());
 					 if(StringUtils.isNotBlank(p.getEmail())){

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

@@ -36,6 +36,7 @@ public class ReleaseUserTask {
 	@Scheduled(cron = "0 0 1  * * ?") 
 //	@RequestMapping(value = "/open/updateUser", method = RequestMethod.GET)
 	public void updateUser(){
+		LoggerUtils.debug(getClass(), "==============客户释放开始============");
 		Date releaseTime = new Date();
 		try {
 			List<User> userList = userServiceImpl.selectUserByRoleName("营销员","营销经理");
@@ -43,15 +44,18 @@ public class ReleaseUserTask {
 			List<LockingReleaseBo> lockBusinessList = new ArrayList<LockingReleaseBo>();
 			List<LockingReleaseBo> userTmpList = null;
 			List<LockingReleaseBo> businessTmpList = null;
-			for(User u : userList){
-				if(StringUtils.isNotBlank(u.getId())) {
-					userTmpList = customerServiceImpl.selectWaitReleaseCustomer(u.getId());
+			if (userList!=null&&!userList.isEmpty()) {
+				for(User u : userList){
+					if(StringUtils.isNotBlank(u.getId())) {
+						userTmpList = customerServiceImpl.selectWaitReleaseCustomer(u.getId());
 //					userTmpList = customerServiceImpl.selectWaitReleaseCustomer("1");
-					lockUserList.addAll(userTmpList);
-					businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
+						lockUserList.addAll(userTmpList);
+						businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
 //					businessTmpList = customerServiceImpl.selectWaitReleaseBusiness("1");
-					lockBusinessList.addAll(businessTmpList);
+						lockBusinessList.addAll(businessTmpList);
+					}
 				}
+				
 			}
 		List<LockingReleaseBo> newList=new ArrayList<LockingReleaseBo>();
 			  if (lockUserList.size()>0) {
@@ -91,6 +95,7 @@ public class ReleaseUserTask {
 			LoggerUtils.error(getClass(), "客户释放失败", e);
 			LoggerUtils.error(getClass(), "=============================================");
 		}
+		LoggerUtils.debug(getClass(), "==============客户释放完成============");
 	}
 	
 }