Browse Source

/data/report/screen/agency/agencydetail-multic

dev_shibei_match
yinzuomei 4 years ago
parent
commit
9b0c2e1805
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
  2. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/AgencyDetailMulticResultDTO.java
  3. 11
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  4. 98
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  5. 48
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  6. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java

9
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 CREATED_TIME = "created_time";
String DEFAULT_CUSTOMER = "default"; String DEFAULT_CUSTOMER = "default";
/**
* 省级:province; 市级: city; 区县级: district ;街道:street ;社区级community
*/
String PROVINCE = "province";
String CITY = "city";
String DISTRICT = "district";
String STREET = "street";
String COMMUNITY = "community";
} }

2
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新增 //以下参数是06.24新增
private String rootAgencyId;
private String parentAreaCode; private String parentAreaCode;
/** /**
* 是否有字客户 * 是否有字客户
@ -94,4 +95,5 @@ public class AgencyDetailMulticResultDTO implements Serializable {
* 子客户列表 * 子客户列表
*/ */
private List<String> subCustomerIds; private List<String> subCustomerIds;
} }

11
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<ScreenCustomerGridDTO> selectGridDTOList(@Param("areaCode") String areaCode, @Param("parentAgencyId") String parentAgencyId); List<ScreenCustomerGridDTO> selectGridDTOList(@Param("areaCode") String areaCode, @Param("parentAgencyId") String parentAgencyId);
List<ParentListResultDTO> selectPAgencyById(@Param("listStr")List<String> pidList); List<ParentListResultDTO> selectPAgencyById(@Param("listStr")List<String> 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);
} }

98
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.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.exception.RenException; 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.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.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.commonservice.AddAreaCodeDictResultDTO;
import com.epmet.dto.result.plugins.AgencyNodeDTO; import com.epmet.dto.result.plugins.AgencyNodeDTO;
import com.epmet.evaluationindex.screen.constant.ScreenConstant; import com.epmet.evaluationindex.screen.constant.ScreenConstant;
@ -39,6 +43,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -376,11 +381,17 @@ public class AgencyServiceImpl implements AgencyService {
return agencysResultDTO; return agencysResultDTO;
} }
agencysResultDTO = ConvertUtils.sourceToTarget(customerAgencyDTO, AgencyDetailMulticResultDTO.class); 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()); //4、如果当前客户不存在子客户则areaCode置为空
//如果当前客户不存在子客户则areaCode置为空
Result<List<String>> crmRes=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); Result<List<String>> crmRes=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId());
if (crmRes.success() &&CollectionUtils.isEmpty(crmRes.getData())) { if (crmRes.success() &&CollectionUtils.isEmpty(crmRes.getData())) {
//不存在子客户,则areaCode相关返参都默认为空字符串
agencysResultDTO.setAreaCode(StrConstant.EPMETY_STR); agencysResultDTO.setAreaCode(StrConstant.EPMETY_STR);
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); agencysResultDTO.setAreaName(StrConstant.EPMETY_STR);
agencysResultDTO.setParentAreaCode(StrConstant.EPMETY_STR); agencysResultDTO.setParentAreaCode(StrConstant.EPMETY_STR);
@ -392,38 +403,63 @@ public class AgencyServiceImpl implements AgencyService {
agencysResultDTO.setSubCustomerIds(crmRes.getData()); agencysResultDTO.setSubCustomerIds(crmRes.getData());
} }
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 start if(agencysResultDTO.getHaveSubCustomer()){
if (null != customerAgencyDTO) { // 5、多客户时根据area_code查询上级,自下向上,查询到当前客户的跟组织即可stop
if ("0".equals(customerAgencyDTO.getPid())||StringUtils.isBlank(customerAgencyDTO.getPid())) { // TODO
agencysResultDTO.setRootlevel(customerAgencyDTO.getLevel()); log.info("多客户版本parentList、level要重新赋值");
} else { ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode());
String rootAgencyId =""; agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency));
if(customerAgencyDTO.getPids().contains(StrConstant.COLON)){ List<ParentListResultDTO> temp = getParentListMultic(parentList,parentAgency,formDTO.getCustomerId(),agencysResultDTO.getRootAgencyId());
rootAgencyId= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COLON)).get(NumConstant.ZERO); agencysResultDTO.setParentList(temp);
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){ }else{
rootAgencyId= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA)).get(NumConstant.ZERO); //单客户
} //6:查询当前组织的所有上级组织,按自上而下层级顺序
ScreenCustomerAgencyDTO rootEntity = screenCustomerAgencyDao.selectByAgencyId(rootAgencyId); if (StringUtils.isBlank(customerAgencyDTO.getPids())) {
if (null != rootEntity) { agencysResultDTO.setParentList(parentList);
agencysResultDTO.setRootlevel(rootEntity.getLevel()); 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));
}
if(!CollectionUtils.isEmpty(pidList)){
//单客户,存在上级时查询...
agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList));
} }
} }
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 end return agencysResultDTO;
}
//2:查询本机关的所有上级机关,按自上而下层级顺序 private List<ParentListResultDTO> getParentListMultic(List<ParentListResultDTO> resList,ScreenCustomerAgencyDTO firstParent, String currentUserCustomerId, String rootAgencyId) {
if (StringUtils.isBlank(customerAgencyDTO.getPids())) { ParentListResultDTO resultDTO = new ParentListResultDTO();
agencysResultDTO.setParentList(parentList); resultDTO.setId(firstParent.getAgencyId());
return agencysResultDTO; resultDTO.setName(firstParent.getAgencyName());
} resultDTO.setLevel(firstParent.getLevel());
List<String> pidList =new ArrayList<>(); resList.add(resultDTO);
if(customerAgencyDTO.getPids().contains(StrConstant.COLON)){ if (firstParent.getCustomerId().equals(currentUserCustomerId) && firstParent.getAgencyId().equals(rootAgencyId)) {
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COLON)); Collections.reverse(resList);
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){ return resList;
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA)); } 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;
} }
} }

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

@ -377,18 +377,44 @@
<select id="selectPAgencyById" resultType="com.epmet.dto.result.ParentListResultDTO"> <select id="selectPAgencyById" resultType="com.epmet.dto.result.ParentListResultDTO">
SELECT SELECT
sca.AGENCY_ID as id, sca.AGENCY_ID as id,
sca.AGENCY_NAME AS 'name' sca.AGENCY_NAME AS 'name',
level
from screen_customer_agency sca from screen_customer_agency sca
WHERE del_flag = '0' WHERE del_flag = '0'
AND AGENCY_ID IN <if test="listStr != null and listStr.size() > 0">
<foreach item="id" collection="listStr" open="(" separator="," close=")" index=""> AND AGENCY_ID IN
#{id} <foreach item="id" collection="listStr" open="(" separator="," close=")" index="">
</foreach> #{id}
ORDER BY field( </foreach>
AGENCY_ID, ORDER BY field(
<foreach item="id" collection="listStr" separator=","> AGENCY_ID,
#{id} <foreach item="id" collection="listStr" separator=",">
</foreach> #{id}
) </foreach>
)
</if>
</select>
<!-- 根据客户id,返回当前客户下的跟组织信息 -->
<select id="selectCustomerRootAgency" resultType="com.epmet.dto.result.ScreenCustomerAgencyDTO">
SELECT
sca.*
FROM
screen_customer_agency sca
WHERE
sca.DEL_FLAG = '0'
AND sca.PID = '0'
AND sca.CUSTOMER_ID = #{customerId}
</select>
<select id="selectByAreaCode" resultType="com.epmet.dto.result.ScreenCustomerAgencyDTO">
SELECT
sca.*
FROM
screen_customer_agency sca
WHERE
sca.DEL_FLAG = '0'
AND sca.AREA_CODE = #{areaCode}
limit 1
</select> </select>
</mapper> </mapper>

5
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 lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
@ -43,4 +42,8 @@ public class ParentListResultDTO implements Serializable {
private String name = ""; private String name = "";
/**
* 省级:province; 市级: city; 区县级: district ;街道:street ;社区级community
*/
private String level="";
} }
Loading…
Cancel
Save