|
|
@ -242,6 +242,9 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
*/ |
|
|
|
public void disposeOneCustomerSub(String level, Boolean isGrid, String customerId, String dateId,List<CustomerAgencyInfoResultDTO> agencyIdList){ |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> result = new ArrayList<>(); |
|
|
|
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); |
|
|
|
List<String> orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
del(customerId,dateId,orgIds); |
|
|
|
if (isGrid){ |
|
|
|
// 是社区级别
|
|
|
|
List<CategoryProjectResultDTO> categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null); |
|
|
@ -274,11 +277,8 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
} |
|
|
|
// 组织项目分类 项目数
|
|
|
|
List<String> orgIds = new ArrayList<>(); |
|
|
|
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); |
|
|
|
List<CustomerAgencyInfoResultDTO> levelAgencyInfo = groupByLevel.get(level); |
|
|
|
if (!CollectionUtils.isEmpty(levelAgencyInfo)){ |
|
|
|
orgIds = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
List<ScreenProjectCategoryGridDailyDTO> screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds,customerId); |
|
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
|
if (!CollectionUtils.isEmpty(screenProjectCategory)){ |
|
|
@ -306,7 +306,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
result.forEach(r -> {r.setOrgType(level);r.setDateId(dateId);}); |
|
|
|
} |
|
|
|
} |
|
|
|
deleteAndInsert(customerId,dateId,result,orgIds); |
|
|
|
insert(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -357,7 +357,15 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
*/ |
|
|
|
private void disposeMoreCustomerSub(String level,Boolean isGrid,String customerId, String dateId, List<CustomerRelationEntity> relationInfo,List<CustomerAgencyInfoResultDTO> agencyIdList){ |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> result = new ArrayList<>(); |
|
|
|
List<String> orgIds = new ArrayList<>(); |
|
|
|
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); |
|
|
|
List<String> orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
if (ScreenConstant.DISTRICT.equals(level)){ |
|
|
|
// 添加此 锦水、孔村、榆山 orgId,删除时使用
|
|
|
|
orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID); |
|
|
|
orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID); |
|
|
|
orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID); |
|
|
|
} |
|
|
|
del(customerId,dateId,orgIds); |
|
|
|
if (isGrid){ |
|
|
|
// community级别走这
|
|
|
|
List<CategoryProjectResultDTO> categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null); |
|
|
@ -401,11 +409,9 @@ 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); |
|
|
|
// 内部客户进行分组
|
|
|
|
Map<String, List<CategoryProjectResultDTO>> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode)); |
|
|
|
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
|
|
|
|
result.clear(); |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result; |
|
|
|
/* List<ScreenProjectCategoryOrgDailyEntity> finalResult = result; |
|
|
|
groupByCategoryCode.forEach((code, list) -> { |
|
|
|
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
@ -418,35 +424,45 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
// 因为根据categoryCode分组,所以level都一样,取第一条的
|
|
|
|
e.setLevel(list.get(NumConstant.ZERO).getLevel()); |
|
|
|
finalResult.add(e); |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
// 内部客户与外部客户 相同的分类累加
|
|
|
|
if (!CollectionUtils.isEmpty(categoryProjectExists)){ |
|
|
|
finalResult.forEach(f -> { |
|
|
|
categoryProjectResultDTOS.forEach(f -> { |
|
|
|
categoryProjectExists.forEach(c -> { |
|
|
|
if (f.getCategoryCode().equals(c.getCategoryCode())){ |
|
|
|
f.setProjectTotal(f.getProjectTotal() + c.getProjectTotal()); |
|
|
|
c.setStatus(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result; |
|
|
|
categoryProjectResultDTOS.forEach(c -> { |
|
|
|
ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(c, ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setCategoryOriginCustomerId(customerId); |
|
|
|
e.setOrgId(entity.getAgencyId()); |
|
|
|
e.setPid(entity.getPid()); |
|
|
|
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); |
|
|
|
finalResult.add(e); |
|
|
|
}); |
|
|
|
// 父客户存在分类,但是父客户没有使用过此分类
|
|
|
|
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus)); |
|
|
|
if (!CollectionUtils.isEmpty(groupByStatus.get(false))){ |
|
|
|
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class); |
|
|
|
result.addAll(entities); |
|
|
|
} |
|
|
|
// 父客户不存在的分类
|
|
|
|
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,删除时使用
|
|
|
|
orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID); |
|
|
|
orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID); |
|
|
|
orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID); |
|
|
|
} |
|
|
|
} |
|
|
|
// 目前不考虑计算子客户组织直接创建的项目,只算内部客户
|
|
|
|
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); |
|
|
|
List<CustomerAgencyInfoResultDTO> levelAgencyInfo = groupByLevel.get(level); |
|
|
|
if (!CollectionUtils.isEmpty(levelAgencyInfo)) { |
|
|
|
List<String> orgIdss = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
orgIds.addAll(orgIdss); |
|
|
|
// 查询客户下,组织直接立项的,各项目分类下的项目数量【筛选组织创建的项目,fact_origin_project_main_daily表gridId为空】
|
|
|
|
List<ScreenProjectCategoryGridDailyDTO> screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds, customerId); |
|
|
|
if (!CollectionUtils.isEmpty(result)) { |
|
|
@ -485,21 +501,29 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
deleteAndInsert(customerId,dateId,result,orgIds); |
|
|
|
insert(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 删除和新增 |
|
|
|
* @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<ScreenProjectCategoryOrgDailyEntity> needInsert,List<String> orgIds){ |
|
|
|
public void insert(List<ScreenProjectCategoryOrgDailyEntity> needInsert){ |
|
|
|
if (CollectionUtils.isEmpty(needInsert)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
List<List<ScreenProjectCategoryOrgDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void del(String customerId, String dateId,List<String> orgIds){ |
|
|
|
if (CollectionUtils.isEmpty(orgIds)){ |
|
|
|
return; |
|
|
|
} |
|
|
@ -507,10 +531,6 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc |
|
|
|
do { |
|
|
|
row = baseDao.deleteAppointData(customerId, dateId,orgIds); |
|
|
|
}while (row > NumConstant.ZERO && row == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<ScreenProjectCategoryOrgDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |