|
|
@@ -11,7 +11,6 @@ import com.xunmei.common.core.constant.CacheConstants;
|
|
|
import com.xunmei.common.core.constant.Constants;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
-import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
@@ -295,24 +294,49 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean saveOrUpdateOrg(SysOrg org) {
|
|
|
+ if (ObjectUtil.isEmpty(org.getShortName())) {
|
|
|
+ org.setShortName(org.getName());
|
|
|
+ }
|
|
|
+// if (StringUtils.isEmpty(org.getManagerPhone())) {
|
|
|
+// org.setManagerPhone(org.getPhone());
|
|
|
+// }
|
|
|
boolean isOk = false;
|
|
|
if (org.getId() != null) {
|
|
|
- if (StringUtils.isEmpty(org.getManagerPhone())) {
|
|
|
- org.setManagerPhone(org.getPhone());
|
|
|
+// if (StringUtils.isEmpty(org.getManagerPhone())) {
|
|
|
+// org.setManagerPhone(org.getPhone());
|
|
|
+// }
|
|
|
+ //修改前的原始机构对象
|
|
|
+ final SysOrg originalOrg = getById(org.getId());
|
|
|
+ //仅系统新增的机构可以修改层级,同步到系统的机构不允许修改机构层级
|
|
|
+ if(ObjectUtil.equal(originalOrg.getSource(),0)) {
|
|
|
+ //父级机构发生变化后,修改机构path ,以及下级机构path
|
|
|
+ if(!ObjectUtil.equal(originalOrg.getParentId(),org.getParentId())){
|
|
|
+ //获取选择的父机构数据
|
|
|
+ SysOrg parentOrg = getById(org.getParentId());
|
|
|
+ //更新机构对应的业务path
|
|
|
+ org.setPath(parentOrg.getPath() + org.getId() + "-");
|
|
|
+ //更新机构对应的机构树path
|
|
|
+ org.setTreeShowPath(parentOrg.getTreeShowPath() + org.getId() + "-");
|
|
|
+ org.setTreeShowParentId(parentOrg.getId());
|
|
|
+
|
|
|
+ //ToDo 刷新当前机构下所有子机构 path
|
|
|
+ //final List<SysOrg> childOrgList = getAllChildOrgList(originalOrg.getPath());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
isOk = this.updateById(org);
|
|
|
} else {
|
|
|
- SysOrg sysOrg = sysOrgMapper.selectById(org.getParentId());
|
|
|
- org.setParentGuid(sysOrg.getGuid());
|
|
|
+ SysOrg parentOrg = sysOrgMapper.selectById(org.getParentId());
|
|
|
+ org.setParentGuid(parentOrg.getGuid());
|
|
|
org.setDeleted(0);
|
|
|
long id = IdWorker.getId();
|
|
|
org.setId(id);
|
|
|
- org.setPath(sysOrg.getPath() + id + "-");
|
|
|
- org.setTreeShowPath(sysOrg.getPath() + id + "-");
|
|
|
+ org.setPath(parentOrg.getPath() + id + "-");
|
|
|
+ org.setTreeShowPath(parentOrg.getPath() + id + "-");
|
|
|
|
|
|
- if (StringUtils.isEmpty(org.getManagerPhone())) {
|
|
|
- org.setManagerPhone(org.getPhone());
|
|
|
- }
|
|
|
+// if (StringUtils.isEmpty(org.getManagerPhone())) {
|
|
|
+// org.setManagerPhone(org.getPhone());
|
|
|
+// }
|
|
|
isOk = this.save(org);
|
|
|
}
|
|
|
/*
|
|
|
@@ -334,6 +358,29 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
return rel;
|
|
|
}
|
|
|
|
|
|
+ private List<SysOrg> getAllChildOrgList(String path)
|
|
|
+ {
|
|
|
+ return sysOrgMapper.selectList(new LambdaQueryWrapper<SysOrg>()
|
|
|
+ .likeRight(SysOrg::getPath, path)
|
|
|
+ .eq(SysOrg::getDeleted, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void reSetOrgAllChildOrgPath(SysOrg newOrg,SysOrg originalOrg)
|
|
|
+ {
|
|
|
+ final List<SysOrg> childOrgList = getAllChildOrgList(originalOrg.getPath());
|
|
|
+ if(ObjectUtil.isEmpty(childOrgList))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void reSetOrgPath(SysOrg parentOrg,List<SysOrg> childOrgList)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static List<SysOrg> handleTree(Map<Long, List<SysOrg>> map, Long parentId) {
|
|
|
List<SysOrg> orgList = map.get(parentId);
|
|
|
if (ObjectUtil.isNotEmpty(orgList)) {
|