Browse Source

Merge remote-tracking branch 'origin/dev'

dev_shibei_match
zxc 4 years ago
parent
commit
1cb8b54b0d
  1. 86
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java
  2. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

86
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<Sc
orgIds.add(PingYinConstant.KONG_CUN_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);
if (isGrid){
// community级别走这
@ -376,7 +377,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
}else {
// 根据客户ID,时间,组织级别查询 分类标签
List<CategoryProjectResultDTO> categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level);
log.info("分类标签:"+categoryProjectResultDTOS);
log.info("分类标签:{}"+JSON.toJSONString(categoryProjectResultDTOS));
List<ScreenCustomerGridDTO> belongGridInfos = gridService.selectBelongGridInfo(customerId, level);
if (!CollectionUtils.isEmpty(belongGridInfos)){
// 存在直属网格
@ -405,29 +406,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
* 在保存一份子客户自己agencyId的
*/
if (ScreenConstant.DISTRICT.equals(level)){
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
// 查询 平阴的agencyId
ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId);
// 子级客户ID
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);
log.info("父客户存在的分类"+categoryProjectExists);
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
/* List<ScreenProjectCategoryOrgDailyEntity> 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<CategoryProjectResultDTO> 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<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.setCustomerId(customerId);
finalSonResult.add(e);
});
result.addAll(finalSonResult);
}
// 内部客户与外部客户 相同的分类累加
if (!CollectionUtils.isEmpty(categoryProjectExists)){
categoryProjectResultDTOS.forEach(f -> {
@ -449,22 +459,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids());
finalResult.add(e);
});
log.info("组合后的数据:"+finalResult);
log.info("组合后的数据{}:"+JSON.toJSONString(finalResult));
// 父客户存在分类,但是父客户没有使用过此分类
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus));
List<CategoryProjectResultDTO> twoResult = new ArrayList<>();
if (!CollectionUtils.isEmpty(groupByStatus.get(false))){
List<ScreenProjectCategoryOrgDailyEntity> 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<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class);
result.addAll(entities);
twoResult.addAll(categoryProjectNotExists);
}
if (!CollectionUtils.isEmpty(twoResult)){
Map<String, List<CategoryProjectResultDTO>> groupOrigin = twoResult.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryOriginCustomerId));
List<ScreenProjectCategoryOrgDailyEntity> finalResult1 = result;
groupOrigin.forEach((originCustomerId, list) -> {
// 父客户存在但是未使用的分类 + 父客户不存在的分类,根据categoryCode分组
Map<String, List<CategoryProjectResultDTO>> 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<Sc
});
}
}
log.info("插入总结果:"+result);
log.info("插入总结果:{}"+JSON.toJSONString(result));
insert(result);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

@ -47,7 +47,7 @@
<!-- 查询组织分类信息【多客户】 -->
<select id="selectOrgCategoryMoreCustomerInfo" resultType="com.epmet.dto.screen.result.CategoryProjectResultDTO">
SELECT
IF(od.pid = '0', od.ORG_ID,od.pid) AS orgId,
od.ORG_ID AS orgId,
IFNULL(sca.PID,'0') AS pid,
IFNULL(sca.PIDS,'0') AS pids,
#{customerId} as customerId,
@ -64,7 +64,7 @@
od.DATE_ID
FROM screen_project_category_org_daily od
LEFT JOIN customer_project_category_dict cd ON (cd.CATEGORY_CODE = od.CATEGORY_CODE AND cd.CUSTOMER_ID = od.CUSTOMER_ID)
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = od.PID
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = od.ORG_ID
WHERE 1=1
AND od.DEL_FLAG = '0'
AND (
@ -81,7 +81,7 @@
</if>
AND od.pid = '0'
AND od.date_id = #{dateId}
GROUP BY categoryCode,od.pid
GROUP BY categoryCode,od.ORG_ID
</select>
<!-- 查询内部客户组织的项目分类 -->

Loading…
Cancel
Save