|
|
@@ -3,12 +3,15 @@ package com.goafanti.common.task;
|
|
|
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.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.utils.AsyncUtils;
|
|
|
+import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.customer.bo.LockingReleaseBo;
|
|
|
@@ -16,8 +19,8 @@ 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.util.ArrayList;
|
|
|
@@ -26,8 +29,8 @@ import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
-@Component
|
|
|
-//@RestController
|
|
|
+//@Component
|
|
|
+@RestController
|
|
|
public class ReleaseUserTask {
|
|
|
@Resource
|
|
|
private CustomerService customerService;
|
|
|
@@ -43,17 +46,21 @@ public class ReleaseUserTask {
|
|
|
|
|
|
int pointsDataLimit = 50;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AdminUserCountMapper adminUserCountMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 每天凌晨一点
|
|
|
*
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
|
-// @Scheduled(cron = "0 31 15 * * ?")
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+// @Scheduled(cron = "0 52 10 * * ?")
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @RequestMapping("/open/test")
|
|
|
public void startTask() {
|
|
|
try {
|
|
|
List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
|
|
|
- pushUserDays(userList);
|
|
|
+// pushUserDays(userList);
|
|
|
Thread.sleep(2000);
|
|
|
updateUser(userList);
|
|
|
Thread.sleep(2000);
|
|
|
@@ -124,7 +131,7 @@ public class ReleaseUserTask {
|
|
|
}
|
|
|
}
|
|
|
List<LockingReleaseBo> newList = new ArrayList<LockingReleaseBo>();
|
|
|
- List<String> aidList=new ArrayList<>();
|
|
|
+ List<LockingReleaseBo> aidList=new ArrayList<>();
|
|
|
if (lockUserList != null && lockUserList.size() > 0) {
|
|
|
for (int i = 0; i < lockUserList.size(); i++) {
|
|
|
newList.add(lockUserList.get(i));
|
|
|
@@ -136,15 +143,26 @@ public class ReleaseUserTask {
|
|
|
Thread.sleep(2000);
|
|
|
}
|
|
|
//设置释放客户修改客户数
|
|
|
- String aid=lockUserList.get(i).getAid();
|
|
|
- if (!aidList.contains(aid)){
|
|
|
- aidList.add(aid);
|
|
|
+ if (aidList.isEmpty()){
|
|
|
+ aidList.add(lockUserList.get(i));
|
|
|
+ }else {
|
|
|
+ for (LockingReleaseBo e : aidList) {
|
|
|
+ boolean flag= true;
|
|
|
+ if (e.getAid().equals(lockUserList.get(i).getAid())&&
|
|
|
+ e.getLockTime().getTime()==lockUserList.get(i).getLockTime().getTime()){
|
|
|
+ flag= false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (flag){
|
|
|
+ aidList.add(lockUserList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- for (String aid : aidList) {
|
|
|
- customerService.updateAdminUserCountByAid(aid);
|
|
|
- }
|
|
|
+ //处理每个人重复的天数
|
|
|
+ pushSalesmanCount(aidList);
|
|
|
pushChannel(releaseTime, userList);
|
|
|
} catch (Exception e) {
|
|
|
Notice n = new Notice(UUID.randomUUID().toString(), new Date(), 0, "1",
|
|
|
@@ -158,6 +176,20 @@ public class ReleaseUserTask {
|
|
|
LoggerUtils.debug(getClass(), "==============客户释放完成============");
|
|
|
}
|
|
|
|
|
|
+ private void pushSalesmanCount(List<LockingReleaseBo> aidList) {
|
|
|
+ for (LockingReleaseBo e : aidList) {
|
|
|
+ String dates= DateUtils.formatDate(e.getLockTime(),AFTConstants.YYYYMMDD);
|
|
|
+ AdminUserCount adminUserCount = customerService.getAdminUserCount(e.getAid(), dates);
|
|
|
+ if (adminUserCount!=null&&adminUserCount.getPrivateCount()>0){
|
|
|
+ AdminUserCount newAdminUserCount = new AdminUserCount();
|
|
|
+ newAdminUserCount.setId(adminUserCount.getId());
|
|
|
+ newAdminUserCount.setPrivateCount(adminUserCount.getPrivateCount()-1);
|
|
|
+ adminUserCountMapper.updateByPrimaryKeySelective(newAdminUserCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处理外联
|
|
|
* @param releaseTime
|