Browse Source

指标计算入口,入参CalculateCommonFormDTO统一添加customerAreaCode、subCustomerIds

dev_shibei_match
yinzuomei 5 years ago
parent
commit
145d8073d5
  1. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java
  2. 28
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerSubInfoDTO.java
  3. 38
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerRelationDao.java
  4. 63
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/CustomerRelationEntity.java
  5. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  6. 44
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerRelationService.java
  7. 56
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerRelationServiceImpl.java
  8. 26
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml

5
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 javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -33,13 +34,13 @@ public class CalculateCommonFormDTO implements Serializable {
/** /**
* 当前客户所属的地区编码 add 01.14 * 当前客户所属的地区编码 add 01.14
*/ */
private String customerAreaCode; private String customerAreaCode = "";
/** /**
* 当前客户下的需要汇聚的子客户列表 add 01.14 * 当前客户下的需要汇聚的子客户列表 add 01.14
* 暂不使用 * 暂不使用
*/ */
private List<String> subCustomerIds; private List<String> subCustomerIds = new ArrayList<>();
public CalculateCommonFormDTO() { public CalculateCommonFormDTO() {
super(); super();

28
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<String> subCustomerIds;
}

38
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<CustomerRelationEntity> {
List<CustomerSubInfoDTO> selectCustomerSubInfo(@Param("list") List<String> customerIds);
}

63
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

19
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.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerSubInfoDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.IndexCalRedis; import com.epmet.redis.IndexCalRedis;
import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.epmet.service.stats.CustomerRelationService;
import com.epmet.util.DimIdGenerator; import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -21,6 +23,7 @@ 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
@ -50,7 +53,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private FactIndexCollectService factIndexCollectService; private FactIndexCollectService factIndexCollectService;
@Autowired @Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao; private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private CustomerRelationService customerRelationService;
@Override @Override
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { public Boolean indexCalculate(CalculateCommonFormDTO formDTO) {
@ -71,11 +75,20 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
} else { } else {
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
if(null!=customerInfoMap.get(customerId)){
param.setCustomerAreaCode(customerInfoMap.get(customerId).getCustomerAreaCode());
param.setSubCustomerIds(customerInfoMap.get(customerId).getSubCustomerIds());
}
flag = calulateCustomerIndexScore(param); flag = calulateCustomerIndexScore(param);
} }
return flag; return flag;
@ -178,4 +191,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
} }
return false; return false;
} }
private Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) {
return customerRelationService.getCustomerInfoMap(customerIds);
}
} }

44
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<CustomerRelationEntity> {
/**
* @return java.util.Map<java.lang.String,com.epmet.dto.indexcal.CustomerSubInfoDTO>
* @param customerIds
* @author yinzuomei
* @description 查询每个客户的area_code以及子客户列表
* @Date 2021/1/14 16:22
**/
Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds);
}

56
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<CustomerRelationDao, CustomerRelationEntity> implements CustomerRelationService {
/**
* @param customerIds
* @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 = baseDao.selectCustomerSubInfo(customerIds);
return list.stream().collect(Collectors.toMap(CustomerSubInfoDTO::getCustomerId, customer -> customer));
}
}

26
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerRelationDao.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.stats.CustomerRelationDao">
<select id="selectCustomerSubInfo" parameterType="map" resultType="com.epmet.dto.indexcal.CustomerSubInfoDTO">
SELECT
CR.PARENT_CUSTOMER_ID AS customerId,
dc.CUSTOMER_NAME AS customerName,
dc.AREA_CODE AS areaCode,
CR.CUSTOMER_ID AS subCustomerId
FROM
customer_relation cr
LEFT JOIN dim_customer dc ON ( cr.PARENT_CUSTOMER_ID = DC.ID )
WHERE
cr.DEL_FLAG = '0'
AND cr.`STATUS` = 'open'
AND cr.PARENT_CUSTOMER_ID != '0'
<if test="null !=list and list.size()>0">
AND cr.PARENT_CUSTOMER_ID IN
<foreach collection="list" item="customerId" index="index" open="(" close=")" separator=",">
#{customerId}
</foreach>
</if>
</select>
</mapper>
Loading…
Cancel
Save