Browse Source

添加统一的统计错误日志

dev_shibei_match
jianjun 5 years ago
parent
commit
6a5ac6bde1
  1. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java
  2. 592
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -46,6 +46,11 @@ public interface ProjectConstant {
/** /**
* 执行失败钉钉消息模版 * 执行失败钉钉消息模版
*/ */
String EXE_FAILED_MSG = "定时任务【%s】执行失败,客户ID:%s,统计时间:%s,异常信息:%s"; String EXE_FAILED_MSG = "统计数据方法【%s】执行失败,客户ID:%s,统计日期:%s,异常信息:%s";
/**
* 统计数据执行失败日志前缀
*/
String STATS_FAILED_PREFIX = "统计数据执行失败:%s 客户ID:%s,统计日期:%s,异常信息:%s";
} }

592
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java

@ -160,10 +160,18 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
if (!CollectionUtils.isEmpty(customerIdList)) { if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) { for (String customerId : customerIdList) {
Date finalStatsDate = statsDate; Date finalStatsDate = statsDate;
//executorService.submit(() -> {
//统计 //统计
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId); try {
//}); statsTagUsedDaily(finalStatsDate, dimIdBean, customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagUsedDailyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被使用次数", customerId, dimIdBean.getMonthId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
}
} }
} }
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -187,13 +195,17 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) { if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) { for (String customerId : customerIdList) {
executorService.submit(() -> { try {
statsTagUsedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "按月统计标签被使用次数", customerId, dimIdBean.getMonthId(), e.getMessage()));
try { try {
statsTagUsedMonthly(dimIdBean.getMonthId(), customerId); String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被使用次数", customerId, dimIdBean.getMonthId(), e.getMessage());
} catch (Exception e) { HttpClientManager.getInstance().sendAlarmMsg(content);
log.error("statsTagUsedMonthly exception", e); } catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
} }
}); }
} }
} }
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -218,9 +230,17 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) { if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) { for (String customerId : customerIdList) {
Date finalStatsDate = statsDate; try {
//统计 statsTagViewedDaily(statsDate, dimIdBean, customerId);
statsTagViewedDaily(finalStatsDate, dimIdBean, customerId); } catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedDailyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被查看次数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", ex);
}
}
} }
} }
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -247,7 +267,13 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
try { try {
statsTagViewedMonthly(dimIdBean.getMonthId(), customerId); statsTagViewedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) { } catch (Exception e) {
log.error("statsTagViewedMonthly exception", e); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedMonthlyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被查看次数", customerId, dimIdBean.getMonthId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
} }
} }
@ -277,7 +303,13 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.debug("start === statsTagUsedQuarterly "); log.debug("start === statsTagUsedQuarterly ");
statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId); statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) { } catch (Exception e) {
log.error("statsTagUsedQuarterly exception", e); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedQuarterly", customerId, dimIdBean.getQuarterId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被使用次数", customerId, dimIdBean.getQuarterId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
}); });
executorService.submit(() -> { executorService.submit(() -> {
@ -285,7 +317,13 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.debug("start === statsTagUsedQuarterly "); log.debug("start === statsTagUsedQuarterly ");
statsTagUsedYearly(dimIdBean.getYearId(), customerId); statsTagUsedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) { } catch (Exception e) {
log.error("statsTagUsedYearly exception", e); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedYearly", customerId, dimIdBean.getYearId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被使用次数", customerId, dimIdBean.getYearId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
}); });
} }
@ -316,15 +354,29 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
log.debug("start === statsTagViewedQuarterly "); log.debug("start === statsTagViewedQuarterly ");
statsTagViewedQuarterly(dimIdBean.getQuarterId(), customerId); statsTagViewedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) { } catch (Exception e) {
log.error("statsTagUsedQuarterly exception", e); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getQuarterId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被查看次数", customerId, dimIdBean.getQuarterId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
}); });
executorService.submit(() -> { executorService.submit(() -> {
try { try {
log.debug("start === statsTagViewedYearly "); log.debug("start === statsTagViewedYearly ");
statsTagViewedYearly(dimIdBean.getYearId(), customerId); statsTagViewedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) { } catch (Exception e) {
log.error("statsTagUsedYearly exception", e); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getYearId(), e.getMessage()));
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被查看次数", customerId, dimIdBean.getYearId(), e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
}); });
} }
@ -363,6 +415,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
} }
boolean b = factArticlePublishedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), departmentDailyEntityMap.values()); boolean b = factArticlePublishedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), departmentDailyEntityMap.values());
} catch (Exception e) { } catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedDepartmentDaily", customerId, statsDate, e.getMessage()));
try { try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage()); String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content); HttpClientManager.getInstance().sendAlarmMsg(content);
@ -436,7 +489,8 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
} }
boolean b = factArticlePublishedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), gridDailyEntityMap.values()); boolean b = factArticlePublishedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), gridDailyEntityMap.values());
} catch (Exception e) { } catch (Exception e) {
log.error("statsPublishedGridDaily exception customerId:{},statsDate:{}", customerId, statsDate); e.printStackTrace();
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedGridDaily", customerId, statsDate, e.getMessage()));
try { try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计网格纬度文章总数", customerId, statsDate, e.getMessage()); String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计网格纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content); HttpClientManager.getInstance().sendAlarmMsg(content);
@ -507,7 +561,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
boolean b = factArticlePublishedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), agencyDailyEntityMap.values()); boolean b = factArticlePublishedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), agencyDailyEntityMap.values());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("statsPublishedAgencyDaily exception,customer:{}", customerId); log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedAgencyDaily", customerId, statsDate, e.getMessage()));
try { try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage()); String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计部门纬度文章总数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content); HttpClientManager.getInstance().sendAlarmMsg(content);
@ -525,89 +579,82 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagUsedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) { private void statsTagUsedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) {
try {
//1.业务数据来源 发布时间为统计时间的 //1.业务数据来源 发布时间为统计时间的
// 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分 // 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
// 1.1查出今天所有的文章标签 根据网格Id // 1.1查出今天所有的文章标签 根据网格Id
// 1.2 // 1.2
//获取所有网格 //获取所有网格
List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId); List<DimAgencyEntity> agencyDTOList = dimAgencyService.getAgencyListByCustomerId(customerId);
if (CollectionUtils.isEmpty(agencyDTOList)) { 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, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o)); Map<String, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o));
//转换为 需要插入的Entity key gridId_tagId //转换为 需要插入的Entity key gridId_tagId
Map<String, FactTagUsedGridDailyEntity> tagUsedGridDailyMap = new HashMap<>(); Map<String, FactTagUsedGridDailyEntity> tagUsedGridDailyMap = new HashMap<>();
Map<String, FactTagUsedDepartmentDailyEntity> tagUsedDeptDailyMap = new HashMap<>(); Map<String, FactTagUsedDepartmentDailyEntity> tagUsedDeptDailyMap = new HashMap<>();
Map<String, FactTagUsedAgencyDailyEntity> tagUsedAgencyDailyMap = new HashMap<>(); Map<String, FactTagUsedAgencyDailyEntity> tagUsedAgencyDailyMap = new HashMap<>();
Map<String, FactTagUsedAgencyDailyEntity> tagUsedAgencyDailySelfMap = new HashMap<>(); Map<String, FactTagUsedAgencyDailyEntity> tagUsedAgencyDailySelfMap = new HashMap<>();
//获取当天的业务数据 //获取当天的业务数据
//1获取文章及机关id,网格Id //1获取文章及机关id,网格Id
List<ArticleEntity> publishedArticleList = articleService.getPublishedArticleByPublishTime(customerId, DateUtils.format(statsDate)); List<ArticleEntity> publishedArticleList = articleService.getPublishedArticleByPublishTime(customerId, DateUtils.format(statsDate));
if (CollectionUtils.isEmpty(publishedArticleList)) { if (CollectionUtils.isEmpty(publishedArticleList)) {
return; return;
} }
//KEY 文章Id //KEY 文章Id
Map<String, ArticleEntity> articleMap = publishedArticleList.stream().collect(Collectors.toMap(ArticleEntity::getId, o -> o)); Map<String, ArticleEntity> articleMap = publishedArticleList.stream().collect(Collectors.toMap(ArticleEntity::getId, o -> o));
Date startTime = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN); Date startTime = DateUtils.integrate(statsDate, DateUtils.DATE_PATTERN);
Date endTime = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN); Date endTime = DateUtils.integrate(DateUtils.addDateDays(statsDate, 1), DateUtils.DATE_PATTERN);
//2 获取文章标签 //2 获取文章标签
List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByCreateTime(customerId, startTime, endTime); List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByCreateTime(customerId, startTime, endTime);
if (CollectionUtils.isEmpty(articleTagsList)) { if (CollectionUtils.isEmpty(articleTagsList)) {
log.error("publicitySummary getArticleTagsByCreateTime customerId:{} have not articleTags,publishedArticleList:{}", customerId, JSON.toJSONString(publishedArticleList)); log.error("publicitySummary getArticleTagsByCreateTime customerId:{} have not articleTags,publishedArticleList:{}", customerId, JSON.toJSONString(publishedArticleList));
return;
}
//tagId
for (ArticleTagsEntity tagEntity : articleTagsList) {
ArticleEntity articleEntity = articleMap.get(tagEntity.getArticleId());
if (articleEntity == null) {
log.error("publicitySummary articleMap articleId:{} ", tagEntity.getArticleId());
return; return;
} }
//tagId DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(articleEntity.getOrgId());
for (ArticleTagsEntity tagEntity : articleTagsList) { convertTagUsedAgencyDailyEntity(dimAgencyEntity.getPid(), tagUsedAgencyDailyMap, articleEntity, tagEntity, dimIdBean);
ArticleEntity articleEntity = articleMap.get(tagEntity.getArticleId()); switch (articleEntity.getPublisherType()) {
if (articleEntity == null) { case ProjectConstant.PUBLISHER_TYPE_GRID:
log.error("publicitySummary articleMap articleId:{} ", tagEntity.getArticleId()); convertTagUsedGridDailyEntity(tagUsedGridDailyMap, articleEntity, tagEntity, dimIdBean);
return; break;
} case ProjectConstant.PUBLISHER_TYPE_DEPT:
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(articleEntity.getOrgId()); convertTagUsedDepartmentDailyEntity(tagUsedDeptDailyMap, articleEntity, tagEntity, dimIdBean);
convertTagUsedAgencyDailyEntity(dimAgencyEntity.getPid(), tagUsedAgencyDailyMap, articleEntity, tagEntity, dimIdBean); break;
switch (articleEntity.getPublisherType()) { case ProjectConstant.PUBLISHER_TYPE_AGENCY:
case ProjectConstant.PUBLISHER_TYPE_GRID: convertTagUsedAgencyDailySelfEntity(dimAgencyEntity.getPid(), tagUsedAgencyDailySelfMap, articleEntity, tagEntity, dimIdBean);
convertTagUsedGridDailyEntity(tagUsedGridDailyMap, articleEntity, tagEntity, dimIdBean); break;
break;
case ProjectConstant.PUBLISHER_TYPE_DEPT:
convertTagUsedDepartmentDailyEntity(tagUsedDeptDailyMap, articleEntity, tagEntity, dimIdBean);
break;
case ProjectConstant.PUBLISHER_TYPE_AGENCY:
convertTagUsedAgencyDailySelfEntity(dimAgencyEntity.getPid(), tagUsedAgencyDailySelfMap, articleEntity, tagEntity, dimIdBean);
break;
}
} }
}
factTagUsedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagUsedGridDailyMap.values()); factTagUsedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagUsedGridDailyMap.values());
factTagUsedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagUsedDeptDailyMap.values()); factTagUsedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagUsedDeptDailyMap.values());
//向上级机关递归添加 数据 //向上级机关递归添加 数据
Map<String, FactTagUsedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>(); Map<String, FactTagUsedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>();
finalTagUsedAgencyDailyMap.putAll(tagUsedAgencyDailyMap); finalTagUsedAgencyDailyMap.putAll(tagUsedAgencyDailyMap);
for (Map.Entry<String, FactTagUsedAgencyDailyEntity> entry : tagUsedAgencyDailyMap.entrySet()) { for (Map.Entry<String, FactTagUsedAgencyDailyEntity> entry : tagUsedAgencyDailyMap.entrySet()) {
String agencyId = entry.getKey().split(StrConstant.UNDER_LINE)[0]; String agencyId = entry.getKey().split(StrConstant.UNDER_LINE)[0];
FactTagUsedAgencyDailyEntity currentEntity = entry.getValue(); FactTagUsedAgencyDailyEntity currentEntity = entry.getValue();
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId()); DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId());
if (dimAgencyEntity == null) { if (dimAgencyEntity == null) {
log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId); log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId);
continue; continue;
}
setTagUsedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
}
if (!CollectionUtils.isEmpty(tagUsedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagUsedAgencyDailySelfMap);
}
factTagUsedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被使用次数", customerId, statsDate, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
} }
setTagUsedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
} }
if (!CollectionUtils.isEmpty(tagUsedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagUsedAgencyDailySelfMap);
}
factTagUsedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
} }
/** /**
@ -618,98 +665,89 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagViewedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) { private void statsTagViewedDaily(Date statsDate, DimIdGenerator.DimIdBean dimIdBean, String customerId) {
try {
//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); //1.业务数据来源 发布时间为统计时间的
if (CollectionUtils.isEmpty(dimGridList)) { // 因为一个客户的发布文章数在同一天不会特别的多,所以以客户为单位查询今天发布的所有带有标签的文章 根据发布单位类型进行拆分
log.debug("statsTagViewedDaily customerId:{} have any grid", customerId); // 1.1查出今天所有的文章标签 根据网格Id
return; // 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<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailySelfMap = 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;
} }
Map<String, DimGridEntity> dimGridEntityMap = dimGridList.stream().collect(Collectors.toMap(DimGridEntity::getId, o -> o)); ArticleEntity articleEntity = articleService.selectArticleById(viewedSummaryDTO.getArticleId());
//转换为 需要插入的Entity if (articleEntity == null) {
Map<String, DimAgencyEntity> dimAgencyEntityMap = agencyDTOList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o)); continue;
//转换为 需要插入的Entity key gridId_tagId
Map<String, FactTagViewedGridDailyEntity> tagViewedGridDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailyMap = new HashMap<>();
Map<String, FactTagViewedAgencyDailyEntity> tagViewedAgencyDailySelfMap = 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;
} }
boolean isAgencyPublished = false;
if (ProjectConstant.PUBLISHER_TYPE_AGENCY.equals(articleEntity.getPublisherType())) {
isAgencyPublished = true;
}
String gridId = viewedSummaryDTO.getGridId();
DimGridEntity dimGridEntity = dimGridEntityMap.get(gridId);
for (ArticleViewedSummaryDTO viewedSummaryDTO : visitRecordList) { if (dimGridEntity == null) {
List<ArticleTagsEntity> articleTagsList = articleTagsService.getArticleTagsByArticleId(customerId, viewedSummaryDTO.getArticleId()); log.error("statsTagViewedDaily viewedRecord gridId:{} not exist in dimGridMap", gridId);
if (CollectionUtils.isEmpty(articleTagsList)) { continue;
continue; }
} DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(dimGridEntity.getAgencyId());
ArticleEntity articleEntity = articleService.selectArticleById(viewedSummaryDTO.getArticleId()); for (ArticleTagsEntity articleTag : articleTagsList) {
if (articleEntity == null) { convertTagViewedGridDailyEntity(dimAgencyEntity, tagViewedGridDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
continue; convertTagViewedAgencyDailyEntity(dimAgencyEntity, tagViewedAgencyDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
} if (isAgencyPublished) {
boolean isAgencyPublished = false; convertTagViewedAgencyDailySelfEntity(dimAgencyEntity, tagViewedAgencyDailySelfMap, articleTag, viewedSummaryDTO, dimIdBean);
if (ProjectConstant.PUBLISHER_TYPE_AGENCY.equals(articleEntity.getPublisherType())) {
isAgencyPublished = true;
}
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());
for (ArticleTagsEntity articleTag : articleTagsList) {
convertTagViewedGridDailyEntity(dimAgencyEntity, tagViewedGridDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
convertTagViewedAgencyDailyEntity(dimAgencyEntity, tagViewedAgencyDailyMap, articleTag, viewedSummaryDTO, dimIdBean);
if (isAgencyPublished) {
convertTagViewedAgencyDailySelfEntity(dimAgencyEntity, tagViewedAgencyDailySelfMap, articleTag, viewedSummaryDTO, dimIdBean);
}
} }
} }
}
factTagViewedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagViewedGridDailyMap.values()); factTagViewedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), tagViewedGridDailyMap.values());
//向上级机关递归添加 数据 //向上级机关递归添加 数据
Map<String, FactTagViewedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>(); Map<String, FactTagViewedAgencyDailyEntity> finalTagUsedAgencyDailyMap = new HashMap<>();
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailyMap); finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailyMap);
for (Map.Entry<String, FactTagViewedAgencyDailyEntity> entry : tagViewedAgencyDailyMap.entrySet()) { for (Map.Entry<String, FactTagViewedAgencyDailyEntity> entry : tagViewedAgencyDailyMap.entrySet()) {
String agencyId = entry.getKey(); String agencyId = entry.getKey();
FactTagViewedAgencyDailyEntity currentEntity = entry.getValue(); FactTagViewedAgencyDailyEntity currentEntity = entry.getValue();
DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId()); DimAgencyEntity dimAgencyEntity = dimAgencyEntityMap.get(currentEntity.getAgencyId());
if (dimAgencyEntity == null) { if (dimAgencyEntity == null) {
log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId); log.error("dimAgencyEntityMap bizData agencyId:{} not exist in dimAgency", agencyId);
continue; continue;
}
setTagViewedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
}
if (!CollectionUtils.isEmpty(tagViewedAgencyDailySelfMap)) {
finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailySelfMap);
} }
factTagViewedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values()); setTagViewedData2ParentAgency(dimAgencyEntityMap, finalTagUsedAgencyDailyMap, currentEntity, dimIdBean);
} catch (Exception e) { }
try { if (!CollectionUtils.isEmpty(tagViewedAgencyDailySelfMap)) {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按日统计标签被查看次数", customerId, statsDate, e.getMessage()); finalTagUsedAgencyDailyMap.putAll(tagViewedAgencyDailySelfMap);
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
factTagViewedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), finalTagUsedAgencyDailyMap.values());
} }
/** /**
@ -719,29 +757,20 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagUsedMonthly(String monthId, String customerId) { private void statsTagUsedMonthly(String monthId, String customerId) {
try { List<FactTagUsedGridDailyEntity> gridDailyList = factTagUsedGridDailyService.getTagUsedCountByMonth(customerId, monthId);
List<FactTagUsedGridDailyEntity> gridDailyList = factTagUsedGridDailyService.getTagUsedCountByMonth(customerId, monthId); if (!CollectionUtils.isEmpty(gridDailyList)) {
if (!CollectionUtils.isEmpty(gridDailyList)) { List<FactTagUsedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagUsedGridMonthlyEntity.class);
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);
List<FactTagUsedDepartmentDailyEntity> deptDailyList = factTagUsedDepartmentDailyService.getTagUsedCountByMonth(customerId, monthId); if (!CollectionUtils.isEmpty(deptDailyList)) {
if (!CollectionUtils.isEmpty(deptDailyList)) { List<FactTagUsedDepartmentMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(deptDailyList, FactTagUsedDepartmentMonthlyEntity.class);
List<FactTagUsedDepartmentMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(deptDailyList, FactTagUsedDepartmentMonthlyEntity.class); factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
factTagUsedDepartmentMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList); }
} List<FactTagUsedAgencyDailyEntity> agencyDailyList = factTagUsedAgencyDailyService.getTagUsedCountByMonth(customerId, monthId);
List<FactTagUsedAgencyDailyEntity> agencyDailyList = factTagUsedAgencyDailyService.getTagUsedCountByMonth(customerId, monthId); if (!CollectionUtils.isEmpty(agencyDailyList)) {
if (!CollectionUtils.isEmpty(agencyDailyList)) { List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagUsedAgencyMonthlyEntity.class);
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagUsedAgencyMonthlyEntity.class); factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
factTagUsedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被使用次数", customerId, monthId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
} }
@ -752,26 +781,19 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagViewedMonthly(String monthId, String customerId) { private void statsTagViewedMonthly(String monthId, String customerId) {
try {
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); List<FactTagViewedGridDailyEntity> gridDailyList = factTagViewedGridDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) { if (!CollectionUtils.isEmpty(gridDailyList)) {
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagViewedAgencyMonthlyEntity.class); List<FactTagViewedGridMonthlyEntity> gridMonthlyList = ConvertUtils.sourceToTarget(gridDailyList, FactTagViewedGridMonthlyEntity.class);
factTagViewedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList)); factTagViewedGridMonthlyService.deleteAndInsertByMonthId(customerId, monthId, gridMonthlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按月统计标签被查看次数", customerId, monthId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
List<FactTagViewedAgencyDailyEntity> agencyDailyList = factTagViewedAgencyDailyService.getTagViewedCountByMonth(customerId, monthId);
if (!CollectionUtils.isEmpty(agencyDailyList)) {
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = ConvertUtils.sourceToTarget(agencyDailyList, FactTagViewedAgencyMonthlyEntity.class);
factTagViewedAgencyMonthlyService.deleteAndInsertByMonthId(customerId, monthId, (agencyMonthlyList));
}
} }
/** /**
@ -781,30 +803,23 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagUsedQuarterly(String quarterId, String customerId) { private void statsTagUsedQuarterly(String quarterId, String customerId) {
try {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) { if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridQuarterlyEntity.class); 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); List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) { if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentQuarterlyEntity> deptQuarterlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentQuarterlyEntity.class); List<FactTagUsedDepartmentQuarterlyEntity> deptQuarterlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentQuarterlyEntity.class);
factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, deptQuarterlyList); factTagUsedDepartmentQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, deptQuarterlyList);
} }
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId); List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyQuarterlyEntity.class); List<FactTagUsedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyQuarterlyEntity.class);
factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList); factTagUsedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被使用次数", customerId, quarterId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
} }
/** /**
@ -814,26 +829,19 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagViewedQuarterly(String quarterId, String customerId) { private void statsTagViewedQuarterly(String quarterId, String customerId) {
try {
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); List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) { if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyQuarterlyEntity.class); List<FactTagViewedGridQuarterlyEntity> gridQuarterlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridQuarterlyEntity.class);
factTagViewedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList); factTagViewedGridQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, gridQuarterlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按季统计标签被查看次数", customerId, quarterId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByQuarterId(customerId, quarterId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyQuarterlyEntity> agencyQuarterlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyQuarterlyEntity.class);
factTagViewedAgencyQuarterlyService.deleteAndInsertByQuarterId(customerId, quarterId, agencyQuarterlyList);
}
} }
/** /**
@ -843,30 +851,23 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
* @param customerId * @param customerId
*/ */
private void statsTagUsedYearly(String yearId, String customerId) { private void statsTagUsedYearly(String yearId, String customerId) {
try {
List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByYearId(customerId, yearId); List<FactTagUsedGridMonthlyEntity> gridMonthlyList = factTagUsedGridMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) { if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagUsedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridYearlyEntity.class); List<FactTagUsedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagUsedGridYearlyEntity.class);
factTagUsedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, 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.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyYearlyEntity.class);
factTagUsedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被使用次数", customerId, yearId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
List<FactTagUsedDepartmentMonthlyEntity> deptMonthlyList = factTagUsedDepartmentMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(deptMonthlyList)) {
List<FactTagUsedDepartmentYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(deptMonthlyList, FactTagUsedDepartmentYearlyEntity.class);
factTagUsedDepartmentYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList);
}
List<FactTagUsedAgencyMonthlyEntity> agencyMonthlyList = factTagUsedAgencyMonthlyService.getTagUsedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagUsedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagUsedAgencyYearlyEntity.class);
factTagUsedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
}
} }
/** /**
@ -877,25 +878,18 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
*/ */
private void statsTagViewedYearly(String yearId, String customerId) { private void statsTagViewedYearly(String yearId, String customerId) {
try {
List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByYearId(customerId, yearId); List<FactTagViewedGridMonthlyEntity> gridMonthlyList = factTagViewedGridMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(gridMonthlyList)) { if (!CollectionUtils.isEmpty(gridMonthlyList)) {
List<FactTagViewedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridYearlyEntity.class); List<FactTagViewedGridYearlyEntity> gridYearlyList = ConvertUtils.sourceToTarget(gridMonthlyList, FactTagViewedGridYearlyEntity.class);
factTagViewedGridYearlyService.deleteAndInsertByYearId(customerId, yearId, gridYearlyList); 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);
}
} catch (Exception e) {
try {
String content = String.format(ProjectConstant.EXE_FAILED_MSG, "按年统计标签被查看次数", customerId, yearId, e.getMessage());
HttpClientManager.getInstance().sendAlarmMsg(content);
} catch (Exception ex) {
log.error("sendAlarmMsg exception", e);
}
} }
List<FactTagViewedAgencyMonthlyEntity> agencyMonthlyList = factTagViewedAgencyMonthlyService.getTagViewedCountByYearId(customerId, yearId);
if (!CollectionUtils.isEmpty(agencyMonthlyList)) {
List<FactTagViewedAgencyYearlyEntity> agencyYearlyList = ConvertUtils.sourceToTarget(agencyMonthlyList, FactTagViewedAgencyYearlyEntity.class);
factTagViewedAgencyYearlyService.deleteAndInsertByYearId(customerId, yearId, agencyYearlyList);
}
} }
private void setTagUsedData2ParentAgency(Map<String, DimAgencyEntity> dimAgencyEntityMap, Map<String, FactTagUsedAgencyDailyEntity> agencyDailyEntityMap, FactTagUsedAgencyDailyEntity currentEntity, DimIdGenerator.DimIdBean dimIdBean) { private void setTagUsedData2ParentAgency(Map<String, DimAgencyEntity> dimAgencyEntityMap, Map<String, FactTagUsedAgencyDailyEntity> agencyDailyEntityMap, FactTagUsedAgencyDailyEntity currentEntity, DimIdGenerator.DimIdBean dimIdBean) {

Loading…
Cancel
Save