Browse Source

多客户修改

dev_shibei_match
zxc 4 years ago
parent
commit
c3059f9c44
  1. 24
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java
  2. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.24__add_categoryOriginCustomerId.sql
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

24
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java

@ -401,12 +401,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
List<String> customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList());
// 父客户存在的分类
List<CategoryProjectResultDTO> categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true);
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
// 外部客户所有分类 = 父客户存在的分类 + 父客户不存在的分类
List<CategoryProjectResultDTO> sonResult = baseDao.selectOrgCategoryMoreCustomerInfoPlus(customerIds, dateId, level, customerId);
categoryProjectResultDTOS.addAll(sonResult);
// 此时的 'categoryProjectResultDTOS' 等于 父子客户所有的分类标签
// 内部客户进行分组
Map<String, List<CategoryProjectResultDTO>> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode));
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
@ -414,6 +409,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
groupByCategoryCode.forEach((code, list) -> {
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity();
e.setCustomerId(customerId);
e.setCategoryOriginCustomerId(customerId);
e.setCategoryCode(code);
e.setOrgId(entity.getAgencyId());
e.setProjectTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal)));
@ -423,8 +419,20 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
e.setLevel(list.get(NumConstant.ZERO).getLevel());
finalResult.add(e);
});
if (!CollectionUtils.isEmpty(sonResult)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(sonResult, ScreenProjectCategoryOrgDailyEntity.class);
// 内部客户与外部客户 相同的分类累加
if (!CollectionUtils.isEmpty(categoryProjectExists)){
finalResult.forEach(f -> {
categoryProjectExists.forEach(c -> {
if (f.getCategoryCode().equals(c.getCategoryCode())){
f.setProjectTotal(f.getProjectTotal() + c.getProjectTotal());
}
});
});
}
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class);
result.addAll(entities);
}
// 添加此 锦水、孔村、榆山 orgId,删除时使用

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.24__add_categoryOriginCustomerId.sql

@ -0,0 +1 @@
alter table `epmet_evaluation_index`.screen_project_category_org_daily add COLUMN `CATEGORY_ORIGIN_CUSTOMER_ID` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '分类来源客户ID' AFTER CUSTOMER_ID;

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

@ -51,8 +51,14 @@
IFNULL(sca.PID,'0') AS pid,
IFNULL(sca.PIDS,'0') AS pids,
#{customerId} as customerId,
od.CATEGORY_ORIGIN_CUSTOMER_ID AS categoryOriginCustomerId,
od.level,
od.CATEGORY_CODE,
<if test="existsStatus == true">
cd.EPMET_CATEGORY_CODE AS categoryCode,
</if>
<if test="existsStatus == false">
od.CATEGORY_CODE AS categoryCode,
</if>
SUM(od.PROJECT_TOTAL) AS projectTotal,
#{level} as orgType,
od.DATE_ID

Loading…
Cancel
Save