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. 82
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  5. 28
      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 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新增
private String rootAgencyId;
private String parentAreaCode;
/**
* 是否有字客户
@ -94,4 +95,5 @@ public class AgencyDetailMulticResultDTO implements Serializable {
* 子客户列表
*/
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<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);
}

82
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<List<String>> 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,26 +403,17 @@ 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());
if(agencysResultDTO.getHaveSubCustomer()){
// 5、多客户时根据area_code查询上级,自下向上,查询到当前客户的跟组织即可stop
// TODO
log.info("多客户版本parentList、level要重新赋值");
ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode());
agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency));
List<ParentListResultDTO> temp = getParentListMultic(parentList,parentAgency,formDTO.getCustomerId(),agencysResultDTO.getRootAgencyId());
agencysResultDTO.setParentList(temp);
}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:查询本机关的所有上级机关,按自上而下层级顺序
//单客户
//6:查询当前组织的所有上级组织,按自上而下层级顺序
if (StringUtils.isBlank(customerAgencyDTO.getPids())) {
agencysResultDTO.setParentList(parentList);
return agencysResultDTO;
@ -422,8 +424,42 @@ public class AgencyServiceImpl implements AgencyService {
}else if(customerAgencyDTO.getPids().contains(StrConstant.COMMA)){
pidList= Arrays.asList(customerAgencyDTO.getPids().split(StrConstant.COMMA));
}
if(!CollectionUtils.isEmpty(pidList)){
//单客户,存在上级时查询...
agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList));
}
}
return agencysResultDTO;
}
private List<ParentListResultDTO> getParentListMultic(List<ParentListResultDTO> 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);
}
}
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;
}
}

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

@ -377,9 +377,11 @@
<select id="selectPAgencyById" resultType="com.epmet.dto.result.ParentListResultDTO">
SELECT
sca.AGENCY_ID as id,
sca.AGENCY_NAME AS 'name'
sca.AGENCY_NAME AS 'name',
level
from screen_customer_agency sca
WHERE del_flag = '0'
<if test="listStr != null and listStr.size() > 0">
AND AGENCY_ID IN
<foreach item="id" collection="listStr" open="(" separator="," close=")" index="">
#{id}
@ -390,5 +392,29 @@
#{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>
</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 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="";
}
Loading…
Cancel
Save