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 eaabf75cc0..23f44b8184 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 @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -365,7 +366,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level); - log.info("分类标签:"+categoryProjectResultDTOS); + log.info("分类标签:{}"+JSON.toJSONString(categoryProjectResultDTOS)); List belongGridInfos = gridService.selectBelongGridInfo(customerId, level); if (!CollectionUtils.isEmpty(belongGridInfos)){ // 存在直属网格 @@ -405,29 +406,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList()); + // 子客户单独存一份【三个街道的】 + List sonCustomerList = new ArrayList<>(); // 父客户存在的分类 List categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true); - log.info("父客户存在的分类"+categoryProjectExists); - // 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】 - result.clear(); -/* List finalResult = result; - 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))); - e.setPid(entity.getPid()); - e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); - // 因为根据categoryCode分组,所以level都一样,取第一条的 - e.setLevel(list.get(NumConstant.ZERO).getLevel()); - finalResult.add(e); - });*/ + log.info("父客户存在的分类{}"+ JSON.toJSONString(categoryProjectExists)); + // 父客户不存在的分类 + List categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); + log.info("父客户不存在的分类{}"+ JSON.toJSONString(categoryProjectNotExists)); + if (!CollectionUtils.isEmpty(categoryProjectExists)){ + sonCustomerList.addAll(categoryProjectExists); + } + if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ + sonCustomerList.addAll(categoryProjectNotExists); + } + if (!CollectionUtils.isEmpty(sonCustomerList)){ + List finalSonResult = result; + sonCustomerList.forEach(s -> { + ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(s, ScreenProjectCategoryOrgDailyEntity.class); + e.setOrgType(ScreenConstant.STREET); + e.setDateId(dateId); + e.setPid(entity.getPid()); + e.setCustomerId(customerId); + finalSonResult.add(e); + }); + result.addAll(finalSonResult); + } // 内部客户与外部客户 相同的分类累加 if (!CollectionUtils.isEmpty(categoryProjectExists)){ categoryProjectResultDTOS.forEach(f -> { @@ -449,22 +459,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus)); + List twoResult = new ArrayList<>(); if (!CollectionUtils.isEmpty(groupByStatus.get(false))){ - List entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class); - result.addAll(entities); + twoResult.addAll(groupByStatus.get(false)); } - log.info("父客户存在的分类,但是未使用的分类:"+groupByStatus.get(false)); - log.info("父客户存在的分类,但是未使用的分类,组合后:"+result); - // 父客户不存在的分类 - List categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ - List entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class); - result.addAll(entities); + twoResult.addAll(categoryProjectNotExists); + } + if (!CollectionUtils.isEmpty(twoResult)){ + Map> groupOrigin = twoResult.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryOriginCustomerId)); + List finalResult1 = result; + groupOrigin.forEach((originCustomerId, list) -> { + // 父客户存在但是未使用的分类 + 父客户不存在的分类,根据categoryCode分组 + Map> sonGroupByCode = list.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode)); + sonGroupByCode.forEach((code,list2) -> { + ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); + e.setCustomerId(customerId); + e.setCategoryOriginCustomerId(originCustomerId); + e.setCategoryCode(code); + e.setOrgId(entity.getAgencyId()); + e.setProjectTotal(CollectionUtils.isEmpty(list2) ? NumConstant.ZERO : list2.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal))); + e.setPid(entity.getPid()); + e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); + // 因为根据categoryCode分组,所以level都一样,取第一条的 + e.setLevel(list2.get(NumConstant.ZERO).getLevel()); + finalResult1.add(e); + }); + }); + } - log.info("父客户不存在的分类:"+categoryProjectNotExists); } } // 目前不考虑计算子客户组织直接创建的项目,只算内部客户 @@ -509,7 +535,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl