提交 4d78a7cd authored 作者: zjm's avatar zjm

fix(单位模块): 添加了根据单位id查询全部下级对象

添加了根据单位id查询全部下级对象
上级 af7fec8d
...@@ -33,6 +33,10 @@ public class AreaCache { ...@@ -33,6 +33,10 @@ public class AreaCache {
Area area = nameMap.get(name); Area area = nameMap.get(name);
return idMap.get(area.getFatherId()); return idMap.get(area.getFatherId());
} }
public List<Area> findAllByFatherId(Integer fatherId) {
return new ArrayList<>(idMap.values()).stream().filter(area -> area.getFatherId().equals(fatherId)).collect(Collectors.toList());
}
public Area findByName(String name) { public Area findByName(String name) {
return nameMap.get(name) == null ? new Area(0, "省直属", 9999, "9999", 0, "") : nameMap.get(name); return nameMap.get(name) == null ? new Area(0, "省直属", 9999, "9999", 0, "") : nameMap.get(name);
......
...@@ -69,4 +69,12 @@ public class UnitsCache { ...@@ -69,4 +69,12 @@ public class UnitsCache {
this.areaIdMpa=unitsList.stream().collect(Collectors.toMap(Units::getAreaId,Function.identity())); this.areaIdMpa=unitsList.stream().collect(Collectors.toMap(Units::getAreaId,Function.identity()));
return this; return this;
} }
/**
* 根据区域id的集合查询所有的单位
*/
public List<Units> findByAllAreaIds(List<Integer> areaIds){
return new ArrayList<>(idMap.values()).stream().filter(units -> areaIds.contains(units.getAreaId())).collect(Collectors.toList());
}
} }
...@@ -34,6 +34,7 @@ public interface AreaService extends PublicService<Area> { ...@@ -34,6 +34,7 @@ public interface AreaService extends PublicService<Area> {
List<Integer> findIdQuerySubordinateIds(Integer areaId); List<Integer> findIdQuerySubordinateIds(Integer areaId);
Area findByIdTosuperiorArea(Integer areaId); Area findByIdTosuperiorArea(Integer areaId);
/** /**
......
...@@ -60,4 +60,10 @@ public interface UserPublicService { ...@@ -60,4 +60,10 @@ public interface UserPublicService {
/*新的区域查询接口*/ /*新的区域查询接口*/
List<Units> accordingExhibitionIdAllUnits(Integer exhibitionId); List<Units> accordingExhibitionIdAllUnits(Integer exhibitionId);
/**
* 根据单位id查询当前单位下的全部子对象,以及对象下的子对象
* @return 单位集合
*/
List<Units> findByUnitIdSubordinateAll(Integer unitId);
} }
...@@ -154,7 +154,7 @@ public class AreaServiceImpl implements AreaService { ...@@ -154,7 +154,7 @@ public class AreaServiceImpl implements AreaService {
private List<Integer> areaId(List<Integer> ids,Integer areaId){ private List<Integer> areaId(List<Integer> ids,Integer areaId){
List<Area> areas= areaDao.findAllByFatherId(areaId); List<Area> areas= areaCache.findAllByFatherId(areaId);
ids.add(areaId); ids.add(areaId);
if (areas!=null&&areas.size()!=0){ if (areas!=null&&areas.size()!=0){
areas.forEach( areas.forEach(
......
...@@ -141,6 +141,12 @@ public class UserPublicServiceImpl implements UserPublicService { ...@@ -141,6 +141,12 @@ public class UserPublicServiceImpl implements UserPublicService {
} }
@Override
public List<Units> findByUnitIdSubordinateAll(Integer unitId) {
Units units= unitsCache.findById(unitId);
List<Integer> areaIds= areaService.findIdQuerySubordinateIds(units.getAreaId());
return unitsCache.findByAllAreaIds(areaIds);
}
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论