|
|
@ -2,6 +2,7 @@ package com.epmet.datareport.service.evaluationindex.screen.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
@ -17,7 +18,10 @@ import com.epmet.dto.ScreenCustomerGridDTO; |
|
|
|
import com.epmet.dto.form.AddAreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.AgencyDetailMulticFormDTO; |
|
|
|
import com.epmet.dto.form.AreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.dto.result.AgencyDetailMulticResultDTO; |
|
|
|
import com.epmet.dto.result.AreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.ParentListResultDTO; |
|
|
|
import com.epmet.dto.result.ScreenCustomerAgencyDTO; |
|
|
|
import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.plugins.AgencyNodeDTO; |
|
|
|
import com.epmet.evaluationindex.screen.constant.ScreenConstant; |
|
|
@ -39,6 +43,7 @@ import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -376,11 +381,17 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
agencysResultDTO = ConvertUtils.sourceToTarget(customerAgencyDTO, AgencyDetailMulticResultDTO.class); |
|
|
|
//2、当前登录用户所属客户,的跟级组织
|
|
|
|
ScreenCustomerAgencyDTO rootAgency=screenCustomerAgencyDao.selectCustomerRootAgency(formDTO.getCustomerId()); |
|
|
|
agencysResultDTO.setRootlevel(rootAgency.getLevel()); |
|
|
|
agencysResultDTO.setRootAgencyId(rootAgency.getAgencyId()); |
|
|
|
//3、当前登录用户所属客户,是否开启了area_code开关
|
|
|
|
agencysResultDTO.setAreaCodeSwitch(govOrgOpenFeignClient.getAreaCodeSwitch(formDTO.getCustomerId()).getData()); |
|
|
|
|
|
|
|
agencysResultDTO.setAreaCodeSwitch(govOrgOpenFeignClient.getAreaCodeSwitch(customerAgencyDTO.getCustomerId()).getData()); |
|
|
|
//如果当前客户不存在子客户则areaCode置为空
|
|
|
|
//4、如果当前客户不存在子客户则areaCode置为空
|
|
|
|
Result<List<String>> crmRes=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); |
|
|
|
if (crmRes.success() &&CollectionUtils.isEmpty(crmRes.getData())) { |
|
|
|
//不存在子客户,则areaCode相关返参都默认为空字符串
|
|
|
|
agencysResultDTO.setAreaCode(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setParentAreaCode(StrConstant.EPMETY_STR); |
|
|
@ -392,26 +403,17 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
agencysResultDTO.setSubCustomerIds(crmRes.getData()); |
|
|
|
} |
|
|
|
|
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 start
|
|
|
|
if (null != customerAgencyDTO) { |
|
|
|
if ("0".equals(customerAgencyDTO.getPid())||StringUtils.isBlank(customerAgencyDTO.getPid())) { |
|
|
|
agencysResultDTO.setRootlevel(customerAgencyDTO.getLevel()); |
|
|
|
if(agencysResultDTO.getHaveSubCustomer()){ |
|
|
|
// 5、多客户时根据area_code查询上级,自下向上,查询到当前客户的跟组织即可stop
|
|
|
|
// TODO
|
|
|
|
log.info("多客户版本parentList、level要重新赋值"); |
|
|
|
ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode()); |
|
|
|
agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency)); |
|
|
|
List<ParentListResultDTO> temp = getParentListMultic(parentList,parentAgency,formDTO.getCustomerId(),agencysResultDTO.getRootAgencyId()); |
|
|
|
agencysResultDTO.setParentList(temp); |
|
|
|
}else{ |
|
|
|
String rootAgencyId =""; |
|
|
|
if(customerAgencyDTO.getPids().contains(StrConstant.COLON)){ |
|
|
|
rootAgencyId= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COLON)).get(NumConstant.ZERO); |
|
|
|
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){ |
|
|
|
rootAgencyId= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA)).get(NumConstant.ZERO); |
|
|
|
} |
|
|
|
ScreenCustomerAgencyDTO rootEntity = screenCustomerAgencyDao.selectByAgencyId(rootAgencyId); |
|
|
|
if (null != rootEntity) { |
|
|
|
agencysResultDTO.setRootlevel(rootEntity.getLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 end
|
|
|
|
|
|
|
|
//2:查询本机关的所有上级机关,按自上而下层级顺序
|
|
|
|
//单客户
|
|
|
|
//6:查询当前组织的所有上级组织,按自上而下层级顺序
|
|
|
|
if (StringUtils.isBlank(customerAgencyDTO.getPids())) { |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
return agencysResultDTO; |
|
|
@ -422,8 +424,42 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){ |
|
|
|
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA)); |
|
|
|
} |
|
|
|
if(!CollectionUtils.isEmpty(pidList)){ |
|
|
|
//单客户,存在上级时查询...
|
|
|
|
agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
private List<ParentListResultDTO> getParentListMultic(List<ParentListResultDTO> resList,ScreenCustomerAgencyDTO firstParent, String currentUserCustomerId, String rootAgencyId) { |
|
|
|
ParentListResultDTO resultDTO = new ParentListResultDTO(); |
|
|
|
resultDTO.setId(firstParent.getAgencyId()); |
|
|
|
resultDTO.setName(firstParent.getAgencyName()); |
|
|
|
resultDTO.setLevel(firstParent.getLevel()); |
|
|
|
resList.add(resultDTO); |
|
|
|
if (firstParent.getCustomerId().equals(currentUserCustomerId) && firstParent.getAgencyId().equals(rootAgencyId)) { |
|
|
|
Collections.reverse(resList); |
|
|
|
return resList; |
|
|
|
} else { |
|
|
|
ScreenCustomerAgencyDTO parentAgency = screenCustomerAgencyDao.selectByAreaCode(firstParent.getParentAreaCode()); |
|
|
|
return getParentListMultic(resList,parentAgency, currentUserCustomerId, rootAgencyId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String getAgencyLevelMultiC(ScreenCustomerAgencyDTO parentAgency) { |
|
|
|
String level=StrConstant.EPMETY_STR; |
|
|
|
if(null!=parentAgency){ |
|
|
|
if(Constant.PROVINCE.equals(parentAgency.getLevel())){ |
|
|
|
return Constant.CITY; |
|
|
|
}else if(Constant.CITY.equals(parentAgency.getLevel())){ |
|
|
|
return Constant.DISTRICT; |
|
|
|
}else if(Constant.DISTRICT.equals(parentAgency.getLevel())){ |
|
|
|
return Constant.STREET; |
|
|
|
}else if(Constant.STREET.equals(parentAgency.getLevel())){ |
|
|
|
return Constant.COMMUNITY; |
|
|
|
} |
|
|
|
} |
|
|
|
return level; |
|
|
|
} |
|
|
|
} |
|
|
|