|
@ -1,12 +1,10 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.dto.stats.ArticleGridPublishedSummaryDTO; |
|
|
import com.epmet.dto.stats.ArticleGridPublishedSummaryDTO; |
|
|
import com.epmet.entity.stats.DimDepartmentEntity; |
|
|
import com.epmet.entity.stats.*; |
|
|
import com.epmet.entity.stats.DimGridEntity; |
|
|
|
|
|
import com.epmet.entity.stats.FactArticlePublishedDepartmentDailyEntity; |
|
|
|
|
|
import com.epmet.entity.stats.FactArticlePublishedGridDailyEntity; |
|
|
|
|
|
import com.epmet.service.StatsPublicityService; |
|
|
import com.epmet.service.StatsPublicityService; |
|
|
import com.epmet.service.stats.*; |
|
|
import com.epmet.service.stats.*; |
|
|
import com.epmet.service.voice.ArticlePublishRangeService; |
|
|
import com.epmet.service.voice.ArticlePublishRangeService; |
|
@ -60,6 +58,9 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
private FactArticlePublishedGridDailyService factArticlePublishedGridDailyService; |
|
|
private FactArticlePublishedGridDailyService factArticlePublishedGridDailyService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private FactArticlePublishedDepartmentDailyService factArticlePublishedDepartmentDailyService; |
|
|
private FactArticlePublishedDepartmentDailyService factArticlePublishedDepartmentDailyService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private FactArticlePublishedAgencyDailyService factArticlePublishedAgencyDailyService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private ExecutorService executorService; |
|
|
private ExecutorService executorService; |
|
@ -101,7 +102,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
//转换为 需要插入的Entity
|
|
|
//转换为 需要插入的Entity
|
|
|
Map<String, FactArticlePublishedDepartmentDailyEntity> departmentDailyEntityMap = convertDepartmentDailyEntity(departmentDTOList, dimIdBean); |
|
|
Map<String, FactArticlePublishedDepartmentDailyEntity> departmentDailyEntityMap = convertDepartmentDailyEntity(departmentDTOList, dimIdBean); |
|
|
//获取当天的业务数据
|
|
|
//获取当天的业务数据
|
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllPublishedCount(customerId,DateUtils.integrate(statsDate,DateUtils.DATE_PATTERN)); |
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllDepartmentPublishedCount(customerId,DateUtils.integrate(statsDate,DateUtils.DATE_PATTERN)); |
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
@ -162,12 +163,12 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
//转换为 需要插入的Entity
|
|
|
//转换为 需要插入的Entity
|
|
|
Map<String, FactArticlePublishedGridDailyEntity> gridDailyEntityMap = convertGridDailyEntity(gridDTOList, dimIdBean); |
|
|
Map<String, FactArticlePublishedGridDailyEntity> gridDailyEntityMap = convertGridDailyEntity(gridDTOList, dimIdBean); |
|
|
//获取当天的业务数据
|
|
|
//获取当天的业务数据
|
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articlePublishRangeService.getAllPublishedCount(customerId, statsDate); |
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllGridPublishedCount(customerId, statsDate); |
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
|
FactArticlePublishedGridDailyEntity gridDailyEntities = gridDailyEntityMap.get(summaryDTO.getGridId()); |
|
|
FactArticlePublishedGridDailyEntity gridDailyEntities = gridDailyEntityMap.get(summaryDTO.getGridId()); |
|
|
if (gridDailyEntities == null) { |
|
|
if (gridDailyEntities == null) { |
|
|
log.error("publicitySummary bizData gridId:{} not exist in dimGrid", summaryDTO.getGridId()); |
|
|
log.error("publicitySummary getAllGridPublishedCount gridId:{} not exist in dimGrid", summaryDTO.getGridId()); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
gridDailyEntities.setArticleTotalCount(summaryDTO.getArticleTotalCount()); |
|
|
gridDailyEntities.setArticleTotalCount(summaryDTO.getArticleTotalCount()); |
|
@ -180,20 +181,20 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void statsPublishedAgencyDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId, Map<String, ArticleGridPublishedSummaryDTO> agencySummaryMap) { |
|
|
private void statsPublishedAgencyDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId, Map<String, ArticleGridPublishedSummaryDTO> agencySummaryMap) { |
|
|
//获取所有客户
|
|
|
//获取所有机关
|
|
|
List<DimDepartmentEntity> departmentDTOList = null;//dimAgencyService.getAgencyListByCustomerId(customerId);
|
|
|
List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId); |
|
|
if (CollectionUtils.isEmpty(departmentDTOList)) { |
|
|
if (CollectionUtils.isEmpty(agencyDTOList)) { |
|
|
log.warn("publicitySummary getAgencyListByCustomerId return empty,customerId:{}", customerId); |
|
|
log.warn("publicitySummary getAgencyListByCustomerId return empty,customerId:{}", customerId); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
//转换为 需要插入的Entity
|
|
|
//转换为 需要插入的Entity
|
|
|
Map<String, FactArticlePublishedDepartmentDailyEntity> departmentDailyEntityMap = convertDepartmentDailyEntity(departmentDTOList, dimIdBean); |
|
|
Map<String, FactArticlePublishedAgencyDailyEntity> agencyDailyEntityMap = convertAgencyDailyEntity(agencyDTOList, dimIdBean); |
|
|
//获取当天的业务数据
|
|
|
//获取当天的业务数据
|
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllPublishedCount(customerId,DateUtils.integrate(statsDate,DateUtils.DATE_PATTERN)); |
|
|
List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articleService.getAllAgencyPublishedCount(customerId,DateUtils.integrate(statsDate,DateUtils.DATE_PATTERN)); |
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
if (!CollectionUtils.isEmpty(publishedArticleCount)) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
|
for (ArticleGridPublishedSummaryDTO summaryDTO : publishedArticleCount) { |
|
|
FactArticlePublishedDepartmentDailyEntity gridDailyEntities = departmentDailyEntityMap.get(summaryDTO.getPublisherId()); |
|
|
FactArticlePublishedAgencyDailyEntity gridDailyEntities = agencyDailyEntityMap.get(summaryDTO.getPublisherId()); |
|
|
if (gridDailyEntities == null) { |
|
|
if (gridDailyEntities == null) { |
|
|
log.error("publicitySummary bizData departmentId:{} not exist in dimDepartment", summaryDTO.getGridId()); |
|
|
log.error("publicitySummary bizData departmentId:{} not exist in dimDepartment", summaryDTO.getGridId()); |
|
|
continue; |
|
|
continue; |
|
@ -204,7 +205,32 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
buildAgencySummaryData(agencySummaryMap, summaryDTO); |
|
|
buildAgencySummaryData(agencySummaryMap, summaryDTO); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
boolean b = factArticlePublishedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), departmentDailyEntityMap.values()); |
|
|
//数据向上级机关添加
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(agencySummaryMap)){ |
|
|
|
|
|
for (Map.Entry<String, ArticleGridPublishedSummaryDTO> entry : agencySummaryMap.entrySet()) { |
|
|
|
|
|
String agencyId = entry.getKey(); |
|
|
|
|
|
ArticleGridPublishedSummaryDTO summary = entry.getValue(); |
|
|
|
|
|
FactArticlePublishedAgencyDailyEntity dailyEntity = agencyDailyEntityMap.get(agencyId); |
|
|
|
|
|
if (dailyEntity == null) { |
|
|
|
|
|
log.error("publicitySummary bizData agencyId:{} not exist in dimAgency", agencyId); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
setData2ParentAgency(agencySummaryMap, summary); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean b = factArticlePublishedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), agencyDailyEntityMap.values()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setData2ParentAgency(Map<String, ArticleGridPublishedSummaryDTO> agencySummaryMap, ArticleGridPublishedSummaryDTO summary) { |
|
|
|
|
|
String pid = summary.getPid(); |
|
|
|
|
|
ArticleGridPublishedSummaryDTO parentAgency = agencySummaryMap.get(pid); |
|
|
|
|
|
parentAgency.setArticleTotalCount(parentAgency.getArticleTotalCount()+summary.getArticleTotalCount()); |
|
|
|
|
|
parentAgency.setArticlePublishedCount(parentAgency.getArticlePublishedCount()+summary.getArticlePublishedCount()); |
|
|
|
|
|
pid = parentAgency.getPid(); |
|
|
|
|
|
if (!NumConstant.ZERO_STR.equals(pid)){ |
|
|
|
|
|
setData2ParentAgency(agencySummaryMap,parentAgency); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -248,4 +274,25 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
}); |
|
|
}); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* desc:将机关卫队对象构建为 agencyDaily 对象 |
|
|
|
|
|
* |
|
|
|
|
|
* @param dimDepartmentEntities |
|
|
|
|
|
* @param dimIdBean |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, FactArticlePublishedAgencyDailyEntity> convertAgencyDailyEntity(List<DimAgencyEntity> dimDepartmentEntities, DimIdGenerator.DimIdBean dimIdBean) { |
|
|
|
|
|
Map<String, FactArticlePublishedAgencyDailyEntity> result = new HashMap<>(); |
|
|
|
|
|
dimDepartmentEntities.forEach(dimGridEntity -> { |
|
|
|
|
|
FactArticlePublishedAgencyDailyEntity entity = ConvertUtils.sourceToTarget(dimIdBean, FactArticlePublishedAgencyDailyEntity.class); |
|
|
|
|
|
entity.setCustomerId(dimGridEntity.getCustomerId()); |
|
|
|
|
|
entity.setPid(dimGridEntity.getPid()); |
|
|
|
|
|
entity.setAgencyId(dimGridEntity.getId()); |
|
|
|
|
|
entity.setArticleTotalCount(0); |
|
|
|
|
|
entity.setArticlePublishedCount(0); |
|
|
|
|
|
result.put(dimGridEntity.getId(), entity); |
|
|
|
|
|
}); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|