Browse Source

定时任务修改

anderx 1 year ago
parent
commit
50ff48ea2f

+ 21 - 7
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -385,6 +385,13 @@
 	 left join user u on t0.uid=u.id  left join user_mid um on t0.uid=um.uid
 	where u.channel=0
 	 and datediff(now(),if(t0.lock_time < um.last_follow_time,um.last_follow_time,t0.lock_time))>30
+    UNION
+    SELECT t0.id, t0.uid, t0.aid, DATE_FORMAT(t0.lock_time , '%Y-%m-%d') lockTime,u.new_channel newChannel,
+           um.last_follow_time lastFollowTime,u.nickname userName ,um.channel_type channelType,u.share_type shareType
+    from (select id,uid,aid,lock_time from user_lock_release where aid = #{aid} and type = 0 and status = 0)t0
+      left join `user` u  on t0.uid=u.id left join user_mid um on u.id =um.uid
+    where u.share_type in(0) and  u.channel=0 and u.new_channel=0
+      and datediff(now(),u.transfer_time) > 270
   </select>
 
   <select id="selectWaitReleaseBusiness"  resultType="com.goafanti.customer.bo.LockingReleaseBo">
@@ -440,13 +447,20 @@
   </select>
 
   <select id="selectUserDays" resultType="com.goafanti.common.bo.userDaysBo">
-      SELECT u.id uid,u.aid,u.nickname name, u.channel ,u.share_type type,u.new_channel newChannel
-      from `user` u left join user_mid um on u.id =um.uid
-      where u.share_type in(0,2) and  u.channel=0 and u.new_channel=0
-        and u.aid =#{aid}
-        and datediff(now(),if (um.last_follow_time >u.transfer_time,um.last_follow_time,u.transfer_time)) &gt; 15
-        and datediff(now(),if (um.last_follow_time >u.transfer_time,um.last_follow_time,u.transfer_time)) &lt; 30
-	UNION
+    SELECT u.id uid,u.aid,u.nickname name, u.channel ,u.share_type type,u.new_channel newChannel
+    from `user` u left join user_mid um on u.id =um.uid
+    where u.share_type in(0,2) and  u.channel=0 and u.new_channel=0
+      and u.aid =#{aid}
+      and (datediff(now(),if (um.last_follow_time >u.transfer_time,um.last_follow_time,u.transfer_time)) &gt; 15 )
+      and (datediff(now(),if (um.last_follow_time >u.transfer_time,um.last_follow_time,u.transfer_time)) &lt; 30)
+    UNION
+    SELECT u.id uid,u.aid,u.nickname name, u.channel ,u.share_type type,u.new_channel newChannel
+    from `user` u left join user_mid um on u.id =um.uid
+    where u.share_type in(0,2) and  u.channel=0 and u.new_channel=0
+      and u.aid =#{aid}
+      and (datediff(now(),u.transfer_time) &gt; 255)
+      and (datediff(now(),u.transfer_time) &lt; 270)
+    UNION
       SELECT u.id uid,u.aid,u.nickname name, u.channel ,u.share_type type,u.new_channel newChannel
       from `user` u left join user_mid um on u.id =um.uid
 	where  u.share_type in(0,2) and  u.channel=1

+ 10 - 12
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -29,7 +29,10 @@ import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
 
 
 @Component
@@ -62,9 +65,9 @@ public class ReleaseUserTask {
 	 * 客户释放
 	 *
 	 */
-//	@Scheduled(cron = "0 22 11  * * ?")
+	@Scheduled(cron = "0 22 14  * * ?")
 //	@RequestMapping("/open/test")
-	@Scheduled(cron = "0 0 1  * * ?")
+//	@Scheduled(cron = "0 0 1  * * ?")
 	public void startTask() {
 		try {
 			List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
@@ -244,8 +247,6 @@ public class ReleaseUserTask {
 				}
 			}
 			List<LockingReleaseBo> newList = new ArrayList<LockingReleaseBo>();
-			Timer timer=new Timer();
-
 			if (lockUserList != null && !lockUserList.isEmpty()) {
 				for (int i = 0; i < lockUserList.size(); i++) {
 					newList.add(lockUserList.get(i));
@@ -292,9 +293,6 @@ public class ReleaseUserTask {
 
 	/**
 	 * 处理外联
-	 * @param releaseTime
-	 * @param userList
-	 * @throws InterruptedException
 	 */
 	private void pushChannel(Date releaseTime, List<User> userList) throws InterruptedException {
 		// 获取超过90天客户,判断是否回收过,未回收则回收,已回收则释放为公共客户
@@ -310,7 +308,7 @@ public class ReleaseUserTask {
 		}
 		List<userDaysBo> hsList=new ArrayList<>();
 		List<userDaysBo> sfList=new ArrayList<>();
-		if (count != null && count.size() > 0) {
+		if (count != null && !count.isEmpty()) {
 			for (int i = 0; i < count.size(); i++) {
 				//回收
 				if (count.get(i).getRecovery()==0) {
@@ -329,7 +327,7 @@ public class ReleaseUserTask {
 			}
 		}
 		List<LockingReleaseBo> lockList = customerService.selectPendinglockUserList();
-		if (lockList.size() > 0)
+		if (!lockList.isEmpty())
 			customerService.updateReleaseLock(releaseTime);
 	}
 
@@ -340,12 +338,12 @@ public class ReleaseUserTask {
 
 	public void addNoticeBatch(List<Notice> ln) {
 		List<Notice> newList=new ArrayList<Notice>();
-		if (ln != null && ln.size() > 0) {
+		if (ln != null && !ln.isEmpty()) {
 			for (int i = 0; i < ln.size(); i++) {
 				ln.get(i).setType(NoticeTypes.getType(ln.get(i).getNoticeType()));
 				newList.add(ln.get(i));
 				if (50 == newList.size() || i == ln.size() - 1) {
-					if (newList.size() > 0) {
+					if (!newList.isEmpty()) {
 						//发送站内信
 						noticeMapper.insertBatch(newList);
 					}