Browse Source

根据工作人员Id 获取组织树 areaCode版

dev
jianjun 4 years ago
parent
commit
867b088718
  1. 70
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/KongCunCustomerEnvEnum.java
  2. 33
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/OrgLevelEnum.java
  3. 38
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeAreaCodeNode.java
  4. 28
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java
  5. 22
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/govOrg/OrgTreeFormDTO.java
  6. 15
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java
  7. 37
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  8. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java
  9. 109
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  10. 15
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  11. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  12. 11
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/OrgTreeNode.java

70
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/KongCunCustomerEnvEnum.java

@ -1,70 +0,0 @@
package com.epmet.commons.tools.enums;
import com.epmet.commons.tools.utils.SpringContextUtils;
import org.springframework.core.env.Environment;
/**
* 系统环境变量枚举类
* dev|test|prod
*
* @author jianjun liu
* @date 2020-07-03 11:14
**/
public enum KongCunCustomerEnvEnum {
/**
* 环境变量枚举
*/
DEV("dev", "开发环境", "613cc61a6b8ce4c70d21bd413dac72cc"),
TEST("test", "体验环境", "b272625617e53620b2b3cbc65d1ecbbb"),
PROD("prod", "生产环境", "6f203e30de1a65aab7e69c058826cd80"),
UN_KNOWN("prod", "生产环境", "6f203e30de1a65aab7e69c058826cd80")
;
private String code;
private String name;
private String customerId;
KongCunCustomerEnvEnum(String code, String name, String customerId) {
this.code = code;
this.name = name;
this.customerId = customerId;
}
public static KongCunCustomerEnvEnum getEnum(String code) {
KongCunCustomerEnvEnum[] values = KongCunCustomerEnvEnum.values();
for (KongCunCustomerEnvEnum value : values) {
if (value.getCode().equals(code)) {
return value;
}
}
return KongCunCustomerEnvEnum.UN_KNOWN;
}
public static KongCunCustomerEnvEnum getCurrentEnv(){
try {
Environment environment = SpringContextUtils.getBean(Environment.class);
String[] activeProfiles = environment.getActiveProfiles();
if (activeProfiles.length > 0) {
return getEnum(activeProfiles[0]);
}
} catch (Exception e) {
e.printStackTrace();
}
return KongCunCustomerEnvEnum.UN_KNOWN;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public String getCustomerId(){
return customerId;
}
}

33
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/OrgLevelEnum.java

@ -1,7 +1,9 @@
package com.epmet.commons.tools.enums; package com.epmet.commons.tools.enums;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import org.apache.commons.lang3.StringUtils;
/** /**
* 组织级别枚举类 * 组织级别枚举类
@ -42,6 +44,37 @@ public enum OrgLevelEnum {
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode()); throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode());
} }
/**
* desc: 获取下一等级的组织级别
*
* @param parentAgencyLevel
* @return java.lang.String
* @author LiuJanJun
* @date 2021/8/5 1:57 下午
* todo 加上数字 根据数据返回
*/
public static String getSubOrgLevel(String parentAgencyLevel) {
String level = StrConstant.EPMETY_STR;
if (StringUtils.isBlank(parentAgencyLevel)) {
return level;
}
OrgLevelEnum anEnum = OrgLevelEnum.getEnum(parentAgencyLevel);
switch (anEnum){
case PROVINCE:
return OrgLevelEnum.CITY.getCode();
case CITY:
return OrgLevelEnum.DISTRICT.getCode();
case DISTRICT:
return OrgLevelEnum.STREET.getCode();
case STREET:
return OrgLevelEnum.COMMUNITY.getCode();
case COMMUNITY:
return OrgLevelEnum.GRID.getCode();
default:
return level;
}
}

38
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeAreaCodeNode.java

@ -0,0 +1,38 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.commons.tools.utils;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 树节点所有需要实现树节点的都需要继承该类
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Data
public class TreeAreaCodeNode<T> extends TreeStringNode<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String areaCode;
/**
* 上级ID
*/
private String parentAreaCode;
/**
* 子节点列表
*/
private List<T> children = new ArrayList<>();
}

28
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java

@ -131,4 +131,32 @@ public class TreeUtils {
return result; return result;
} }
/**
* 构建树节点
*/
public static <T extends TreeAreaCodeNode> List<T> buildTreeByAreaCode(List<T> treeNodes) {
List<T> result = new ArrayList<>();
//list转map
Map<String, T> nodeMap = new LinkedHashMap<>(treeNodes.size());
for(T treeNode : treeNodes){
nodeMap.put(treeNode.getAreaCode(), treeNode);
}
for(T node : nodeMap.values()) {
T parent = nodeMap.get(node.getParentAreaCode());
if(parent != null && !(node.getAreaCode().equals(parent.getAreaCode()))){
if (parent.getChildren() == null){
parent.setChildren(new ArrayList());
}
parent.getChildren().add(node);
continue;
}
result.add(node);
}
return result;
}
} }

22
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/govOrg/OrgTreeFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.form.govOrg;
import lombok.Data;
import java.io.Serializable;
/**
* 各机关注册用户数入参DTO
*
* @author yinzuomei@elink-cn.com
* @date 2020/6/22 12:47
*/
@Data
public class OrgTreeFormDTO implements Serializable {
private static final long serialVersionUID = 6649155066499141632L;
private String mobile;
private String customerId;
}

15
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java

@ -5,9 +5,11 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.dto.OrgTreeNode;
import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AgencyDetailMulticFormDTO; import com.epmet.dto.form.AgencyDetailMulticFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.form.govOrg.OrgTreeFormDTO;
import com.epmet.dto.result.AgencyDetailMulticResultDTO; import com.epmet.dto.result.AgencyDetailMulticResultDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO;
@ -129,4 +131,17 @@ public class AgencyController {
ValidatorUtils.validateEntity(formDTO, AgencyDetailMulticFormDTO.AddUserInternalGroup.class); ValidatorUtils.validateEntity(formDTO, AgencyDetailMulticFormDTO.AddUserInternalGroup.class);
return new Result<AgencyDetailMulticResultDTO>().ok(agencyService.queryAgencyDetailMultiC(formDTO)); return new Result<AgencyDetailMulticResultDTO>().ok(agencyService.queryAgencyDetailMultiC(formDTO));
} }
/**
* desc: 获取组织树 含所有直线上级 但不含部门和网格 目前
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.plugins.AgencyNodeDTO>
* @author LiuJanJun
* @date 2021/8/3 5:17 下午
*/
@PostMapping("getStaffAgencyTree")
public Result<OrgTreeNode> getStaffAgencyTree(@RequestBody OrgTreeFormDTO formDTO) {
return new Result<OrgTreeNode>().ok(agencyService.getStaffAgencyTree(formDTO));
}
} }

37
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -114,7 +114,7 @@ public interface ScreenCustomerAgencyDao {
CompartmentResultDTO getAgencyInfoByAegncyId(@Param("agencyId") String agencyId); CompartmentResultDTO getAgencyInfoByAegncyId(@Param("agencyId") String agencyId);
/** /**
* @Description 查询组织的下级组织ID * @Description 查询组织的下级组织ID
* @Param agencyId * @Param agencyId
* @author zxc * @author zxc
* @date 2020/10/28 10:33 上午 * @date 2020/10/28 10:33 上午
@ -134,7 +134,7 @@ public interface ScreenCustomerAgencyDao {
* @description 根据areaCode查询组织机构 * @description 根据areaCode查询组织机构
* @Date 2021/2/4 21:51 * @Date 2021/2/4 21:51
**/ **/
List<AgencyNodeDTO> queryStaffAgencyTree(@Param("areaCode")String areaCode); List<AgencyNodeDTO> queryStaffAgencyTree(@Param("areaCode") String areaCode);
/** /**
* @param areaCode * @param areaCode
@ -143,7 +143,7 @@ public interface ScreenCustomerAgencyDao {
* @description 查找组织下的部门 * @description 查找组织下的部门
* @Date 2021/2/4 21:51 * @Date 2021/2/4 21:51
**/ **/
List<DeptNodeDTO> selectDeptList(@Param("areaCode") String areaCode,@Param("agencyId") String agencyId); List<DeptNodeDTO> selectDeptList(@Param("areaCode") String areaCode, @Param("agencyId") String agencyId);
/** /**
* @param areaCode * @param areaCode
@ -152,27 +152,27 @@ public interface ScreenCustomerAgencyDao {
* @description 查找组织下的网格 * @description 查找组织下的网格
* @Date 2021/2/4 21:52 * @Date 2021/2/4 21:52
**/ **/
List<GridNodeDTO> selectGridList(@Param("areaCode") String areaCode,@Param("agencyId") String agencyId); List<GridNodeDTO> selectGridList(@Param("areaCode") String areaCode, @Param("agencyId") String agencyId);
/** /**
* @return java.util.List<java.lang.String>
* @param areaCode * @param areaCode
* @param agencyId * @param agencyId
* @return java.util.List<java.lang.String>
* @author yinzuomei * @author yinzuomei
* @description 下一级组织+直属网格 * @description 下一级组织+直属网格
* @Date 2021/5/10 14:02 * @Date 2021/5/10 14:02
**/ **/
List<String> getNextAgencyIds(@Param("areaCode")String areaCode,@Param("agencyId")String agencyId); List<String> getNextAgencyIds(@Param("areaCode") String areaCode, @Param("agencyId") String agencyId);
List<ScreenCustomerAgencyCommonDTO> selectSubAgencyIds(@Param("areaCode")String areaCode, @Param("agencyId")String agencyId); List<ScreenCustomerAgencyCommonDTO> selectSubAgencyIds(@Param("areaCode") String areaCode, @Param("agencyId") String agencyId);
/** /**
* @Description 根据agencyId查询网格 * @Description 根据agencyId查询网格
* @Param agencyId * @Param agencyId
* @author zxc * @author zxc
* @date 2021/6/8 1:27 下午 * @date 2021/6/8 1:27 下午
*/ */
List<GridManagerListResultDTO> selectGrid(@Param("agencyId")String agencyId,@Param("areaCode")String areaCode); List<GridManagerListResultDTO> selectGrid(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode);
/** /**
* 查询当前组织的下一级组织可根据areaCode查询也可根据pid查询 * 查询当前组织的下一级组织可根据areaCode查询也可根据pid查询
@ -190,13 +190,13 @@ public interface ScreenCustomerAgencyDao {
* @param parentAgencyId * @param parentAgencyId
* @return java.util.List<com.epmet.dto.result.ScreenCustomerAgencyDTO> * @return java.util.List<com.epmet.dto.result.ScreenCustomerAgencyDTO>
*/ */
List<ScreenCustomerGridDTO> selectGridDTOList(@Param("areaCode") String areaCode, @Param("parentAgencyId") String parentAgencyId,@Param("allCustomerIds") List<String> allCustomerIds); List<ScreenCustomerGridDTO> selectGridDTOList(@Param("areaCode") String areaCode, @Param("parentAgencyId") String parentAgencyId, @Param("allCustomerIds") List<String> allCustomerIds);
List<ParentListResultDTO> selectPAgencyById(@Param("listStr")List<String> pidList); List<ParentListResultDTO> selectPAgencyById(@Param("listStr") List<String> pidList);
/** /**
* @return com.epmet.dto.result.ScreenCustomerAgencyDTO
* @param customerId * @param customerId
* @return com.epmet.dto.result.ScreenCustomerAgencyDTO
* @author yinzuomei * @author yinzuomei
* @description 根据客户id返回当前客户下的跟组织信息 * @description 根据客户id返回当前客户下的跟组织信息
* @Date 2021/6/24 17:43 * @Date 2021/6/24 17:43
@ -204,4 +204,15 @@ public interface ScreenCustomerAgencyDao {
ScreenCustomerAgencyDTO selectCustomerRootAgency(String customerId); ScreenCustomerAgencyDTO selectCustomerRootAgency(String customerId);
ScreenCustomerAgencyDTO selectByAreaCode(String areaCode); ScreenCustomerAgencyDTO selectByAreaCode(String areaCode);
}
/**
* desc: 根据pids 或者 areaCode 获取所有下级组织
*
* @param pids
* @param areaCode
* @return java.util.List<com.epmet.dto.result.ScreenCustomerAgencyDTO>
* @author LiuJanJun
* @date 2021/8/5 11:01 上午
*/
List<ScreenCustomerAgencyDTO> selectAllSubAgencyList(@Param("pids") String pids, @Param("areaCode") String areaCode);
}

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java

@ -1,10 +1,12 @@
package com.epmet.datareport.service.evaluationindex.screen; package com.epmet.datareport.service.evaluationindex.screen;
import com.epmet.dto.AgencyInfoDTO; import com.epmet.dto.AgencyInfoDTO;
import com.epmet.dto.OrgTreeNode;
import com.epmet.dto.ScreenCustomerGridDTO; import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AgencyDetailMulticFormDTO; import com.epmet.dto.form.AgencyDetailMulticFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.form.govOrg.OrgTreeFormDTO;
import com.epmet.dto.result.AgencyDetailMulticResultDTO; import com.epmet.dto.result.AgencyDetailMulticResultDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.ScreenCustomerAgencyDTO; import com.epmet.dto.result.ScreenCustomerAgencyDTO;
@ -104,4 +106,14 @@ public interface AgencyService {
* @return com.epmet.dto.result.AgencyDetailMulticResultDTO * @return com.epmet.dto.result.AgencyDetailMulticResultDTO
*/ */
AgencyDetailMulticResultDTO queryAgencyDetailMultiC(AgencyDetailMulticFormDTO formDTO); AgencyDetailMulticResultDTO queryAgencyDetailMultiC(AgencyDetailMulticFormDTO formDTO);
/**
* desc: 获取工作人员组织树 含所有直线上级组织 不含网格及部门
*
* @param mobile
* @return com.epmet.dto.result.plugins.AgencyNodeDTO
* @author LiuJanJun
* @date 2021/8/3 5:03 下午
*/
OrgTreeNode getStaffAgencyTree(OrgTreeFormDTO mobile);
} }

109
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java

@ -2,23 +2,26 @@ package com.epmet.datareport.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; 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.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; 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.exception.RenException;
import com.epmet.commons.tools.utils.AgencyTreeUtils; import com.epmet.commons.tools.utils.AgencyTreeUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.TreeUtils;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.datareport.redis.DataReportRedis; import com.epmet.datareport.redis.DataReportRedis;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.dto.AgencyInfoDTO; import com.epmet.dto.*;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AgencyDetailMulticFormDTO; import com.epmet.dto.form.AgencyDetailMulticFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO; 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.AgencyDetailMulticResultDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.ParentListResultDTO; 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.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO; import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.feign.OperCrmOpenFeignClient;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -70,6 +74,8 @@ public class AgencyServiceImpl implements AgencyService {
private OperCrmOpenFeignClient operCrmOpenFeignClient; private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired @Autowired
private DataReportRedis dataReportRedis; private DataReportRedis dataReportRedis;
@Autowired
private EpmetUserOpenFeignClient userOpenFeignClient;
/** /**
* @Description 1组织机构树 * @Description 1组织机构树
@ -438,7 +444,7 @@ public class AgencyServiceImpl implements AgencyService {
log.info("多客户版本parentList、level要重新赋值;agencysResultDTO.getParentAreaCode()="+agencysResultDTO.getParentAreaCode()); log.info("多客户版本parentList、level要重新赋值;agencysResultDTO.getParentAreaCode()="+agencysResultDTO.getParentAreaCode());
ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode()); ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode());
if (null != parentAgency) { if (null != parentAgency) {
agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency)); agencysResultDTO.setLevel(OrgLevelEnum.getSubOrgLevel(parentAgency.getLevel()));
List<ParentListResultDTO> temp = getParentListMultic(parentList, parentAgency, formDTO.getCustomerId(), agencysResultDTO.getRootAgencyId()); List<ParentListResultDTO> temp = getParentListMultic(parentList, parentAgency, formDTO.getCustomerId(), agencysResultDTO.getRootAgencyId());
agencysResultDTO.setParentList(temp); agencysResultDTO.setParentList(temp);
} }
@ -468,6 +474,85 @@ public class AgencyServiceImpl implements AgencyService {
return agencysResultDTO; 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) { private List<ParentListResultDTO> getParentListMultic(List<ParentListResultDTO> resList, ScreenCustomerAgencyDTO firstParent, String currentUserCustomerId, String rootAgencyId) {
ParentListResultDTO resultDTO = new ParentListResultDTO(); ParentListResultDTO resultDTO = new ParentListResultDTO();
resultDTO.setId(firstParent.getAgencyId()); 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;
}
} }

15
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -433,4 +433,19 @@
AND sca.AREA_CODE = #{areaCode} AND sca.AREA_CODE = #{areaCode}
limit 1 limit 1
</select> </select>
<select id="selectAllSubAgencyList" resultType="com.epmet.dto.result.ScreenCustomerAgencyDTO">
SELECT
sca.*
FROM
screen_customer_agency sca
WHERE
sca.DEL_FLAG = '0'
<if test="pids != null and pids != ''">
AND sca.pids like CONCAT(#{pids},'%')
</if>
<if test="areaCode != null and areaCode != ''">
AND sca.AREA_CODE like CONCAT(#{areaCode},'%')
</if>
</select>
</mapper> </mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.KongCunCustomerEnvEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;

11
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/OrgTreeNode.java

@ -1,13 +1,18 @@
package com.epmet.dto; package com.epmet.dto;
import com.epmet.commons.tools.utils.TreeAreaCodeNode;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
public class OrgTreeNode { public class OrgTreeNode extends TreeAreaCodeNode<OrgTreeNode> {
private String id;
private String pid;
private String orgId; private String orgId;
private String orgName; private String orgName;
private String orgType; private String level;
private List<OrgTreeNode> subOrgs;
private List<OrgTreeNode> children=new ArrayList<>();
} }

Loading…
Cancel
Save