From 5c5d610f38e888d803abbadfbb3fc36bbf6d4be5 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 14 Jan 2021 13:38:49 +0800 Subject: [PATCH] =?UTF-8?q?dimCustomer=E5=88=9D=E5=A7=8B=E5=8C=96=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0areaCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/result/CustomerAreaCodeResultDTO.java | 25 +++++++++++++++++++ .../epmet/dao/org/StatsCustomerAgencyDao.java | 9 +++++++ .../com/epmet/entity/crm/CustomerEntity.java | 3 +++ .../epmet/entity/stats/DimCustomerEntity.java | 2 ++ .../service/impl/StatsDimServiceImpl.java | 17 +++++++++++++ .../service/org/CustomerAgencyService.java | 9 +++++++ .../org/impl/CustomerAgencyServiceImpl.java | 18 +++++++++++++ .../stats/impl/DimCustomerServiceImpl.java | 2 ++ .../mapper/org/StatsCustomerAgencyDao.xml | 17 +++++++++++++ .../resources/mapper/stats/DimCustomerDao.xml | 2 ++ 10 files changed, 104 insertions(+) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAreaCodeResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAreaCodeResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAreaCodeResultDTO.java new file mode 100644 index 0000000000..f3b4a73048 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAreaCodeResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.org.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/1/14 上午11:05 + */ +@Data +public class CustomerAreaCodeResultDTO implements Serializable { + + private static final long serialVersionUID = -4722604654441455214L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 行政区域编码 + */ + private String areaCode; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index eb02051e91..9c1217bd02 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java @@ -2,6 +2,7 @@ package com.epmet.dao.org; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.entity.org.CustomerAgencyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -22,4 +23,12 @@ public interface StatsCustomerAgencyDao extends BaseDao { List selectSubAgencyByPid(@Param("pid")String pid); List listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); + + /** + * @Description 查询客户所属区域编码 + * @Param customerIds + * @author zxc + * @date 2021/1/14 上午11:07 + */ + List selectCustomerAreaCodeById(@Param("customerIds") List customerIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java index a2fa408a43..c6dc6dba64 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java @@ -17,6 +17,7 @@ package com.epmet.entity.crm; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.epmet.commons.mybatis.entity.BaseEpmetEntity; @@ -88,4 +89,6 @@ public class CustomerEntity extends BaseEpmetEntity { */ private String logo; + @TableField(exist = false) + private String areaCode; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimCustomerEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimCustomerEntity.java index a287006414..6641ecd2dc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimCustomerEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimCustomerEntity.java @@ -43,4 +43,6 @@ public class DimCustomerEntity extends BaseEpmetEntity { */ private String customerName; + private String areaCode; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java index 5c09458416..6338145260 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.epmet.constant.RobotConstant; +import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.entity.crm.CustomerEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.org.CustomerDepartmentEntity; @@ -199,6 +200,14 @@ public class StatsDimServiceImpl implements StatsDimService { List customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime); + // 添加 areaCode + if (!CollectionUtils.isEmpty(customers)){ + List customerIds = customers.stream().map(m -> m.getId()).collect(Collectors.toList()); + List areaCodes = customerAgencyService.selectCustomerAreaCodeById(customerIds); + if (!CollectionUtils.isEmpty(areaCodes)){ + customers.forEach(c -> areaCodes.stream().filter(a -> c.getId().equals(a.getCustomerId())).forEach(a -> c.setAreaCode(a.getAreaCode()))); + } + } return customers; } @@ -212,6 +221,14 @@ public class StatsDimServiceImpl implements StatsDimService { if (lastCreatedDim != null) { // 说明不是首次初始化 List customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime); + // 添加 areaCode + if (!CollectionUtils.isEmpty(customers)){ + List customerIds = customers.stream().map(m -> m.getId()).collect(Collectors.toList()); + List areaCodes = customerAgencyService.selectCustomerAreaCodeById(customerIds); + if (!CollectionUtils.isEmpty(areaCodes)){ + customers.forEach(c -> areaCodes.stream().filter(a -> c.getId().equals(a.getCustomerId())).forEach(a -> c.setAreaCode(a.getAreaCode()))); + } + } return customers; } return new ArrayList<>(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 96669f2ae9..b93c4563ec 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java @@ -1,5 +1,6 @@ package com.epmet.service.org; +import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.entity.org.CustomerAgencyEntity; import java.util.Date; @@ -9,4 +10,12 @@ public interface CustomerAgencyService { List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime); List listAgenciesByUpdatedTime(Date updatedTime, Date now); + + /** + * @Description 查询客户所属区域编码 + * @Param customerIds + * @author zxc + * @date 2021/1/14 上午11:07 + */ + List selectCustomerAreaCodeById(List customerIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index 4813309176..702da0930d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java @@ -3,11 +3,14 @@ package com.epmet.service.org.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.StatsCustomerAgencyDao; +import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.service.org.CustomerAgencyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -27,4 +30,19 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { public List listAgenciesByUpdatedTime(Date startTime, Date endTime) { return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime); } + + /** + * @Description 查询客户所属区域编码 + * @Param customerIds + * @author zxc + * @date 2021/1/14 上午11:07 + */ + @Override + public List selectCustomerAreaCodeById(List customerIds) { + if (!CollectionUtils.isEmpty(customerIds)){ + List resultDTOS = customerAgencyDao.selectCustomerAreaCodeById(customerIds); + return resultDTOS; + } + return new ArrayList<>(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java index 367b06629b..feae456fb3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java @@ -128,6 +128,7 @@ public class DimCustomerServiceImpl extends BaseServiceImpl #{endTime} + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml index 54914e24d0..457801d6b5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml @@ -15,6 +15,7 @@