| | |
| | | import cn.afterturn.easypoi.excel.ExcelImportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ImportParams; |
| | | import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.handler.DeptVerifyHandler; |
| | | import com.ruoyi.system.mapper.TbDeptMapper; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | |
| | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TbDeptServiceImpl extends ServiceImpl<TbDeptMapper, TbDept> implements TbDeptService { |
| | | |
| | | private final DeptVerifyHandler deptVerifyHandler; |
| | | private final HttpServletResponse response; |
| | | |
| | | @Override |
| | | public PageVO<DeptVO> queryPage(DeptQuery query) { |
| | | public PageDTO<DeptVO> queryPage(DeptQuery query) { |
| | | Page<TbDept> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | LambdaQueryWrapper<TbDept> queryWrapper = new LambdaQueryWrapper<TbDept>() |
| | | .like(StringUtils.isNotEmpty(query.getAreaName()), TbDept::getAreaName, query.getAreaName()) |
| | | Page<TbDept> tbDeptPage = this.lambdaQuery().like(StringUtils.isNotEmpty(query.getAreaName()), TbDept::getAreaName, query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getAccount()), TbDept::getAccount, query.getAccount()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), TbDept::getPhone, query.getPhone()) |
| | | .orderByDesc(TbDept::getCreateTime); |
| | | Page<TbDept> deptPage = this.baseMapper.selectPage(page, queryWrapper); |
| | | PageVO<DeptVO> pageVO = new PageVO<>(); |
| | | pageVO.setPageNo(deptPage.getPages()); |
| | | pageVO.setPageSize(deptPage.getSize()); |
| | | pageVO.setTotalPages(deptPage.getTotal()); |
| | | pageVO.setTotalCount(deptPage.getTotal()); |
| | | IPage<DeptVO> convert = deptPage.convert(result -> { |
| | | DeptVO deptVO = new DeptVO(); |
| | | BeanUtils.copyBeanProp(deptVO, result); |
| | | return deptVO; |
| | | }); |
| | | pageVO.setRecords(convert.getRecords()); |
| | | return pageVO; |
| | | .orderByDesc(TbDept::getCreateTime) |
| | | .page(page); |
| | | if (CollUtils.isEmpty(tbDeptPage.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(tbDeptPage, DeptVO.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 校验区划代码是否重复 |
| | | * @param deptList |
| | | * @return |
| | | * @param deptList 部门列表 |
| | | * @return 重复的区划代码 |
| | | */ |
| | | public List<String> hasDuplicateAreaCode(List<TbDept> deptList) { |
| | | Set<String> areaCodes = new HashSet<>(); |