|
|
@ -65,6 +65,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void extractCategoryProjectGridData(String customerId, String dateId) { |
|
|
|
log.info("开始执行网格项目分类统计"); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); |
|
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
|
customerIds.add(customerId); |
|
|
@ -72,19 +74,28 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedList = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isEmpty(relationInfo)){ |
|
|
|
// 单客户
|
|
|
|
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); |
|
|
|
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); |
|
|
|
allList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); |
|
|
|
closedList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); |
|
|
|
}else { |
|
|
|
// 多客户
|
|
|
|
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); |
|
|
|
customerIds.addAll(subCustomerIds); |
|
|
|
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.TWO); |
|
|
|
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.TWO); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> finalAllList = allList; |
|
|
|
List<GridAndOrgCategoryCountResultDTO> finalClosedList1 = closedList; |
|
|
|
customerIds.forEach(c -> { |
|
|
|
List<GridAndOrgCategoryCountResultDTO> all = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL, c, NumConstant.TWO); |
|
|
|
finalAllList.addAll(all); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> closed = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED, c, NumConstant.TWO); |
|
|
|
finalClosedList1.addAll(closed); |
|
|
|
}); |
|
|
|
} |
|
|
|
List<GridAndOrgCategoryCountResultDTO> finalClosedList = closedList; |
|
|
|
allList.forEach(a -> finalClosedList.stream().filter(c -> c.getGridId().equals(a.getGridId()) && c.getCategoryCode().equals(a.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
gridDel(customerId,dateId); |
|
|
|
log.info("网格-所有项目分类即将插入的集合{}",JSON.toJSONString(allList)); |
|
|
|
gridInsert(allList); |
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
log.info("网格项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -128,6 +139,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void extractCategoryProjectOrgData(String customerId, String dateId) { |
|
|
|
log.info("开始执行组织项目分类统计"); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); |
|
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
|
customerIds.add(customerId); |
|
|
@ -136,14 +149,18 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
// one customer
|
|
|
|
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class); |
|
|
|
|
|
|
|
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
|
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
|
|
result.addAll(oneLevelList); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
// more customers
|
|
|
|
// 去除孔村的客户ID,孔村镇的单独查😡
|
|
|
|
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); |
|
|
@ -153,22 +170,28 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
subCustomerIds.add(customerId); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID); |
|
|
|
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> allOrgCategoryList = result; |
|
|
|
partition.forEach(p -> { |
|
|
|
List<GridAndOrgCategoryCountResultDTO> allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
allOrgList.addAll(oneLevelList); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); |
|
|
|
allOrgList.forEach(a -> closedOrgList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); |
|
|
|
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); |
|
|
|
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
|
|
allOrgList.addAll(oneLevelList); |
|
|
|
allOrgCategoryList.addAll(allOrgList); |
|
|
|
}); |
|
|
|
} |
|
|
|
orgDel(customerId,dateId); |
|
|
|
log.info("组织-即将插入的项目分类{}",JSON.toJSONString(result)); |
|
|
|
orgInsert(result); |
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
log.info("组织项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|