|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyJoinMapper companyJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建财务公司 | 
|---|
|  |  |  | * @param company | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer createFinanceCompany(Company company) { | 
|---|
|  |  |  | company.setType(Constants.TWO); | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getName,company.getName()) | 
|---|
|  |  |  | .eq(Company::getType,company.getType()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | company.setCreateDate(new Date()); | 
|---|
|  |  |  | company.setCreator(company.getLoginUserInfo().getId()); | 
|---|
|  |  |  | company.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | company.setStatus(Constants.ZERO); | 
|---|
|  |  |  | company.setSortnum(0);//默认最上面 | 
|---|
|  |  |  | company.setHkDate(company.getCreateDate()); | 
|---|
|  |  |  | company.setEditDate(company.getCreateDate()); | 
|---|
|  |  |  | company.setEditor(company.getCreator()); | 
|---|
|  |  |  | companyMapper.insert(company); | 
|---|
|  |  |  | return company.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public Integer create(Company company) { | 
|---|
|  |  |  | 
|---|
|  |  |  | .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')") | 
|---|
|  |  |  | .likeRight(Company::getCompanyPath,model.getCompanyPath())); | 
|---|
|  |  |  | //下发海康安防平台 | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getHkId())){ | 
|---|
|  |  |  | /*  if(StringUtils.isNotBlank(model.getHkId())){ | 
|---|
|  |  |  | if(!editHkOrg(company)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织同步下发失败,请稍后重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!addHkOrg(company)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织同步下发失败,请稍后重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | checkUnique(company); | 
|---|
|  |  |  | companyMapper.updateById(company); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer updateFinanceCompany(Company company) { | 
|---|
|  |  |  | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() | 
|---|
|  |  |  | .eq(Company::getName,company.getName()) | 
|---|
|  |  |  | .eq(Company::getType,company.getType()) | 
|---|
|  |  |  | .ne(Company::getId,company.getId()) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | companyMapper.updateById(company); | 
|---|
|  |  |  | return company.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | /*        .leftJoin(Member.class, Member::getId,Company::getHeadId)*/ | 
|---|
|  |  |  | /*  queryWrapper.leftJoin(" company c on c.id=t.parent_id");*/ | 
|---|
|  |  |  | queryWrapper.selectAll(Company.class) | 
|---|
|  |  |  | .select("(select count(m.id) from member m where m.COMPANY_ID=t.id and m.ISDELETED=0) as countNum") ; | 
|---|
|  |  |  | .select("(select count(m.id) from member m where m.COMPANY_ID=t.id and m.ISDELETED=0) ",Company::getCountNum) | 
|---|
|  |  |  | .select("(select count(m.id) from yw_account m where m.COMPANY_ID=t.id and m.ISDELETED=0)",Company::getAccountNum) ; | 
|---|
|  |  |  | queryWrapper.select("t1.name",Company::getParentName); | 
|---|
|  |  |  | queryWrapper.select("t1.company_path",Company::getParentCompanyPath); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getStatus()),Company::getStatus,Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<Company> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | wrapper.lambda() | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Company::getType,company.getType()) | 
|---|
|  |  |  | .eq(Company::getName,company.getName()); | 
|---|
|  |  |  | List<Company> companies = companyMapper.selectList(wrapper); | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(companies)){ | 
|---|