| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.dto.user.AdminDepartDTO; |
| | | import com.ycl.entity.depart.UmsDepart; |
| | | import com.ycl.entity.dict.DataDictionary; |
| | | import com.ycl.entity.user.UmsDepartManage; |
| | | 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.UmsDepartManageService; |
| | | import com.ycl.service.user.UmsAdminService; |
| | | import com.ycl.service.user.UmsDepartManageService; |
| | | import com.ycl.utils.common.PojoUtils; |
| | | import com.ycl.vo.depart.DepartVO; |
| | | import com.ycl.vo.depart.UmsDepartVO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private UmsDepartManageService umsAdminDepartService; |
| | | @Resource |
| | | private UmsAdminService umsAdminService; |
| | | @Resource |
| | | IDepartManagerService iDepartManagerService; |
| | | @Resource |
| | | UmsDepartService umsDepartService; |
| | | @Resource |
| | | DataDictionaryMapper dataDictionaryMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | UmsDepart depart = new UmsDepart(); |
| | | BeanUtils.copyProperties(addDepartVO, depart); |
| | | depart.setStatus(Short.valueOf("1")); |
| | | if (sccgDepartMapper.insert(depart) != 1) { |
| | | throw new ApiException(ResultCode.RECORD_SAVE_FAIL); |
| | | } |
| | | depart.setStatus(Short.valueOf("1")); |
| | | umsDepartService.save(depart); |
| | | addDepartVO.getDepartManagerList() |
| | | .forEach(item -> { |
| | | item.setCreateTime(LocalDateTime.now()); |
| | | item.setDepartId(depart.getId()); |
| | | }); |
| | | iDepartManagerService.saveBatch(addDepartVO.getDepartManagerList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public List<UmsDepart> tree() { |
| | | // 1.查出所有网格 |
| | | List<UmsDepart> list = list(); |
| | | List<UmsDepart> list = baseMapper.selectDepartList(); |
| | | |
| | | // 2.组装成父子的树型结构 |
| | | // 2.1、找到所有的一级网格:使用jdk8的stream流进行过滤 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<UmsDepart> pageDepart(DepartVO.PageDepartVO params) { |
| | | public IPage<UmsDepartVO> pageDepart(DepartVO.PageDepartVO params) { |
| | | Page<UmsDepart> page = new Page<>(params.getCurrent(), params.getPageSize()); |
| | | LambdaQueryWrapper<UmsDepart> query = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(params.getDepartName())) { |
| | |
| | | } |
| | | query.orderByDesc(UmsDepart::getCreateTime); |
| | | Page<UmsDepart> departPage = sccgDepartMapper.selectPage(page, query); |
| | | List<UmsDepart> records = departPage.getRecords(); |
| | | Page<UmsDepartVO> umsDepartVOPage = new Page<>(); |
| | | BeanUtils.copyProperties(departPage, umsDepartVOPage); |
| | | List<UmsDepartVO> umsDepartVOList = new ArrayList<>(); |
| | | //负责人 |
| | | if (CollUtil.isNotEmpty(records)) { |
| | | for (UmsDepart record : records) { |
| | | if (CollUtil.isNotEmpty(departPage.getRecords())) { |
| | | for (UmsDepart record : departPage.getRecords()) { |
| | | UmsDepartVO umsDepartVO = new UmsDepartVO(); |
| | | BeanUtils.copyProperties(record, umsDepartVO); |
| | | umsDepartVO.setDepartType(dataDictionaryMapper |
| | | .selectOne(new LambdaQueryWrapper<DataDictionary>() |
| | | .eq(DataDictionary::getId, record.getDepartType())) |
| | | .getName()); |
| | | umsDepartVOList.add(umsDepartVO); |
| | | List<UmsDepartManage> umsAdminDeparts = umsAdminDepartService.queryByDepartId(record.getId()); |
| | | if (CollUtil.isNotEmpty(umsAdminDeparts)) { |
| | | List<AdminDepartDTO.UserInfoDTO> userInfoDTOS = umsAdminDeparts.stream().map(a -> { |
| | |
| | | } |
| | | } |
| | | } |
| | | return departPage; |
| | | umsDepartVOPage.setRecords(umsDepartVOList); |
| | | return umsDepartVOPage; |
| | | } |
| | | |
| | | @Override |