|
|
@@ -1,10 +1,13 @@
|
|
|
package com.goafanti.admin.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -17,10 +20,13 @@ import com.goafanti.common.dao.AdminLocationMapper;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.UserRoleMapper;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
+import com.goafanti.common.utils.LoggerUtils;
|
|
|
+import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import com.goafanti.customer.bo.LockingReleaseBo;
|
|
|
|
|
|
@Service
|
|
|
public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements AdminService {
|
|
|
@@ -30,6 +36,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
|
|
|
private UserRoleMapper userRoleMapper;
|
|
|
@Autowired
|
|
|
private AdminLocationMapper adminLocationMapper;
|
|
|
+ @Resource(name = "passwordUtil")
|
|
|
+ private PasswordUtil passwordUtil;
|
|
|
@Override
|
|
|
public List<Admin> selectAllAdmin() {
|
|
|
return adminMapper.selectAllAdmin();
|
|
|
@@ -230,6 +238,71 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
|
|
|
return adminMapper.selectDepartmentStaff( departmentId, name);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int updateLockAdmin() {
|
|
|
+ int count=0;
|
|
|
+ List<Admin> list=adminMapper.selectAllAdmin();//获取所有用户
|
|
|
+ List<List<Admin>>aList=groupList(list);//拆分成多个
|
|
|
+ String lockIds = "";
|
|
|
+ for(List<Admin> al:aList){
|
|
|
+ for (Admin a : al) {
|
|
|
+ String pwd=a.getPassword();
|
|
|
+ a.setPassword("123456");
|
|
|
+ String pwd2=passwordUtil.getEncryptPwd(a);
|
|
|
+ if (pwd.equals(pwd2)) {
|
|
|
+ lockIds += a.getId() + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(lockIds.length()>0){
|
|
|
+ try {
|
|
|
+ lockIds = "'" + lockIds.substring(0,lockIds.length()-1).replace(",", "','") + "'";
|
|
|
+ count+= adminMapper.updateLockIds(lockIds);
|
|
|
+ lockIds = "";
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ LoggerUtils.error(getClass(), "未修改管理员锁定失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * List分割
|
|
|
+ */
|
|
|
+ public List<List<Admin>> groupList(List<Admin> list) {
|
|
|
+ List<List<Admin>> listGroup = new ArrayList<List<Admin>>();
|
|
|
+ int listSize = list.size();
|
|
|
+ //子集合的长度
|
|
|
+ int toIndex = 100;
|
|
|
+ for (int i = 0; i < list.size(); i += toIndex) {
|
|
|
+ if (i + toIndex > listSize) {
|
|
|
+ toIndex = listSize - i;
|
|
|
+ }
|
|
|
+ List<Admin> newList = list.subList(i, i + toIndex);
|
|
|
+ listGroup.add(newList);
|
|
|
+ }
|
|
|
+ return listGroup;
|
|
|
+ }
|
|
|
+ /* public static void main(String[] args) {
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ for (int i = 1; i < 888; i++) {
|
|
|
+ list.add(String.valueOf(i));
|
|
|
+ }
|
|
|
+ List<List<String>> listGroup = new ArrayList<List<String>>();
|
|
|
+ int listSize = list.size();
|
|
|
+ //子集合的长度
|
|
|
+ int toIndex = 100;
|
|
|
+ for (int i = 0; i < list.size(); i += 100) {
|
|
|
+ if (i + 100 > listSize) {
|
|
|
+ toIndex = listSize - i;
|
|
|
+ }
|
|
|
+ List<String> newList = list.subList(i, i + toIndex);
|
|
|
+ listGroup.add(newList);
|
|
|
+ }
|
|
|
+ System.out.println(listGroup);
|
|
|
+ }*/
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|