From 9e370ecc344ff3383f5f4777b74e198757f6b116 Mon Sep 17 00:00:00 2001
From: fengjin <1435304038@qq.com>
Date: 星期四, 17 十一月 2022 13:59:28 +0800
Subject: [PATCH] 修改Bug
---
flower_city/src/main/java/com/dg/core/service/impl/OrganizationChartImpl.java | 125 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 116 insertions(+), 9 deletions(-)
diff --git a/flower_city/src/main/java/com/dg/core/service/impl/OrganizationChartImpl.java b/flower_city/src/main/java/com/dg/core/service/impl/OrganizationChartImpl.java
index c06ddb6..a2a27e6 100644
--- a/flower_city/src/main/java/com/dg/core/service/impl/OrganizationChartImpl.java
+++ b/flower_city/src/main/java/com/dg/core/service/impl/OrganizationChartImpl.java
@@ -6,8 +6,10 @@
import com.dg.core.db.gen.entity.OrganizationChartEntity;
import com.dg.core.db.gen.mapper.OrganizationChartMapper;
import com.dg.core.service.IOrganizationChartService;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
@Service
@@ -16,13 +18,20 @@
{
@Override
- public List<OrganizationChartEntity> selectConfigList(String parentId,String grade)
+ public List<OrganizationChartEntity> selectConfigList(String parentId,String grade,List<String> ids)
{
- List<OrganizationChartEntity> ocList=baseMapper.selectConfigList("","1");
+ List<OrganizationChartEntity> ocList=baseMapper.selectConfigList(parentId,"1",ids);
+
+ if(ocList==null || ocList.size()<1)
+ {
+ List<String> id=new ArrayList<>();
+ id.add(parentId);
+ ocList=baseMapper.selectConfigList(null,null,id);
+ }
for (OrganizationChartEntity entity:ocList)
{
- entity.setChild(baseMapper.selectConfigList(entity.getId()+"",""));
+ entity.setChild(baseMapper.selectConfigList(entity.getId()+"","",null));
if (entity.getChild()!=null)
{
@@ -56,9 +65,9 @@
public List<OrganizationChartEntity> selectConfigList(String parentsId) {
- List<OrganizationChartEntity> list =baseMapper.selectConfigList(parentsId,"");
+ List<OrganizationChartEntity> list =baseMapper.selectConfigList(parentsId,"",null);
for (OrganizationChartEntity sysStreet:list) {
- sysStreet.setChild(baseMapper.selectConfigList(sysStreet.getId().toString(),""));
+ sysStreet.setChild(baseMapper.selectConfigList(sysStreet.getId().toString(),"",null));
if (sysStreet.getChild()!=null)
{
sysStreet.setChild(this.selectConfigList(sysStreet.getId().toString()));
@@ -79,12 +88,110 @@
}
@Override
- public List<OrganizationChartEntity> queryList(IPage<OrganizationChartEntity> page, Integer state, String organizationName) {
- return baseMapper.queryList(page,state,organizationName);
+ public List<OrganizationChartEntity> queryList(IPage<OrganizationChartEntity> page, Integer state,
+ String organizationName,List<String> ids) {
+ return baseMapper.queryList(page,state,organizationName,ids);
}
@Override
- public int countList(String organizationName) {
- return baseMapper.countList(organizationName);
+ public int countList(String organizationName,List<String> ids) {
+ return baseMapper.countList(organizationName,ids);
}
+
+
+ @Override
+ public List<OrganizationChartEntity> selectParentList(String parentId, String grade) {
+ return baseMapper.selectConfigList(parentId,grade,null);
+ }
+
+ /**
+ * 递归获取id 内部使用
+ * @param id
+ * @return
+ */
+
+ @Override
+ public List<String> getIds(String id)
+ {
+ List<String> ids=new ArrayList<>();
+ List<OrganizationChartEntity> lists = baseMapper.selectConfigList(id,"",null);
+ if(lists.size()<1)
+ {
+ lists.add(baseMapper.selectConfigById(id));
+ }
+ ids=disposestreetId(lists);
+ if(ids.size()<1)
+ {
+ return null;
+ }
+ ids.add(id);
+ return ids;
+ }
+
+ @Override
+ public List<String> getDepartmentId(String id){
+ String parentId = parentId(id);
+ List<String> departmentIds=new ArrayList<>();
+ departmentIds.add(parentId);
+ List<OrganizationChartEntity> organizationChartEntities = baseMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getParentId, parentId));
+ for (OrganizationChartEntity organizationChart :organizationChartEntities){
+ departmentIds.add(organizationChart.getId().toString());
+ departmentIds=getDepartmentIds(organizationChart.getId().toString(),departmentIds);
+ }
+ return departmentIds;
+ }
+
+
+ public String parentId(String id){
+ String parentId=id;
+ OrganizationChartEntity organizationChart = baseMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getId, id));
+ if (organizationChart.getParentId().length()>0){
+ parentId=parentId(organizationChart.getParentId());
+ }
+ return parentId;
+ }
+
+ public List<String> getDepartmentIds(String id,List<String> departmentIds){
+ List<OrganizationChartEntity> organizationChartEntities = baseMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getParentId, id));
+ if (organizationChartEntities.size()==0){
+ return departmentIds;
+ }
+ else {
+ for (OrganizationChartEntity organizationChart :organizationChartEntities){
+ departmentIds.add(organizationChart.getId().toString());
+ departmentIds=getDepartmentIds(organizationChart.getId().toString(),departmentIds);
+ }
+ }
+ return departmentIds;
+ }
+
+
+
+ //递归取id
+ private List<String> disposestreetId(List<OrganizationChartEntity> lists)
+ {
+ List<String> ids=new ArrayList<>();
+ if(lists==null || lists.size()<1)
+ {
+ return ids;
+ }
+
+ for (OrganizationChartEntity sysStreet:lists)
+ {
+ if(sysStreet!=null&&sysStreet.getId()!=null)
+ {
+ if(sysStreet.getChild()!=null && sysStreet.getChild().size()>0)
+ {
+ ids.addAll(disposestreetId(sysStreet.getChild()));
+ }
+ else
+ {
+ ids.add(sysStreet.getId()+"");
+ }
+ }
+ }
+ return ids;
+ }
+
+
}
--
Gitblit v1.7.1