| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.admin.request.UpdateCompanySortDTO; |
| | | import com.doumee.dao.admin.response.CompanyDTO; |
| | | import com.doumee.dao.business.CompanyMapper; |
| | | import com.doumee.dao.business.join.CompanyJoinMapper; |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.dto.UpdateSystemMenuSortDTO; |
| | | import com.doumee.dao.system.model.SystemMenu; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.common.tree.CompanyTree; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | |
| | | if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息不存在~"); |
| | | } |
| | | if(StringUtils.isBlank(parent.getHkParentId())){ |
| | | if(StringUtils.isBlank(parent.getHkId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息尚未同步下发成功~"); |
| | | |
| | | } |
| | | company.setHkParentId(parent.getHkParentId()); |
| | | company.setHkParentId(parent.getHkId()); |
| | | } |
| | | company.setCreateDate(new Date()); |
| | | company.setCreator(user.getId()); |
| | |
| | | if(StringUtils.isBlank(model.getHkId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,组织信息尚未同步下发成功,暂不支持修改,请尝试删除后重新添加~"); |
| | | } |
| | | |
| | | Company company = new Company(); |
| | | company.setId(id); |
| | | company.setEditDate(new Date()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"公司名称已存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Company> companyTree(Integer type) { |
| | | MPJLambdaWrapper<Company> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Company.class); |
| | | queryWrapper.selectAs(Member::getName,Company::getHeadName); |
| | | queryWrapper.selectAs(Member::getPhone,Company::getHeadPhone); |
| | | queryWrapper.leftJoin(Member.class,Member::getId,Company::getHeadId); |
| | | queryWrapper.eq(Company::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Company::getType,type); |
| | | List<Company> companyList = companyJoinMapper.selectJoinList(Company.class,queryWrapper); |
| | | //配置组员人员类型来源方式 0自建 1ERP |
| | | String origin = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode(); |
| | | CompanyTree treeBuild = new CompanyTree(companyList,Integer.valueOf(origin)); |
| | | companyList = treeBuild.buildTree(); |
| | | return companyList; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateSort(UpdateCompanySortDTO dto) { |
| | | Company company = companyMapper.selectById(dto.getId()); |
| | | if(Objects.isNull(company)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | |
| | | List<Company> companyPool; |
| | | if (company.getParentId() == null) { |
| | | companyPool = companyMapper.selectList(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .isNull(Company::getParentId) |
| | | .orderByAsc(Company::getSortnum) |
| | | ); |
| | | } else { |
| | | companyPool = companyMapper.selectList(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .eq(Company::getParentId,company.getParentId()) |
| | | .orderByAsc(Company::getSortnum) |
| | | ); |
| | | } |
| | | int currentMenuIndex = 0; |
| | | for (int i = 0; i < companyPool.size(); i++) { |
| | | if (companyPool.get(i).getId().equals(dto.getId())) { |
| | | currentMenuIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | // 上移 |
| | | if ("top".equals(dto.getDirection())) { |
| | | if (currentMenuIndex - 1 < 0) { |
| | | return; |
| | | } |
| | | Company preMenu = companyPool.remove(currentMenuIndex - 1); |
| | | companyPool.add(currentMenuIndex, preMenu); |
| | | } |
| | | // 下移 |
| | | else { |
| | | if (currentMenuIndex + 1 > companyPool.size() - 1) { |
| | | return; |
| | | } |
| | | Company nextMenu = companyPool.remove(currentMenuIndex + 1); |
| | | companyPool.add(currentMenuIndex, nextMenu); |
| | | } |
| | | for (int i = 0; i < companyPool.size(); i++) { |
| | | companyPool.get(i).setSortnum(i); |
| | | } |
| | | |
| | | for (Company updCompany:companyPool) { |
| | | companyMapper.updateById(updCompany); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |