|
|
@ -3,8 +3,10 @@ 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.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.AgencyTreeUtils; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
@ -13,10 +15,10 @@ import com.epmet.datareport.service.evaluationindex.screen.AgencyService; |
|
|
|
import com.epmet.dto.AgencyInfoDTO; |
|
|
|
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.AreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.ScreenCustomerAgencyDTO; |
|
|
|
import com.epmet.dto.result.plugins.AgencyNodeDTO; |
|
|
|
import com.epmet.evaluationindex.screen.constant.ScreenConstant; |
|
|
|
import com.epmet.evaluationindex.screen.dto.form.CompartmentByBizTypeFormDTO; |
|
|
@ -26,6 +28,8 @@ import com.epmet.evaluationindex.screen.dto.result.AgencyDistributionResultDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.ibatis.exceptions.TooManyResultsException; |
|
|
@ -34,6 +38,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -53,6 +58,10 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
private ScreenCustomerGridDao screenCustomerGridDao; |
|
|
|
@Autowired |
|
|
|
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1、组织机构树 |
|
|
@ -347,4 +356,74 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
public List<ScreenCustomerGridDTO> queryGridList(String areaCode, String parentAgencyId) { |
|
|
|
return screenCustomerAgencyDao.selectGridDTOList(areaCode,parentAgencyId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 工作端小程序-数据上面的 当前组织调用此接口 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.dto.result.AgencyDetailMulticResultDTO |
|
|
|
*/ |
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) |
|
|
|
@Override |
|
|
|
public AgencyDetailMulticResultDTO queryAgencyDetailMultiC(AgencyDetailMulticFormDTO formDTO) { |
|
|
|
AgencyDetailMulticResultDTO agencysResultDTO = new AgencyDetailMulticResultDTO(); |
|
|
|
List<ParentListResultDTO> parentList = new ArrayList<>(); |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
|
|
|
|
//1:查询本机关详细信息
|
|
|
|
ScreenCustomerAgencyDTO customerAgencyDTO = screenCustomerAgencyDao.selectByAgencyId(formDTO.getAgencyId()); |
|
|
|
if (null == customerAgencyDTO) { |
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
agencysResultDTO = ConvertUtils.sourceToTarget(customerAgencyDTO, AgencyDetailMulticResultDTO.class); |
|
|
|
|
|
|
|
agencysResultDTO.setAreaCodeSwitch(govOrgOpenFeignClient.getAreaCodeSwitch(customerAgencyDTO.getCustomerId()).getData()); |
|
|
|
//如果当前客户不存在子客户则areaCode置为空
|
|
|
|
Result<List<String>> crmRes=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); |
|
|
|
if (crmRes.success() &&CollectionUtils.isEmpty(crmRes.getData())) { |
|
|
|
agencysResultDTO.setAreaCode(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setParentAreaCode(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setHaveSubCustomer(false); |
|
|
|
agencysResultDTO.setSubCustomerIds(new ArrayList<>()); |
|
|
|
}else{ |
|
|
|
agencysResultDTO.setAreaName(agencysResultDTO.getAgencyName()); |
|
|
|
agencysResultDTO.setHaveSubCustomer(true); |
|
|
|
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()); |
|
|
|
} 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:查询本机关的所有上级机关,按自上而下层级顺序
|
|
|
|
if (StringUtils.isBlank(customerAgencyDTO.getPids())) { |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
List<String> pidList =new ArrayList<>(); |
|
|
|
if(customerAgencyDTO.getPids().contains(StrConstant.COLON)){ |
|
|
|
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COLON)); |
|
|
|
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){ |
|
|
|
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA)); |
|
|
|
} |
|
|
|
agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList)); |
|
|
|
|
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
} |
|
|
|