|
|
@@ -6,28 +6,31 @@ import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.R;
|
|
|
import com.xunmei.common.core.utils.bean.BeanUtils;
|
|
|
import com.xunmei.common.core.utils.snowId.IDHelper;
|
|
|
+import com.xunmei.sync.domain.FjnxOrg;
|
|
|
import com.xunmei.sync.domain.FjnxOrgBusinessRelation;
|
|
|
-import com.xunmei.sync.domain.OrgFjnx;
|
|
|
+import com.xunmei.sync.domain.FjnxUser;
|
|
|
import com.xunmei.sync.dto.fjnxsync.FJNXOrgDto;
|
|
|
+import com.xunmei.sync.dto.fjnxsync.FJNXUserDto;
|
|
|
import com.xunmei.sync.dto.fjnxsync.FJNXXmlOrgDto;
|
|
|
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlUserDto;
|
|
|
import com.xunmei.sync.mapper.FjnxOrgBusinessRelationMapper;
|
|
|
-import com.xunmei.sync.service.IFJNXOrgSyncService;
|
|
|
-import com.xunmei.sync.service.IFJNXSyncService;
|
|
|
-import com.xunmei.sync.service.IFJNXUserSyncService;
|
|
|
-import com.xunmei.sync.service.IOrgJinxService;
|
|
|
+import com.xunmei.sync.service.*;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.RemoteUserService;
|
|
|
import com.xunmei.system.api.domain.Org;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.domain.SysUser;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import okhttp3.internal.Internal;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -45,89 +48,87 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
IFJNXUserSyncService ifjnxUserSyncService;
|
|
|
|
|
|
@Autowired
|
|
|
- IOrgJinxService iOrgJinxService;
|
|
|
+ IFJNXOrgService ifjnxOrgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IFJNXUserService ifjnxUserService;
|
|
|
|
|
|
@Autowired
|
|
|
RemoteOrgService remoteOrgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RemoteUserService remoteUserService;
|
|
|
+
|
|
|
@Resource
|
|
|
FjnxOrgBusinessRelationMapper fjnxOrgBusinessRelationMapper;
|
|
|
|
|
|
-// @Autowired
|
|
|
-// OrgService orgService;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private OrgRepository orgRepository;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private UserRepository userRepository;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// FjnxOrgBusinessRelationMapper orgBusinessRelationMapper;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private OrgExtendInfoMapper orgExtendInfoMapper;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private OrgExtendInfoServiceImpl orgExtendInfoService;
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public String SyncUserInfo() {
|
|
|
-// FJNXXmlUserDto fjnxXmlUserDto = ifjnxUserSyncService.getUserInfoByFileInfo();
|
|
|
-// if (fjnxXmlUserDto == null || ObjectUtil.isEmpty(fjnxXmlUserDto.getUserVos())) return "未获取到用户信息数据";
|
|
|
-//
|
|
|
-// List<User> existUserList = userRepository.findAll();
|
|
|
-// List<Org> existOrgList = orgRepository.findAll();
|
|
|
-//
|
|
|
-// if (ObjectUtil.isEmpty(existUserList)) {
|
|
|
-// userRepository.saveAll(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList));
|
|
|
-// } else {
|
|
|
-// List<User> addList = new ArrayList<>();
|
|
|
-// List<User> updateList = new ArrayList<>();
|
|
|
-// List<User> deleteList = new ArrayList<>();
|
|
|
-// List<String> fjnxUserCodeList = new ArrayList<>();
|
|
|
-//
|
|
|
-// fjnxXmlUserDto.getUserVos().stream().forEach(fjnxUser -> {
|
|
|
-// String orgCode = fjnxUser.getDepCode();
|
|
|
-// if (!StringUtil.isNullOrEmpty(orgCode) && !StringUtil.isNullOrEmpty(fjnxUser.getUserId())) {
|
|
|
-// Optional<Org> optionalOrg = existOrgList.stream().filter(x -> orgCode.equals(x.getCode())).findFirst();
|
|
|
-// if (optionalOrg.isPresent()) {
|
|
|
-// Optional<User> optionalUser = existUserList.stream().filter(x -> fjnxUser.getUserId().equals(x.getCode())).findFirst();
|
|
|
-// if (optionalUser.isPresent()) {
|
|
|
-// updateList.add(FjnxUserConvertToUser(fjnxUser, optionalUser.get(), optionalOrg.get()));
|
|
|
-// } else {
|
|
|
-// addList.add(FjnxUserConvertToUser(fjnxUser, optionalOrg.get()));
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", fjnxUser.getUserId() + fjnxUser.getUserName(), fjnxUser.getDepCode(), fjnxUser);
|
|
|
-// }
|
|
|
-// fjnxUserCodeList.add(fjnxUser.getUserId());
|
|
|
-// }
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-// // 人员在本系统中存在 但是在统一运营门户中不存在
|
|
|
-// deleteList = existUserList.stream().filter(entity -> !fjnxUserCodeList.contains(entity.getCode())).collect(Collectors.toList());
|
|
|
-// deleteList.forEach(x -> x.setDeleted(true));
|
|
|
-//
|
|
|
-// if (ObjectUtil.isNotEmpty(addList)) {
|
|
|
-// userRepository.saveAll(addList);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (ObjectUtil.isNotEmpty(updateList)) {
|
|
|
-// userRepository.saveAll(updateList);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (ObjectUtil.isNotEmpty(deleteList)) {
|
|
|
-// userRepository.saveAll(deleteList);
|
|
|
-// }
|
|
|
+ FJNXXmlUserDto fjnxXmlUserDto = ifjnxUserSyncService.getUserInfoByFileInfo();
|
|
|
+ if (fjnxXmlUserDto == null || ObjectUtil.isEmpty(fjnxXmlUserDto.getUserVos())) return "未获取到用户信息数据";
|
|
|
+
|
|
|
+ // 将同步到的用户数据线保存下来
|
|
|
+ List<FjnxUser> fjnxUserList = FjnxXmlUsersDtoConvertToFjnxUsers(fjnxXmlUserDto.getUserVos());
|
|
|
+ ifjnxUserService.saveOrUpdateBatch(fjnxUserList);
|
|
|
+
|
|
|
+ // 获取系统当前存在的用户信息
|
|
|
+ SysUser request = new SysUser();
|
|
|
+ request.setSource(1);
|
|
|
+ R<List<SysUser>> existUserResult = remoteUserService.getAllSyncUser(request,SecurityConstants.INNER);
|
|
|
+ if (existUserResult.getCode() != 200) {
|
|
|
+ return "remoteUserService.getAllSyncUser 调用失败:" + existUserResult.getMsg();
|
|
|
+ }
|
|
|
+ List<SysUser> existUserList = existUserResult.getData();
|
|
|
|
|
|
+ // 获取系统当前存在的机构信息
|
|
|
+ R<List<SysOrg>> existAllOrgResult = remoteOrgService.getAllOrg(SecurityConstants.INNER);
|
|
|
+ if (existAllOrgResult.getCode() != 200) {
|
|
|
+ return "remoteOrgService.getAllOrg 调用失败:" + existAllOrgResult.getMsg();
|
|
|
+ }
|
|
|
+ List<SysOrg> existOrgList = existAllOrgResult.getData();
|
|
|
|
|
|
-// }
|
|
|
+ //将FJNXUser 转换为SysUser 并保存
|
|
|
+ if (ObjectUtil.isEmpty(existUserList)) {
|
|
|
+ final R<Boolean> booleanR = remoteUserService.batchSaveSyncUser(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList), SecurityConstants.INNER);
|
|
|
+ if (booleanR != null && booleanR.getCode() != 200) {
|
|
|
+ log.error("调用远程服务接口remoteUserService.batchSaveSyncOrg 失败:{0}", booleanR.getMsg());
|
|
|
+ return "remoteUserService.batchSaveSyncUser 调用失败:" + booleanR.getMsg();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<SysUser> addList = new ArrayList<>();
|
|
|
+ List<SysUser> updateList = new ArrayList<>();
|
|
|
+ List<SysUser> deleteList = new ArrayList<>();
|
|
|
+ List<String> fjnxUserCodeList = new ArrayList<>();
|
|
|
+
|
|
|
+ fjnxXmlUserDto.getUserVos().stream().forEach(fjnxUser -> {
|
|
|
+ String orgCode = fjnxUser.getDepCode();
|
|
|
+ if (!StringUtil.isNullOrEmpty(orgCode) && !StringUtil.isNullOrEmpty(fjnxUser.getUserId())) {
|
|
|
+ Optional<SysOrg> optionalOrg = existOrgList.stream().filter(x -> orgCode.equals(x.getCode())).findFirst();
|
|
|
+ if (optionalOrg.isPresent()) {
|
|
|
+ Optional<SysUser> optionalUser = existUserList.stream().filter(x -> fjnxUser.getUserId().equals(x.getCode())).findFirst();
|
|
|
+ if (optionalUser.isPresent()) {
|
|
|
+ updateList.add(FjnxUserConvertToUser(fjnxUser, optionalUser.get(), optionalOrg.get()));
|
|
|
+ } else {
|
|
|
+ addList.add(FjnxUserConvertToUser(fjnxUser, optionalOrg.get()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", fjnxUser.getUserId() + fjnxUser.getUserName(), fjnxUser.getDepCode(), fjnxUser);
|
|
|
+ }
|
|
|
+ fjnxUserCodeList.add(fjnxUser.getUserId());
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ // 人员在本系统中存在 但是在统一运营门户中不存在
|
|
|
+ deleteList = existUserList.stream().filter(entity -> !fjnxUserCodeList.contains(entity.getCode())&& entity.getSource()==1).collect(Collectors.toList());
|
|
|
+ deleteList.forEach(x -> x.setDeleted(1L));
|
|
|
+ existUserList.addAll(addList);
|
|
|
|
|
|
+ final R<Boolean> booleanR = remoteUserService.batchSaveSyncUser(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList), SecurityConstants.INNER);
|
|
|
+ if (booleanR != null && booleanR.getCode() != 200) {
|
|
|
+ log.error("调用远程服务接口remoteUserService.batchSaveSyncOrg 失败:{0}", booleanR.getMsg());
|
|
|
+ return "remoteUserService.batchSaveSyncUser 调用失败:" + booleanR.getMsg();
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -145,12 +146,12 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
if (fjnxXmlOrgDto == null || ObjectUtil.isEmpty(fjnxXmlOrgDto.getOrgVos())) return "未获取到机构信息数据";
|
|
|
|
|
|
|
|
|
- List<OrgFjnx> fjnxOrgList=ConvertXmlOrgDtoToOrgJinx(fjnxXmlOrgDto.getOrgVos());
|
|
|
- iOrgJinxService.saveOrUpdateBatch(fjnxOrgList);
|
|
|
+ List<FjnxOrg> fjnxOrgList = ConvertXmlOrgDtoToOrgJinx(fjnxXmlOrgDto.getOrgVos());
|
|
|
+ ifjnxOrgService.saveOrUpdateBatch(fjnxOrgList);
|
|
|
|
|
|
|
|
|
R<List<SysOrg>> existAllOrgResult = remoteOrgService.getAllOrg(SecurityConstants.INNER);
|
|
|
- if(existAllOrgResult.getCode()!=200){
|
|
|
+ if (existAllOrgResult.getCode() != 200) {
|
|
|
return existAllOrgResult.getMsg();
|
|
|
}
|
|
|
List<SysOrg> existOrgList = existAllOrgResult.getData();
|
|
|
@@ -162,9 +163,8 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
List<SysOrg> rList = FjnxOrgsConvertToSysOrgs(fjnxOrgList);
|
|
|
resetParentIdAndPath(rList);
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(rList, SecurityConstants.INNER);
|
|
|
- if(listR.getCode()!=200)
|
|
|
- {
|
|
|
- log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}",listR.getMsg());
|
|
|
+ if (listR != null && listR.getCode() != 200) {
|
|
|
+ log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}", listR.getMsg());
|
|
|
return listR.getMsg();
|
|
|
}
|
|
|
return null;
|
|
|
@@ -177,21 +177,18 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
fjnxOrgList.stream().forEach(fjnxOrg -> {
|
|
|
String fjnxorgCode = fjnxOrg.getOrgCode();
|
|
|
if (!StringUtil.isNullOrEmpty(fjnxorgCode)) {
|
|
|
- if(ObjectUtil.isNotEmpty(existOrgList)){
|
|
|
+ if (ObjectUtil.isNotEmpty(existOrgList)) {
|
|
|
Optional<SysOrg> optional = existOrgList.stream().filter(x -> fjnxOrg.getOrgCode().equals(x.getCode())).findFirst();
|
|
|
if (optional.isPresent()) {
|
|
|
updateList.add(FjnxOrgConvertToSysOrg(optional.get(), fjnxOrg));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
addList.add(FjnxOrgConvertToSysOrg(fjnxOrg));
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
addList.add(FjnxOrgConvertToSysOrg(fjnxOrg));
|
|
|
}
|
|
|
fjnxOrgCodeList.add(fjnxOrg.getOrgCode());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
log.error("机构编码为空停止转换为系统机构,机构名称{0}", fjnxOrg.getOrgName());
|
|
|
}
|
|
|
});
|
|
|
@@ -205,9 +202,8 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
resetParentIdAndPath(existOrgList);
|
|
|
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(existOrgList, SecurityConstants.INNER);
|
|
|
- if(ObjectUtil.isNotEmpty(listR) && listR.getCode()!=200)
|
|
|
- {
|
|
|
- log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}",listR.getMsg());
|
|
|
+ if (ObjectUtil.isNotEmpty(listR) && listR.getCode() != 200) {
|
|
|
+ log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}", listR.getMsg());
|
|
|
return listR.getMsg();
|
|
|
}
|
|
|
return null;
|
|
|
@@ -254,7 +250,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
public void resetParentIdAndPath(List<SysOrg> orgList) {
|
|
|
|
|
|
- final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0==topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
+ final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0 == topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
collect.stream().forEach(org -> {
|
|
|
org.setParentId(-1L);
|
|
|
// org.setLevel(1);
|
|
|
@@ -267,14 +263,13 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(org.getDeleted().equals(1))
|
|
|
- {
|
|
|
+ if (org.getDeleted().equals(1)) {
|
|
|
// 已删除
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!StringUtil.isNullOrEmpty(org.getParentGuid())) {
|
|
|
- Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg ->!StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(org.getParentGuid())).findFirst();
|
|
|
+ Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg -> !StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(org.getParentGuid())).findFirst();
|
|
|
if (parentOrgOptional.isPresent()) {
|
|
|
org.setParentId(parentOrgOptional.get().getId());
|
|
|
if (StringUtil.isNullOrEmpty(parentOrgOptional.get().getPath())) {
|
|
|
@@ -296,7 +291,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
}
|
|
|
|
|
|
public void resetParentOrgPath(SysOrg parentOrg, List<SysOrg> childOrg, List<SysOrg> orgList) {
|
|
|
- Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg ->!StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(parentOrg.getParentGuid())).findFirst();
|
|
|
+ Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg -> !StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(parentOrg.getParentGuid())).findFirst();
|
|
|
if (parentOrgOptional.isPresent()) {
|
|
|
parentOrg.setParentId(parentOrgOptional.get().getId());
|
|
|
if (!StringUtil.isNullOrEmpty(parentOrgOptional.get().getPath())) {
|
|
|
@@ -361,7 +356,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
- private SysOrg FjnxOrgConvertToOrg(OrgFjnx fjnxOrgDto) {
|
|
|
+ private SysOrg FjnxOrgConvertToOrg(FjnxOrg fjnxOrgDto) {
|
|
|
SysOrg org = new SysOrg();
|
|
|
org.setId(IDHelper.id());
|
|
|
org.setName(fjnxOrgDto.getOrgName());
|
|
|
@@ -383,7 +378,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private List<SysOrg> FjnxOrgsConvertToSysOrgs(List<OrgFjnx> fjnxOrgList) {
|
|
|
+ private List<SysOrg> FjnxOrgsConvertToSysOrgs(List<FjnxOrg> fjnxOrgList) {
|
|
|
List<SysOrg> result = new ArrayList<>();
|
|
|
if (ObjectUtil.isNotEmpty(fjnxOrgList)) {
|
|
|
fjnxOrgList.stream().forEach(x -> {
|
|
|
@@ -393,7 +388,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private SysOrg FjnxOrgConvertToSysOrg(OrgFjnx fjnxOrgDto) {
|
|
|
+ private SysOrg FjnxOrgConvertToSysOrg(FjnxOrg fjnxOrgDto) {
|
|
|
SysOrg org = new SysOrg();
|
|
|
org.setId(IDHelper.id());
|
|
|
org.setName(fjnxOrgDto.getOrgName());
|
|
|
@@ -471,7 +466,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private SysOrg FjnxOrgConvertToSysOrg(SysOrg org, OrgFjnx fjnxOrg) {
|
|
|
+ private SysOrg FjnxOrgConvertToSysOrg(SysOrg org, FjnxOrg fjnxOrg) {
|
|
|
org.setName(fjnxOrg.getOrgName());
|
|
|
org.setShortName(fjnxOrg.getShortName());
|
|
|
org.setCode(fjnxOrg.getOrgCode());
|
|
|
@@ -490,88 +485,105 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// private List<User> FjnxUsersConvertToUsers(List<FJNXUserDto> fjnxUserDtoList, List<Org> orgList) {
|
|
|
-// List<User> result = new ArrayList<>();
|
|
|
-// if (ObjectUtil.isNotEmpty(fjnxUserDtoList)) {
|
|
|
-// fjnxUserDtoList.stream().forEach(x -> {
|
|
|
-// Optional<Org> optionalOrg = orgList.stream().filter(org -> org.getCode().equals(x.getDepCode())).findFirst();
|
|
|
-// if (optionalOrg.isPresent()) {
|
|
|
-// result.add(FjnxUserConvertToUser(x, optionalOrg.get()));
|
|
|
-// } else {
|
|
|
-// log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", x.getUserId() + x.getUserName(), x.getDepCode(), x);
|
|
|
-// }
|
|
|
-//
|
|
|
-// });
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// private User FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, Org org) {
|
|
|
-// User user = new User();
|
|
|
-// user.setCode(fjnxUserDto.getUserId());
|
|
|
-// user.setName(fjnxUserDto.getUserName());
|
|
|
-// user.setUsername(fjnxUserDto.getLoginName());
|
|
|
-// user.setPhone(fjnxUserDto.getMobile());
|
|
|
-// user.setGender(fjnxUserDto.getSex().equals("1") ? Gender.MAN : Gender.WOMAN);
|
|
|
-// user.setCard(fjnxUserDto.getIdCard());
|
|
|
-// user.setJobNumber(fjnxUserDto.getTeller());
|
|
|
-// user.setApproveStatus(ApproveStatus.PASS);
|
|
|
-// user.setUpdateTime(fjnxUserDto.getUpdateTime());
|
|
|
-// user.setOrgId(org.getId());
|
|
|
-// user.setOrgName(org.getName());
|
|
|
-// user.setOrgPath(org.getPath());
|
|
|
-// //0 禁用 1 启用已改密码 2 启用未改密码
|
|
|
-// user.setIsLock(fjnxUserDto.getUserStatus().equals("0") ? true : false);
|
|
|
-// // TODO 机构状态和机构类型转换
|
|
|
-// //user.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
-// return user;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// private User FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, User user, Org org) {
|
|
|
-// user.setCode(fjnxUserDto.getUserId());
|
|
|
-// user.setName(fjnxUserDto.getUserName());
|
|
|
-// user.setUsername(fjnxUserDto.getLoginName());
|
|
|
-// user.setPhone(fjnxUserDto.getMobile());
|
|
|
-// user.setGender(fjnxUserDto.getSex().equals("1") ? Gender.MAN : Gender.WOMAN);
|
|
|
-// user.setCard(fjnxUserDto.getIdCard());
|
|
|
-// user.setJobNumber(fjnxUserDto.getTeller());
|
|
|
+
|
|
|
+ private List<FjnxUser> FjnxXmlUsersDtoConvertToFjnxUsers(List<FJNXUserDto> fjnxUserDtoList) {
|
|
|
+ List<FjnxUser> result = new ArrayList<>();
|
|
|
+ Date syncDateTime = new Date();
|
|
|
+ if (ObjectUtil.isNotEmpty(fjnxUserDtoList)) {
|
|
|
+ fjnxUserDtoList.stream().forEach(userDto -> {
|
|
|
+
|
|
|
+ FjnxUser tempFjnxUser = new FjnxUser();
|
|
|
+ BeanUtils.copyBeanProp(tempFjnxUser, userDto);
|
|
|
+ tempFjnxUser.setLastSyncTime(syncDateTime);
|
|
|
+ result.add(tempFjnxUser);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<SysUser> FjnxUsersConvertToUsers(List<FJNXUserDto> fjnxUserDtoList, List<SysOrg> orgList) {
|
|
|
+ List<SysUser> result = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(fjnxUserDtoList)) {
|
|
|
+ fjnxUserDtoList.stream().forEach(x -> {
|
|
|
+ Optional<SysOrg> optionalOrg = orgList.stream().filter(org -> org.getCode().equals(x.getDepCode())).findFirst();
|
|
|
+ if (optionalOrg.isPresent()) {
|
|
|
+ result.add(FjnxUserConvertToUser(x, optionalOrg.get()));
|
|
|
+ } else {
|
|
|
+ log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", x.getUserId() + x.getUserName(), x.getDepCode(), x);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysOrg org) {
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ user.setCode(fjnxUserDto.getUserId());
|
|
|
+ user.setName(fjnxUserDto.getUserName());
|
|
|
+ user.setUsername(fjnxUserDto.getLoginName());
|
|
|
+ user.setPhone(fjnxUserDto.getMobile());
|
|
|
+ user.setGender(fjnxUserDto.getSex());
|
|
|
+ user.setCard(fjnxUserDto.getIdCard());
|
|
|
+ user.setJobNumber(fjnxUserDto.getTeller());
|
|
|
// user.setApproveStatus(ApproveStatus.PASS);
|
|
|
-// user.setUpdateTime(fjnxUserDto.getUpdateTime());
|
|
|
-// user.setOrgId(org.getId());
|
|
|
-// user.setOrgName(org.getName());
|
|
|
-// user.setOrgPath(org.getPath());
|
|
|
-// //0 禁用 1 启用已改密码 2 启用未改密码
|
|
|
-// user.setIsLock(fjnxUserDto.getUserStatus().equals("0") ? true : false);
|
|
|
-// // TODO 机构状态和机构类型转换
|
|
|
-// //user.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
-// return user;
|
|
|
-//
|
|
|
-// }
|
|
|
+ user.setUpdateTime(fjnxUserDto.getUpdateTime());
|
|
|
+ user.setOrgId(org.getId());
|
|
|
+ user.setOrgName(org.getName());
|
|
|
+ user.setOrgPath(org.getPath());
|
|
|
+ //0 禁用 1 启用已改密码 2 启用未改密码
|
|
|
+ user.setIsLock(fjnxUserDto.getUserStatus());
|
|
|
+ user.setSource(1);
|
|
|
+ // TODO 机构状态和机构类型转换
|
|
|
+ //user.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
+ return user;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysUser user, SysOrg org) {
|
|
|
+ user.setCode(fjnxUserDto.getUserId());
|
|
|
+ user.setName(fjnxUserDto.getUserName());
|
|
|
+ user.setUsername(fjnxUserDto.getLoginName());
|
|
|
+ user.setPhone(fjnxUserDto.getMobile());
|
|
|
+ user.setGender(fjnxUserDto.getSex());
|
|
|
+ user.setCard(fjnxUserDto.getIdCard());
|
|
|
+ user.setJobNumber(fjnxUserDto.getTeller());
|
|
|
+ user.setApproveStatus(1L);
|
|
|
+ user.setUpdateTime(fjnxUserDto.getUpdateTime());
|
|
|
+ user.setOrgId(org.getId());
|
|
|
+ user.setOrgName(org.getName());
|
|
|
+ user.setOrgPath(org.getPath());
|
|
|
+ //0 禁用 1 启用已改密码 2 启用未改密码
|
|
|
+ user.setIsLock(fjnxUserDto.getUserStatus());
|
|
|
+ // TODO 机构状态和机构类型转换
|
|
|
+ //user.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
+ user.setSource(1);
|
|
|
+ return user;
|
|
|
|
|
|
- private List<OrgFjnx> ConvertXmlOrgDtoToOrgJinx(List<FJNXOrgDto> list) {
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<FjnxOrg> ConvertXmlOrgDtoToOrgJinx(List<FJNXOrgDto> list) {
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
- return new ArrayList<OrgFjnx>();
|
|
|
+ return new ArrayList<FjnxOrg>();
|
|
|
}
|
|
|
List<FjnxOrgBusinessRelation> fjnxOrgBusinessRelationList = fjnxOrgBusinessRelationMapper.selectList(Wrappers.emptyWrapper());
|
|
|
- final ArrayList<OrgFjnx> resultList = new ArrayList<>();
|
|
|
- Date syncDateTime=new Date();
|
|
|
+ final ArrayList<FjnxOrg> resultList = new ArrayList<>();
|
|
|
+ Date syncDateTime = new Date();
|
|
|
list.stream().forEach(item -> {
|
|
|
- OrgFjnx tempOrg = new OrgFjnx();
|
|
|
+ FjnxOrg tempOrg = new FjnxOrg();
|
|
|
BeanUtils.copyBeanProp(tempOrg, item);
|
|
|
|
|
|
tempOrg.setLastSyncTime(syncDateTime);
|
|
|
tempOrg.setBusinessParentCode(tempOrg.getOrgParent());
|
|
|
|
|
|
Optional<FjnxOrgBusinessRelation> first = fjnxOrgBusinessRelationList.stream().filter(b -> b.getOrgCode().equals(item.getOrgCode())).findFirst();
|
|
|
- if(first.isPresent())
|
|
|
- {
|
|
|
- if( list.stream().anyMatch(y->y.getOrgCode().equals(first.get().getBusinessParentCode()))){
|
|
|
- tempOrg.setBusinessParentCode(first.get().getBusinessParentCode());
|
|
|
- }
|
|
|
- else{
|
|
|
- log.error("设置fjnx业务父级机构失败,机构名称:{0},机构编码:{1},业务父级机构编码:{2}", item.getOrgName(),first.get().getOrgCode(), first.get().getBusinessParentCode());
|
|
|
- }
|
|
|
+ if (first.isPresent()) {
|
|
|
+ if (list.stream().anyMatch(y -> y.getOrgCode().equals(first.get().getBusinessParentCode()))) {
|
|
|
+ tempOrg.setBusinessParentCode(first.get().getBusinessParentCode());
|
|
|
+ } else {
|
|
|
+ log.error("设置fjnx业务父级机构失败,机构名称:{0},机构编码:{1},业务父级机构编码:{2}", item.getOrgName(), first.get().getOrgCode(), first.get().getBusinessParentCode());
|
|
|
+ }
|
|
|
}
|
|
|
resultList.add(tempOrg);
|
|
|
});
|