|
|
|
@ -36,6 +36,7 @@ import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO; |
|
|
|
import com.epmet.dto.screen.result.CategoryProjectResultDTO; |
|
|
|
import com.epmet.dto.screencoll.ScreenCollFormDTO; |
|
|
|
import com.epmet.entity.crm.CustomerRelationEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; |
|
|
|
import com.epmet.service.crm.CustomerRelationService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectCategoryDailyService; |
|
|
|
@ -378,13 +379,46 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
categoryProjectResultDTOS.addAll(categoryProjectResultDTOS1); |
|
|
|
} |
|
|
|
} |
|
|
|
result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
// result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);
|
|
|
|
/** |
|
|
|
* 查询父子客户所有的分类,根据分类分组,然后把agencyId统一换成父客户的 |
|
|
|
* 在保存一份子客户自己agencyId的 |
|
|
|
*/ |
|
|
|
if (ScreenConstant.DISTRICT.equals(level)){ |
|
|
|
ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId); |
|
|
|
// 子级客户ID
|
|
|
|
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 = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(categoryProjectExists)){ |
|
|
|
categoryProjectResultDTOS.addAll(categoryProjectExists); |
|
|
|
sonResult.addAll(categoryProjectExists); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ |
|
|
|
categoryProjectResultDTOS.addAll(categoryProjectNotExists); |
|
|
|
sonResult.addAll(categoryProjectNotExists); |
|
|
|
} |
|
|
|
// 此时的 'categoryProjectResultDTOS' 等于 父子客户所有的分类标签
|
|
|
|
Map<String, List<CategoryProjectResultDTO>> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode)); |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result; |
|
|
|
groupByCategoryCode.forEach((code, list) -> { |
|
|
|
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setCategoryCode(code); |
|
|
|
e.setOrgId(entity.getAgencyId()); |
|
|
|
e.setProjectTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal))); |
|
|
|
e.setPid(entity.getPid()); |
|
|
|
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); |
|
|
|
finalResult.add(e); |
|
|
|
}); |
|
|
|
if (!CollectionUtils.isEmpty(sonResult)){ |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(sonResult, ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
result.addAll(entities); |
|
|
|
} |
|
|
|
/*if (!CollectionUtils.isEmpty(categoryProjectExists)){ |
|
|
|
result.forEach(r -> { |
|
|
|
categoryProjectExists.forEach(c -> { |
|
|
|
if (r.getCategoryCode().equals(c.getCategoryCode())){ |
|
|
|
@ -400,12 +434,10 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
result.addAll(f); |
|
|
|
} |
|
|
|
} |
|
|
|
// 父客户不存在的分类
|
|
|
|
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); |
|
|
|
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> notExists = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
result.addAll(notExists); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
// 目前不考虑计算子客户组织直接创建的项目,只算内部客户
|
|
|
|
|