|
|
@@ -4,10 +4,7 @@ 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.dao.UserTransferLogMapper;
|
|
|
+import com.goafanti.common.dao.*;
|
|
|
import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.model.AdminUserCount;
|
|
|
@@ -22,12 +19,11 @@ import com.goafanti.customer.service.CustomerService;
|
|
|
import com.goafanti.user.service.UserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -35,8 +31,8 @@ import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
-@Component
|
|
|
-//@RestController
|
|
|
+//@Component
|
|
|
+@RestController
|
|
|
public class ReleaseUserTask {
|
|
|
@Resource
|
|
|
private CustomerService customerService;
|
|
|
@@ -52,36 +48,92 @@ public class ReleaseUserTask {
|
|
|
|
|
|
int pointsDataLimit = 50;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private AdminUserCountMapper adminUserCountMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private RestrictProjectMapper restProjectMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private UserTransferLogMapper userTransferLogMapper;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
|
/**
|
|
|
* 客户释放
|
|
|
*
|
|
|
*/
|
|
|
// @Scheduled(cron = "0 10 17 * * ?")
|
|
|
-// @RequestMapping("/open/test")
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @RequestMapping("/open/test")
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
public void startTask() {
|
|
|
try {
|
|
|
List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
|
|
|
- pushUserDays(userList);
|
|
|
- Thread.sleep(2000);
|
|
|
- updateUser(userList);
|
|
|
+// pushUserDays(userList);
|
|
|
+// Thread.sleep(2000);
|
|
|
+// updateUser(userList);
|
|
|
+// Thread.sleep(2000);
|
|
|
+// pushRestrictProject(userList);
|
|
|
Thread.sleep(2000);
|
|
|
- pushRestrictProject(userList);
|
|
|
+ pushReleaseClueyUser(userList);
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void pushReleaseClueyUser(List<User> userList) {
|
|
|
+ LoggerUtils.debug(getClass(), "==============线索客户丢失开始============");
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ Date date = new Date();
|
|
|
+ List<Notice> ln = new ArrayList<>();
|
|
|
+ List<User> releaseUserList = new ArrayList<>();
|
|
|
+ List<UserTransferLog> logList=new ArrayList<>();
|
|
|
+ for (User admin : userList) {
|
|
|
+ List<User> users = userMapper.selectClueUserByClueType(admin.getId());
|
|
|
+ for (User u : users) {
|
|
|
+ LocalDateTime clueTime = u.getClueTime().toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ LocalDateTime endTime = clueTime.plusDays(15);
|
|
|
+ long between= ChronoUnit.DAYS.between(now, endTime);
|
|
|
+ if (between<1){
|
|
|
+ releaseUserList.add(u);
|
|
|
+ String aid=admin.getId();
|
|
|
+ if (u.getClueProcess()==1)aid=u.getAid();
|
|
|
+ logList.add(new UserTransferLog(u.getId(), "1",null, 27, "",date));
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),date, 0, aid,
|
|
|
+ NoticeStatus.CLUE_USER_RELEASE.getCode(),
|
|
|
+ String.format("您的线索客户[%s]已丢失!",u.getNickname())
|
|
|
+ ,u.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ addNoticeBatch(ln);
|
|
|
+ addUserTransferLogBatch(logList);
|
|
|
+ pushClueUserRelease(releaseUserList);
|
|
|
+ LoggerUtils.debug(getClass(), "==============线索客户丢失结束============");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushClueUserRelease(List<User> lu) {
|
|
|
+ List<User> updateList=new ArrayList<>();
|
|
|
+ if (lu != null && !lu.isEmpty()) {
|
|
|
+ for (int i = 0; i < lu.size(); i++) {
|
|
|
+ updateList.add(lu.get(i));
|
|
|
+ if (50 == updateList.size() || i == lu.size() - 1) {
|
|
|
+ userMapper.updateClueUserRelease(updateList);
|
|
|
+ updateList.clear();
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 限时项目定时任务
|
|
|
*/
|
|
|
@@ -163,14 +215,7 @@ public class ReleaseUserTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- LocalDateTime endTime = LocalDateTime.of(2024,5,14,0,0);
|
|
|
- endTime= endTime.minusDays(270);
|
|
|
- long between = ChronoUnit.DAYS.between(now, endTime);
|
|
|
- System.out.println(between);
|
|
|
- System.out.println(endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private void pushReleaseRestrictProject(List<Integer> list) {
|
|
|
List<Integer> list2 = new ArrayList<>();
|