k94314517
2024-10-16 17efddc6a667670dca682bf36b51a43e99615e6d
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -36,7 +36,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -104,6 +103,7 @@
                }
            }
            idPath = parent.getCompanyPath();
            company.setHkParentId(parent.getHkId());
            company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/");
            company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName());
        }
@@ -134,7 +134,7 @@
        List<OrgAddRequest> addList = new ArrayList<>();
        addList.add(getOrgAddModel(company));
        BaseResponse<OrgOrUserAddResponse> result =  HKService.addBatchOrg(addList);
        if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
        if(result !=null && StringUtils.equals(result.getCode(), HKConstants.RESPONSE_SUCCEE)){
            OrgOrUserAddResponse data = result.getData();
            if(data.getSuccesses()!=null && data.getSuccesses().size()>0){
                //处理新增成功的数据,修改海康同步状态
@@ -156,6 +156,7 @@
    }
    private boolean delHkOrg(Company company) {
        OrgDelRequest request =new OrgDelRequest();
        request.setIndexCodes(new String[]{company.getHkId()});
        BaseResponse<List<OrgUpdateFailureResponse>> result =  HKService.delBatchOrg(request);
        if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
@@ -232,6 +233,7 @@
                .eq(Member::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该部门下存在人员信息,不能进行删除操作!");
        }
        Company company = new Company();
        company.setId(id);
        company.setEditDate(new Date());
@@ -241,7 +243,7 @@
        company.setHkDate(company.getHkDate());
        companyMapper.updateById(company);
        //下发海康安防平台
        if(StringUtils.isBlank(model.getHkId()) && Constants.equalsInteger(Constants.ONE,model.getHkStatus()) && !delHkOrg(model)){
        if(StringUtils.isNotBlank(model.getHkId()) && Constants.equalsInteger(Constants.ONE,model.getHkStatus()) && !delHkOrg(model)){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织删除下发失败,请确认该组织无下级组织或组织人员信息~");
        }
    }
@@ -287,12 +289,13 @@
        if(model == null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,组织信息不存在~");
        }
         if( Constants.equalsObject(Constants.ONE,model.getType())&& Constants.equalsObject(Constants.ZERO,company.getType())){
         if( Constants.equalsInteger(Constants.ONE,model.getType())&& Constants.equalsInteger(Constants.ZERO,company.getType())){
        //如果由内部组织切换成内部组织,排查下级组织是否有内部组织
             if(companyJoinMapper.selectCount(new QueryWrapper<Company>().lambda()
                     .eq(Company::getIsdeleted,Constants.ZERO )
                     .eq(Company::getType,Constants.ONE )
                     .likeRight(Company::getCompanyPath,company.getCompanyPath())) >0){
                     .ne(Company::getId,model.getId())
                     .likeRight(Company::getCompanyPath,model.getCompanyPath())) >0){
                 throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,下级部门存在内部组织,该部门不支持切换为相关方组织!~");
             }
        }
@@ -482,13 +485,11 @@
        companyMapper.updateById(company);
    }
    @Override
    public long count(Company company) {
        QueryWrapper<Company> wrapper = new QueryWrapper<>(company);
        return companyMapper.selectCount(wrapper);
    }
    @Override
    public List<CompanyDTO> findCompanyTreePage(Integer type) {
@@ -500,7 +501,6 @@
        List<Company> companies = companyMapper.selectList(wrapper);
        return getCompanyTree( companies, null);
    }
    private List<CompanyDTO> getCompanyTree(List<Company> companies, String parentId){
        if (CollectionUtils.isEmpty(companies)){
@@ -576,7 +576,7 @@
        queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Company::getEditor);
        queryWrapper.eq(Company::getIsdeleted,Constants.ZERO);
        queryWrapper.eq(type!=null,Company::getType,type);
        queryWrapper.orderByAsc(Company::getSortnum );
        queryWrapper.orderByAsc(true,"t.sortnum");
        List<Company> companyList = companyJoinMapper.selectJoinList(Company.class,queryWrapper);
        //配置组员人员类型来源方式 0自建 1ERP
        CompanyTree treeBuild = new CompanyTree(companyList, dataSyncConfig.getOrgUserDataOrigin());
@@ -618,7 +618,8 @@
            if (currentMenuIndex - 1 < 0) {
                return;
            }
            Company preMenu = companyPool.remove(currentMenuIndex - 1);
            Company preMenu = companyPool.get(currentMenuIndex - 1);
            companyPool.remove(currentMenuIndex - 1);
            companyPool.add(currentMenuIndex, preMenu);
        }
        // 下移