Browse Source

再次修改

dev_shibei_match
zxc 4 years ago
parent
commit
b1e3614c5a
  1. 61
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java

61
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; 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
@ -365,7 +366,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID); orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID);
orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID); orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID);
} }
log.info("groupByLevel:"+groupByLevel+"orgIds:"+orgIds); log.info("groupByLevel:{}"+JSON.toJSONString(groupByLevel)+"orgIds:{}"+JSON.toJSONString(orgIds));
del(customerId,dateId,orgIds); del(customerId,dateId,orgIds);
if (isGrid){ if (isGrid){
// community级别走这 // community级别走这
@ -376,7 +377,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
}else { }else {
// 根据客户ID,时间,组织级别查询 分类标签 // 根据客户ID,时间,组织级别查询 分类标签
List<CategoryProjectResultDTO> categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level); List<CategoryProjectResultDTO> categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level);
log.info("分类标签:"+categoryProjectResultDTOS); log.info("分类标签:{}"+JSON.toJSONString(categoryProjectResultDTOS));
List<ScreenCustomerGridDTO> belongGridInfos = gridService.selectBelongGridInfo(customerId, level); List<ScreenCustomerGridDTO> belongGridInfos = gridService.selectBelongGridInfo(customerId, level);
if (!CollectionUtils.isEmpty(belongGridInfos)){ if (!CollectionUtils.isEmpty(belongGridInfos)){
// 存在直属网格 // 存在直属网格
@ -405,29 +406,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
* 在保存一份子客户自己agencyId的 * 在保存一份子客户自己agencyId的
*/ */
if (ScreenConstant.DISTRICT.equals(level)){ if (ScreenConstant.DISTRICT.equals(level)){
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
// 查询 平阴的agencyId // 查询 平阴的agencyId
ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId); ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId);
// 子级客户ID // 子级客户ID
List<String> customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList()); List<String> customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList());
// 子客户单独存一份【三个街道的】
List<CategoryProjectResultDTO> sonCustomerList = new ArrayList<>();
// 父客户存在的分类 // 父客户存在的分类
List<CategoryProjectResultDTO> categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true); List<CategoryProjectResultDTO> categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true);
log.info("父客户存在的分类"+categoryProjectExists); log.info("父客户存在的分类{}"+ JSON.toJSONString(categoryProjectExists));
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】 // 父客户不存在的分类
result.clear(); List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
/* List<ScreenProjectCategoryOrgDailyEntity> finalResult = result; log.info("父客户不存在的分类{}"+ JSON.toJSONString(categoryProjectNotExists));
groupByCategoryCode.forEach((code, list) -> { if (!CollectionUtils.isEmpty(categoryProjectExists)){
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); sonCustomerList.addAll(categoryProjectExists);
e.setCustomerId(customerId); }
e.setCategoryOriginCustomerId(customerId); if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
e.setCategoryCode(code); sonCustomerList.addAll(categoryProjectNotExists);
e.setOrgId(entity.getAgencyId()); }
e.setProjectTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal))); if (!CollectionUtils.isEmpty(sonCustomerList)){
List<ScreenProjectCategoryOrgDailyEntity> finalSonResult = result;
sonCustomerList.forEach(s -> {
ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(s, ScreenProjectCategoryOrgDailyEntity.class);
e.setOrgType(ScreenConstant.STREET);
e.setDateId(dateId);
e.setPid(entity.getPid()); e.setPid(entity.getPid());
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); e.setCustomerId(customerId);
// 因为根据categoryCode分组,所以level都一样,取第一条的 finalSonResult.add(e);
e.setLevel(list.get(NumConstant.ZERO).getLevel()); });
finalResult.add(e); result.addAll(finalSonResult);
});*/ }
// 内部客户与外部客户 相同的分类累加 // 内部客户与外部客户 相同的分类累加
if (!CollectionUtils.isEmpty(categoryProjectExists)){ if (!CollectionUtils.isEmpty(categoryProjectExists)){
categoryProjectResultDTOS.forEach(f -> { categoryProjectResultDTOS.forEach(f -> {
@ -449,22 +459,23 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids());
finalResult.add(e); finalResult.add(e);
}); });
log.info("组合后的数据:"+finalResult); log.info("组合后的数据{}:"+JSON.toJSONString(finalResult));
// 父客户存在分类,但是父客户没有使用过此分类 // 父客户存在分类,但是父客户没有使用过此分类
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus)); Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus));
if (!CollectionUtils.isEmpty(groupByStatus.get(false))){ if (!CollectionUtils.isEmpty(groupByStatus.get(false))){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class); List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class);
entities.forEach(e -> {
e.setOrgId(entity.getAgencyId());
});
result.addAll(entities); result.addAll(entities);
} }
log.info("父客户存在的分类,但是未使用的分类:"+groupByStatus.get(false));
log.info("父客户存在的分类,但是未使用的分类,组合后:"+result);
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class); List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class);
entities.forEach(e -> {
e.setOrgId(entity.getAgencyId());
});
result.addAll(entities); result.addAll(entities);
} }
log.info("父客户不存在的分类:"+categoryProjectNotExists);
} }
} }
// 目前不考虑计算子客户组织直接创建的项目,只算内部客户 // 目前不考虑计算子客户组织直接创建的项目,只算内部客户
@ -509,7 +520,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
}); });
} }
} }
log.info("插入总结果:"+result); log.info("插入总结果:{}"+JSON.toJSONString(result));
insert(result); insert(result);
} }

Loading…
Cancel
Save