|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.admin.request.UpdateCompanySortDTO; | 
|---|
|  |  |  | import com.doumee.dao.admin.response.CompanyDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwContractMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.CompanyMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.join.CompanyJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Company; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwContract; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CompanyTree; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.CompanyService; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyJoinMapper companyJoinMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwContractMapper ywContractMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建财务公司 | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Company::getType,company.getType()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(company.getCode())){ | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getCode,company.getCode()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | company.setCreateDate(new Date()); | 
|---|
|  |  |  | company.setCreator(company.getLoginUserInfo().getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Company::getName,company.getName()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,组织名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(company.getCode())){ | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getCode,company.getCode()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(user ==null){ | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该部门下存在人员信息,不能进行删除操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(ywContractMapper.selectCount(new QueryWrapper<YwContract>().lambda().eq(YwContract::getCompanyId,id))>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "当前公司已关联业务,不可删除"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Company company = new Company(); | 
|---|
|  |  |  | company.setId(id); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,组织名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(company.getCode())){ | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getCode,company.getCode()) | 
|---|
|  |  |  | .ne(Company::getId,company.getId()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(user == null){ | 
|---|
|  |  |  | user = company.getLoginUserInfo(); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(company.getCode())){ | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getCode,company.getCode()) | 
|---|
|  |  |  | .ne(Company::getId,company.getId()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | companyMapper.updateById(company); | 
|---|
|  |  |  | return company.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return companyMapper.selectOne(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  List<Company>  listForConstract(Company company) { | 
|---|
|  |  |  | MPJLambdaWrapper<Company> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(Company.class); | 
|---|
|  |  |  | queryWrapper.like(company.getName() != null,Company::getName, company.getName()); | 
|---|
|  |  |  | queryWrapper.eq(Company::getStatus, Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.eq(Company::getType, Constants.TWO); | 
|---|
|  |  |  | queryWrapper.eq(Company::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.exists("select b.id from yw_account b where b.isdeleted=0 and b.company_id=t.id and b.status=0"); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Company::getCreateDate); | 
|---|
|  |  |  | return companyMapper.selectList(queryWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Company> findList(Company company) { | 
|---|
|  |  |  | MPJLambdaWrapper<Company> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.select("t1.name",Company::getParentName); | 
|---|
|  |  |  | queryWrapper.select("t1.company_path",Company::getParentCompanyPath); | 
|---|
|  |  |  | queryWrapper.apply(" t.isdeleted = 0 ") ; | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(company.getStatus()),Company::getStatus,Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.apply(" t.status = 0 ") ; | 
|---|
|  |  |  | //        queryWrapper.eq(Objects.nonNull(company.getStatus()),Company::getStatus,Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(company.getName()),Company::getName,company.getName()); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(company.getParentName()),"t1.name",company.getParentName()); | 
|---|
|  |  |  | return companyMapper.selectList(queryWrapper); | 
|---|