From 1faecb4f6c6d41abed5f0e11325cee92aa300e2f Mon Sep 17 00:00:00 2001 From: wangchao Date: Wed, 24 Jun 2020 18:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=B4=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/StatsTopicServiceImpl.java | 17 ++++++-- .../service/impl/StatsUserServiceImpl.java | 21 ++++++++-- .../service/topic/impl/TopicServiceImpl.java | 39 ++++++++++--------- .../service/user/impl/UserServiceImpl.java | 17 +++++++- .../java/com/epmet/util/ModuleConstant.java | 2 +- .../topic/FactTopicStatusAgencyMonthlyDao.xml | 2 +- .../main/resources/mapper/topic/TopicDao.xml | 1 + 7 files changed, 69 insertions(+), 30 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java index e2f275f83c..e481f0a596 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.ProjectConstant; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.DimTopicStatusDTO; import com.epmet.dto.stats.topic.result.TopicStatisticalData; @@ -12,6 +13,8 @@ import com.epmet.service.stats.DimTopicStatusService; import com.epmet.service.stats.topic.TopicStatisticalService; import com.epmet.service.topic.TopicService; import com.epmet.util.DimIdGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -27,6 +30,8 @@ import java.util.*; @Service public class StatsTopicServiceImpl implements StatsTopicService { + protected static final Logger log = LoggerFactory.getLogger(StatsTopicServiceImpl.class); + @Autowired private DimCustomerService dimCustomerService; @@ -80,10 +85,14 @@ public class StatsTopicServiceImpl implements StatsTopicService { List agencies = dimAgencyService.getAllAgency(customerId); //5.计算统计数据 - TopicStatisticalData data = - topicService.compute(agencies,date,timeDimension,customerId,topicStatusDimension); + try { + TopicStatisticalData data = + topicService.compute(agencies, date, timeDimension, customerId, topicStatusDimension); + //6.生成唯一性统计数据 + topicStatisticalService.insertUniquely(data); + }catch(Exception e){ + log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "topicStats", customerId, new Date().toString(), e.getMessage())); + } - //6.生成唯一性统计数据 - topicStatisticalService.insertUniquely(data); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java index d0c6d3a40c..04101bc378 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.ProjectConstant; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.service.StatsUserService; @@ -10,6 +11,8 @@ import com.epmet.service.stats.DimCustomerService; import com.epmet.service.stats.user.UserStatisticalService; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -28,6 +31,8 @@ import java.util.List; @Service public class StatsUserServiceImpl implements StatsUserService { + protected static final Logger log = LoggerFactory.getLogger(StatsUserServiceImpl.class); + @Autowired private DimCustomerService dimCustomerService; @@ -75,11 +80,19 @@ public class StatsUserServiceImpl implements StatsUserService { //List topAgencies = dimAgencyService.getTopAgency(customerId); //4.计算机关统计数据、生成唯一性统计数据 - UserStatisticalData agencyData = userService.traverseAgencyUser(agencies,date,timeDimension); - userStatisticalService.insertUniquely(agencyData); + try { + 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())); + } //5.计算网格统计数据、生成唯一性统计数据 - UserStatisticalData gridData = userService.traverseGridUser(agencies,date,timeDimension); - userStatisticalService.insertUniquely(gridData); + try { + 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())); + } } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java index 61eeb5f503..296d66ee22 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java @@ -360,37 +360,38 @@ public class TopicServiceImpl implements TopicService { List groups = gridGroupMap.get(gridId); - groups.forEach(group -> { - if(null != group && StringUtils.isNotBlank(group.getGroupId())){ + if(null != groups) { + groups.forEach(group -> { + if (null != group && StringUtils.isNotBlank(group.getGroupId())) { - issueAgencyM.setIssueIncr(issueAgencyM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); - issueAgencyM.setIssueTotal(issueAgencyM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); + issueAgencyM.setIssueIncr(issueAgencyM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); + issueAgencyM.setIssueTotal(issueAgencyM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); - issueGridM.setIssueIncr(issueGridM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); - issueGridM.setIssueTotal(issueGridM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); + issueGridM.setIssueIncr(issueGridM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); + issueGridM.setIssueTotal(issueGridM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); - GroupTopicData data = groupTopicData.get(group.getGroupId()); - if(null != data){ + GroupTopicData data = groupTopicData.get(group.getGroupId()); + if (null != data) { - topicAgencyM_discussing.setTopicCount(topicAgencyM_discussing.getTopicCount() + data.getDiscussingTotal()); - topicAgencyM_discussing.setTopicIncr(topicAgencyM_discussing.getTopicIncr() + data.getDiscussingIncr()); + topicAgencyM_discussing.setTopicCount(topicAgencyM_discussing.getTopicCount() + data.getDiscussingTotal()); + topicAgencyM_discussing.setTopicIncr(topicAgencyM_discussing.getTopicIncr() + data.getDiscussingIncr()); - topicAgencyM_hidden.setTopicCount(topicAgencyM_hidden.getTopicCount() + data.getHiddenTotal()); - topicAgencyM_hidden.setTopicIncr(topicAgencyM_hidden.getTopicIncr() + data.getHiddenIncr()); + topicAgencyM_hidden.setTopicCount(topicAgencyM_hidden.getTopicCount() + data.getHiddenTotal()); + topicAgencyM_hidden.setTopicIncr(topicAgencyM_hidden.getTopicIncr() + data.getHiddenIncr()); - topicAgencyM_closed.setTopicCount(topicAgencyM_closed.getTopicCount() + data.getClosedTotal()); - topicAgencyM_closed.setTopicIncr(topicAgencyM_closed.getTopicIncr() + data.getClosedIncr()); + topicAgencyM_closed.setTopicCount(topicAgencyM_closed.getTopicCount() + data.getClosedTotal()); + topicAgencyM_closed.setTopicIncr(topicAgencyM_closed.getTopicIncr() + data.getClosedIncr()); - } - - } + } + } - }); + }); + } if(!gridDistinct.get(gridId)) { setGridMonthlyDataPacket(dataPacket, issueGridM); } @@ -446,7 +447,7 @@ public class TopicServiceImpl implements TopicService { }else{ for (ResiTopicResultDTO topic : group.getTopics()) { - + if(StringUtils.isBlank(topic.getTopicId())) continue; if (StringUtils.equals(NumConstant.ONE_STR, topic.getIncrFlag())) { groupTopicData.setTopicIncr(groupTopicData.getTopicIncr() + NumConstant.ONE); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 26fe63a713..2fca7b32fb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -338,6 +338,14 @@ public class UserServiceImpl implements UserService { regAgencyM.setPartymemberProportion(regAgencyD.getPartymemberProportion()); regAgencyM.setWarmHeartedProportion(regAgencyD.getWarmHeartedProportion()); regAgencyM.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); + if(null == dataPacket.getRegAgencyMonthlyList()){ + List list = new LinkedList<>(); + list.add(regAgencyM); + dataPacket.setRegAgencyMonthlyList(list); + }else{ + dataPacket.getRegAgencyMonthlyList().add(regAgencyM); + } + FactParticipationUserAgencyMonthlyDTO partiAgencyM = new FactParticipationUserAgencyMonthlyDTO(); partiAgencyM.setCustomerId(customerId); @@ -356,7 +364,13 @@ public class UserServiceImpl implements UserService { partiAgencyM.setPartymemberProportion(partiAgencyD.getPartymemberProportion()); partiAgencyM.setWarmHeartedProportion(partiAgencyD.getWarmHeartedProportion()); partiAgencyM.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); - + if(null == dataPacket.getPartiAgencyMonthlyList()){ + List list = new LinkedList<>(); + list.add(partiAgencyM); + dataPacket.setPartiAgencyMonthlyList(list); + }else{ + dataPacket.getPartiAgencyMonthlyList().add(partiAgencyM); + } } @@ -521,6 +535,7 @@ public class UserServiceImpl implements UserService { FactParticipationUserGridMonthlyDTO partiGridM = new FactParticipationUserGridMonthlyDTO(); partiGridM.setCustomerId(customerId); partiGridM.setAgencyId(agencyId); + partiGridM.setGridId(gridId); partiGridM.setMonthId(timeDimension.getMonthId()); partiGridM.setQuarterId(timeDimension.getQuarterId()); partiGridM.setYearId(timeDimension.getYearId()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java index 8a196f82f4..48a1b9a08c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java @@ -30,5 +30,5 @@ public interface ModuleConstant { /** * 统计机器人 * */ - String CREATED_BY_STATISTICAL_ROBOT = "statisticalRobot"; + String CREATED_BY_STATISTICAL_ROBOT = "STATISTICAL_ROBOT"; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicStatusAgencyMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicStatusAgencyMonthlyDao.xml index dc61db8665..721ba53791 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicStatusAgencyMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/topic/FactTopicStatusAgencyMonthlyDao.xml @@ -60,7 +60,7 @@ #{item.topicProportion}, - #{item.topicIncrement}, + #{item.topicIncr}, #{item.createdBy}, diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/topic/TopicDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/topic/TopicDao.xml index 10bf5cd05b..819674dbbf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/topic/TopicDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/topic/TopicDao.xml @@ -109,6 +109,7 @@ date_format(CREATED_TIME,'%Y-%m-%d') AS createdTime FROM RESI_TOPIC_OPERATION operation WHERE operation.DEL_FLAG = '0' + AND CREATED_TIME =]]> #{startDate} AND CREATED_TIME DATE_SUB( #{endDate}, INTERVAL - 1 DAY) order by TOPIC_ID