From a10bdbfd49a3fa83368afa896cdf4d4fa0da6d54 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 4 Mar 2021 21:42:01 +0800 Subject: [PATCH] test --- .../controller/IndexCalculateController.java | 16 +++++----- .../service/crm/CustomerRelationService.java | 7 ++-- .../crm/impl/CustomerRelationServiceImpl.java | 30 +++++------------ .../indexcal/IndexCalculateService.java | 5 +-- .../impl/IndexCalculateServiceImpl.java | 32 ++++++++----------- 5 files changed, 33 insertions(+), 57 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index 415f4cbdea..9f2a4b06cd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java @@ -10,6 +10,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.CalculateStatus; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.CustomerSubInfoDTO; import com.epmet.dto.indexcal.IndexStatisticsFormDTO; import com.epmet.model.CalculateFlagModel; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; @@ -17,13 +18,15 @@ import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.util.DimIdGenerator; import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.PreDestroy; -import java.util.*; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import java.util.concurrent.*; /** @@ -356,11 +359,8 @@ public class IndexCalculateController { return new Result(); } - @PostMapping("getCustomerInfoMap") - public Result getCustomerInfoMap(@RequestBody List customerIds) { - if(CollectionUtils.isNotEmpty(customerIds)){ - return new Result().ok(indexCalculateService.getCustomerInfoMap(customerIds)); - } - return new Result().error("customerIds不能为空"); + @PostMapping("getCustomerSubInfo") + public Result getCustomerSubInfo(@RequestParam("customerId") String customerId) { + return new Result().ok(indexCalculateService.getCustomerSubInfo(customerId)); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java index 7d9a9f8aca..f139c49bab 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java @@ -22,9 +22,6 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.indexcal.CustomerSubInfoDTO; import com.epmet.entity.crm.CustomerRelationEntity; -import java.util.List; -import java.util.Map; - /** * 客户关系表(01.14 add) * @@ -35,12 +32,12 @@ public interface CustomerRelationService extends BaseService - * @param customerIds + * @param customerId * @author yinzuomei * @description 查询每个客户的area_code、以及下一级客户列表 * @Date 2021/1/14 16:22 **/ - Map getCustomerInfoMap(List customerIds); + CustomerSubInfoDTO getCustomerSubInfo(String customerId); boolean haveSubCustomer(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 0af903eb6c..cab6ed0adc 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 @@ -29,13 +29,8 @@ import com.epmet.service.stats.DimCustomerService; import lombok.extern.slf4j.Slf4j; 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; -import java.util.stream.Collectors; /** * 客户关系表(01.14 add) @@ -51,35 +46,26 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl * @author yinzuomei * @description 查询每个客户的area_code、以及下一级客户列表 * @Date 2021/1/14 16:22 **/ @Override - public Map getCustomerInfoMap(List customerIds) { - List list=new ArrayList<>(); - for(String customerId:customerIds){ - CustomerSubInfoDTO customerSubInfoDTO = baseDao.selectCustomerSubInfo(customerId); - if(null==customerSubInfoDTO){ - log.info(String.format("当前客户customerId: %s, 没有下一级客户 ",customerId)); - continue; - } - DimCustomerDTO dimCustomerDTO=dimCustomerService.get(customerId); + public CustomerSubInfoDTO getCustomerSubInfo(String customerId) { + CustomerSubInfoDTO customerSubInfoDTO = baseDao.selectCustomerSubInfo(customerId); + if (null != customerSubInfoDTO) { + DimCustomerDTO dimCustomerDTO = dimCustomerService.get(customerId); customerSubInfoDTO.setCustomerName(dimCustomerDTO.getCustomerName()); - list.add(customerSubInfoDTO); } - if(CollectionUtils.isEmpty(list)){ - return new HashMap<>(); - } - return list.stream().collect(Collectors.toMap(CustomerSubInfoDTO::getCustomerId, customer -> customer)); + return customerSubInfoDTO; } @Override public boolean haveSubCustomer(String customerId) { - List list=baseDao.selectListByPids(customerId); - if(null==list||list.isEmpty()){ + List list = baseDao.selectListByPids(customerId); + if (null == list || list.isEmpty()) { return false; } return true; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java index 137a2624b1..d5d41e48a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java @@ -4,9 +4,6 @@ import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CustomerSubInfoDTO; import com.epmet.dto.indexcal.IndexStatisticsFormDTO; -import java.util.List; -import java.util.Map; - /** * 指标计算service * @@ -32,5 +29,5 @@ public interface IndexCalculateService { **/ void toScreenIndexData(CalculateCommonFormDTO formDTO); - Map getCustomerInfoMap(List customerIds); + CustomerSubInfoDTO getCustomerSubInfo(String customerId); } 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 abdfa9a343..d080e31712 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 @@ -28,7 +28,6 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Map; /** * @author liujianjun @@ -83,18 +82,17 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { 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 (!customerInfoMap.isEmpty() && null != customerInfoMap.get(customerId)) { - param.setCustomerAreaCode(customerInfoMap.get(customerId).getCustomerAreaCode()); - param.setSubCustomerIds(customerInfoMap.get(customerId).getSubCustomerIds()); + //01.14 add 查询客户编码、以及下一级客户列表 + CustomerSubInfoDTO customerSubInfoDTO=this.getCustomerSubInfo(customerId); + if (null != customerSubInfoDTO) { + param.setCustomerAreaCode(customerSubInfoDTO.getCustomerAreaCode()); + param.setSubCustomerIds(customerSubInfoDTO.getSubCustomerIds()); } flag = calulateCustomerIndexScore(param); } @@ -202,14 +200,14 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } /** - * @param customerIds + * @param customerId * @author yinzuomei * @description 查询当前客户的area_code信息、以及下一级客户列表 * @Date 2021/1/21 11:28 **/ @Override - public Map getCustomerInfoMap(List customerIds) { - return customerRelationService.getCustomerInfoMap(customerIds); + public CustomerSubInfoDTO getCustomerSubInfo(String customerId) { + return customerRelationService.getCustomerSubInfo(customerId); } @Async @@ -256,17 +254,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { **/ @Override public void toScreenIndexData(CalculateCommonFormDTO formDTO) { - List customerIds=new ArrayList<>(); - customerIds.add(formDTO.getCustomerId()); //查询客户编码、以及下一级客户列表 add01.14 - Map customerInfoMap=this.getCustomerInfoMap(customerIds); - log.info("customerInfoMap: "+JSON.toJSONString(customerInfoMap,true)); + CustomerSubInfoDTO customerSubInfoDTO = this.getCustomerSubInfo(formDTO.getCustomerId()); + log.info("customerInfoMap: " + JSON.toJSONString(customerSubInfoDTO, true)); //01.14 add - if (!customerInfoMap.isEmpty() && null != customerInfoMap.get(formDTO.getCustomerId())) { - formDTO.setCustomerAreaCode(customerInfoMap.get(formDTO.getCustomerId()).getCustomerAreaCode()); - formDTO.setSubCustomerIds(customerInfoMap.get(formDTO.getCustomerId()).getSubCustomerIds()); + if (null != customerSubInfoDTO) { + formDTO.setCustomerAreaCode(customerSubInfoDTO.getCustomerAreaCode()); + formDTO.setSubCustomerIds(customerSubInfoDTO.getSubCustomerIds()); } - log.info("入参: "+JSON.toJSONString(formDTO,true)); + log.info("入参: " + JSON.toJSONString(formDTO, true)); factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO); } }