Browse Source

error日志统一处理

master
jianjun 5 years ago
parent
commit
8b861db5bd
  1. 28
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  2. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java
  4. 83
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java
  6. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java

28
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java

@ -1,6 +1,5 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.AgencySubDeptTreeDto;
import com.epmet.dto.AgencySubTreeDto;
@ -51,64 +50,55 @@ public class DimController {
dimDateService.initDimDate();
logger.info("初始化按日维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化按日维度失败:%s", errorStackTrace));
logger.error("初始化按日维度失败:", e);
}
try {
statsDimService.initGridDim();
logger.info("初始化网格维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化网格维度失败:%s", errorStackTrace));
logger.error("初始化网格维度失败:", e);
}
try {
statsDimService.initAgencyDim();
logger.info("初始化机关维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化机关维度失败:%s", errorStackTrace));
logger.error("初始化机关维度失败:", e);
}
try {
statsDimService.initCustomerDim();
logger.info("初始化客户维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化客户维度失败:%s", errorStackTrace));
logger.error("初始化客户维度失败:", e);
}
try {
statsDimService.initDepartmentDim();
logger.info("初始化部门维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化部门维度失败:%s", errorStackTrace));
logger.error("初始化部门维度失败:", e);
}
try {
dimMonthService.initMonthDim();
logger.info("初始化按月维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化按月维度失败:%s", errorStackTrace));
logger.error("初始化按月维度失败:", e);
}
try {
quarterService.initQuarterDim();
logger.info("初始化季度维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化季度维度失败:%s", errorStackTrace));
logger.error("初始化季度维度失败:", e);
}
try {
dimYearService.initYearDim();
logger.info("初始化年度维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化年度维度失败:%s", errorStackTrace));
logger.error("初始化年度维度失败:", e);
}
try {
dimWeekService.initWeekDim();
logger.info("初始化按周维度成功");
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("初始化按周维度失败:%s", errorStackTrace));
logger.error("初始化按周维度失败:", e);
}
return new Result();
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java

@ -20,9 +20,7 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.*;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -73,8 +71,8 @@ public class StatsIssueServiceImpl implements StatsIssueService {
try {
customerStats(customerId, date);
} catch(Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", customerId, DateUtils.format(date),
e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", customerId, DateUtils.format(date)),
e);
}
}
}
@ -95,7 +93,7 @@ public class StatsIssueServiceImpl implements StatsIssueService {
try {
customerStats(customerId, date);
} catch(Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", DateUtils.format(date), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", DateUtils.format(date)), e);
}
}
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java

@ -117,7 +117,7 @@ public class StatsProjectServiceImpl implements StatsProjectService {
log.info("StatsProjectServiceImpl.customerAgencyStats-开始执行机关日统计方法,方法名:agencyDateProjectStats,客户Id:" + customerId);
agencyDateProjectStats(customerId, dimId, dimAgencyList, projectList, processList);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyDateProjectStats", customerId, dimId.getDateId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyDateProjectStats", customerId, dimId.getDateId()), e);
}
//5.2:执行机关月数据统计
@ -126,7 +126,7 @@ public class StatsProjectServiceImpl implements StatsProjectService {
log.info("StatsProjectServiceImpl.customerAgencyStats-开始执行机关月统计方法,方法名:agencyMonthProjectStats,客户Id:" + customerId);
agencyMonthProjectStats(customerId, dimId, dimAgencyList);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyMonthProjectStats", customerId, dimId.getMonthId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyMonthProjectStats", customerId, dimId.getMonthId()), e);
}
//}
}
@ -409,7 +409,7 @@ public class StatsProjectServiceImpl implements StatsProjectService {
log.info("StatsProjectServiceImpl.customerGridStats-开始执行机关日统计方法,方法名:gridDateProjectStats,客户Id:" + customerId);
gridDateProjectStats(customerId, dimId, dimGridList, projectList, processList);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridDateProjectStats", customerId, dimId.getDateId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridDateProjectStats", customerId, dimId.getDateId()), e);
}
//5.2:执行网格月数据统计
@ -418,7 +418,7 @@ public class StatsProjectServiceImpl implements StatsProjectService {
log.info("StatsProjectServiceImpl.customerGridStats-开始执行机关月统计方法,方法名:gridMonthProjectStats,客户Id:" + customerId);
gridMonthProjectStats(customerId, dimId, dimGridList);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridMonthProjectStats", customerId, dimId.getMonthId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridMonthProjectStats", customerId, dimId.getMonthId()), e);
}
//}
}

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

@ -163,7 +163,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
try {
statsTagUsedDaily(finalStatsDate, dimIdBean, customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagUsedDailyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagUsedDailyStatsjob", customerId, dimIdBean.getDateId()), e);
}
}
}
@ -191,7 +191,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
try {
statsTagUsedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "按月统计标签被使用次数", customerId, dimIdBean.getMonthId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "按月统计标签被使用次数", customerId, dimIdBean.getMonthId()), e);
}
}
}
@ -220,7 +220,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
try {
statsTagViewedDaily(statsDate, dimIdBean, customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedDailyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedDailyStatsjob", customerId, dimIdBean.getDateId()), e);
}
}
}
@ -248,7 +248,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
try {
statsTagViewedMonthly(dimIdBean.getMonthId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedMonthlyStatsjob", customerId, dimIdBean.getDateId(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagViewedMonthlyStatsjob", customerId, dimIdBean.getDateId()), e);
}
}
}
@ -273,22 +273,18 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
executorService.submit(() -> {
try {
log.debug("start === statsTagUsedQuarterly ");
statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedQuarterly", customerId, dimIdBean.getQuarterId(), e.getMessage()));
}
});
executorService.submit(() -> {
try {
log.debug("start === statsTagUsedQuarterly ");
statsTagUsedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedYearly", customerId, dimIdBean.getYearId(), e.getMessage()));
}
});
try {
log.debug("start === statsTagUsedQuarterly ");
statsTagUsedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedQuarterly", customerId, dimIdBean.getQuarterId()), e);
}
try {
log.debug("start === statsTagUsedQuarterly ");
statsTagUsedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagUsedYearly", customerId, dimIdBean.getYearId()), e);
}
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -312,24 +308,20 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
executorService.submit(() -> {
try {
log.debug("start === statsTagViewedQuarterly ");
statsTagViewedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getQuarterId(), e.getMessage()));
}
});
executorService.submit(() -> {
try {
log.debug("start === statsTagViewedYearly ");
statsTagViewedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getYearId(), e.getMessage()));
}
});
try {
log.debug("start === statsTagViewedQuarterly ");
statsTagViewedQuarterly(dimIdBean.getQuarterId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getQuarterId()), e);
}
try {
log.debug("start === statsTagViewedYearly ");
statsTagViewedYearly(dimIdBean.getYearId(), customerId);
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsTagViewedQuarterly", customerId, dimIdBean.getYearId()), e);
}
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -366,7 +358,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
}
boolean b = factArticlePublishedDepartmentDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), departmentDailyEntityMap.values());
} catch (Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedDepartmentDaily", customerId, statsDate, e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedDepartmentDaily", customerId, statsDate), e);
}
}
@ -435,7 +427,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
boolean b = factArticlePublishedGridDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), gridDailyEntityMap.values());
} catch (Exception e) {
e.printStackTrace();
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedGridDaily", customerId, statsDate, e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedGridDaily", customerId, statsDate), e);
}
@ -468,7 +460,6 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
gridDailyEntities.setPublishedCount(summaryDTO.getPublishedCount());
haveDataAgencyDailyMap.put(summaryDTO.getAgencyId(), gridDailyEntities);
//构建机关自己的数据
@ -482,7 +473,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
haveDataAgencyDailySelfMap.put(selfDaily.getAgencyId(), selfDaily);
}
}
if (!CollectionUtils.isEmpty(agencySummaryMap)){
if (!CollectionUtils.isEmpty(agencySummaryMap)) {
//同一个机关下数据累加
for (Map.Entry<String, ArticleGridPublishedSummaryDTO> entry : agencySummaryMap.entrySet()) {
String agencyId = entry.getKey();
@ -491,9 +482,9 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
if (dimAgencyEntity == null) {
continue;
}
dimAgencyEntity.setArticleTotalCount(dimAgencyEntity.getArticlePublishedCount()+summary.getArticleTotalCount());
dimAgencyEntity.setArticlePublishedCount(dimAgencyEntity.getPublishedCount()+summary.getArticlePublishedCount());
dimAgencyEntity.setPublishedCount(dimAgencyEntity.getPublishedCount()+summary.getPublishedCount());
dimAgencyEntity.setArticleTotalCount(dimAgencyEntity.getArticlePublishedCount() + summary.getArticleTotalCount());
dimAgencyEntity.setArticlePublishedCount(dimAgencyEntity.getPublishedCount() + summary.getArticlePublishedCount());
dimAgencyEntity.setPublishedCount(dimAgencyEntity.getPublishedCount() + summary.getPublishedCount());
}
}
//数据向上级机关添加
@ -517,7 +508,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService {
boolean b = factArticlePublishedAgencyDailyService.deleteAndInsertBatch(customerId, dimIdBean.getDateId(), agencyDailyEntityMap.values());
} catch (Exception e) {
e.printStackTrace();
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedAgencyDaily", customerId, statsDate, e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "statsPublishedAgencyDaily", customerId, statsDate), e);
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java

@ -91,7 +91,7 @@ public class StatsTopicServiceImpl implements StatsTopicService {
//6.生成唯一性统计数据
topicStatisticalService.insertUniquely(data);
}catch(Exception e){
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "topicStats", customerId, new Date().toString(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "topicStats", customerId, date), e);
}
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java

@ -84,7 +84,7 @@ public class StatsUserServiceImpl implements StatsUserService {
UserStatisticalData agencyData = userService.traverseAgencyUser(agencies, date, timeDimension);
userStatisticalService.insertUniquely(agencyData);
}catch(Exception e){
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyUserStats", customerId, new Date().toString(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyUserStats", customerId, new Date().toString()), e);
}
//5.计算网格统计数据、生成唯一性统计数据
@ -92,7 +92,7 @@ public class StatsUserServiceImpl implements StatsUserService {
UserStatisticalData gridData = userService.traverseGridUser(agencies, date, timeDimension);
userStatisticalService.insertUniquely(gridData);
}catch(Exception e){
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridUserStats", customerId, new Date().toString(), e.getMessage()));
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridUserStats", customerId, new Date().toString()), e);
}
}
}

Loading…
Cancel
Save