|
|
@ -2,23 +2,26 @@ 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.enums.OrgLevelEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
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.commons.tools.utils.TreeUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
|
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao; |
|
|
|
import com.epmet.datareport.redis.DataReportRedis; |
|
|
|
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; |
|
|
|
import com.epmet.dto.AgencyInfoDTO; |
|
|
|
import com.epmet.dto.ScreenCustomerGridDTO; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.AddAreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.AgencyDetailMulticFormDTO; |
|
|
|
import com.epmet.dto.form.AreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.CustomerStaffFormDTO; |
|
|
|
import com.epmet.dto.form.govOrg.OrgTreeFormDTO; |
|
|
|
import com.epmet.dto.result.AgencyDetailMulticResultDTO; |
|
|
|
import com.epmet.dto.result.AreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.ParentListResultDTO; |
|
|
@ -33,6 +36,7 @@ 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.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -70,6 +74,8 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private DataReportRedis dataReportRedis; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient userOpenFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1、组织机构树 |
|
|
@ -438,7 +444,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
log.info("多客户版本parentList、level要重新赋值;agencysResultDTO.getParentAreaCode()="+agencysResultDTO.getParentAreaCode()); |
|
|
|
ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode()); |
|
|
|
if (null != parentAgency) { |
|
|
|
agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency)); |
|
|
|
agencysResultDTO.setLevel(OrgLevelEnum.getSubOrgLevel(parentAgency.getLevel())); |
|
|
|
List<ParentListResultDTO> temp = getParentListMultic(parentList, parentAgency, formDTO.getCustomerId(), agencysResultDTO.getRootAgencyId()); |
|
|
|
agencysResultDTO.setParentList(temp); |
|
|
|
} |
|
|
@ -468,6 +474,85 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
return agencysResultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public OrgTreeNode getStaffAgencyTree(OrgTreeFormDTO formDTO) { |
|
|
|
//todo 获取客户的所有组织 然后遍历剔除 再构建出一颗树 咋样
|
|
|
|
//获取工作人员信息
|
|
|
|
CustomerStaffFormDTO staffParam = new CustomerStaffFormDTO(); |
|
|
|
staffParam.setMobile(formDTO.getMobile()); |
|
|
|
staffParam.setCustomerId(formDTO.getCustomerId()); |
|
|
|
Result<CustomerStaffDTO> staffInfoResult = userOpenFeignClient.getCustomerStaffInfo(staffParam); |
|
|
|
if (!staffInfoResult.success()){ |
|
|
|
throw new RenException(staffInfoResult.getCode(),staffInfoResult.getInternalMsg()); |
|
|
|
} |
|
|
|
//获取工作人员组织信息
|
|
|
|
Result<CustomerAgencyDTO> agencyByStaff = govOrgOpenFeignClient.getAgencyByStaff(staffInfoResult.getData().getUserId()); |
|
|
|
if (!agencyByStaff.success() || agencyByStaff.getData()== null || StringUtils.isBlank(agencyByStaff.getData().getId()) ){ |
|
|
|
throw new RenException(staffInfoResult.getCode(),staffInfoResult.getMsg()); |
|
|
|
} |
|
|
|
CustomerAgencyDTO staffAgencyDTO = agencyByStaff.getData(); |
|
|
|
|
|
|
|
|
|
|
|
//4、如果当前客户不存在子客户则areaCode置为空
|
|
|
|
Result<List<String>> crmRes=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); |
|
|
|
if (!crmRes.success()){ |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} |
|
|
|
List<OrgTreeNode> nodes = new ArrayList<>(); |
|
|
|
//单客户
|
|
|
|
if (CollectionUtils.isEmpty(crmRes.getData())){ |
|
|
|
//todo 暂不处理 有时间再说
|
|
|
|
}else { |
|
|
|
ScreenCustomerAgencyDTO parentAgencyDTO = null; |
|
|
|
String subAgencyAreaCode = staffAgencyDTO.getParentAreaCode(); |
|
|
|
List<OrgTreeNode> nodeList = new ArrayList<>(); |
|
|
|
|
|
|
|
/*ScreenCustomerAgencyDTO currentAgency = new ScreenCustomerAgencyDTO(); |
|
|
|
currentAgency.setCustomerId(staffAgencyDTO.getCustomerId()); |
|
|
|
currentAgency.setAgencyId(staffAgencyDTO.getId()); |
|
|
|
currentAgency.setAgencyName(staffAgencyDTO.getOrganizationName()); |
|
|
|
currentAgency.setLevel(staffAgencyDTO.getLevel()); |
|
|
|
currentAgency.setAreaCode(staffAgencyDTO.getAreaCode()); |
|
|
|
currentAgency.setParentAreaCode(staffAgencyDTO.getParentAreaCode()); |
|
|
|
currentAgency.setPid(staffAgencyDTO.getPid()); |
|
|
|
currentAgency.setPids(staffAgencyDTO.getPids()); |
|
|
|
|
|
|
|
convertOrgTreeNode(nodeList, currentAgency);*/ |
|
|
|
//多客户 获取所有直线上级
|
|
|
|
do { |
|
|
|
parentAgencyDTO = screenCustomerAgencyDao.selectByAreaCode(subAgencyAreaCode); |
|
|
|
if (parentAgencyDTO == null){ |
|
|
|
break; |
|
|
|
} |
|
|
|
convertOrgTreeNode(nodeList, parentAgencyDTO); |
|
|
|
if (parentAgencyDTO.getPid() == null || NumConstant.ZERO_STR.equals(parentAgencyDTO.getPid())){ |
|
|
|
break; |
|
|
|
} |
|
|
|
subAgencyAreaCode = parentAgencyDTO.getAreaCode(); |
|
|
|
} while (true); |
|
|
|
//多客户 获取所有下级
|
|
|
|
List<ScreenCustomerAgencyDTO> agencyNodeDTOS = screenCustomerAgencyDao.selectAllSubAgencyList(null,staffAgencyDTO.getAreaCode()); |
|
|
|
//孔村降级处理
|
|
|
|
String KONG_CUN_AGENCY_ID = "1234085031077498881"; |
|
|
|
agencyNodeDTOS.forEach(e->{ |
|
|
|
if (e.getPids().contains(KONG_CUN_AGENCY_ID)){ |
|
|
|
e.setLevel(OrgLevelEnum.getSubOrgLevel(e.getLevel())); |
|
|
|
} |
|
|
|
convertOrgTreeNode(nodeList, e); |
|
|
|
}); |
|
|
|
nodes = TreeUtils.buildTreeByAreaCode(nodeList); |
|
|
|
} |
|
|
|
//只有一个根节点的树 所以返回一个
|
|
|
|
return nodes.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
private void convertOrgTreeNode(List<OrgTreeNode> nodeList, ScreenCustomerAgencyDTO currentAgency) { |
|
|
|
OrgTreeNode orgTreeNode = ConvertUtils.sourceToTarget(currentAgency, OrgTreeNode.class); |
|
|
|
orgTreeNode.setOrgId(currentAgency.getAgencyId()); |
|
|
|
orgTreeNode.setOrgName(currentAgency.getAgencyName()); |
|
|
|
nodeList.add(orgTreeNode); |
|
|
|
} |
|
|
|
|
|
|
|
private List<ParentListResultDTO> getParentListMultic(List<ParentListResultDTO> resList, ScreenCustomerAgencyDTO firstParent, String currentUserCustomerId, String rootAgencyId) { |
|
|
|
ParentListResultDTO resultDTO = new ParentListResultDTO(); |
|
|
|
resultDTO.setId(firstParent.getAgencyId()); |
|
|
@ -491,20 +576,4 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|