8 changed files with 276 additions and 3 deletions
@ -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; |
||||
|
} |
@ -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); |
||||
|
} |
@ -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; |
||||
|
|
||||
|
} |
@ -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); |
||||
|
} |
@ -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)); |
||||
|
} |
||||
|
} |
@ -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…
Reference in new issue