Commit ad886553 authored by 赵啸非's avatar 赵啸非

添加线程发送消息

parent 977ba3d2
...@@ -326,7 +326,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -326,7 +326,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
//分组查找存在的与不存在的用户 //分组查找存在的与不存在的用户
Map<Boolean, List<UserPdu>> collect = list.parallelStream().collect(Collectors.partitioningBy(x -> existUserMap.containsKey(x.getLoginName()))); Map<Boolean, List<UserPdu>> collect = list.parallelStream().collect(Collectors.partitioningBy(x -> existUserMap.containsKey(x.getLoginName())));
List<UserPdu> userPdusUpdate = collect.get(true);//更新 List<UserPdu> userPdusUpdate = collect.get(true);//更新
List<UserEntity> userEntityUpdate = new ArrayList<>();
List<UserPdu> userPdusSave = collect.get(false);//新增 List<UserPdu> userPdusSave = collect.get(false);//新增
List<UserEntity> userEntitySave = new ArrayList<>(); List<UserEntity> userEntitySave = new ArrayList<>();
...@@ -356,7 +355,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -356,7 +355,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
Map<String, List<UserEntity>> saveSitesCollect = userEntitySave.stream().collect(Collectors.groupingBy(x -> x.getSiteIds())); Map<String, List<UserEntity>> saveSitesCollect = userEntitySave.stream().collect(Collectors.groupingBy(x -> x.getSiteIds()));
// Map<String, List<UserEntity>> updateSitesCollect = userEntityUpdate.stream().collect(Collectors.groupingBy(x -> x.getSiteIds())); // Map<String, List<UserEntity>> updateSitesCollect = userEntityUpdate.stream().collect(Collectors.groupingBy(x -> x.getSiteIds()));
saveSitesCollect.entrySet().stream().forEach(item -> { saveSitesCollect.entrySet().stream().forEach(item -> {
String siteIds = item.getKey();
List<UserEntity> userEntities = item.getValue(); List<UserEntity> userEntities = item.getValue();
if (!ObjectUtils.isEmpty(userEntities)) { if (!ObjectUtils.isEmpty(userEntities)) {
Context context = new Context(); Context context = new Context();
...@@ -364,35 +362,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -364,35 +362,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context, userEntities)); ThreadPool.getInstance().execute(new SyncTreeSiteThread(context, userEntities));
} }
}); });
/*
//如果用户未有所属站点 则不更新
for (UserPdu user : list) {
UserEntity tempUser = this.selectOne(new UserQuery().loginName(user.getLoginName()));
if (ObjectUtils.isEmpty(tempUser)) {
//新增
UserEntity entity = new UserEntity();
entity.initAttrValue();
BeanUtils.copyProperties(user, entity, BeanUtil.getNullPropertyNames(user));
this.save(entity);
if (!ObjectUtils.isEmpty(entity.getSiteIds())) {
Context context = new Context();
context.setUser(entity);
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
}
} else {
//更新
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"loginPwd", "loginName", "userType", "status", "lastLoginTime", "lastLoginAddress"});
userEntity.setId(tempUser.getId());
this.updateWidthDao(userEntity);
if (!ObjectUtils.isEmpty(userEntity.getSiteIds())) {
Context context = new Context();
context.setUser(userEntity);
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
}
}
}*/
} }
...@@ -458,8 +427,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -458,8 +427,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
log.info("需要删除的本地用户数量:{}", removeUserIds.length); log.info("需要删除的本地用户数量:{}", removeUserIds.length);
this.remove(removeUserIds, null); this.remove(removeUserIds, null);
} }
this.updateUserList(userPduList);
} }
//查找新增 与更新
} }
return Rest.ok(); return Rest.ok();
} }
......
...@@ -42,6 +42,9 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -42,6 +42,9 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
userService.refreshUser();
log.info("同步用户"); log.info("同步用户");
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
userPdu.setPage(1); userPdu.setPage(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment