|
|
@@ -178,7 +178,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
if (ObjectUtil.isEmpty(existOrgList)) {
|
|
|
List<SysOrg> rList = FjnxOrgsConvertToSysOrgs(fjnxOrgList);
|
|
|
resetParentIdAndPath(rList);
|
|
|
- resetTreeParentIdAndPath(rList);
|
|
|
+// resetTreeParentIdAndPath(rList);
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(rList, SecurityConstants.INNER);
|
|
|
if (listR != null && listR.getCode() != 200) {
|
|
|
log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{}", listR.getMsg());
|
|
|
@@ -217,7 +217,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
existOrgList.addAll(addList);
|
|
|
|
|
|
resetParentIdAndPath(existOrgList);
|
|
|
- resetTreeParentIdAndPath(existOrgList);
|
|
|
+// resetTreeParentIdAndPath(existOrgList);
|
|
|
|
|
|
final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(existOrgList, SecurityConstants.INNER);
|
|
|
if (ObjectUtil.isNotEmpty(listR) && listR.getCode() != 200) {
|
|
|
@@ -267,50 +267,146 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
// return;
|
|
|
}
|
|
|
|
|
|
- public void resetParentIdAndPath(List<SysOrg> orgList) {
|
|
|
- orgList.stream().forEach(x -> {
|
|
|
- x.setPath("");
|
|
|
+ public void resetSyncOrgParentId(List<SysOrg> orgList)
|
|
|
+ {
|
|
|
+ orgList.stream().filter(org->org.getSource()==1).forEach(org->{
|
|
|
+ resetOrgParentId(org,orgList);
|
|
|
+ resetOrgTreeShowParentId(org,orgList);
|
|
|
+// if(StringUtil.isNullOrEmpty(org.getParentGuid())){
|
|
|
+// org.setParentId(-1L);
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// 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());
|
|
|
+// }
|
|
|
+// }
|
|
|
});
|
|
|
- final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0 == topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
- collect.forEach(org -> {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetOrgParentId(SysOrg org, List<SysOrg> orgList){
|
|
|
+ if(StringUtil.isNullOrEmpty(org.getParentGuid())){
|
|
|
org.setParentId(-1L);
|
|
|
-// org.setLevel(1);
|
|
|
- org.setPath(org.getId() + "-");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetOrgTreeShowParentId(SysOrg org, List<SysOrg> orgList){
|
|
|
+ if(StringUtil.isNullOrEmpty(org.getTreeParentCode())){
|
|
|
+ org.setTreeShowParentId(-1L);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetAllOrgPath(List<SysOrg> orgList){
|
|
|
+ resetOrgPath(orgList);
|
|
|
+ resetOrgTreePath(orgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetOrgPath(List<SysOrg> orgList)
|
|
|
+ {
|
|
|
+
|
|
|
+ final List<SysOrg> collect = orgList.stream().filter(topOrg -> ObjectUtil.isNull(topOrg.getParentId())).collect(Collectors.toList());
|
|
|
+ final List<SysOrg> topOrgList = orgList.stream().filter(topOrg -> ObjectUtil.equal(topOrg.getParentId(),-1L)).collect(Collectors.toList());
|
|
|
+ topOrgList.forEach(topOrg->{
|
|
|
+ topOrg.setPath(topOrg.getId() + "-");
|
|
|
+ resetChildOrgPath(topOrg,orgList);
|
|
|
});
|
|
|
+ }
|
|
|
|
|
|
- orgList.forEach(org -> {
|
|
|
+ public void resetChildOrgPath(SysOrg parentOrg,List<SysOrg> orgList)
|
|
|
+ {
|
|
|
+ List<SysOrg> childOrgList = orgList.stream().filter(childOrg ->ObjectUtil.equal(childOrg.getParentId(),parentOrg.getId())).collect(Collectors.toList());
|
|
|
+ if(childOrgList.size()==0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ childOrgList.stream().forEach(org->{
|
|
|
+ org.setPath(parentOrg.getPath() + org.getId() + "-");
|
|
|
+ resetChildOrgPath(org,orgList);
|
|
|
+ });
|
|
|
|
|
|
-// if (org.getParentId() != null) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
+ }
|
|
|
|
|
|
- if (org.getDeleted().equals(1)) {
|
|
|
- // 已删除
|
|
|
- return;
|
|
|
- }
|
|
|
+ public void resetOrgTreePath(List<SysOrg> orgList)
|
|
|
+ {
|
|
|
+ final List<SysOrg> topOrgList = orgList.stream().filter(topOrg ->ObjectUtil.equal(topOrg.getTreeShowParentId(),-1L)).collect(Collectors.toList());
|
|
|
+ topOrgList.forEach(topOrg->{
|
|
|
+ topOrg.setTreeShowPath(topOrg.getId() + "-");
|
|
|
+ resetChildOrgTreePath(topOrg,orgList);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (!StringUtil.isNullOrEmpty(org.getParentGuid())) {
|
|
|
- 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())) {
|
|
|
- List<SysOrg> childOrg = new ArrayList<>();
|
|
|
- childOrg.add(org);
|
|
|
- resetParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
|
|
|
- } else {
|
|
|
- org.setPath(parentOrgOptional.get().getPath() + org.getId() + "-");
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", org.getName(), org.getGuid(), org.getParentGuid(), org);
|
|
|
- }
|
|
|
- } else {
|
|
|
- org.setParentId(-1L);
|
|
|
-// org.setLevel(1);
|
|
|
- org.setPath(org.getId() + "-");
|
|
|
- }
|
|
|
+ public void resetChildOrgTreePath(SysOrg parentOrg,List<SysOrg> orgList)
|
|
|
+ {
|
|
|
+ List<SysOrg> childOrgList = orgList.stream().filter(childOrg ->ObjectUtil.equal(childOrg.getTreeShowParentId(),parentOrg.getId())).collect(Collectors.toList());
|
|
|
+ if(childOrgList.size()==0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ childOrgList.stream().forEach(org->{
|
|
|
+ org.setTreeShowPath(parentOrg.getTreeShowPath() + org.getId() + "-");
|
|
|
+ resetChildOrgTreePath(org,orgList);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public void resetParentIdAndPath(List<SysOrg> orgList) {
|
|
|
+ resetSyncOrgParentId(orgList);
|
|
|
+ resetAllOrgPath(orgList);
|
|
|
+
|
|
|
+// orgList.stream().forEach(x -> {
|
|
|
+// x.setPath("");
|
|
|
+// });
|
|
|
+// final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0 == topOrg.getDeleted()).collect(Collectors.toList());
|
|
|
+// collect.forEach(org -> {
|
|
|
+// org.setParentId(-1L);
|
|
|
+// org.setPath(org.getId() + "-");
|
|
|
+// });
|
|
|
+//
|
|
|
+// orgList.forEach(org -> {
|
|
|
+// if (org.getDeleted().equals(1)) {
|
|
|
+// // 已删除
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(org.getSource()==0) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (!StringUtil.isNullOrEmpty(org.getParentGuid())) {
|
|
|
+// 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())) {
|
|
|
+// List<SysOrg> childOrg = new ArrayList<>();
|
|
|
+// childOrg.add(org);
|
|
|
+// resetParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
|
|
|
+// } else {
|
|
|
+// org.setPath(parentOrgOptional.get().getPath() + org.getId() + "-");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", org.getName(), org.getGuid(), org.getParentGuid(), org);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// org.setParentId(-1L);
|
|
|
+// org.setPath(org.getId() + "-");
|
|
|
+// }
|
|
|
+// });
|
|
|
+ }
|
|
|
+
|
|
|
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();
|
|
|
if (parentOrgOptional.isPresent()) {
|
|
|
@@ -328,6 +424,24 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void resetSystemParentOrgPath(SysOrg parentOrg, List<SysOrg> childOrg, List<SysOrg> orgList) {
|
|
|
+ Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg -> pOrg.getId().equals(parentOrg.getParentId())).findFirst();
|
|
|
+ if (parentOrgOptional.isPresent()) {
|
|
|
+ parentOrg.setParentId(parentOrgOptional.get().getId());
|
|
|
+ if (!StringUtil.isNullOrEmpty(parentOrgOptional.get().getPath())) {
|
|
|
+ retOrgPath(parentOrgOptional.get(), parentOrg);
|
|
|
+ retChildOrgPath(parentOrg, childOrg);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ childOrg.add(parentOrg);
|
|
|
+ resetSystemParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", parentOrg.getName(), parentOrg.getGuid(), parentOrg.getParentGuid(), parentOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void retOrgPath(SysOrg parentOrg, SysOrg org) {
|
|
|
org.setParentId(parentOrg.getId());
|
|
|
/* if (parentOrg.getLevel() != null) {
|
|
|
@@ -716,6 +830,9 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
final ArrayList<FjnxOrg> resultList = new ArrayList<>();
|
|
|
Date syncDateTime = new Date();
|
|
|
list.forEach(item -> {
|
|
|
+ if(StringUtil.isNullOrEmpty(item.getOrgCode())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
FjnxOrg tempOrg = new FjnxOrg();
|
|
|
BeanUtils.copyBeanProp(tempOrg, item);
|
|
|
|
|
|
@@ -730,6 +847,7 @@ public class FJNXSyncServiceImpl implements IFJNXSyncService {
|
|
|
tempOrg.setTreeShowParentCode(item.getOrgParent());
|
|
|
} else {
|
|
|
log.error("设置fjnx业务父级机构失败,机构名称:{},机构编码:{},业务父级机构编码:{}", item.getOrgName(), first.get().getOrgCode(), first.get().getBusinessParentCode());
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
resultList.add(tempOrg);
|