|
|
@@ -7,11 +7,13 @@ 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.enums.NoticeStatus;
|
|
|
import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.model.AdminUserCount;
|
|
|
import com.goafanti.common.model.Notice;
|
|
|
import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.model.UserTransferLog;
|
|
|
import com.goafanti.common.utils.AsyncUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -52,13 +55,16 @@ public class ReleaseUserTask {
|
|
|
@Autowired
|
|
|
private RestrictProjectMapper restProjectMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserTransferLogMapper userTransferLogMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 每天凌晨一点
|
|
|
*
|
|
|
*/
|
|
|
-// @Scheduled(cron = "0 52 10 * * ?")
|
|
|
+ @Scheduled(cron = "0 31 14 * * ?")
|
|
|
// @RequestMapping("/open/test")
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
public void startTask() {
|
|
|
try {
|
|
|
List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
|
|
|
@@ -76,7 +82,9 @@ public class ReleaseUserTask {
|
|
|
private void pushRestrictProject(List<User> userList) {
|
|
|
LoggerUtils.debug(getClass(), "==============限时项目丢失开始============");
|
|
|
List<Notice> ln = new ArrayList<>();
|
|
|
+ List<UserTransferLog> lu=new ArrayList<>();
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
+ Date date = new Date();
|
|
|
List<Integer> list = new ArrayList<>();
|
|
|
for (User u : userList) {
|
|
|
if (StringUtils.isNotBlank(u.getId())) {
|
|
|
@@ -84,25 +92,47 @@ public class ReleaseUserTask {
|
|
|
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())
|
|
|
+ LocalDateTime endTime2 = lockTime.plusDays(15);
|
|
|
+ long between2 = ChronoUnit.DAYS.between(now, endTime2);
|
|
|
+ if (between2==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),date, 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE30_REMIND.getCode(),
|
|
|
+ String.format("您的客户[%s]限时私有项目[%s]还有15天即将丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
,rp.getUid()));
|
|
|
- list.add(rp.getId());
|
|
|
+ }else {
|
|
|
+ LocalDateTime endTime = lockTime.plusDays(30);
|
|
|
+ long between = ChronoUnit.DAYS.between(now, endTime);
|
|
|
+ if (between==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),date, 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE30.getCode(),
|
|
|
+ String.format("您的客户[%s]限时私有项目[%s]已丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
+ ,rp.getUid()));
|
|
|
+ list.add(rp.getId());
|
|
|
+ lu.add(new UserTransferLog(rp.getUid(), rp.getAid(), rp.getPid(), 18, "限时项目释放(30天)",date));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}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())
|
|
|
+ LocalDateTime endTime2 = lockTime.plusDays(255);
|
|
|
+ long between2 = ChronoUnit.DAYS.between(now, endTime2);
|
|
|
+ if (between2==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),date, 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE270_REMIND.getCode(),
|
|
|
+ String.format("您的客户[%s]限时签单项目[%s]还有15天即将丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
,rp.getUid()));
|
|
|
- list.add(rp.getId());
|
|
|
+ }else{
|
|
|
+ LocalDateTime endTime = lockTime.plusDays(270);
|
|
|
+ long between = ChronoUnit.DAYS.between(now, endTime);
|
|
|
+ if (between==0){
|
|
|
+ ln.add(new Notice(UUID.randomUUID().toString(),date, 0, rp.getAid(),
|
|
|
+ NoticeStatus.RESTRICT_PROJECT_LOSE270.getCode(),
|
|
|
+ String.format("您的客户[%s]限时签单项目[%s]已丢失!",rp.getUserName(), rp.getProjectName())
|
|
|
+ ,rp.getUid()));
|
|
|
+ list.add(rp.getId());
|
|
|
+ lu.add(new UserTransferLog(rp.getUid(), rp.getAid(), rp.getPid(), 19, "限时项目释放(270天)",date));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -110,9 +140,32 @@ public class ReleaseUserTask {
|
|
|
}
|
|
|
addNoticeBatch(ln);
|
|
|
pushReleaseRestrictProject(list);
|
|
|
+ addUserTransferLogBatch(lu);
|
|
|
LoggerUtils.debug(getClass(), "==============限时项目结束============");
|
|
|
}
|
|
|
|
|
|
+ private void addUserTransferLogBatch(List<UserTransferLog> list) {
|
|
|
+ List<UserTransferLog> list2 = new ArrayList<>();
|
|
|
+ int i=0;
|
|
|
+ for (UserTransferLog e : list) {
|
|
|
+ i++;
|
|
|
+ list2.add(e);
|
|
|
+ if(list2.size()==pointsDataLimit||i==list.size()){
|
|
|
+ userTransferLogMapper.insertList(list2);
|
|
|
+ list2.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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<>();
|
|
|
int i=0;
|