From f47aca28de7a1848170c8b7912120a92b33373a5 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 24 Feb 2021 17:27:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AreaCodeServiceImpl.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java index 1360f92778..5e865cfc44 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java +++ b/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 areaCodeChildDTOS = childDao.selectAllChild(); List fourResult = new ArrayList<>(); + List fiveResult = new ArrayList<>(); // 街道-社区 Map> groupByLevel = areaCodeChildDTOS.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getLevel)); //社区 @@ -393,23 +394,40 @@ public class AreaCodeServiceImpl extends BaseServiceImpl> groupByPCode = levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode)); //街道 List levelFour = groupByLevel.get(NumConstant.FOUR); + // 6级 + List levelSix = groupByLevel.get(NumConstant.SIX); + Map> 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 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 collect = six.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList()); + dto.setChildren(collect); + } + }); + fiveResult.add(dto); + }); + Map> 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 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 fiveSort = fiveResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList()); - dto.setChildren(fiveSort); + dto.setChildren(v); } }); fourResult.add(dto); From abef0b95d3299a400b2c8bd096fc42847cb3e792 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 24 Feb 2021 19:51:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?data-stat=E7=BB=9F=E8=AE=A1=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=BF=AE=E6=94=B9:=E6=8C=87=E6=A0=87=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E8=8E=B7=E5=8F=96=E5=AD=90=E5=AE=A2=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dao/crm/CustomerRelationDao.java | 6 ++---- .../crm/impl/CustomerRelationServiceImpl.java | 19 +++++++++++++++++-- .../mapper/crm/CustomerRelationDao.xml | 16 +++------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java index d79e843076..87a8db63bf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java +++ b/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 { /** - * @param customerIds + * @param customerId * @author yinzuomei * @description 查询当前客户的area_code信息、以及下一级客户列表 * @Date 2021/1/21 11:27 **/ - List selectCustomerSubInfo(@Param("list") List customerIds); + CustomerSubInfoDTO selectCustomerSubInfo(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java index 018e215af1..440491f8a5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java +++ b/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 implements CustomerRelationService { - + @Autowired + private DimCustomerService dimCustomerService; /** * @param customerIds * @return java.util.Map @@ -52,7 +57,17 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl getCustomerInfoMap(List customerIds) { - List list = baseDao.selectCustomerSubInfo(customerIds); + List 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<>(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml index b6d60ae9a4..a92c55e9f9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml @@ -4,7 +4,6 @@ - @@ -14,22 +13,13 @@ \ No newline at end of file