|
|
@ -7,6 +7,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dto.voice.ArticleGridPublishedSummaryDTO; |
|
|
|
import com.epmet.dto.voice.ArticleViewedSummaryDTO; |
|
|
|
import com.epmet.entity.stats.*; |
|
|
|
import com.epmet.entity.voice.ArticleEntity; |
|
|
|
import com.epmet.entity.voice.ArticleTagsEntity; |
|
|
@ -15,6 +16,7 @@ import com.epmet.service.stats.*; |
|
|
|
import com.epmet.service.voice.ArticlePublishRangeService; |
|
|
|
import com.epmet.service.voice.ArticleService; |
|
|
|
import com.epmet.service.voice.ArticleTagsService; |
|
|
|
import com.epmet.service.voice.ArticleVisitRecordService; |
|
|
|
import com.epmet.util.DimIdGenerator; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -64,6 +66,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
@Autowired |
|
|
|
private ArticlePublishRangeService articlePublishRangeService; |
|
|
|
@Autowired |
|
|
|
private ArticleVisitRecordService articleVisitRecordService; |
|
|
|
@Autowired |
|
|
|
private FactArticlePublishedGridDailyService factArticlePublishedGridDailyService; |
|
|
|
@Autowired |
|
|
|
private FactArticlePublishedDepartmentDailyService factArticlePublishedDepartmentDailyService; |
|
|
@ -94,6 +98,22 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
@Autowired |
|
|
|
private FactTagUsedAgencyYearlyService factTagUsedAgencyYearlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedGridDailyService factTagViewedGridDailyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedAgencyDailyService factTagViewedAgencyDailyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedGridMonthlyService factTagViewedGridMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedAgencyMonthlyService factTagViewedAgencyMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedGridQuarterlyService factTagViewedGridQuarterlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedAgencyQuarterlyService factTagViewedAgencyQuarterlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedGridYearlyService factTagViewedGridYearlyService; |
|
|
|
@Autowired |
|
|
|
private FactTagViewedAgencyYearlyService factTagViewedAgencyYearlyService; |
|
|
|
@Autowired |
|
|
|
private ExecutorService executorService; |
|
|
|
|
|
|
|
@Override |
|
|
@ -127,7 +147,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() >= pageSize); |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -151,14 +171,12 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
Date finalStatsDate = statsDate; |
|
|
|
executorService.submit(() -> { |
|
|
|
//key:所在机关Id
|
|
|
|
Map<String, ArticleGridPublishedSummaryDTO> agencySummaryMap = new HashMap<>(); |
|
|
|
//统计
|
|
|
|
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId, agencySummaryMap); |
|
|
|
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() >= pageSize); |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -183,21 +201,14 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
statsTagUsedMonthly(dimIdBean.getMonthId(), customerId); |
|
|
|
//statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId);
|
|
|
|
//statsTagUsedYearly(dimIdBean.getYearId(), customerId);
|
|
|
|
countDownLatch.countDown(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("statsTagUsedMonthly exception", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
log.debug("start === statsTagUsedQuarterly "); |
|
|
|
try { |
|
|
|
countDownLatch.await(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("countDownLatch.await() interrupted", e); |
|
|
|
} |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
countDownLatch.await(); |
|
|
|
log.debug("start === statsTagUsedQuarterly "); |
|
|
|
statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId); |
|
|
|
} catch (Exception e) { |
|
|
@ -206,6 +217,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
}); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
countDownLatch.await(); |
|
|
|
log.debug("start === statsTagUsedQuarterly "); |
|
|
|
statsTagUsedYearly(dimIdBean.getYearId(), customerId); |
|
|
|
} catch (Exception e) { |
|
|
@ -214,7 +226,90 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() >= pageSize); |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean tagViewedDayStatsjob(Date statsDate) { |
|
|
|
|
|
|
|
//如果不传时间 则统计数据为今天之前的数据和,否则统计的是截止到传入的日期数据的和
|
|
|
|
if (statsDate == null) { |
|
|
|
//当天的凌晨时间 即为今天之前的数据
|
|
|
|
statsDate = DateUtils.integrate(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN); |
|
|
|
} else { |
|
|
|
statsDate = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN); |
|
|
|
} |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(statsDate); |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
Date finalStatsDate = statsDate; |
|
|
|
//executorService.submit(() -> {
|
|
|
|
//统计
|
|
|
|
statsTagViewedDaily(finalStatsDate, dimIdBean, customerId); |
|
|
|
//});
|
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean tagViewedMonthStatsjob(Date statsDate) { |
|
|
|
//如果不传时间 则统计数据为今天之前的数据和,否则统计的是截止到传入的日期数据的和
|
|
|
|
if (statsDate == null) { |
|
|
|
//当天的凌晨时间 即为今天之前的数据
|
|
|
|
statsDate = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); |
|
|
|
} else { |
|
|
|
statsDate = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN); |
|
|
|
} |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(statsDate); |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(1); |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
if (!"6c8cfc2c14afeb6d3664b3e283fc9074".equals(customerId)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
statsTagViewedMonthly(dimIdBean.getMonthId(), customerId); |
|
|
|
countDownLatch.countDown(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("statsTagViewedMonthly exception", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
countDownLatch.await(); |
|
|
|
log.debug("start === statsTagViewedQuarterly "); |
|
|
|
statsTagViewedQuarterly(dimIdBean.getQuarterId(), customerId); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("statsTagUsedQuarterly exception", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
countDownLatch.await(); |
|
|
|
log.debug("start === statsTagViewedYearly "); |
|
|
|
statsTagViewedYearly(dimIdBean.getYearId(), customerId); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("statsTagUsedYearly exception", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -357,9 +452,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
* @param statsDate |
|
|
|
* @param dimIdBean |
|
|
|
* @param customerId |
|
|
|
* @param agencySummaryMap |
|
|
|
*/ |
|
|
|
private void statsTagUsedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId, Map<String, ArticleGridPublishedSummaryDTO> agencySummaryMap) { |
|
|
|
private void statsTagUsedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) { |
|
|
|
//1.业务数据来源 发布时间为统计时间的
|
|
|
|
// 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
|
|
|
|
// 1.1查出今天所有的文章标签 根据网格Id
|
|
|
@ -409,7 +503,6 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
convertTagUsedDepartmentDailyEntity(tagUsedDeptDailyMap, articleEntity, tagEntity, dimIdBean); |
|
|
|
break; |
|
|
|
} |
|
|
|
convertTagUsedGridDailyEntity(tagUsedGridDailyMap, articleEntity, tagEntity, dimIdBean); |
|
|
|
} |
|
|
|
|
|
|
|
factTagUsedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagUsedGridDailyMap.values()); |
|
|
@ -430,6 +523,82 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
factTagUsedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:按日统计 标签被阅读的次数 |
|
|
|
* |
|
|
|
* @param statsDate |
|
|
|
* @param dimIdBean |
|
|
|
* @param customerId |
|
|
|
*/ |
|
|
|
private void statsTagViewedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) { |
|
|
|
//1.业务数据来源 发布时间为统计时间的
|
|
|
|
// 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
|
|
|
|
// 1.1查出今天所有的文章标签 根据网格Id
|
|
|
|
// 1.2
|
|
|
|
//获取所有机关 用于后面想上级添加数据
|
|
|
|
List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId); |
|
|
|
if (CollectionUtils.isEmpty(agencyDTOList)) { |
|
|
|
log.debug("statsTagViewedDaily customerId:{} have any agency", customerId); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
if (CollectionUtils.isEmpty(dimGridList)) { |
|
|
|
log.debug("statsTagViewedDaily customerId:{} have any grid", customerId); |
|
|
|
return; |
|
|
|
} |
|
|
|
Map<String, DimGridEntity> dimGridEntityMap = dimGridList.stream().collect(Collectors.toMap(DimGridEntity::getId, o -> o)); |
|
|
|
//转换为 需要插入的Entity
|
|
|
|
Map<String, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o)); |
|
|
|
//转换为 需要插入的Entity key gridId_tagId
|
|
|
|
Map<String, FactTagViewedGridDailyEntity> tagViewedGridDailyMap = new HashMap<>(); |
|
|
|
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailyMap = new HashMap<>(); |
|
|
|
//获取当天的业务数据
|
|
|
|
//1获取今天文章的阅读记录数
|
|
|
|
Date startTime = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN); |
|
|
|
Date endTime = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN); |
|
|
|
List<ArticleViewedSummaryDTO> visitRecordList = articleVisitRecordService.getArticleVisitByCreateTime(customerId, startTime, endTime); |
|
|
|
if (CollectionUtils.isEmpty(visitRecordList)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
for (ArticleViewedSummaryDTO viewedSummaryDTO : visitRecordList) { |
|
|
|
List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByArticleId(customerId, viewedSummaryDTO.getArticleId()); |
|
|
|
if (CollectionUtils.isEmpty(articleTagsList)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
String gridId = viewedSummaryDTO.getGridId(); |
|
|
|
DimGridEntity dimGridEntity = dimGridEntityMap.get(gridId); |
|
|
|
|
|
|
|
if (dimGridEntity == null) { |
|
|
|
log.error("statsTagViewedDaily viewedRecord gridId:{} not exist in dimGridMap", gridId); |
|
|
|
continue; |
|
|
|
} |
|
|
|
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(dimGridEntity.getAgencyId()); |
|
|
|
articleTagsList.forEach(articleTag -> { |
|
|
|
convertTagViewedGridDailyEntity(dimAgencyEntity, tagViewedGridDailyMap, articleTag, viewedSummaryDTO, dimIdBean); |
|
|
|
convertTagViewedAgencyDailyEntity(dimAgencyEntity, tagViewedAgencyDailyMap, articleTag, viewedSummaryDTO, dimIdBean); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
factTagViewedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagViewedGridDailyMap.values()); |
|
|
|
|
|
|
|
//向上级机关递归添加 数据
|
|
|
|
Map<String, FactTagViewedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>(); |
|
|
|
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailyMap); |
|
|
|
for (Map.Entry<String, FactTagViewedAgencyDailyEntity> entry : tagViewedAgencyDailyMap.entrySet()) { |
|
|
|
String agencyId = entry.getKey(); |
|
|
|
FactTagViewedAgencyDailyEntity currentEntity = entry.getValue(); |
|
|
|
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId()); |
|
|
|
if (dimAgencyEntity == null) { |
|
|
|
log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId); |
|
|
|
continue; |
|
|
|
} |
|
|
|
setTagViewedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean); |
|
|
|
} |
|
|
|
factTagViewedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:按月统计 标签使用数 |
|
|
|
* |
|
|
@ -440,17 +609,37 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
List<FactTagUsedGridDailyEntity> gridDailyList = factTagUsedGridDailyService.getTagUsedCountByMonth(customerId, monthId); |
|
|
|
if (!CollectionUtils.isEmpty(gridDailyList)) { |
|
|
|
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagUsedGridMonthlyEntity.class); |
|
|
|
factTagUsedGridMonthlyService.deleteAndInsertByMonthId(customerId,monthId,gridMonthlyList); |
|
|
|
factTagUsedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList); |
|
|
|
} |
|
|
|
List<FactTagUsedDepartmentDailyEntity> deptDailyList = factTagUsedDepartmentDailyService.getTagUsedCountByMonth(customerId, monthId); |
|
|
|
if (!CollectionUtils.isEmpty(deptDailyList)) { |
|
|
|
List<FactTagUsedDepartmentMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(deptDailyList, FactTagUsedDepartmentMonthlyEntity.class); |
|
|
|
factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId,monthId,gridMonthlyList); |
|
|
|
factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList); |
|
|
|
} |
|
|
|
List<FactTagUsedGridDailyEntity> agencyDailyList = factTagUsedAgencyDailyService.getTagUsedCountByMonth(customerId, monthId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyDailyList)) { |
|
|
|
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagUsedAgencyMonthlyEntity.class); |
|
|
|
factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId,monthId,(agencyMonthlyList)); |
|
|
|
factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:按月统计 标签使用数 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
*/ |
|
|
|
private void statsTagViewedMonthly(String monthId, String customerId) { |
|
|
|
List<FactTagViewedGridDailyEntity> gridDailyList = factTagViewedGridDailyService.getTagViewedCountByMonth(customerId, monthId); |
|
|
|
if (!CollectionUtils.isEmpty(gridDailyList)) { |
|
|
|
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagViewedGridMonthlyEntity.class); |
|
|
|
factTagViewedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList); |
|
|
|
} |
|
|
|
|
|
|
|
List<FactTagViewedAgencyDailyEntity> agencyDailyList = factTagViewedAgencyDailyService.getTagViewedCountByMonth(customerId, monthId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyDailyList)) { |
|
|
|
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagViewedAgencyMonthlyEntity.class); |
|
|
|
factTagViewedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -464,18 +653,37 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); |
|
|
|
if (!CollectionUtils.isEmpty(gridMonthlyList)) { |
|
|
|
List<FactTagUsedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridQuarterlyEntity.class); |
|
|
|
factTagUsedGridQuarterlyService.deleteAndInsertByQuarterId(customerId,quarterId,gridQuarterlyList); |
|
|
|
factTagUsedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList); |
|
|
|
} |
|
|
|
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); |
|
|
|
if (!CollectionUtils.isEmpty(deptMonthlyList)) { |
|
|
|
List<FactTagUsedDepartmentQuarterlyEntity> deptQuarterlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentQuarterlyEntity.class); |
|
|
|
factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId,quarterId,deptQuarterlyList); |
|
|
|
factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, deptQuarterlyList); |
|
|
|
} |
|
|
|
//TODO 机关的需要添加 pid
|
|
|
|
List<FactTagUsedGridMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); |
|
|
|
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { |
|
|
|
List<FactTagUsedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyQuarterlyEntity.class); |
|
|
|
factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId,agencyQuarterlyList); |
|
|
|
factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:按季统计 标签查看数 |
|
|
|
* |
|
|
|
* @param quarterId |
|
|
|
* @param customerId |
|
|
|
*/ |
|
|
|
private void statsTagViewedQuarterly(String quarterId, String customerId) { |
|
|
|
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId); |
|
|
|
if (!CollectionUtils.isEmpty(gridMonthlyList)) { |
|
|
|
List<FactTagViewedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridQuarterlyEntity.class); |
|
|
|
factTagViewedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList); |
|
|
|
} |
|
|
|
|
|
|
|
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { |
|
|
|
List<FactTagViewedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyQuarterlyEntity.class); |
|
|
|
factTagViewedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -489,21 +697,36 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByYearId(customerId, yearId); |
|
|
|
if (!CollectionUtils.isEmpty(gridMonthlyList)) { |
|
|
|
List<FactTagUsedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridYearlyEntity.class); |
|
|
|
//TODO 改为一个方法 添加事务
|
|
|
|
factTagUsedGridYearlyService.deleteByYearId(customerId, yearId); |
|
|
|
factTagUsedGridYearlyService.insertBatch(gridYearlyList); |
|
|
|
factTagUsedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList); |
|
|
|
} |
|
|
|
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByYearId(customerId, yearId); |
|
|
|
if (!CollectionUtils.isEmpty(deptMonthlyList)) { |
|
|
|
List<FactTagUsedDepartmentYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentYearlyEntity.class); |
|
|
|
factTagUsedDepartmentYearlyService.deleteByYearId(customerId, yearId); |
|
|
|
factTagUsedDepartmentYearlyService.insertBatch(gridYearlyList); |
|
|
|
factTagUsedDepartmentYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList); |
|
|
|
} |
|
|
|
List<FactTagUsedGridMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId); |
|
|
|
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { |
|
|
|
List<FactTagUsedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyYearlyEntity.class); |
|
|
|
factTagUsedAgencyYearlyService.deleteByYearId(customerId, yearId); |
|
|
|
factTagUsedAgencyYearlyService.insertBatch(agencyYearlyList); |
|
|
|
factTagUsedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:按年统计 标签阅读数 |
|
|
|
* |
|
|
|
* @param yearId |
|
|
|
* @param customerId |
|
|
|
*/ |
|
|
|
private void statsTagViewedYearly(String yearId, String customerId) { |
|
|
|
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByYearId(customerId, yearId); |
|
|
|
if (!CollectionUtils.isEmpty(gridMonthlyList)) { |
|
|
|
List<FactTagViewedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridYearlyEntity.class); |
|
|
|
factTagViewedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList); |
|
|
|
} |
|
|
|
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByYearId(customerId, yearId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { |
|
|
|
List<FactTagViewedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyYearlyEntity.class); |
|
|
|
factTagViewedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -534,6 +757,33 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setTagViewedData2ParentAgency(Map<String, DimAgencyEntity> dimAgencyEntityMap, Map<String, FactTagViewedAgencyDailyEntity> agencyDailyEntityMap, FactTagViewedAgencyDailyEntity currentEntity, DimIdGenerator.DimIdBean dimIdBean) { |
|
|
|
String pid = currentEntity.getPid(); |
|
|
|
String tagId = currentEntity.getTagId(); |
|
|
|
String key = pid.concat(StrConstant.UNDER_LINE).concat(tagId); |
|
|
|
FactTagViewedAgencyDailyEntity parentAgencyDailyEntity = agencyDailyEntityMap.get(key); |
|
|
|
DimAgencyEntity currentDimAgency = dimAgencyEntityMap.get(pid); |
|
|
|
if (currentDimAgency == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (parentAgencyDailyEntity == null) { |
|
|
|
parentAgencyDailyEntity = ConvertUtils.sourceToTarget(dimIdBean, FactTagViewedAgencyDailyEntity.class); |
|
|
|
parentAgencyDailyEntity.setCustomerId(currentEntity.getCustomerId()); |
|
|
|
parentAgencyDailyEntity.setPid(currentDimAgency.getPid()); |
|
|
|
parentAgencyDailyEntity.setAgencyId(currentDimAgency.getId()); |
|
|
|
parentAgencyDailyEntity.setTagId(currentEntity.getTagId()); |
|
|
|
parentAgencyDailyEntity.setTagName(currentEntity.getTagName()); |
|
|
|
parentAgencyDailyEntity.setTagReadCount(currentEntity.getTagReadCount()); |
|
|
|
agencyDailyEntityMap.put(key, parentAgencyDailyEntity); |
|
|
|
} else { |
|
|
|
parentAgencyDailyEntity.setTagReadCount(parentAgencyDailyEntity.getTagReadCount() + currentEntity.getTagReadCount()); |
|
|
|
} |
|
|
|
pid = currentDimAgency.getPid(); |
|
|
|
if (!NumConstant.ZERO_STR.equals(pid)) { |
|
|
|
setTagViewedData2ParentAgency(dimAgencyEntityMap, agencyDailyEntityMap, parentAgencyDailyEntity, dimIdBean); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setPublishedData2ParentAgency(Map<String, FactArticlePublishedAgencyDailyEntity> agencyDailyEntityMap, FactArticlePublishedAgencyDailyEntity agencySummary, FactArticlePublishedAgencyDailyEntity summary) { |
|
|
|
String pid = summary.getPid(); |
|
|
|
FactArticlePublishedAgencyDailyEntity parentAgency = agencyDailyEntityMap.get(pid); |
|
|
@ -690,4 +940,46 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { |
|
|
|
entity.setUsedCount(entity.getUsedCount() + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void convertTagViewedGridDailyEntity(DimAgencyEntity dimAgencyEntity, Map<String, FactTagViewedGridDailyEntity> result, |
|
|
|
ArticleTagsEntity tagEntity, ArticleViewedSummaryDTO viewedSummaryDTO, DimIdGenerator.DimIdBean dimIdBean) { |
|
|
|
String gridId = viewedSummaryDTO.getGridId(); |
|
|
|
String tagId = tagEntity.getTagId(); |
|
|
|
String key = gridId.concat(StrConstant.UNDER_LINE).concat(tagId); |
|
|
|
Integer viewedCount = viewedSummaryDTO.getViewedCount() == null ? 0 : viewedSummaryDTO.getViewedCount(); |
|
|
|
FactTagViewedGridDailyEntity entity = result.get(key); |
|
|
|
if (entity == null) { |
|
|
|
entity = ConvertUtils.sourceToTarget(dimIdBean, FactTagViewedGridDailyEntity.class); |
|
|
|
entity.setGridId(gridId); |
|
|
|
entity.setCustomerId(tagEntity.getCustomerId()); |
|
|
|
entity.setAgencyId(dimAgencyEntity.getId()); |
|
|
|
entity.setTagId(tagId); |
|
|
|
entity.setTagName(tagEntity.getTagName()); |
|
|
|
entity.setTagReadCount(viewedCount); |
|
|
|
result.put(key, entity); |
|
|
|
} else { |
|
|
|
entity.setTagReadCount(entity.getTagReadCount() + viewedCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void convertTagViewedAgencyDailyEntity(DimAgencyEntity dimAgencyEntity, Map<String, FactTagViewedAgencyDailyEntity> result, |
|
|
|
ArticleTagsEntity tagEntity, ArticleViewedSummaryDTO viewedSummaryDTO, DimIdGenerator.DimIdBean dimIdBean) { |
|
|
|
String agencyId = dimAgencyEntity.getId(); |
|
|
|
String tagId = tagEntity.getTagId(); |
|
|
|
String key = agencyId.concat(StrConstant.UNDER_LINE).concat(tagId); |
|
|
|
Integer viewedCount = viewedSummaryDTO.getViewedCount() == null ? 0 : viewedSummaryDTO.getViewedCount(); |
|
|
|
FactTagViewedAgencyDailyEntity entity = result.get(key); |
|
|
|
if (entity == null) { |
|
|
|
entity = ConvertUtils.sourceToTarget(dimIdBean, FactTagViewedAgencyDailyEntity.class); |
|
|
|
entity.setPid(dimAgencyEntity.getPid()); |
|
|
|
entity.setCustomerId(tagEntity.getCustomerId()); |
|
|
|
entity.setAgencyId(agencyId); |
|
|
|
entity.setTagId(tagId); |
|
|
|
entity.setTagName(tagEntity.getTagName()); |
|
|
|
entity.setTagReadCount(viewedCount); |
|
|
|
result.put(key, entity); |
|
|
|
} else { |
|
|
|
entity.setTagReadCount(entity.getTagReadCount() + viewedCount); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|