|
|
@@ -12,37 +12,87 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.customer.bo.LockingReleaseBo;
|
|
|
import com.goafanti.customer.service.CustomerService;
|
|
|
import com.goafanti.user.service.UserService;
|
|
|
-@Component
|
|
|
-//@Controller
|
|
|
+//@Component
|
|
|
+@Controller
|
|
|
public class ReleaseUserTask {
|
|
|
@Resource
|
|
|
private CustomerService customerServiceImpl;
|
|
|
@Resource
|
|
|
private UserService userServiceImpl;
|
|
|
|
|
|
+ int pointsDataLimit=100;
|
|
|
+ Date releaseTime = new Date();
|
|
|
/**
|
|
|
- * 每天凌晨一点释放客户和业务
|
|
|
+ * 每天凌晨一点将客户和业务转为待释放
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
-// @RequestMapping(value = "/releaseUser")
|
|
|
+ @SuppressWarnings("null")
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @RequestMapping(value = "/updateUser")
|
|
|
+ public void updateUser(){
|
|
|
+ try {
|
|
|
+ List<User> userList = userServiceImpl.selectUserByRoleName("营销员","营销经理");
|
|
|
+ List<LockingReleaseBo> lockUserList = new ArrayList<LockingReleaseBo>();
|
|
|
+ List<LockingReleaseBo> lockBusinessList = new ArrayList<LockingReleaseBo>();
|
|
|
+ List<LockingReleaseBo> userTmpList = null;
|
|
|
+ List<LockingReleaseBo> businessTmpList = null;
|
|
|
+ for(User u : userList){
|
|
|
+ userTmpList = customerServiceImpl.selectWaitReleaseCustomer(u.getId());
|
|
|
+ lockUserList.addAll(userTmpList);
|
|
|
+ businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
|
|
|
+ lockBusinessList.addAll(businessTmpList);
|
|
|
+ }
|
|
|
+ List<LockingReleaseBo> newList=null;
|
|
|
+ for(int i=0;i<userTmpList.size();i++){
|
|
|
+ newList.add(userTmpList.get(i));
|
|
|
+ if(pointsDataLimit == newList.size()||i == userTmpList.size()-1){
|
|
|
+ if(newList.size()>0) customerServiceImpl.updatePendingReleaseLock(newList);
|
|
|
+ newList.clear();
|
|
|
+ Thread.sleep(2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int i=0;i<businessTmpList.size();i++){
|
|
|
+ newList.add(businessTmpList.get(i));
|
|
|
+ if(pointsDataLimit == newList.size()||i == businessTmpList.size()-1){
|
|
|
+ if(newList.size()>0) customerServiceImpl.updatePendingReleaseLock(newList);
|
|
|
+ newList.clear();
|
|
|
+ Thread.sleep(2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*if(lockUserList.size()>0) customerServiceImpl.updateReleaseLock(lockUserList,releaseTime);
|
|
|
+ if(lockBusinessList.size()>0) customerServiceImpl.updateReleaseLock(lockBusinessList,releaseTime);
|
|
|
+ if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);*/
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ LoggerUtils.error(getClass(), "=============================================", e);
|
|
|
+ LoggerUtils.error(getClass(), "客户标记待释放失败", e);
|
|
|
+ LoggerUtils.error(getClass(), "=============================================", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("null")
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @RequestMapping(value = "/releaseUser")
|
|
|
public void releaseUser(){
|
|
|
- Date releaseTime = new Date();
|
|
|
- List<User> userList = userServiceImpl.selectUserByRoleName("营销员","营销经理");
|
|
|
- List<LockingReleaseBo> lockUserList = new ArrayList<LockingReleaseBo>();
|
|
|
- List<LockingReleaseBo> lockBusinessList = new ArrayList<LockingReleaseBo>();
|
|
|
- List<LockingReleaseBo> userTmpList = null;
|
|
|
- List<LockingReleaseBo> businessTmpList = null;
|
|
|
- for(User u : userList){
|
|
|
- userTmpList = customerServiceImpl.selectWaitReleaseCustomer(u.getId());
|
|
|
- lockUserList.addAll(userTmpList);
|
|
|
- businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
|
|
|
- lockBusinessList.addAll(businessTmpList);
|
|
|
+ try {
|
|
|
+ List<LockingReleaseBo> lockList=customerServiceImpl.selectPendinglockUserList();
|
|
|
+ List<LockingReleaseBo> newList=null;
|
|
|
+ for(int i=0;i<lockList.size();i++){
|
|
|
+ newList.add(lockList.get(i));
|
|
|
+ if(pointsDataLimit == newList.size()||i == lockList.size()-1){
|
|
|
+ if(newList.size()>0) customerServiceImpl.updateReleaseLock(newList,releaseTime);
|
|
|
+ newList.clear();
|
|
|
+ Thread.sleep(2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ LoggerUtils.error(getClass(), "=============================================", e);
|
|
|
+ LoggerUtils.error(getClass(), "客户释放失败", e);
|
|
|
+ LoggerUtils.error(getClass(), "=============================================", e);
|
|
|
}
|
|
|
- if(lockUserList.size()>0) customerServiceImpl.updateReleaseLock(lockUserList,releaseTime);
|
|
|
- if(lockBusinessList.size()>0) customerServiceImpl.updateReleaseLock(lockBusinessList,releaseTime);
|
|
|
- if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);
|
|
|
+
|
|
|
}
|
|
|
}
|