|
@@ -1,6 +1,8 @@
|
|
|
package com.storlead.user.service.impl;
|
|
package com.storlead.user.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -140,6 +142,8 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
boolean sj = syncJob();
|
|
boolean sj = syncJob();
|
|
|
if (c && sc && sj) {
|
|
if (c && sc && sj) {
|
|
|
syncUser();
|
|
syncUser();
|
|
|
|
|
+ // 同步企业微信id,根据手机号
|
|
|
|
|
+ syncWxId();
|
|
|
}
|
|
}
|
|
|
log.error("syncCompany--------------end = "+(System.currentTimeMillis() - d));
|
|
log.error("syncCompany--------------end = "+(System.currentTimeMillis() - d));
|
|
|
}
|
|
}
|
|
@@ -155,29 +159,37 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean syncWxId() {
|
|
public Boolean syncWxId() {
|
|
|
LambdaQueryWrapper<UserEntity> wp = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<UserEntity> wp = new LambdaQueryWrapper<>();
|
|
|
- wp.isNull(UserEntity::getXworkUserId);
|
|
|
|
|
wp.eq(UserEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
wp.eq(UserEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
wp.isNotNull(UserEntity::getMobile).ne(UserEntity::getMobile,"");
|
|
wp.isNotNull(UserEntity::getMobile).ne(UserEntity::getMobile,"");
|
|
|
wp.ne(UserEntity::getStatus,Integer.valueOf(5));
|
|
wp.ne(UserEntity::getStatus,Integer.valueOf(5));
|
|
|
- wp.isNotNull(UserEntity::getPermanentDate);
|
|
|
|
|
|
|
+ wp.isNull(UserEntity::getXworkUserId);
|
|
|
|
|
+
|
|
|
List<UserEntity> list = list(wp);
|
|
List<UserEntity> list = list(wp);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ String token = corpWeChatService.getAddressAccessTokenFromTencent().getToken();
|
|
|
|
|
|
|
|
- List<com.storlead.framework.common.vo.UserVo> us = new ArrayList<>();
|
|
|
|
|
- List<com.storlead.framework.common.vo.UserVo> finalUs = us;
|
|
|
|
|
- list.forEach(a -> {
|
|
|
|
|
- com.storlead.framework.common.vo.UserVo v = new com.storlead.framework.common.vo.UserVo();
|
|
|
|
|
- BeanUtils.copyProperties(a,v);
|
|
|
|
|
- finalUs.add(v);
|
|
|
|
|
- });
|
|
|
|
|
- corpWeChatService.syncWxUserIdByMobile(finalUs);
|
|
|
|
|
- for (com.storlead.framework.common.vo.UserVo user : us) {
|
|
|
|
|
- if (Objects.nonNull(user.getXworkUserId())) {
|
|
|
|
|
|
|
+ for (UserEntity user : list) {
|
|
|
|
|
+ String mobile = user.getMobile();
|
|
|
|
|
+ boolean isValid = Validator.isMobile(mobile);
|
|
|
|
|
+ if (!isValid) {
|
|
|
LambdaUpdateWrapper<UserEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<UserEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.eq(UserEntity::getMobile,user.getMobile());
|
|
|
|
|
- updateWrapper.set(UserEntity::getXworkUserId,user.getXworkUserId());
|
|
|
|
|
|
|
+ updateWrapper.eq(UserEntity::getId,user.getId());
|
|
|
|
|
+ updateWrapper.set(UserEntity::getXworkUserId,"");
|
|
|
update(updateWrapper);
|
|
update(updateWrapper);
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ String xworkUserId = corpWeChatService.syncWxUserIdByMobile(token,mobile);
|
|
|
|
|
+ LambdaUpdateWrapper<UserEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ if (StrUtil.isBlank(xworkUserId)) {
|
|
|
|
|
+ updateWrapper.eq(UserEntity::getRemark,"账号异常,未获取到微信Id");
|
|
|
|
|
+ }
|
|
|
|
|
+ updateWrapper.eq(UserEntity::getId,user.getId());
|
|
|
|
|
+ updateWrapper.set(UserEntity::getXworkUserId,xworkUserId);
|
|
|
|
|
+ update(updateWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return Boolean.TRUE;
|
|
return Boolean.TRUE;
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
@@ -383,20 +395,17 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
currentUser = new LoginUser().setId(0L);
|
|
currentUser = new LoginUser().setId(0L);
|
|
|
}
|
|
}
|
|
|
List<UserEntity> userList = hrmresourceService.getUserList();
|
|
List<UserEntity> userList = hrmresourceService.getUserList();
|
|
|
- log.error("syncUser--------------end3 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
List<UserEntity> dbUserList = list();
|
|
List<UserEntity> dbUserList = list();
|
|
|
List<UserEntity> addList = new ArrayList<>();
|
|
List<UserEntity> addList = new ArrayList<>();
|
|
|
List<UserEntity> updateList = new ArrayList<>();
|
|
List<UserEntity> updateList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<DeptEntity> depts = departService.list();
|
|
List<DeptEntity> depts = departService.list();
|
|
|
- log.error("syncUser--------------end4 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
Map deptMap = new HashMap();
|
|
Map deptMap = new HashMap();
|
|
|
depts.forEach(c -> {
|
|
depts.forEach(c -> {
|
|
|
deptMap.put(c.getId(),c.getRouteCode());
|
|
deptMap.put(c.getId(),c.getRouteCode());
|
|
|
});
|
|
});
|
|
|
// 默认密码
|
|
// 默认密码
|
|
|
String defaultPassWord = "storlead123456";
|
|
String defaultPassWord = "storlead123456";
|
|
|
- log.error("syncUser--------------end5 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
for (UserEntity user : userList) {
|
|
for (UserEntity user : userList) {
|
|
|
UserEntity userDb = dbUserList.stream().filter(u -> u.getId().equals(user.getId())).findFirst().orElse(null);
|
|
UserEntity userDb = dbUserList.stream().filter(u -> u.getId().equals(user.getId())).findFirst().orElse(null);
|
|
|
String routeCode = Objects.isNull(deptMap.get(user.getDeptId())) ? "" : deptMap.get(user.getDeptId()).toString();
|
|
String routeCode = Objects.isNull(deptMap.get(user.getDeptId())) ? "" : deptMap.get(user.getDeptId()).toString();
|
|
@@ -406,8 +415,10 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
.setUserName(user.getMobile()).setOrgRouteCode(routeCode)
|
|
.setUserName(user.getMobile()).setOrgRouteCode(routeCode)
|
|
|
.setPassword(passwordEncoder.encode(defaultPassWord))
|
|
.setPassword(passwordEncoder.encode(defaultPassWord))
|
|
|
.setDataSource(0)
|
|
.setDataSource(0)
|
|
|
- .setCreateBy(currentUser.getId())
|
|
|
|
|
- .setEnabled(false);
|
|
|
|
|
|
|
+ .setCreateBy(currentUser.getId());
|
|
|
|
|
+ if (user.getStatus()!=null && Integer.parseInt(user.getStatus()) == 5) {
|
|
|
|
|
+ user.setEnabled(false);
|
|
|
|
|
+ }
|
|
|
addList.add(user);
|
|
addList.add(user);
|
|
|
} else {
|
|
} else {
|
|
|
//禁用离职状态的用户
|
|
//禁用离职状态的用户
|
|
@@ -417,31 +428,29 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
|
|
|
|
|
user
|
|
user
|
|
|
.setOrgRouteCode(routeCode)
|
|
.setOrgRouteCode(routeCode)
|
|
|
|
|
+ .setXworkUserId(user.getXworkUserId())
|
|
|
.setUserName(user.getMobile());
|
|
.setUserName(user.getMobile());
|
|
|
|
|
+
|
|
|
updateList.add(user);
|
|
updateList.add(user);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- log.error("syncUser--------------end6 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
if (!CollectionUtils.isEmpty(addList)) {
|
|
if (!CollectionUtils.isEmpty(addList)) {
|
|
|
this.saveBatch(addList);
|
|
this.saveBatch(addList);
|
|
|
}
|
|
}
|
|
|
- if (CollectionUtils.isEmpty(updateList)) {
|
|
|
|
|
- syncUserOpenIdFormTencent();
|
|
|
|
|
- }
|
|
|
|
|
- log.error("syncUser--------------end7 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
- if (!CollectionUtils.isEmpty(updateList)) {
|
|
|
|
|
- ThreadPoolUtil.execute(new Runnable() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
- saveOrUpdateBatch(updateList);
|
|
|
|
|
- syncUserOpenIdFormTencent();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- log.error("syncUser--------------end8 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+// if (CollectionUtils.isEmpty(updateList)) {
|
|
|
|
|
+// syncUserOpenIdFormTencent();
|
|
|
|
|
+// }
|
|
|
|
|
+// log.error("syncUser--------------end7 = "+(System.currentTimeMillis()-d));
|
|
|
|
|
+// if (!CollectionUtils.isEmpty(updateList)) {
|
|
|
|
|
+// ThreadPoolUtil.execute(new Runnable() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+// saveOrUpdateBatch(updateList);
|
|
|
|
|
+// syncUserOpenIdFormTencent();
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -452,6 +461,9 @@ public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, UserEntity> i
|
|
|
* @date 2021-6-15 上午 11:58
|
|
* @date 2021-6-15 上午 11:58
|
|
|
*/
|
|
*/
|
|
|
public boolean syncUserOpenIdFormTencent() {
|
|
public boolean syncUserOpenIdFormTencent() {
|
|
|
|
|
+
|
|
|
|
|
+// LambdaQueryWrapper<UserEntity> us = new LambdaQueryWrapper();
|
|
|
|
|
+// us.eq(UserEntity::getIsDelete,CommonConstant.DEL_FLAG_0);
|
|
|
List<UserEntity> list = this.list();
|
|
List<UserEntity> list = this.list();
|
|
|
|
|
|
|
|
List<com.storlead.framework.common.vo.UserVo> us = new ArrayList<>();
|
|
List<com.storlead.framework.common.vo.UserVo> us = new ArrayList<>();
|