|
|
@@ -1,10 +1,12 @@
|
|
|
package com.goafanti.common.task;
|
|
|
|
|
|
+import com.goafanti.business.bo.OutRestrictProject;
|
|
|
import com.goafanti.common.bo.EmailBo;
|
|
|
import com.goafanti.common.bo.userDaysBo;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.AdminUserCountMapper;
|
|
|
import com.goafanti.common.dao.NoticeMapper;
|
|
|
+import com.goafanti.common.dao.RestrictProjectMapper;
|
|
|
import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.model.AdminUserCount;
|
|
|
@@ -22,6 +24,8 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -45,6 +49,9 @@ public class ReleaseUserTask {
|
|
|
@Autowired
|
|
|
private AdminUserCountMapper adminUserCountMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestrictProjectMapper restProjectMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 每天凌晨一点
|
|
|
*
|
|
|
@@ -55,16 +62,70 @@ public class ReleaseUserTask {
|
|
|
public void startTask() {
|
|
|
try {
|
|
|
List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
|
|
|
- pushUserDays(userList);
|
|
|
+// pushUserDays(userList);
|
|
|
Thread.sleep(2000);
|
|
|
- updateUser(userList);
|
|
|
+// updateUser(userList);
|
|
|
Thread.sleep(2000);
|
|
|
+ pushRestrictProject(userList);
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void pushRestrictProject(List<User> userList) {
|
|
|
+ LoggerUtils.debug(getClass(), "==============限时项目丢失开始============");
|
|
|
+ List<Notice> ln = new ArrayList<>();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ for (User u : userList) {
|
|
|
+ if (StringUtils.isNotBlank(u.getId())) {
|
|
|
+ List<OutRestrictProject> rpList = restProjectMapper.selectByUid(u.getId());
|
|
|
+ for (OutRestrictProject rp : rpList) {
|
|
|
+ LocalDateTime lockTime = rp.getLockTime().toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ if (rp.getType()==1){
|
|
|
+ LocalDateTime endTime = lockTime.plusDays(30);
|
|
|
+ long between = ChronoUnit.DAYS.between(now, endTime);
|
|
|
+ if (between==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),new Date(), 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE30.getCode(),
|
|
|
+ String.format("您的客户[%s]限时私有项目[%s]已丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
+ ,rp.getUid()));
|
|
|
+ list.add(rp.getId());
|
|
|
+ }
|
|
|
+ }else if (rp.getType()==2){
|
|
|
+ LocalDateTime endTime = lockTime.plusDays(270);
|
|
|
+ long between = ChronoUnit.DAYS.between(now, endTime);
|
|
|
+ if (between==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),new Date(), 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE270.getCode(),
|
|
|
+ String.format("您的客户[%s]限时签单项目[%s]已丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
+ ,rp.getUid()));
|
|
|
+ list.add(rp.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ addNoticeBatch(ln);
|
|
|
+ pushReleaseRestrictProject(list);
|
|
|
+ LoggerUtils.debug(getClass(), "==============限时项目结束============");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushReleaseRestrictProject(List<Integer> list) {
|
|
|
+ List<Integer> list2 = new ArrayList<>();
|
|
|
+ int i=0;
|
|
|
+ for (Integer e : list) {
|
|
|
+ i++;
|
|
|
+ list2.add(e);
|
|
|
+ if(list2.size()==pointsDataLimit||i==list.size()){
|
|
|
+ restProjectMapper.updateRelease(list2);
|
|
|
+ list2.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void pushUserDays(List<User> userList ) throws InterruptedException {
|
|
|
LoggerUtils.debug(getClass(), "==============客户提醒开始============");
|
|
|
List<Notice> ln = new ArrayList<>();
|