| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.doumee.core.utils.qiyeweixin.QywxUtil; |
| | | import com.doumee.core.utils.qiyeweixin.model.response.QywxDepartInfoResponse; |
| | | import com.doumee.dao.business.CompanyMapper; |
| | | import com.doumee.dao.business.CompanyMemberMapper; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.business.model.CompanyMember; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.vo.CompanyTree; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Service |
| | | public class CompanyServiceImpl implements CompanyService { |
| | | |
| | | @Resource(name="sessionRedisTemplate") |
| | | private RedisTemplate<Object, Serializable> redisTemplate; |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private CompanyMemberMapper companyMemberMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<Company> findList(Company company) { |
| | | QueryWrapper<Company> wrapper = new QueryWrapper<>(company); |
| | | return companyMapper.selectList(wrapper); |
| | | MPJLambdaWrapper<Company> wrapper = new MPJLambdaWrapper<Company>(); |
| | | wrapper.selectAll(Company.class ) |
| | | .select(" (select count(1) from company t1 where t1.isdeleted=0 and t1.parent_id = t.id )",Company::getChildNum) |
| | | .isNull(company.getParentId()==null,Company::getParentId) |
| | | .eq(company.getParentId()!=null,Company::getParentId,company.getParentId()) |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(Company::getName); |
| | | List<Company> companyList = companyMapper.selectJoinList(Company.class,wrapper); |
| | | |
| | | if(companyList.size()>0){ |
| | | for (Company c : companyList){ |
| | | c.setHasChildren(Constants.formatIntegerNum(c.getChildNum())>0); |
| | | } |
| | | } |
| | | return companyList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public List<Company> companyTree( ) { |
| | | return companyTreeBiz(0); |
| | | } |
| | | public List<Company> companyTreeBiz(int type ) { |
| | | MPJLambdaWrapper<Company> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Company.class); |
| | | queryWrapper.selectAs(SystemUser::getUsername,Company::getEditorName); |
| | |
| | | queryWrapper.leftJoin(Company.class,Company::getId,Company::getParentId); |
| | | queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Company::getEditor); |
| | | queryWrapper.eq(Company::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.orderByAsc( "t.code"); |
| | | queryWrapper.orderByAsc( "t.name"); |
| | | List<Company> companyList = companyMapper.selectJoinList(Company.class,queryWrapper); |
| | | CompanyTree treeBuild = new CompanyTree(companyList, 0); |
| | | List<CompanyMember> memberList = null; |
| | | if(type == 1){ |
| | | memberList = companyMemberMapper.selectJoinList(CompanyMember.class,new MPJLambdaWrapper<CompanyMember>() |
| | | .selectAll(CompanyMember.class) |
| | | .selectAs(Member::getName,CompanyMember::getMemberName) |
| | | .leftJoin(Member.class,Member::getId,CompanyMember::getMemberId) |
| | | .eq(Member::getIsdeleted,Constants.ZERO ) |
| | | .eq(CompanyMember::getIsdeleted,Constants.ZERO ) |
| | | .orderByAsc(Member::getName)); |
| | | } |
| | | CompanyTree treeBuild = new CompanyTree(companyList, 0,memberList); |
| | | companyList = treeBuild.buildTree(); |
| | | return companyList; |
| | | } |
| | | @Override |
| | | public List<Company> companyTreeWithMember() { |
| | | return companyTreeBiz(1); |
| | | } |
| | | |
| | | @Override |
| | | public int syncAll(Company company) { |