Browse Source

Merge remote-tracking branch 'origin/dev'

dev_shibei_match
yinzuomei 5 years ago
parent
commit
323ba482f4
  1. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java
  2. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java
  3. 16
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml
  4. 40
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java

@ -23,8 +23,6 @@ import com.epmet.entity.crm.CustomerRelationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户关系表(01.14 add)
*
@ -35,10 +33,10 @@ import java.util.List;
public interface CustomerRelationDao extends BaseDao<CustomerRelationEntity> {
/**
* @param customerIds
* @param customerId
* @author yinzuomei
* @description 查询当前客户的area_code信息以及下一级客户列表
* @Date 2021/1/21 11:27
**/
List<CustomerSubInfoDTO> selectCustomerSubInfo(@Param("list") List<String> customerIds);
CustomerSubInfoDTO selectCustomerSubInfo(@Param("customerId")String customerId);
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java

@ -22,11 +22,15 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.crm.CustomerRelationDao;
import com.epmet.dto.indexcal.CustomerSubInfoDTO;
import com.epmet.dto.stats.DimCustomerDTO;
import com.epmet.entity.crm.CustomerRelationEntity;
import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.stats.DimCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,7 +46,8 @@ import java.util.stream.Collectors;
@Service
public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelationDao, CustomerRelationEntity> implements CustomerRelationService {
@Autowired
private DimCustomerService dimCustomerService;
/**
* @param customerIds
* @return java.util.Map<java.lang.String, com.epmet.dto.indexcal.CustomerSubInfoDTO>
@ -52,7 +57,17 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
**/
@Override
public Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) {
List<CustomerSubInfoDTO> list = baseDao.selectCustomerSubInfo(customerIds);
List<CustomerSubInfoDTO> list=new ArrayList<>();
for(String customerId:customerIds){
CustomerSubInfoDTO customerSubInfoDTO = baseDao.selectCustomerSubInfo(customerId);
if(null!=customerSubInfoDTO){
DimCustomerDTO dimCustomerDTO=dimCustomerService.get(customerId);
if(null!=dimCustomerDTO){
customerSubInfoDTO.setCustomerName(dimCustomerDTO.getCustomerName());
}
list.add(customerSubInfoDTO);
}
}
if(CollectionUtils.isEmpty(list)){
return new HashMap<>();
}

16
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml

@ -4,7 +4,6 @@
<mapper namespace="com.epmet.dao.crm.CustomerRelationDao">
<resultMap id="CustomerSubInfoDTOResMap" type="com.epmet.dto.indexcal.CustomerSubInfoDTO">
<result property="customerId" column="customerId"></result>
<result property="customerName" column="customerName"></result>
<result property="customerAreaCode" column="customerAreaCode"></result>
<collection property="subCustomerIds" ofType="java.lang.String">
<result column="subCustomerId"/>
@ -14,22 +13,13 @@
<select id="selectCustomerSubInfo" parameterType="map" resultMap="CustomerSubInfoDTOResMap">
SELECT
CR.PARENT_CUSTOMER_ID AS customerId,
dc.CUSTOMER_NAME AS customerName,
dc.AREA_CODE AS customerAreaCode,
CR.CUSTOMER_ID AS subCustomerId
CR.CUSTOMER_ID AS subCustomerId,
(select c.AREA_CODE from customer_relation c where c.del_flag='0' and c.CUSTOMER_ID=#{customerId}) as customerAreaCode
FROM
customer_relation cr
LEFT JOIN dim_customer dc ON ( cr.PARENT_CUSTOMER_ID = DC.ID and dc.del_flag='0')
WHERE
cr.DEL_FLAG = '0'
AND cr.`STATUS` = 'open'
AND cr.PARENT_CUSTOMER_ID != '0'
<if test="null !=list and list.size()>0">
AND cr.PARENT_CUSTOMER_ID IN
<foreach collection="list" item="customerId" index="index" open="(" close=")" separator=",">
#{customerId}
</foreach>
</if>
AND cr.PARENT_CUSTOMER_ID =#{customerId}
</select>
</mapper>

40
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

@ -386,6 +386,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
// 查询所有街道、社区
List<AreaCodeChildDTO> areaCodeChildDTOS = childDao.selectAllChild();
List<AreaCodeDictResultDTO> fourResult = new ArrayList<>();
List<AreaCodeDictResultDTO> fiveResult = new ArrayList<>();
// 街道-社区
Map<Integer, List<AreaCodeChildDTO>> groupByLevel = areaCodeChildDTOS.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getLevel));
//社区
@ -393,23 +394,40 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
Map<String, List<AreaCodeChildDTO>> groupByPCode = levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
//街道
List<AreaCodeChildDTO> levelFour = groupByLevel.get(NumConstant.FOUR);
// 6级
List<AreaCodeChildDTO> levelSix = groupByLevel.get(NumConstant.SIX);
Map<String, List<AreaCodeChildDTO>> groupBySixPCode = levelSix.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
levelFive.forEach(f -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(f.getCode());
dto.setName(f.getName());
dto.setParentCode(f.getPCode());
groupBySixPCode.forEach((k,v) -> {
if (dto.getCode().equals(k)){
List<AreaCodeDictResultDTO> six = new ArrayList<>();
v.forEach(s -> {
AreaCodeDictResultDTO sixDto = new AreaCodeDictResultDTO();
sixDto.setCode(s.getCode());
sixDto.setName(s.getName());
sixDto.setParentCode(k);
six.add(sixDto);
});
List<AreaCodeDictResultDTO> collect = six.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
dto.setChildren(collect);
}
});
fiveResult.add(dto);
});
Map<String, List<AreaCodeDictResultDTO>> groupByFivePCode = fiveResult.stream().collect(Collectors.groupingBy(AreaCodeDictResultDTO::getParentCode));
levelFour.forEach(four -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(four.getCode());
dto.setName(four.getName());
dto.setParentCode(four.getPCode());
groupByPCode.forEach((pCode,v) -> {
groupByFivePCode.forEach((pCode,v) -> {
if (dto.getCode().equals(pCode)){
List<AreaCodeDictResultDTO> fiveResult = new ArrayList<>();
v.forEach(five -> {
AreaCodeDictResultDTO fiveDto = new AreaCodeDictResultDTO();
fiveDto.setCode(five.getCode());
fiveDto.setName(five.getName());
fiveDto.setParentCode(pCode);
fiveResult.add(fiveDto);
});
List<AreaCodeDictResultDTO> fiveSort = fiveResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
dto.setChildren(fiveSort);
dto.setChildren(v);
}
});
fourResult.add(dto);

Loading…
Cancel
Save