Browse Source

Merge remote-tracking branch 'origin/dev_category_project_20210521' into dev

master
yinzuomei 4 years ago
parent
commit
ec7902cdc6
  1. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  2. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.java
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  4. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  5. 75
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java
  6. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  7. 13
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -213,4 +213,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @date 2021/5/8 9:03 上午
*/
List<AgencyMonthCountResultDTO> selectAllOrgByCustomerId(@Param("customerId")String customerId);
/**
* @Description 查询顶级组织ID
* @Param customerId
* @author zxc
* @date 2021/5/24 9:42 上午
*/
ScreenCustomerAgencyEntity selectTopAgency(@Param("customerId")String customerId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.java

@ -65,4 +65,14 @@ public interface ScreenProjectCategoryOrgDailyDao extends BaseDao<ScreenProjectC
*/
List<CategoryProjectResultDTO> selectOrgCategoryMoreCustomerInfo(@Param("customerIds")List<String> customerIds, @Param("dateId") String dateId,
@Param("level")String level, @Param("customerId")String customerId, @Param("existsStatus")Boolean existsStatus);
/**
* @Description 根据客户ID天ID组织ID删除旧数据
* @Param customerId
* @Param dateId
* @Param orgIds
* @author zxc
* @date 2021/5/21 3:26 下午
*/
int deleteAppointData(@Param("customerId") String customerId, @Param("dateId") String dateId,@Param("orgIds")List<String> orgIds);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java

@ -106,4 +106,12 @@ public interface ScreenCustomerAgencyService{
* @date 2020/9/24 1:27 下午
*/
List<OrgNameResultDTO> selectOrgNameAgency(List<String> agencyIds);
/**
* @Description 查询顶级组织ID
* @Param customerId
* @author zxc
* @date 2021/5/24 9:42 上午
*/
ScreenCustomerAgencyEntity selectTopAgency(String customerId);
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java

@ -256,5 +256,16 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
return screenCustomerAgencyDao.selectAllAgencyId(customerId);
}
/**
* @Description 查询顶级组织ID
* @Param customerId
* @author zxc
* @date 2021/5/24 9:42 上午
*/
@Override
public ScreenCustomerAgencyEntity selectTopAgency(String customerId) {
return screenCustomerAgencyDao.selectTopAgency(customerId);
}
}

75
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java

@ -36,6 +36,7 @@ import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO;
import com.epmet.dto.screen.result.CategoryProjectResultDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.crm.CustomerRelationEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectCategoryDailyService;
@ -179,6 +180,12 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
* 1.查自己客户分类标签统计
* 2.查询子级客户分类标签分为 epmet_category_code is null is not nullpid = '0'跟父客户对比同类标签项目数累加不同直接添加到父客户
* 加入直属网格
*
* 2021-05-21新注释
* 1.查询客户自己的分类标签
* 2.查询子客户的分类标签把子客户分类标签一样的累加
* 3.子客户累加后的跟父客户对比 categoryCode一样累加到父客户不一样直接添加到父客户agencyId一并改为父客户的
* 4.父客户数据处理好在存储一套子客户数据
*/
disposeMoreCustomer(customerId,dateId,relationInfo);
}
@ -254,16 +261,19 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
});
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectGrid.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus));
List<CategoryProjectResultDTO> categoryProjectResultDTOS1 = groupByStatus.get(false);
if (!CollectionUtils.isEmpty(categoryProjectResultDTOS1)) categoryProjectResultDTOS.addAll(categoryProjectResultDTOS1);
if (!CollectionUtils.isEmpty(categoryProjectResultDTOS1)) {
categoryProjectResultDTOS.addAll(categoryProjectResultDTOS1);
}
}
}
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)){
List<String> orgIds = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
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)){
@ -291,7 +301,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
result.forEach(r -> {r.setOrgType(level);r.setDateId(dateId);});
}
}
deleteAndInsert(customerId,dateId,result);
deleteAndInsert(customerId,dateId,result,orgIds);
}
/**
@ -349,15 +359,18 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
result = ConvertUtils.sourceToTarget(categoryInfos, ScreenProjectCategoryOrgDailyEntity.class);
}
}else {
// 根据客户ID,时间,组织级别查询 分类标签
List<CategoryProjectResultDTO> categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level);
List<ScreenCustomerGridDTO> belongGridInfos = gridService.selectBelongGridInfo(customerId, level);
if (!CollectionUtils.isEmpty(belongGridInfos)){
// 存在直属网格
List<String> gridIds = belongGridInfos.stream().map(m -> m.getGridId()).collect(Collectors.toList());
// 根据网格ID查询分类标签
List<CategoryProjectResultDTO> categoryProjectGrid = gridDailyDao.selectCategoryInfo(customerId, dateId, level, gridIds);
if (!CollectionUtils.isEmpty(categoryProjectGrid)){
categoryProjectResultDTOS.forEach(agency -> {
categoryProjectGrid.forEach(grid -> {
// 组织ID 和 分类标签code一样时,项目数累加
if (agency.getOrgId().equals(grid.getOrgId()) && agency.getCategoryCode().equals(grid.getCategoryCode())){
agency.setProjectTotal(agency.getProjectTotal() + grid.getProjectTotal());
grid.setStatus(true);
@ -365,17 +378,55 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
});
});
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectGrid.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus));
// 取出分类标签code不一样的数据
List<CategoryProjectResultDTO> categoryProjectResultDTOS1 = groupByStatus.get(false);
categoryProjectResultDTOS.addAll(categoryProjectResultDTOS1);
}
}
result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);
// result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);
/**
* 查询父子客户所有的分类根据分类分组然后把agencyId统一换成父客户的
* 在保存一份子客户自己agencyId的
*/
if (ScreenConstant.DISTRICT.equals(level)){
// 查询 平阴的agencyId
ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId);
// 子级客户ID
List<String> customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList());
// 父客户存在的分类
List<CategoryProjectResultDTO> categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true);
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
// 子级客户的分类标签数据
List<CategoryProjectResultDTO> sonResult = new ArrayList<>();
if (!CollectionUtils.isEmpty(categoryProjectExists)){
categoryProjectResultDTOS.addAll(categoryProjectExists);
sonResult.addAll(categoryProjectExists);
}
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
categoryProjectResultDTOS.addAll(categoryProjectNotExists);
sonResult.addAll(categoryProjectNotExists);
}
// 此时的 'categoryProjectResultDTOS' 等于 父子客户所有的分类标签
Map<String, List<CategoryProjectResultDTO>> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode));
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result;
groupByCategoryCode.forEach((code, list) -> {
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity();
e.setCustomerId(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);
});
if (!CollectionUtils.isEmpty(sonResult)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(sonResult, ScreenProjectCategoryOrgDailyEntity.class);
result.addAll(entities);
}
/*if (!CollectionUtils.isEmpty(categoryProjectExists)){
result.forEach(r -> {
categoryProjectExists.forEach(c -> {
if (r.getCategoryCode().equals(c.getCategoryCode())){
@ -391,19 +442,18 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
result.addAll(f);
}
}
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
List<ScreenProjectCategoryOrgDailyEntity> notExists = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class);
result.addAll(notExists);
}
}*/
}
}
// 目前不考虑计算子客户组织直接创建的项目,只算内部客户
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)) {
List<String> orgIds = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
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)) {
@ -434,7 +484,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
});
}
}
deleteAndInsert(customerId,dateId,result);
deleteAndInsert(customerId,dateId,result,orgIds);
}
/**
@ -445,13 +495,16 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
* @date 2021/3/23 上午10:52
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String dateId, List<ScreenProjectCategoryOrgDailyEntity> needInsert){
public void deleteAndInsert(String customerId, String dateId, List<ScreenProjectCategoryOrgDailyEntity> needInsert,List<String> orgIds){
if (CollectionUtils.isEmpty(needInsert)){
return;
}
if (CollectionUtils.isEmpty(orgIds)){
return;
}
Integer row = NumConstant.ZERO;
do {
row = baseDao.deleteByDateIdAndCustomerId(customerId, dateId);
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 -> {

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -426,4 +426,18 @@
(SELECT GRID_ID AS orgId FROM screen_customer_grid WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId}) UNION ALL
(SELECT DEPT_ID AS orgId FROM screen_customer_dept WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId})
</select>
<!-- 查询顶级组织ID -->
<select id="selectTopAgency" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
AGENCY_ID,
PID,
PIDS
FROM
screen_customer_agency
WHERE
DEL_FLAG = '0'
AND PID = '0'
AND CUSTOMER_ID = #{customerId}
</select>
</mapper>

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

@ -9,6 +9,19 @@
limit 1000
</delete>
<!-- 根据客户ID,天ID,组织ID删除旧数据 -->
<delete id="deleteAppointData">
delete from screen_project_category_org_daily
where customer_id = #{customerId}
and date_id = #{dateId}
and (
<foreach collection="orgIds" item="orgId" separator=" OR ">
ORG_ID = #{orgId}
</foreach>
)
limit 1000
</delete>
<!-- 查询组织分类信息 -->
<select id="selectOrgCategoryInfo" resultType="com.epmet.dto.screen.result.CategoryProjectResultDTO">
SELECT

Loading…
Cancel
Save