|
|
@@ -20,7 +20,6 @@ import com.xunmei.system.api.RemoteUserService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.domain.SysUser;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -66,7 +65,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String SyncUserInfo() {
|
|
|
FJNXXmlUserDto fjnxXmlUserDto = ifjnxUserSyncService.getUserInfoByFileInfo();
|
|
|
- if (fjnxXmlUserDto == null || ObjectUtil.isEmpty(fjnxXmlUserDto.getUserVos())){
|
|
|
+ if (fjnxXmlUserDto == null || ObjectUtil.isEmpty(fjnxXmlUserDto.getUserVos())) {
|
|
|
return "未获取到用户信息数据";
|
|
|
}
|
|
|
|
|
|
@@ -78,7 +77,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
// 获取系统当前存在的用户信息
|
|
|
SysUser request = new SysUser();
|
|
|
request.setSource(1);
|
|
|
- R<List<SysUser>> existUserResult = remoteUserService.getAllSyncUser(request,SecurityConstants.INNER);
|
|
|
+ R<List<SysUser>> existUserResult = remoteUserService.getAllSyncUser(request, SecurityConstants.INNER);
|
|
|
if (existUserResult.getCode() != 200) {
|
|
|
return "remoteUserService.getAllSyncUser 调用失败:" + existUserResult.getMsg();
|
|
|
}
|
|
|
@@ -95,7 +94,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
//将FJNXUser 转换为SysUser 并保存
|
|
|
if (ObjectUtil.isEmpty(existUserList)) {
|
|
|
- final R<Boolean> booleanR = remoteUserService.batchSaveSyncUser(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList,existFjnxOrgList), SecurityConstants.INNER);
|
|
|
+ final R<Boolean> booleanR = remoteUserService.batchSaveSyncUser(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList, existFjnxOrgList), SecurityConstants.INNER);
|
|
|
if (booleanR != null && booleanR.getCode() != 200) {
|
|
|
log.error("调用远程服务接口remoteUserService.batchSaveSyncOrg 失败:{}", booleanR.getMsg());
|
|
|
return "remoteUserService.batchSaveSyncUser 调用失败:" + booleanR.getMsg();
|
|
|
@@ -114,7 +113,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
Optional<SysOrg> optionalOrg = existOrgList.stream().filter(x -> orgCode.equals(x.getCode())).findFirst();
|
|
|
|
|
|
- SysOrg userBusinessSysOrg= getUserBusinessFjnxOrg(existFjnxOrgList,existOrgList,fjnxUser);
|
|
|
+ SysOrg userBusinessSysOrg = getUserBusinessFjnxOrg(existFjnxOrgList, existOrgList, fjnxUser);
|
|
|
if (optionalOrg.isPresent() && ObjectUtil.isNotEmpty(userBusinessSysOrg)) {
|
|
|
// final Optional<SysOrg> businessSysOrgOptional = existOrgList.stream().filter(x -> userBusinessFjnxOrg.getOrgCode().equals(x.getCode())).findFirst();
|
|
|
// if(!businessSysOrgOptional.isPresent())
|
|
|
@@ -123,9 +122,9 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
// }
|
|
|
Optional<SysUser> optionalUser = existUserList.stream().filter(x -> fjnxUser.getUserId().equals(x.getCode())).findFirst();
|
|
|
if (optionalUser.isPresent()) {
|
|
|
- updateList.add(FjnxUserConvertToUser(fjnxUser, optionalUser.get(), optionalOrg.get(),userBusinessSysOrg));
|
|
|
+ updateList.add(FjnxUserConvertToUser(fjnxUser, optionalUser.get(), optionalOrg.get(), userBusinessSysOrg));
|
|
|
} else {
|
|
|
- addList.add(FjnxUserConvertToUser(fjnxUser, optionalOrg.get(),userBusinessSysOrg));
|
|
|
+ addList.add(FjnxUserConvertToUser(fjnxUser, optionalOrg.get(), userBusinessSysOrg));
|
|
|
}
|
|
|
} else {
|
|
|
log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", fjnxUser.getUserId() + fjnxUser.getUserName(), fjnxUser.getDepCode(), fjnxUser);
|
|
|
@@ -135,7 +134,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
});
|
|
|
|
|
|
// 人员在本系统中存在 但是在统一运营门户中不存在
|
|
|
- deleteList = existUserList.stream().filter(entity -> !fjnxUserCodeList.contains(entity.getCode())&& entity.getSource()==1).collect(Collectors.toList());
|
|
|
+ deleteList = existUserList.stream().filter(entity -> !fjnxUserCodeList.contains(entity.getCode()) && entity.getSource() == 1).collect(Collectors.toList());
|
|
|
deleteList.forEach(x -> x.setDeleted(1));
|
|
|
existUserList.addAll(addList);
|
|
|
|
|
|
@@ -158,8 +157,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
* 5、调用机构接口保存机构数据
|
|
|
* */
|
|
|
FJNXXmlOrgDto fjnxXmlOrgDto = ifjnxOrgSyncService.getOrgInfoByFileInfo();
|
|
|
- if (fjnxXmlOrgDto == null || ObjectUtil.isEmpty(fjnxXmlOrgDto.getOrgVos()))
|
|
|
- {
|
|
|
+ if (fjnxXmlOrgDto == null || ObjectUtil.isEmpty(fjnxXmlOrgDto.getOrgVos())) {
|
|
|
return "未获取到机构信息数据";
|
|
|
}
|
|
|
|
|
|
@@ -180,6 +178,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
if (ObjectUtil.isEmpty(existOrgList)) {
|
|
|
List<SysOrg> rList = FjnxOrgsConvertToSysOrgs(fjnxOrgList);
|
|
|
resetParentIdAndPath(rList);
|
|
|
+ resetTreeParentIdAndPath(rList);
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(rList, SecurityConstants.INNER);
|
|
|
if (listR != null && listR.getCode() != 200) {
|
|
|
log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{}", listR.getMsg());
|
|
|
@@ -218,6 +217,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
existOrgList.addAll(addList);
|
|
|
|
|
|
resetParentIdAndPath(existOrgList);
|
|
|
+ resetTreeParentIdAndPath(existOrgList);
|
|
|
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(existOrgList, SecurityConstants.INNER);
|
|
|
if (ObjectUtil.isNotEmpty(listR) && listR.getCode() != 200) {
|
|
|
@@ -268,7 +268,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
}
|
|
|
|
|
|
public void resetParentIdAndPath(List<SysOrg> orgList) {
|
|
|
- orgList.stream().forEach(x->{
|
|
|
+ orgList.stream().forEach(x -> {
|
|
|
x.setPath("");
|
|
|
});
|
|
|
final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0 == topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
@@ -352,6 +352,82 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void resetTreeParentIdAndPath(List<SysOrg> orgList) {
|
|
|
+ orgList.stream().forEach(x -> {
|
|
|
+ x.setTreeShowPath("");
|
|
|
+ });
|
|
|
+ final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getTreeParentCode()) && 0 == topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
+ collect.forEach(org -> {
|
|
|
+ org.setTreeShowParentId(-1L);
|
|
|
+ org.setTreeShowPath(org.getId() + "-");
|
|
|
+ });
|
|
|
+
|
|
|
+ orgList.forEach(org -> {
|
|
|
+ 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.getTreeParentCode())).findFirst();
|
|
|
+ if (parentOrgOptional.isPresent()) {
|
|
|
+ org.setTreeShowParentId(parentOrgOptional.get().getId());
|
|
|
+ if (StringUtil.isNullOrEmpty(parentOrgOptional.get().getTreeShowPath())) {
|
|
|
+ List<SysOrg> childOrg = new ArrayList<>();
|
|
|
+ childOrg.add(org);
|
|
|
+ resetTreeParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
|
|
|
+ } else {
|
|
|
+ org.setTreeShowPath(parentOrgOptional.get().getTreeShowPath() + org.getId() + "-");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", org.getName(), org.getGuid(), org.getParentGuid(), org);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ org.setTreeShowParentId(-1L);
|
|
|
+// org.setLevel(1);
|
|
|
+ org.setTreeShowPath(org.getId() + "-");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetTreeParentOrgPath(SysOrg parentOrg, List<SysOrg> childOrg, List<SysOrg> orgList) {
|
|
|
+ Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg -> !StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(parentOrg.getTreeParentCode())).findFirst();
|
|
|
+ if (parentOrgOptional.isPresent()) {
|
|
|
+ parentOrg.setTreeShowParentId(parentOrgOptional.get().getId());
|
|
|
+ if (!StringUtil.isNullOrEmpty(parentOrgOptional.get().getTreeShowPath())) {
|
|
|
+ retTreeOrgPath(parentOrgOptional.get(), parentOrg);
|
|
|
+ retChildTreeOrgPath(parentOrg, childOrg);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ childOrg.add(parentOrg);
|
|
|
+ resetTreeParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", parentOrg.getName(), parentOrg.getGuid(), parentOrg.getParentGuid(), parentOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void retTreeOrgPath(SysOrg parentOrg, SysOrg org) {
|
|
|
+ org.setTreeShowParentId(parentOrg.getId());
|
|
|
+ org.setTreeShowPath(parentOrg.getTreeShowPath() + org.getId() + "-");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void retChildTreeOrgPath(SysOrg parentOrg, List<SysOrg> childOrgs) {
|
|
|
+ if (ObjectUtil.isNotEmpty(childOrgs)) {
|
|
|
+ if (ObjectUtil.isNotEmpty(parentOrg)) {
|
|
|
+ Optional<SysOrg> orgOptional = childOrgs.stream().filter(org -> org.getTreeShowParentId().equals(parentOrg.getId())).findFirst();
|
|
|
+ if (orgOptional.isPresent()) {
|
|
|
+ SysOrg childOrg = orgOptional.get();
|
|
|
+ retTreeOrgPath(parentOrg, childOrg);
|
|
|
+ childOrgs.remove(childOrg);
|
|
|
+ retChildTreeOrgPath(childOrg, childOrgs);
|
|
|
+ } else {
|
|
|
+ log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", parentOrg.getName(), parentOrg.getGuid(), parentOrg.getParentGuid(), parentOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// private void updateChildBusinessPath(Org businessParentOrg, List<Org> allOrgList) {
|
|
|
// List<Org> childrenOrgs = allOrgList.stream().filter(aorg -> businessParentOrg.getId().equals(aorg.getParentId())).collect(Collectors.toList());
|
|
|
// for (final Org org : childrenOrgs) {
|
|
|
@@ -377,27 +453,27 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
- private SysOrg FjnxOrgConvertToOrg(FjnxOrg fjnxOrgDto) {
|
|
|
- SysOrg org = new SysOrg();
|
|
|
- org.setId(IDHelper.id());
|
|
|
- org.setName(fjnxOrgDto.getOrgName());
|
|
|
- org.setShortName(fjnxOrgDto.getShortName());
|
|
|
- org.setGuid(fjnxOrgDto.getOrgCode());
|
|
|
- org.setParentGuid(fjnxOrgDto.getOrgParent());
|
|
|
- org.setCode(fjnxOrgDto.getOrgCode());
|
|
|
- org.setPhone(fjnxOrgDto.getOrgPhone());
|
|
|
- org.setAddress(fjnxOrgDto.getOrgAddress());
|
|
|
-// org.setCodePath(fjnxOrgDto.getOrgPath());
|
|
|
- org.setSort(fjnxOrgDto.getOrgOrder());
|
|
|
- org.setUpdateTime(fjnxOrgDto.getUpdateTime());
|
|
|
- org.setRemark(fjnxOrgDto.getRemark());
|
|
|
-// org.setLevel(fjnxOrgDto.getOrgPath().split("/").length);
|
|
|
- // TODO 机构状态和机构类型转换
|
|
|
- //org.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
- org.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
- return org;
|
|
|
-
|
|
|
- }
|
|
|
+// private SysOrg FjnxOrgConvertToOrg(FjnxOrg fjnxOrgDto) {
|
|
|
+// SysOrg org = new SysOrg();
|
|
|
+// org.setId(IDHelper.id());
|
|
|
+// org.setName(fjnxOrgDto.getOrgName());
|
|
|
+// org.setShortName(fjnxOrgDto.getShortName());
|
|
|
+// org.setGuid(fjnxOrgDto.getOrgCode());
|
|
|
+// org.setParentGuid(fjnxOrgDto.getOrgParent());
|
|
|
+// org.setCode(fjnxOrgDto.getOrgCode());
|
|
|
+// org.setPhone(fjnxOrgDto.getOrgPhone());
|
|
|
+// org.setAddress(fjnxOrgDto.getOrgAddress());
|
|
|
+//// org.setCodePath(fjnxOrgDto.getOrgPath());
|
|
|
+// org.setSort(fjnxOrgDto.getOrgOrder());
|
|
|
+// org.setUpdateTime(fjnxOrgDto.getUpdateTime());
|
|
|
+// org.setRemark(fjnxOrgDto.getRemark());
|
|
|
+//// org.setLevel(fjnxOrgDto.getOrgPath().split("/").length);
|
|
|
+// // TODO 机构状态和机构类型转换
|
|
|
+// //org.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
+// org.setIsLock(fjnxOrgDto.getUsableFlag());
|
|
|
+// return org;
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
private List<SysOrg> FjnxOrgsConvertToSysOrgs(List<FjnxOrg> fjnxOrgList) {
|
|
|
List<SysOrg> result = new ArrayList<>();
|
|
|
@@ -417,6 +493,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
org.setCode(fjnxOrgDto.getOrgCode());
|
|
|
org.setGuid(fjnxOrgDto.getOrgCode());
|
|
|
org.setParentGuid(fjnxOrgDto.getBusinessParentCode());
|
|
|
+ org.setTreeParentCode(fjnxOrgDto.getTreeShowParentCode());
|
|
|
org.setPhone(fjnxOrgDto.getOrgPhone());
|
|
|
org.setAddress(fjnxOrgDto.getOrgAddress());
|
|
|
org.setSort(fjnxOrgDto.getOrgOrder());
|
|
|
@@ -494,6 +571,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
org.setCode(fjnxOrg.getOrgCode());
|
|
|
org.setGuid(fjnxOrg.getOrgCode());
|
|
|
org.setParentGuid(fjnxOrg.getBusinessParentCode());
|
|
|
+ org.setTreeParentCode(fjnxOrg.getTreeShowParentCode());
|
|
|
org.setPhone(fjnxOrg.getOrgPhone());
|
|
|
org.setAddress(fjnxOrg.getOrgAddress());
|
|
|
org.setSort(fjnxOrg.getOrgOrder());
|
|
|
@@ -507,15 +585,12 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Integer ConvertOrgIsLockValue(Integer fjnxOrgUsableFlag)
|
|
|
- {
|
|
|
+ private Integer ConvertOrgIsLockValue(Integer fjnxOrgUsableFlag) {
|
|
|
// fjnx usableFlag 是否可以 0 禁用 1 可用 2 撤并
|
|
|
- Integer usable=1;
|
|
|
- if(usable.equals(fjnxOrgUsableFlag))
|
|
|
- {
|
|
|
+ Integer usable = 1;
|
|
|
+ if (usable.equals(fjnxOrgUsableFlag)) {
|
|
|
return 0;
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
@@ -537,14 +612,14 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private List<SysUser> FjnxUsersConvertToUsers(List<FJNXUserDto> fjnxUserDtoList, List<SysOrg> orgList,List<FjnxOrg> fjnxOrgList) {
|
|
|
+ private List<SysUser> FjnxUsersConvertToUsers(List<FJNXUserDto> fjnxUserDtoList, List<SysOrg> orgList, List<FjnxOrg> fjnxOrgList) {
|
|
|
List<SysUser> result = new ArrayList<>();
|
|
|
if (ObjectUtil.isNotEmpty(fjnxUserDtoList)) {
|
|
|
fjnxUserDtoList.forEach(x -> {
|
|
|
- SysOrg userBusinessSysOrg= getUserBusinessFjnxOrg(fjnxOrgList,orgList,x);
|
|
|
+ SysOrg userBusinessSysOrg = getUserBusinessFjnxOrg(fjnxOrgList, orgList, x);
|
|
|
Optional<SysOrg> optionalOrg = orgList.stream().filter(org -> org.getCode().equals(x.getDepCode())).findFirst();
|
|
|
if (optionalOrg.isPresent() && ObjectUtil.isNotEmpty(userBusinessSysOrg)) {
|
|
|
- result.add(FjnxUserConvertToUser(x, optionalOrg.get(),userBusinessSysOrg));
|
|
|
+ result.add(FjnxUserConvertToUser(x, optionalOrg.get(), userBusinessSysOrg));
|
|
|
} else {
|
|
|
log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", x.getUserId() + x.getUserName(), x.getDepCode(), x);
|
|
|
}
|
|
|
@@ -553,7 +628,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysOrg org,SysOrg businessOrg) {
|
|
|
+ private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysOrg org, SysOrg businessOrg) {
|
|
|
SysUser user = new SysUser();
|
|
|
user.setCode(fjnxUserDto.getUserId());
|
|
|
user.setName(fjnxUserDto.getUserName());
|
|
|
@@ -577,7 +652,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysUser user, SysOrg org,SysOrg businessOrg) {
|
|
|
+ private SysUser FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, SysUser user, SysOrg org, SysOrg businessOrg) {
|
|
|
user.setCode(fjnxUserDto.getUserId());
|
|
|
user.setName(fjnxUserDto.getUserName());
|
|
|
user.setUsername(fjnxUserDto.getLoginName());
|
|
|
@@ -602,38 +677,33 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
/**
|
|
|
* 获取用户的业务机构
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- private SysOrg getUserBusinessFjnxOrg(List<FjnxOrg> fjnxOrgList,List<SysOrg> existOrgList,FJNXUserDto fjnxUserDto){
|
|
|
+ private SysOrg getUserBusinessFjnxOrg(List<FjnxOrg> fjnxOrgList, List<SysOrg> existOrgList, FJNXUserDto fjnxUserDto) {
|
|
|
final Optional<FjnxOrg> fjnxOrgOptional = fjnxOrgList.stream().filter(x -> x.getOrgCode().equals(fjnxUserDto.getDepCode())).findFirst();
|
|
|
- if(fjnxOrgOptional.isPresent())
|
|
|
- {
|
|
|
- if("0001".equals(fjnxOrgOptional.get().getOrgType()))
|
|
|
- {
|
|
|
- final Optional<FjnxOrg> corporCodeOptional = fjnxOrgList.stream().filter(x -> x.getOrgCode().equals(fjnxUserDto.getCorporCode())).findFirst();
|
|
|
- if(corporCodeOptional.isPresent())
|
|
|
- {
|
|
|
- return getSysOrgByFjnxOrg(existOrgList, corporCodeOptional.get());
|
|
|
- }else {
|
|
|
- log.error("同步人员【{}】所属法人机构编码【{}】在当前fjnx_org中未找到对应法人机构,{}", fjnxUserDto.getUserId() + fjnxUserDto.getUserName(), fjnxUserDto.getCorporCode(), fjnxUserDto);
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- return getSysOrgByFjnxOrg(existOrgList,fjnxOrgOptional.get());
|
|
|
+ if (fjnxOrgOptional.isPresent()) {
|
|
|
+ if ("0001".equals(fjnxOrgOptional.get().getOrgType())) {
|
|
|
+ final Optional<FjnxOrg> corporCodeOptional = fjnxOrgList.stream().filter(x -> x.getOrgCode().equals(fjnxUserDto.getCorporCode())).findFirst();
|
|
|
+ if (corporCodeOptional.isPresent()) {
|
|
|
+ return getSysOrgByFjnxOrg(existOrgList, corporCodeOptional.get());
|
|
|
+ } else {
|
|
|
+ log.error("同步人员【{}】所属法人机构编码【{}】在当前fjnx_org中未找到对应法人机构,{}", fjnxUserDto.getUserId() + fjnxUserDto.getUserName(), fjnxUserDto.getCorporCode(), fjnxUserDto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return getSysOrgByFjnxOrg(existOrgList, fjnxOrgOptional.get());
|
|
|
// return fjnxOrgOptional.get();
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
+ }
|
|
|
+ } else {
|
|
|
log.error("同步人员【{}】所属机构编码【{}】在当前fjnx_org中未找到对应机构,{}", fjnxUserDto.getUserId() + fjnxUserDto.getUserName(), fjnxUserDto.getDepCode(), fjnxUserDto);
|
|
|
}
|
|
|
- return null;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
- private SysOrg getSysOrgByFjnxOrg(List<SysOrg> existOrgList,FjnxOrg fjnxOrg)
|
|
|
- {
|
|
|
+ private SysOrg getSysOrgByFjnxOrg(List<SysOrg> existOrgList, FjnxOrg fjnxOrg) {
|
|
|
final Optional<SysOrg> businessSysOrgOptional = existOrgList.stream().filter(x -> fjnxOrg.getOrgCode().equals(x.getCode())).findFirst();
|
|
|
- if(businessSysOrgOptional.isPresent())
|
|
|
- return businessSysOrgOptional.get();
|
|
|
+ if (businessSysOrgOptional.isPresent())
|
|
|
+ return businessSysOrgOptional.get();
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
@@ -651,18 +721,105 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
|
|
|
tempOrg.setLastSyncTime(syncDateTime);
|
|
|
tempOrg.setBusinessParentCode(tempOrg.getOrgParent());
|
|
|
+ tempOrg.setTreeShowParentCode(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());
|
|
|
+ tempOrg.setTreeShowParentCode(item.getOrgParent());
|
|
|
} else {
|
|
|
log.error("设置fjnx业务父级机构失败,机构名称:{},机构编码:{},业务父级机构编码:{}", item.getOrgName(), first.get().getOrgCode(), first.get().getBusinessParentCode());
|
|
|
}
|
|
|
}
|
|
|
resultList.add(tempOrg);
|
|
|
});
|
|
|
- return resultList;
|
|
|
+ return AddCustomOrg(resultList);
|
|
|
+// return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增 机关机构
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<FjnxOrg> AddCustomOrg(List<FjnxOrg> list) {
|
|
|
+ final List<FjnxOrg> topOrgList = list.stream().filter(x -> ObjectUtil.isEmpty(x.getOrgParent())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ topOrgList.forEach(topOrg -> {
|
|
|
+ changeOrgHierarchical(topOrg, list);
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void changeOrgHierarchical(FjnxOrg parentOrg, List<FjnxOrg> list) {
|
|
|
+ if(StringUtil.isNullOrEmpty( parentOrg.getOrgCode()))
|
|
|
+ return;
|
|
|
+ List<FjnxOrg> childOrgList = list.stream().filter(x -> parentOrg.getOrgCode().equals(x.getOrgParent())).collect(Collectors.toList());
|
|
|
+ if (childOrgList.size() == 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ final List<FjnxOrg> nendChangeOrgHierarchical =new ArrayList<>();
|
|
|
+ List<FjnxOrg> deptOrgList = childOrgList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getOrgCode()) && x.getOrgCode().toLowerCase().startsWith("m")).collect(Collectors.toList());
|
|
|
+ if (deptOrgList.size() > 0) {
|
|
|
+
|
|
|
+ final List<FjnxOrg> collect = deptOrgList.stream().filter(x -> !x.getOrgName().endsWith("地区行社") && !x.getOrgName().endsWith("办事处")).collect(Collectors.toList());
|
|
|
+ nendChangeOrgHierarchical.addAll(collect);
|
|
|
+ if (nendChangeOrgHierarchical.size() > 0) {
|
|
|
+ FjnxOrg customOrg = findCustomAddOrg(parentOrg, "机关部门",list);
|
|
|
+ list.add(customOrg);
|
|
|
+ nendChangeOrgHierarchical.forEach(x -> {
|
|
|
+ x.setBusinessParentCode(customOrg.getOrgCode());
|
|
|
+ x.setTreeShowParentCode(customOrg.getOrgCode());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ childOrgList.forEach(org->{
|
|
|
+ if(nendChangeOrgHierarchical.stream().anyMatch(changeOrg->changeOrg.getOrgCode().equals(org.getOrgCode())))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeOrgHierarchical(org,list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Boolean needAddCustomOrg(List<FjnxOrg> orgList) {
|
|
|
+ if (orgList.size() == 0)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ List<FjnxOrg> deptOrgList = orgList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getOrgCode()) && x.getOrgCode().toLowerCase().startsWith("m")).collect(Collectors.toList());
|
|
|
+ if (deptOrgList.size() == 0)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return deptOrgList.stream().anyMatch(x -> !x.getOrgName().endsWith("地区行社") && !x.getOrgName().endsWith("办事处"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private FjnxOrg findCustomAddOrg(FjnxOrg parentOrg,String customOrgName,List<FjnxOrg> orgList)
|
|
|
+ {
|
|
|
+ final Optional<FjnxOrg> first = orgList.stream().filter(x -> x.getOrgCode().equals(parentOrg.getOrgCode() + "001")).findFirst();
|
|
|
+ if(first.isPresent()) return first.get();
|
|
|
+
|
|
|
+ return createCustomOrg(parentOrg,customOrgName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增自定义机构(机关机构)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private FjnxOrg createCustomOrg(FjnxOrg parentOrg, String customOrgName) {
|
|
|
+ FjnxOrg customOrg = new FjnxOrg();
|
|
|
+ customOrg.setOrgName(customOrgName);
|
|
|
+ customOrg.setShortName(customOrgName);
|
|
|
+ customOrg.setOrgCode(parentOrg.getOrgCode() + "001");
|
|
|
+ customOrg.setOrgPath(parentOrg.getOrgPath() + "/" + customOrg.getOrgCode());
|
|
|
+ customOrg.setOrgParent(parentOrg.getOrgCode());
|
|
|
+ customOrg.setBusinessParentCode(parentOrg.getOrgCode());
|
|
|
+ customOrg.setTreeShowParentCode(parentOrg.getOrgCode());
|
|
|
+ customOrg.setUsableFlag(1);
|
|
|
+ return customOrg;
|
|
|
}
|
|
|
|
|
|
}
|