From 9b0c2e18059ecdc33412eea99c92609020d65720 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 25 Jun 2021 09:13:00 +0800 Subject: [PATCH] /data/report/screen/agency/agencydetail-multic --- .../commons/tools/constant/Constant.java | 9 ++ .../result/AgencyDetailMulticResultDTO.java | 2 + .../screen/ScreenCustomerAgencyDao.java | 11 +++ .../screen/impl/AgencyServiceImpl.java | 98 +++++++++++++------ .../mapper/screen/ScreenCustomerAgencyDao.xml | 48 ++++++--- .../epmet/dto/result/ParentListResultDTO.java | 5 +- 6 files changed, 130 insertions(+), 43 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java index 9ff138efe7..49681043e0 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java @@ -136,4 +136,13 @@ public interface Constant { String CREATED_TIME = "created_time"; String DEFAULT_CUSTOMER = "default"; + + /** + * 省级:province; 市级: city; 区县级: district ;乡(镇、街道)级:street ;社区级:community + */ + String PROVINCE = "province"; + String CITY = "city"; + String DISTRICT = "district"; + String STREET = "street"; + String COMMUNITY = "community"; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/AgencyDetailMulticResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/AgencyDetailMulticResultDTO.java index bdc2add52a..bcd8c3adf5 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/AgencyDetailMulticResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/AgencyDetailMulticResultDTO.java @@ -84,6 +84,7 @@ public class AgencyDetailMulticResultDTO implements Serializable { //以下参数是06.24新增 + private String rootAgencyId; private String parentAreaCode; /** * 是否有字客户 @@ -94,4 +95,5 @@ public class AgencyDetailMulticResultDTO implements Serializable { * 子客户列表 */ private List subCustomerIds; + } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index d31eee8700..aed418f5ab 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -192,4 +192,15 @@ public interface ScreenCustomerAgencyDao { List selectGridDTOList(@Param("areaCode") String areaCode, @Param("parentAgencyId") String parentAgencyId); List selectPAgencyById(@Param("listStr")List pidList); + + /** + * @return com.epmet.dto.result.ScreenCustomerAgencyDTO + * @param customerId + * @author yinzuomei + * @description 根据客户id,返回当前客户下的跟组织信息 + * @Date 2021/6/24 17:43 + **/ + ScreenCustomerAgencyDTO selectCustomerRootAgency(String customerId); + + ScreenCustomerAgencyDTO selectByAreaCode(String areaCode); } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java index 722673691b..1d039d9f01 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java @@ -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> 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,38 +403,63 @@ 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()); - } 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()); - } + if(agencysResultDTO.getHaveSubCustomer()){ + // 5、多客户时根据area_code查询上级,自下向上,查询到当前客户的跟组织即可stop + // TODO + log.info("多客户版本parentList、level要重新赋值"); + ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode()); + agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency)); + List temp = getParentListMultic(parentList,parentAgency,formDTO.getCustomerId(),agencysResultDTO.getRootAgencyId()); + agencysResultDTO.setParentList(temp); + }else{ + //单客户 + //6:查询当前组织的所有上级组织,按自上而下层级顺序 + if (StringUtils.isBlank(customerAgencyDTO.getPids())) { + agencysResultDTO.setParentList(parentList); + return agencysResultDTO; + } + List 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)); + } + if(!CollectionUtils.isEmpty(pidList)){ + //单客户,存在上级时查询... + agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList)); } } - //2021.5.26 sun 添加当前组织对应客户的根组织级别返参 end + return agencysResultDTO; + } - //2:查询本机关的所有上级机关,按自上而下层级顺序 - if (StringUtils.isBlank(customerAgencyDTO.getPids())) { - agencysResultDTO.setParentList(parentList); - return agencysResultDTO; - } - List 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)); + private List getParentListMultic(List 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); } - agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList)); + } - return agencysResultDTO; + 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; } } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml index 5a1e506707..0a076134ef 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml @@ -377,18 +377,44 @@ + + + + + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java index 60683bf779..421ecabd25 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java @@ -19,7 +19,6 @@ package com.epmet.dto.result; import lombok.Data; -import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -43,4 +42,8 @@ public class ParentListResultDTO implements Serializable { private String name = ""; + /** + * 省级:province; 市级: city; 区县级: district ;乡(镇、街道)级:street ;社区级:community + */ + private String level=""; } \ No newline at end of file