| | |
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * 创建财务公司 |
| | | * @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(), "对不起,名称不能重复~"); |
| | | } |
| | | 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()); |
| | | 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) { |
| | | company.setType(Constants.ONE); |
| | | if(StringUtils.isBlank(company.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | |
| | | .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){ |
| | |
| | | company.setHkId(UUID.randomUUID().toString().replace("-","")); |
| | | companyMapper.insert(company); |
| | | //下发海康安防平台 |
| | | if(!addHkOrg(company)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织同步下发失败,请稍后重试"); |
| | | } |
| | | // if(!addHkOrg(company)){ |
| | | // throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织同步下发失败,请稍后重试"); |
| | | // } |
| | | Company com = new Company(); |
| | | com.setId(company.getId()); |
| | | com.setCompanyPath(idPath+company.getId()+"/"); |
| | |
| | | .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); |
| | |
| | | company.setHkDate(company.getHkDate()); |
| | | companyMapper.updateById(company); |
| | | //下发海康安防平台 |
| | | if(StringUtils.isNotBlank(model.getHkId()) && Constants.equalsInteger(Constants.ONE,model.getHkStatus()) && !delHkOrg(model)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织删除下发失败,请确认该组织无下级组织或组织人员信息~"); |
| | | } |
| | | // if(StringUtils.isNotBlank(model.getHkId()) && Constants.equalsInteger(Constants.ONE,model.getHkStatus()) && !delHkOrg(model)){ |
| | | // throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织删除下发失败,请确认该组织无下级组织或组织人员信息~"); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | .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(); |
| | |
| | | .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(), "对不起,名称不能重复~"); |
| | | } |
| | | 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(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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::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.apply(" t.id in ( select hdp.COMPANY_ID from hidden_danger_param hdp where hdp.ISDELETED = 0 and hdp.STATUS = 0 and hdp.TYPE = 0 ) "); |
| | | } |
| | | queryWrapper.orderByDesc(Company::getCreateDate); |
| | | queryWrapper.leftJoin(Company.class,Company::getId,Company::getParentId); |
| | | queryWrapper.leftJoin("company t1 on t1.id=t.parent_id"); |
| | | queryWrapper.select(" t.* ") |
| | | .select("(select count(m.id) from member m where m.COMPANY_ID=t.id and m.ISDELETED=0) as countNum") ; |
| | | queryWrapper.select("t1.name",Company::getParentName); |
| | |
| | | queryWrapper.apply(" t.isdeleted = 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()),"c.name",company.getParentName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(company.getParentName()),"t1.name",company.getParentName()); |
| | | return companyMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | |
| | | queryWrapper.le(Company::getFsDate, Utils.Date.getEnd(pageWrap.getModel().getFsDate())); |
| | | } |
| | | queryWrapper.orderByDesc(Company::getCreateDate); |
| | | queryWrapper.leftJoin(Company.class,Company::getId,Company::getParentId); |
| | | /* .leftJoin(Member.class, Member::getId,Company::getHeadId)*/ |
| | | /* queryWrapper.leftJoin(" company c on c.id=t.parent_id");*/ |
| | | queryWrapper.leftJoin("company t1 on t1.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.like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Company::getName,pageWrap.getModel().getName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getParentName()),"c.name",pageWrap.getModel().getParentName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getParentName()),"t1.name",pageWrap.getModel().getParentName()); |
| | | IPage<Company> companyIPage = companyJoinMapper.selectJoinPage(page, Company.class, queryWrapper); |
| | | return PageData.from(companyIPage); |
| | | } |
| | | |
| | | @Override |
| | | public void updateStatusById(Company company) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | LoginUserInfo loginUserInfo = company.getLoginUserInfo(); |
| | | if(loginUserInfo==null){ |
| | | loginUserInfo = company.getLoginUserInfo(); |
| | | } |
| | |
| | | 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)){ |