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.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.CalculateStatus; import com.epmet.constant.CalculateStatus;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerSubInfoDTO;
import com.epmet.dto.indexcal.IndexStatisticsFormDTO; import com.epmet.dto.indexcal.IndexStatisticsFormDTO;
import com.epmet.model.CalculateFlagModel; import com.epmet.model.CalculateFlagModel;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; 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.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.PreDestroy; 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.*; import java.util.concurrent.*;
/** /**
@ -356,11 +359,8 @@ public class IndexCalculateController {
return new Result(); return new Result();
} }
@PostMapping("getCustomerInfoMap") @PostMapping("getCustomerSubInfo")
public Result getCustomerInfoMap(@RequestBody List<String> customerIds) { public Result<CustomerSubInfoDTO> getCustomerSubInfo(@RequestParam("customerId") String customerId) {
if(CollectionUtils.isNotEmpty(customerIds)){ return new Result<CustomerSubInfoDTO>().ok(indexCalculateService.getCustomerSubInfo(customerId));
return new Result().ok(indexCalculateService.getCustomerInfoMap(customerIds));
}
return new Result().error("customerIds不能为空");
} }
} }

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.dto.indexcal.CustomerSubInfoDTO;
import com.epmet.entity.crm.CustomerRelationEntity; import com.epmet.entity.crm.CustomerRelationEntity;
import java.util.List;
import java.util.Map;
/** /**
* 客户关系表(01.14 add) * 客户关系表(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> * @return java.util.Map<java.lang.String,com.epmet.dto.indexcal.CustomerSubInfoDTO>
* @param customerIds * @param customerId
* @author yinzuomei * @author yinzuomei
* @description 查询每个客户的area_code以及下一级客户列表 * @description 查询每个客户的area_code以及下一级客户列表
* @Date 2021/1/14 16:22 * @Date 2021/1/14 16:22
**/ **/
Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds); CustomerSubInfoDTO getCustomerSubInfo(String customerId);
boolean haveSubCustomer(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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 客户关系表(01.14 add) * 客户关系表(01.14 add)
@ -51,35 +46,26 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
@Autowired @Autowired
private DimCustomerService dimCustomerService; private DimCustomerService dimCustomerService;
/** /**
* @param customerIds * @param customerId
* @return java.util.Map<java.lang.String, com.epmet.dto.indexcal.CustomerSubInfoDTO> * @return java.util.Map<java.lang.String, com.epmet.dto.indexcal.CustomerSubInfoDTO>
* @author yinzuomei * @author yinzuomei
* @description 查询每个客户的area_code以及下一级客户列表 * @description 查询每个客户的area_code以及下一级客户列表
* @Date 2021/1/14 16:22 * @Date 2021/1/14 16:22
**/ **/
@Override @Override
public Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) { public CustomerSubInfoDTO getCustomerSubInfo(String customerId) {
List<CustomerSubInfoDTO> list=new ArrayList<>(); CustomerSubInfoDTO customerSubInfoDTO = baseDao.selectCustomerSubInfo(customerId);
for(String customerId:customerIds){ if (null != customerSubInfoDTO) {
CustomerSubInfoDTO customerSubInfoDTO = baseDao.selectCustomerSubInfo(customerId); DimCustomerDTO dimCustomerDTO = dimCustomerService.get(customerId);
if(null==customerSubInfoDTO){
log.info(String.format("当前客户customerId: %s, 没有下一级客户 ",customerId));
continue;
}
DimCustomerDTO dimCustomerDTO=dimCustomerService.get(customerId);
customerSubInfoDTO.setCustomerName(dimCustomerDTO.getCustomerName()); customerSubInfoDTO.setCustomerName(dimCustomerDTO.getCustomerName());
list.add(customerSubInfoDTO);
} }
if(CollectionUtils.isEmpty(list)){ return customerSubInfoDTO;
return new HashMap<>();
}
return list.stream().collect(Collectors.toMap(CustomerSubInfoDTO::getCustomerId, customer -> customer));
} }
@Override @Override
public boolean haveSubCustomer(String customerId) { public boolean haveSubCustomer(String customerId) {
List<CustomerRelationEntity> list=baseDao.selectListByPids(customerId); List<CustomerRelationEntity> list = baseDao.selectListByPids(customerId);
if(null==list||list.isEmpty()){ if (null == list || list.isEmpty()) {
return false; return false;
} }
return true; 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.CustomerSubInfoDTO;
import com.epmet.dto.indexcal.IndexStatisticsFormDTO; import com.epmet.dto.indexcal.IndexStatisticsFormDTO;
import java.util.List;
import java.util.Map;
/** /**
* 指标计算service * 指标计算service
* *
@ -32,5 +29,5 @@ public interface IndexCalculateService {
**/ **/
void toScreenIndexData(CalculateCommonFormDTO formDTO); 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author liujianjun * @author liujianjun
@ -83,18 +82,17 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
customerIds.add(formDTO.getCustomerId()); customerIds.add(formDTO.getCustomerId());
} }
//查询客户编码、以及下一级客户列表 add01.14
Map<String, CustomerSubInfoDTO> customerInfoMap=this.getCustomerInfoMap(customerIds);
Boolean flag = false; Boolean flag = false;
for (String customerId : customerIds) { for (String customerId : customerIds) {
CalculateCommonFormDTO param = new CalculateCommonFormDTO(); CalculateCommonFormDTO param = new CalculateCommonFormDTO();
param.setCustomerId(customerId); param.setCustomerId(customerId);
param.setMonthId(formDTO.getMonthId()); param.setMonthId(formDTO.getMonthId());
//01.14 add //01.14 add 查询客户编码、以及下一级客户列表
if (!customerInfoMap.isEmpty() && null != customerInfoMap.get(customerId)) { CustomerSubInfoDTO customerSubInfoDTO=this.getCustomerSubInfo(customerId);
param.setCustomerAreaCode(customerInfoMap.get(customerId).getCustomerAreaCode()); if (null != customerSubInfoDTO) {
param.setSubCustomerIds(customerInfoMap.get(customerId).getSubCustomerIds()); param.setCustomerAreaCode(customerSubInfoDTO.getCustomerAreaCode());
param.setSubCustomerIds(customerSubInfoDTO.getSubCustomerIds());
} }
flag = calulateCustomerIndexScore(param); flag = calulateCustomerIndexScore(param);
} }
@ -202,14 +200,14 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
} }
/** /**
* @param customerIds * @param customerId
* @author yinzuomei * @author yinzuomei
* @description 查询当前客户的area_code信息以及下一级客户列表 * @description 查询当前客户的area_code信息以及下一级客户列表
* @Date 2021/1/21 11:28 * @Date 2021/1/21 11:28
**/ **/
@Override @Override
public Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) { public CustomerSubInfoDTO getCustomerSubInfo(String customerId) {
return customerRelationService.getCustomerInfoMap(customerIds); return customerRelationService.getCustomerSubInfo(customerId);
} }
@Async @Async
@ -256,17 +254,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
**/ **/
@Override @Override
public void toScreenIndexData(CalculateCommonFormDTO formDTO) { public void toScreenIndexData(CalculateCommonFormDTO formDTO) {
List<String> customerIds=new ArrayList<>();
customerIds.add(formDTO.getCustomerId());
//查询客户编码、以及下一级客户列表 add01.14 //查询客户编码、以及下一级客户列表 add01.14
Map<String, CustomerSubInfoDTO> customerInfoMap=this.getCustomerInfoMap(customerIds); CustomerSubInfoDTO customerSubInfoDTO = this.getCustomerSubInfo(formDTO.getCustomerId());
log.info("customerInfoMap: "+JSON.toJSONString(customerInfoMap,true)); log.info("customerInfoMap: " + JSON.toJSONString(customerSubInfoDTO, true));
//01.14 add //01.14 add
if (!customerInfoMap.isEmpty() && null != customerInfoMap.get(formDTO.getCustomerId())) { if (null != customerSubInfoDTO) {
formDTO.setCustomerAreaCode(customerInfoMap.get(formDTO.getCustomerId()).getCustomerAreaCode()); formDTO.setCustomerAreaCode(customerSubInfoDTO.getCustomerAreaCode());
formDTO.setSubCustomerIds(customerInfoMap.get(formDTO.getCustomerId()).getSubCustomerIds()); formDTO.setSubCustomerIds(customerSubInfoDTO.getSubCustomerIds());
} }
log.info("入参: "+JSON.toJSONString(formDTO,true)); log.info("入参: " + JSON.toJSONString(formDTO, true));
factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO); factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO);
} }
} }

Loading…
Cancel
Save