From 145d8073d554548a9a2e830a62d5a5a5d7b44c36 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 14 Jan 2021 16:46:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=85=A5=E5=8F=82CalculateCommonFormDTO?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=B7=BB=E5=8A=A0customerAreaCode=E3=80=81su?= =?UTF-8?q?bCustomerIds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/indexcal/CalculateCommonFormDTO.java | 5 +- .../dto/indexcal/CustomerSubInfoDTO.java | 28 +++++++++ .../epmet/dao/stats/CustomerRelationDao.java | 38 +++++++++++ .../entity/stats/CustomerRelationEntity.java | 63 +++++++++++++++++++ .../impl/IndexCalculateServiceImpl.java | 19 +++++- .../stats/CustomerRelationService.java | 44 +++++++++++++ .../impl/CustomerRelationServiceImpl.java | 56 +++++++++++++++++ .../mapper/stats/CustomerRelationDao.xml | 26 ++++++++ 8 files changed, 276 insertions(+), 3 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerSubInfoDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerRelationDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/CustomerRelationEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerRelationService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerRelationServiceImpl.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java index f27057a9d4..03c5ae0ddb 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; /** @@ -33,13 +34,13 @@ public class CalculateCommonFormDTO implements Serializable { /** * 当前客户所属的地区编码 add 01.14 */ - private String customerAreaCode; + private String customerAreaCode = ""; /** * 当前客户下的需要汇聚的子客户列表 add 01.14 * 暂不使用 */ - private List subCustomerIds; + private List subCustomerIds = new ArrayList<>(); public CalculateCommonFormDTO() { super(); diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerSubInfoDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerSubInfoDTO.java new file mode 100644 index 0000000000..57f401c301 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerSubInfoDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2021/1/14 16:17 + */ +@Data +public class CustomerSubInfoDTO implements Serializable { + private String customerId; + + /** + * 当前客户所属的地区编码 add 01.14 + */ + private String customerAreaCode; + + /** + * 当前客户下的需要汇聚的子客户列表 add 01.14 + * 暂不使用 + */ + private List subCustomerIds; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerRelationDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerRelationDao.java new file mode 100644 index 0000000000..a5c15ff8cc --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerRelationDao.java @@ -0,0 +1,38 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.stats; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcal.CustomerSubInfoDTO; +import com.epmet.entity.stats.CustomerRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-14 + */ +@Mapper +public interface CustomerRelationDao extends BaseDao { + + List selectCustomerSubInfo(@Param("list") List customerIds); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/CustomerRelationEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/CustomerRelationEntity.java new file mode 100644 index 0000000000..4c3d7098c9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/CustomerRelationEntity.java @@ -0,0 +1,63 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity.stats; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_relation") +public class CustomerRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 父级客户id;如果是顶级客户,此列=0 + */ + private String parentCustomerId; + + /** + * 当前客户类型取值: external:外部客户,internal:内部客户 + */ + private String customerType; + + /** + * 父级客户类型取值: external:外部客户,internal:内部客户;如果是顶级客户,此列=0 + */ + private String parentCustomerType; + + /** + * open,closed是否启用 + */ + private String status; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index 753dc70726..9a03124895 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -8,10 +8,12 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.CustomerSubInfoDTO; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.redis.IndexCalRedis; import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; +import com.epmet.service.stats.CustomerRelationService; import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -21,6 +23,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * @author liujianjun @@ -50,7 +53,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { private FactIndexCollectService factIndexCollectService; @Autowired private ScreenCustomerAgencyDao screenCustomerAgencyDao; - + @Autowired + private CustomerRelationService customerRelationService; @Override public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { @@ -71,11 +75,20 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } else { customerIds.add(formDTO.getCustomerId()); } + + //查询客户编码、子客户信息 add01.14 + Map customerInfoMap=this.getCustomerInfoMap(customerIds); + Boolean flag = false; for (String customerId : customerIds) { CalculateCommonFormDTO param = new CalculateCommonFormDTO(); param.setCustomerId(customerId); param.setMonthId(formDTO.getMonthId()); + //01.14 add + if(null!=customerInfoMap.get(customerId)){ + param.setCustomerAreaCode(customerInfoMap.get(customerId).getCustomerAreaCode()); + param.setSubCustomerIds(customerInfoMap.get(customerId).getSubCustomerIds()); + } flag = calulateCustomerIndexScore(param); } return flag; @@ -178,4 +191,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } return false; } + + private Map getCustomerInfoMap(List customerIds) { + return customerRelationService.getCustomerInfoMap(customerIds); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerRelationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerRelationService.java new file mode 100644 index 0000000000..cc94faa6c2 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerRelationService.java @@ -0,0 +1,44 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.stats; + + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.indexcal.CustomerSubInfoDTO; +import com.epmet.entity.stats.CustomerRelationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-14 + */ +public interface CustomerRelationService extends BaseService { + + /** + * @return java.util.Map + * @param customerIds + * @author yinzuomei + * @description 查询每个客户的area_code以及子客户列表 + * @Date 2021/1/14 16:22 + **/ + Map getCustomerInfoMap(List customerIds); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerRelationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerRelationServiceImpl.java new file mode 100644 index 0000000000..bbdbb9f386 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerRelationServiceImpl.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.stats.impl; + +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.stats.CustomerRelationDao; +import com.epmet.dto.indexcal.CustomerSubInfoDTO; +import com.epmet.entity.stats.CustomerRelationEntity; +import com.epmet.service.stats.CustomerRelationService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-14 + */ +@DataSource(DataSourceConstant.STATS) +@Service +public class CustomerRelationServiceImpl extends BaseServiceImpl implements CustomerRelationService { + + + /** + * @param customerIds + * @return java.util.Map + * @author yinzuomei + * @description 查询每个客户的area_code以及子客户列表 + * @Date 2021/1/14 16:22 + **/ + @Override + public Map getCustomerInfoMap(List customerIds) { + List list = baseDao.selectCustomerSubInfo(customerIds); + return list.stream().collect(Collectors.toMap(CustomerSubInfoDTO::getCustomerId, customer -> customer)); + } +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml new file mode 100644 index 0000000000..e959443001 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file