Browse Source

Merge remote-tracking branch 'origin/dev_pyscreen' into dev_temp

dev_shibei_match
yinzuomei 5 years ago
parent
commit
3f868ba63b
  1. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  2. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java
  3. 30
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java
  4. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java
  5. 32
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java

16
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<String> customerIds) {
if(CollectionUtils.isNotEmpty(customerIds)){
return new Result().ok(indexCalculateService.getCustomerInfoMap(customerIds));
}
return new Result().error("customerIds不能为空");
@PostMapping("getCustomerSubInfo")
public Result<CustomerSubInfoDTO> getCustomerSubInfo(@RequestParam("customerId") String customerId) {
return new Result<CustomerSubInfoDTO>().ok(indexCalculateService.getCustomerSubInfo(customerId));
}
}

7
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<CustomerRelationEnt
/**
* @return java.util.Map<java.lang.String,com.epmet.dto.indexcal.CustomerSubInfoDTO>
* @param customerIds
* @param customerId
* @author yinzuomei
* @description 查询每个客户的area_code以及下一级客户列表
* @Date 2021/1/14 16:22
**/
Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds);
CustomerSubInfoDTO getCustomerSubInfo(String customerId);
boolean haveSubCustomer(String customerId);
}

30
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<CustomerRelatio
@Autowired
private DimCustomerService dimCustomerService;
/**
* @param customerIds
* @param customerId
* @return java.util.Map<java.lang.String, com.epmet.dto.indexcal.CustomerSubInfoDTO>
* @author yinzuomei
* @description 查询每个客户的area_code以及下一级客户列表
* @Date 2021/1/14 16:22
**/
@Override
public Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) {
List<CustomerSubInfoDTO> 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<CustomerRelationEntity> list=baseDao.selectListByPids(customerId);
if(null==list||list.isEmpty()){
List<CustomerRelationEntity> list = baseDao.selectListByPids(customerId);
if (null == list || list.isEmpty()) {
return false;
}
return true;

5
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<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds);
CustomerSubInfoDTO getCustomerSubInfo(String customerId);
}

32
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<String, CustomerSubInfoDTO> 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<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> 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<String> customerIds=new ArrayList<>();
customerIds.add(formDTO.getCustomerId());
//查询客户编码、以及下一级客户列表 add01.14
Map<String, CustomerSubInfoDTO> 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);
}
}

Loading…
Cancel
Save