| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.dto.UmsDepartDto; |
| | | import com.ycl.entity.depart.UmsDepart; |
| | | import com.ycl.entity.user.UmsAdmin; |
| | | import com.ycl.enums.common.ResultCode; |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.mapper.depart.UmsDepartMapper; |
| | | import com.ycl.mapper.dict.DataDictionaryMapper; |
| | | import com.ycl.service.depart.IDepartManagerService; |
| | | import com.ycl.service.depart.UmsDepartService; |
| | | import com.ycl.service.user.UmsAdminService; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | IDepartManagerService iDepartManagerService; |
| | | @Resource |
| | | UmsDepartService umsDepartService; |
| | | @Resource |
| | | DataDictionaryMapper dataDictionaryMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | // 2.组装成父子的树型结构 |
| | | // 2.1、找到所有的一级网格:使用jdk8的stream流进行过滤 |
| | | List<UmsDepart> collect = list.stream().filter(griddingEntity -> { |
| | | List<UmsDepart> collect = list.stream().filter(item -> |
| | | //分类父id为0就表示该网格为 一级网格 |
| | | return griddingEntity.getParentId() == 0; |
| | | }).map(item -> { |
| | | item.getParentId() == 0 |
| | | ).map(item -> { |
| | | // 找到子网格 set进children属性中 |
| | | item.setChildren(getChildrens(item, list)); |
| | | return item; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsDepartDto> departExp() { |
| | | List<UmsDepart> umsDeparts = sccgDepartMapper.selectDepartList(); |
| | | List<UmsDepartDto> res = umsDeparts |
| | | .stream() |
| | | .map(item -> { |
| | | UmsDepartDto umsDepartDto = new UmsDepartDto(); |
| | | umsDepartDto.setId(item.getId()); |
| | | umsDepartDto.setDepartTypeName(item.getDepartName()); |
| | | String departType = sccgDepartMapper.getDepartType(item.getDepartType()); |
| | | umsDepartDto.setDepartType(departType); |
| | | UmsDepart umsDepartFather = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getId, item.getParentId())); |
| | | if (Objects.isNull(umsDepartFather)){ |
| | | umsDepartDto.setParentDepartName(""); |
| | | }else { |
| | | umsDepartDto.setParentDepartName(umsDepartFather.getDepartName()); |
| | | } |
| | | umsDepartDto.setDepartDes(item.getDepartDes()); |
| | | return umsDepartDto; |
| | | }).collect(Collectors.toList()); |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public void updateStatus(DepartVO.StatusDepartVO params) { |
| | | UmsDepart sccgDepart = this.loadDepartById(params.getId()); |
| | | BeanUtils.copyProperties(params, sccgDepart); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsAdmin> selectSurplusUser() { |
| | | return sccgDepartMapper.selectSurplusUser(); |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsAdmin> selectSurplusUserAndExistUser(Long id) { |
| | | return sccgDepartMapper.selectSurplusUserAndExistUser(id); |
| | | } |
| | | |
| | | /** |
| | | * 利用递归将最后一级空集合变为null,前端联级选择器最后才不会出现 暂无数据的bug |