From c72cf84966b4995d56d4fb512b4d30669b3497dd Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 23 Mar 2021 11:03:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dao/crm/CustomerRelationDao.java | 8 ++ .../service/crm/CustomerRelationService.java | 10 +++ .../crm/impl/CustomerRelationServiceImpl.java | 16 ++++ .../ScreenProjectCategoryOrgDailyService.java | 9 +++ ...eenProjectCategoryOrgDailyServiceImpl.java | 74 +++++++++++++++++++ .../mapper/crm/CustomerRelationDao.xml | 5 ++ 6 files changed, 122 insertions(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java index fabee946e7..11ec9c119c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java @@ -43,4 +43,12 @@ public interface CustomerRelationDao extends BaseDao { CustomerSubInfoDTO selectCustomerSubInfo(@Param("customerId")String customerId); List selectListByPids(String customerId); + + /** + * @Description 查询子级客户 + * @Param customerId + * @author zxc + * @date 2021/3/23 上午10:21 + */ + List selectSubCustomer(@Param("customerId") 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/CustomerRelationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java index f139c49bab..4c2a37620f 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,6 +22,8 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.indexcal.CustomerSubInfoDTO; import com.epmet.entity.crm.CustomerRelationEntity; +import java.util.List; + /** * 客户关系表(01.14 add) * @@ -40,4 +42,12 @@ public interface CustomerRelationService extends BaseService selectSubCustomer(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 cab6ed0adc..06d2b580fc 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 @@ -27,9 +27,11 @@ import com.epmet.entity.crm.CustomerRelationEntity; import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.stats.DimCustomerService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -70,4 +72,18 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl selectSubCustomer(String customerId) { + if (StringUtils.isEmpty(customerId)){ + return new ArrayList<>(); + } + return baseDao.selectSubCustomer(customerId); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryOrgDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryOrgDailyService.java index ce71722794..150c15a0d4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryOrgDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryOrgDailyService.java @@ -102,4 +102,13 @@ public interface ScreenProjectCategoryOrgDailyService extends BaseService param); + + /** + * @Description 按组织计算分类统计项目数量 + * @Param customerId + * @Param dateId + * @author zxc + * @date 2021/3/23 上午10:07 + */ + void extractProjectCategoryOrgData(String customerId, String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java index 5660fad150..c9af2a289c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java @@ -29,14 +29,19 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO; +import com.epmet.entity.crm.CustomerRelationEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; +import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService; import com.google.common.collect.Lists; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -51,6 +56,8 @@ import java.util.Map; @DataSource(DataSourceConstant.EVALUATION_INDEX) public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl implements ScreenProjectCategoryOrgDailyService { + @Autowired + private CustomerRelationService relationService; @Override public PageData page(Map params) { @@ -131,4 +138,71 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl needInsert = new ArrayList<>(); + // 先查询有无子客户 + List relationInfo = relationService.selectSubCustomer(customerId); + if (CollectionUtils.isEmpty(relationInfo)){ + needInsert = disposeOneCustomer(customerId, dateId); + }else { + needInsert = disposeMoreCustomer(customerId,dateId,relationInfo); + } + deleteAndInsert(customerId,dateId,needInsert); + } + + /** + * @Description 单客户处理 + * @Param customerId + * @Param dateId + * @author zxc + * @date 2021/3/23 上午10:40 + */ + private List disposeOneCustomer(String customerId, String dateId){ + + return new ArrayList<>(); + } + + /** + * @Description 多客户处理 + * @Param customerId + * @Param dateId + * @Param relationInfo 子级客户信息 + * @author zxc + * @date 2021/3/23 上午10:40 + */ + private List disposeMoreCustomer(String customerId, String dateId,List relationInfo){ + + return new ArrayList<>(); + } + + /** + * @Description 删除和新增 + * @Param customerId + * @Param dateId + * @author zxc + * @date 2021/3/23 上午10:52 + */ + @Transactional(rollbackFor = Exception.class) + public void deleteAndInsert(String customerId, String dateId, List needInsert){ + if (CollectionUtils.isEmpty(needInsert)){ + return; + } + Integer row = NumConstant.ZERO; + do { + row = baseDao.deleteByDateIdAndCustomerId(customerId, dateId); + }while (row > NumConstant.ZERO && row == NumConstant.ONE_THOUSAND); + List> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + insertBatch(p); + }); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml index 88c12c8deb..fad1ca0443 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml @@ -34,4 +34,9 @@ #{customerId}, '%') + + + \ No newline at end of file