From 08fed15a5cf6f3972443311645dd8ee4ebb0ad69 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期二, 14 五月 2024 17:07:06 +0800 Subject: [PATCH] 最新版本 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java | 40 ++++++++++++++++++++++++++++++++-------- 1 files changed, 32 insertions(+), 8 deletions(-) diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java index 73aa6e2..f62d26d 100644 --- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java +++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java @@ -36,6 +36,7 @@ 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; @@ -87,6 +88,7 @@ company.setCompanyPath(company.getId()+"/");//鍚嶇О璺緞 company.setCompanyNamePath(company.getName());//鍚嶇О璺緞 company.setHkParentId(rootOrgId); + String idPath = ""; if(company.getParentId() !=null){ Company parent = findById(company.getParentId()); if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ @@ -95,11 +97,17 @@ if(StringUtils.isBlank(parent.getHkId())){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅灏氭湭鍚屾涓嬪彂鎴愬姛~"); } - company.setHkParentId(parent.getHkId()); + if(Constants.equalsInteger(parent.getType(),Constants.ZERO)){ + //濡傛灉鐖剁骇鏄浉鍏虫柟缁勭粐锛屼笅绾т笉鑳藉缓绔嬪唴閮ㄧ粍缁� + if(Constants.equalsInteger(company.getType(),Constants.ONE)){ + throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐩稿叧鏂圭粍缁囷紝涓嬬骇涓嶈兘寤虹珛鍐呴儴缁勭粐~"); + } + } + idPath = parent.getCompanyPath(); company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/"); company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName()); } - company.setHkCompanyPath(company.getCompanyPath()); + company.setHkCompanyPath(company.getCompanyNamePath()); company.setCreateDate(new Date()); company.setCreator(user.getId()); company.setIsdeleted(Constants.ZERO); @@ -115,6 +123,10 @@ if(!addHkOrg(company)){ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯"); } + Company com = new Company(); + com.setId(company.getId()); + com.setCompanyPath(idPath+company.getId()+"/"); + companyMapper.updateById(com); return company.getId(); } @@ -275,8 +287,14 @@ if(model == null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝缁勭粐淇℃伅涓嶅瓨鍦▇"); } - if(StringUtils.isBlank(model.getHkId())){ - throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝缁勭粐淇℃伅灏氭湭鍚屾涓嬪彂鎴愬姛,鏆備笉鏀寔淇敼锛岃灏濊瘯鍒犻櫎鍚庨噸鏂版坊鍔爚"); + if( Constants.equalsObject(Constants.ONE,model.getType())&& Constants.equalsObject(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){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝涓嬬骇閮ㄩ棬瀛樺湪鍐呴儴缁勭粐锛岃閮ㄩ棬涓嶆敮鎸佸垏鎹负鐩稿叧鏂圭粍缁囷紒~"); + } } company.setEditDate(new Date()); company.setEditor(user.getId()); @@ -285,14 +303,19 @@ company.setHkId(StringUtils.defaultString(model.getHkId(),UUID.randomUUID().toString().replace("-",""))); company.setParentId(null);//涓嶆敮鎸佷慨鏀圭埗绾� companyMapper.updateById(company); + //鏇存柊鐨刢ompanyPath + String newName = model.getCompanyNamePath().replace(model.getName(),company.getName()); + companyMapper.update(null,new UpdateWrapper<Company>().lambda() + .setSql("company_name_path=REPLACE(company_name_path,'"+ model.getCompanyNamePath()+"','"+newName+"')") + .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')") + .likeRight(Company::getCompanyPath,model.getCompanyPath())); //涓嬪彂娴峰悍瀹夐槻骞冲彴 - if(StringUtils.isNotBlank(model.getHkId()) - && Constants.equalsObject(Constants.ONE,model.getHkStatus())){ - if(editHkOrg(company)){ + if(StringUtils.isNotBlank(model.getHkId())){ + if(!editHkOrg(company)){ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯"); } }else{//濡傛灉娌℃湁涓嬪彂杩囷紝鐩存帴鏂板缓瀹夐槻骞冲彴缁勭粐 - if(addHkOrg(company)){ + if(!addHkOrg(company)){ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯"); } } @@ -547,6 +570,7 @@ queryWrapper.selectAs(Member::getPhone,Company::getHeadPhone); queryWrapper.select("t1.name",Company::getParentName); queryWrapper.select("t1.company_path",Company::getParentCompanyPath); + queryWrapper.select("t1.type",Company::getParentType); queryWrapper.leftJoin(Company.class,Company::getId,Company::getParentId); queryWrapper.leftJoin(Member.class,Member::getId,Company::getHeadId); queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Company::getEditor); -- Gitblit v1.9.3