diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index a7a768b095..a4cecaa3c0 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -19,11 +19,8 @@ import org.joda.time.format.DateTimeFormatter; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.time.DateTimeException; import java.time.ZoneId; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * 日期处理工具类 @@ -464,10 +461,41 @@ public class DateUtils { // 日期加1(包含结束) tempEnd.add(Calendar.DATE, +1); while (tempStart.before(tempEnd)) { - days.add(DateUtils.format(tempStart.getTime(),DateUtils.DATE_PATTERN_YYYYMMDD)); + days.add(DateUtils.format(tempStart.getTime(), DateUtils.DATE_PATTERN_YYYYMMDD)); tempStart.add(Calendar.DAY_OF_YEAR, 1); } - }catch (Exception e){ + } catch (Exception e) { + e.printStackTrace(); + } + return days; + } + + /** + * @param startTime yyyyMMdd + * @param endTime yyyyMMdd + * @return java.util.List 返回yyyyMMdd + * @author yinzuomei + * @description 获取两个日期之间所有的日期集合,包含开始结束 + * @Date 2020/6/23 1:26 + **/ + public static List getDaysBetween(String startTime, String endTime, String sourceFormatPattern, String resultFormatPattern) { + // 返回的日期集合 + List days = new ArrayList(); + try { + Date start = DateUtils.parse(startTime, sourceFormatPattern); + Date end = DateUtils.parse(endTime, sourceFormatPattern); + + Calendar tempStart = Calendar.getInstance(); + tempStart.setTime(start); + Calendar tempEnd = Calendar.getInstance(); + tempEnd.setTime(end); + // 日期加1(包含结束) + tempEnd.add(Calendar.DATE, +1); + while (tempStart.before(tempEnd)) { + days.add(DateUtils.format(tempStart.getTime(), resultFormatPattern)); + tempStart.add(Calendar.DAY_OF_YEAR, 1); + } + } catch (Exception e) { e.printStackTrace(); } return days; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/AggregationExtractFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/AggregationExtractFormDTO.java new file mode 100644 index 0000000000..e307587313 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/AggregationExtractFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.extract.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc: 从业务数据抽取到统计库Form DTO + * + * @Author zxc + * @DateTime 2020/9/16 6:01 下午 + */ +@Data +public class AggregationExtractFormDTO implements Serializable { + + private static final long serialVersionUID = -5488214001979782952L; + + private String customerId; + /** + * 开始日期 yyyy-MM-dd + */ + private String startDate; + + /** + * 结束日期 yyyy-MM-dd + */ + private String endDate; + + /** + * 抽取类型 monthly,daily + */ + private String type; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index 5020fd3c63..4be6144bc2 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java @@ -7,13 +7,11 @@ import com.epmet.dto.extract.form.ExtractIndexFormDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; -import com.epmet.dto.issue.form.IssueJobFromDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; /** * desc: 数据统计 对外feign client @@ -84,7 +82,7 @@ public interface DataStatisticalOpenFeignClient { /** * desc: 【季,年】 统计阅读最多的标签 包含 机关 网格 * - * @param date + * @param formDTO * @date: 2020/6/22 9:09 * @author: jianjun liu */ @@ -124,18 +122,7 @@ public interface DataStatisticalOpenFeignClient { * @date 2020/6/23 14:34 */ @PostMapping("/data/stats/statsissue/issuestats") - Result agencyGridIssueStats(); - - /** - * 指定日期统计 - * - * @param fromDTO - * @return com.epmet.commons.tools.utils.Result - * @author zhaoqifeng - * @date 2020/7/1 15:29 - */ - @PostMapping("/data/stats/statsissue/issuestatsofdate") - Result agencyGridIssueStatsOfDate(@RequestBody IssueJobFromDTO fromDTO); + Result agencyGridIssueStats(StatsFormDTO formDTO); /** * @Description 数据统计-项目-机关日月统计 @@ -167,7 +154,7 @@ public interface DataStatisticalOpenFeignClient { * @date 2020.06.29 09:26 **/ @PostMapping("/data/stats/statsuser/execute") - Result execUserStatistical(@RequestParam(value = "date", required = false) String date); + Result execUserStatistical(@RequestBody StatsFormDTO formDTO); /** * @param @@ -177,7 +164,7 @@ public interface DataStatisticalOpenFeignClient { * @date 2020.06.29 09:27 **/ @PostMapping("/data/stats/statstopic/execute") - Result execTopicStatistical(@RequestParam(value = "date", required = false) String date); + Result execTopicStatistical(@RequestBody StatsFormDTO formDTO); /** * @param customerIdAndDateIdFormDTO diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index 344f0ff7a1..0f09dc88b9 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java @@ -8,7 +8,6 @@ import com.epmet.dto.extract.form.ExtractIndexFormDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; -import com.epmet.dto.issue.form.IssueJobFromDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; import org.springframework.stereotype.Component; @@ -119,13 +118,8 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp } @Override - public Result agencyGridIssueStats() { - return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "agencyGridIssueStats"); - } - - @Override - public Result agencyGridIssueStatsOfDate(IssueJobFromDTO fromDTO) { - return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "agencyGridIssueStatsOfDate"); + public Result agencyGridIssueStats(StatsFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "agencyGridIssueStats", formDTO); } /** @@ -152,27 +146,27 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp } /** - * @Description 执行用户统计 * @param * @return + * @Description 执行用户统计 * @author wangc * @date 2020.06.29 09:26 **/ @Override - public Result execUserStatistical(String date) { - return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "execUserStatistical",date); + public Result execUserStatistical(StatsFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "execUserStatistical", formDTO); } /** - * @Description 执行话题统计 * @param * @return + * @Description 执行话题统计 * @author wangc * @date 2020.06.29 09:27 **/ @Override - public Result execTopicStatistical(String date) { - return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "execTopicStatistical",date); + public Result execTopicStatistical(StatsFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "execTopicStatistical", formDTO); } @Override diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactAggregationExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactAggregationExtractController.java new file mode 100644 index 0000000000..c0618c9250 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactAggregationExtractController.java @@ -0,0 +1,163 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; +import com.epmet.dto.extract.form.AggregationExtractFormDTO; +import com.epmet.dto.group.form.GroupStatsFormDTO; +import com.epmet.service.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; +import java.util.List; + +/** + * @author liujianjun + * @Description 业务数据聚合统计 + * @ClassName FactAggregationExtractController + * @Date 2020-06-23 15:18 + */ +@Slf4j +@RestController +@RequestMapping("fact/aggregation") +public class FactAggregationExtractController { + @Autowired + private StatsGroupService statsGroupService; + @Autowired + private StatsUserService statsUserService; + @Autowired + private StatsTopicService statsTopicService; + @Autowired + private StatsIssueService statsIssueService; + @Autowired + private StatsProjectService statsProjectService; + @Autowired + private StatsPublicityService statsPublicityService; + + /** + * desc: 按月或者天抽取业务数据到统计库 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author LiuJanJun + * @date 2020/11/10 3:14 下午 + */ + @RequestMapping("extractDailyOrMonthly") + public Result extractDaily(@RequestBody AggregationExtractFormDTO formDTO) { + if (StringUtils.isBlank(formDTO.getStartDate()) && StringUtils.isBlank(formDTO.getEndDate())) { + log.error("抽取日期范围不能为空"); + return new Result().error(); + } + if (formDTO.getStartDate().indexOf(StrConstant.HYPHEN) < 0 || formDTO.getEndDate().indexOf(StrConstant.HYPHEN) < 0) { + log.error("抽取日期范围格式不正确,yyyy-MM-dd"); + return new Result().error(); + } + List daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate(), DateUtils.DATE_PATTERN, DateUtils.DATE_PATTERN); + daysBetween.forEach(dateId -> { + Date date = DateUtils.parse(dateId, DateUtils.DATE_PATTERN); + StatsFormDTO param = new StatsFormDTO(); + param.setCustomerId(formDTO.getCustomerId()); + param.setDate(dateId); + + switch (formDTO.getType()) { + case "monthly": + extractGroupDataMonthly(param); + extractArticleDataMonthlyAndQuarterly(param); + break; + default: + extractUserDataDaily(param); + extractGroupDataDaily(param); + extractTopicDataDaily(param); + extractIssueDataDaily(param); + extractProjectDataDaily(param); + extractAtricleDataDaily(param); + } + }); + return new Result(); + } + + private void extractUserDataDaily(StatsFormDTO formDTO) { + try { + statsUserService.partition(formDTO); + } catch (Exception e) { + log.error("抽取【用户】数据失败", e); + } + } + + private void extractTopicDataDaily(StatsFormDTO formDTO) { + try { + statsTopicService.partition(formDTO); + } catch (Exception e) { + log.error("抽取【话题】数据失败", e); + } + } + + private void extractIssueDataDaily(StatsFormDTO formDTO) { + try { + statsIssueService.agencyGridIssueStats(formDTO); + } catch (Exception e) { + log.error("抽取【议题】数据失败", e); + } + } + + private void extractProjectDataDaily(StatsFormDTO formDTO) { + try { + statsProjectService.gridProjectStats(formDTO); + statsProjectService.agencyProjectStats(formDTO); + } catch (Exception e) { + log.error("抽取【项目】数据失败", e); + } + } + + private void extractAtricleDataDaily(StatsFormDTO formDTO) { + try { + statsPublicityService.articleSummaryDailyStatsjob(formDTO); + statsPublicityService.tagUsedDailyStatsjob(formDTO); + statsPublicityService.tagViewedDailyStatsjob(formDTO); + } catch (Exception e) { + log.error("抽取【文章】数据失败", e); + } + } + + private void extractGroupDataDaily(StatsFormDTO formDTO) { + try { + GroupStatsFormDTO groupStatsFormDTO = new GroupStatsFormDTO(); + groupStatsFormDTO.setDate(formDTO.getDate()); + groupStatsFormDTO.setCustomerId(formDTO.getCustomerId()); + + statsGroupService.groupGridDaily(groupStatsFormDTO); + statsGroupService.groupAgencyDaily(groupStatsFormDTO); + } catch (Exception e) { + log.error("抽取【小组】数据失败", e); + } + } + + private void extractGroupDataMonthly(StatsFormDTO formDTO) { + try { + GroupStatsFormDTO groupStatsFormDTO = new GroupStatsFormDTO(); + groupStatsFormDTO.setDate(formDTO.getDate()); + groupStatsFormDTO.setCustomerId(formDTO.getCustomerId()); + + statsGroupService.groupAgencyMonthly(groupStatsFormDTO); + } catch (Exception e) { + log.error("抽取【小组】数据失败", e); + } + } + + private void extractArticleDataMonthlyAndQuarterly(StatsFormDTO formDTO) { + try { + statsPublicityService.tagUsedMonthlyStatsjob(formDTO); + statsPublicityService.tagUsedQuarterlyStatsjob(formDTO); + statsPublicityService.tagViewedMonthlyStatsjob(formDTO); + statsPublicityService.tagViewedQuarterlyStatsjob(formDTO); + } catch (Exception e) { + log.error("抽取【文章】数据失败", e); + } + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java index 7a6e11f801..2abcd81edd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java @@ -40,16 +40,6 @@ public class FactOriginExtractController { */ @PostMapping("extractall") public Result extractAll(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - /*if (StringUtils.isNotBlank(extractOriginFormDTO.getStartDate()) && StringUtils.isNotBlank(extractOriginFormDTO.getEndDate())) { - List daysBetween = DateUtils.getDaysBetween(extractOriginFormDTO.getStartDate(), extractOriginFormDTO.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - extractOriginFormDTO.setDateId(dateDimId); - factOriginExtractService.extractAll(extractOriginFormDTO); - } - } else { - factOriginExtractService.extractAll(extractOriginFormDTO); - }*/ factOriginExtractService.extractAll(extractOriginFormDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java index 5c03066bda..a55bf68e82 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java @@ -1,18 +1,14 @@ package com.epmet.controller; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.issue.form.IssueJobFromDTO; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsIssueService; -import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.io.Serializable; - /** * @author zhaoqifeng * @dscription @@ -25,28 +21,16 @@ public class StatsIssueController { private StatsIssueService statsIssueService; /** - * 议题统计 - * @author zhaoqifeng - * @date 2020/6/22 14:28 + * 议题统计 可制定日期和客户id + * * @param * @return com.epmet.commons.tools.utils.Result - */ - @PostMapping("issuestats") - public Result agencyGridIssueStats() { - statsIssueService.agencyGridIssueStats(); - return new Result(); - } - - /** - * 指定日期统计 * @author zhaoqifeng - * @date 2020/7/1 15:29 - * @param fromDTO - * @return com.epmet.commons.tools.utils.Result + * @date 2020/6/22 14:28 */ - @PostMapping("issuestatsofdate") - public Result agencyGridIssueStatsOfDate(@RequestBody IssueJobFromDTO fromDTO) { - statsIssueService.agencyGridIssueStatsOfDate(DateUtils.parse(fromDTO.getDate(), DateUtils.DATE_PATTERN)); + @PostMapping("issuestats") + public Result agencyGridIssueStats(@RequestBody(required = false) StatsFormDTO formDTO) { + statsIssueService.agencyGridIssueStats(formDTO); return new Result(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsPublicityController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsPublicityController.java index 91fea2b2db..11c08411a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsPublicityController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsPublicityController.java @@ -11,8 +11,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.concurrent.ExecutorService; - /** * desc:宣传能力controller */ @@ -24,8 +22,6 @@ public class StatsPublicityController { @Autowired private StatsPublicityService statsPublicityService; - @Autowired - private ExecutorService executorService; /** * desc:【日】统计文章总数及在线文章总数 包含 机关 部门 网格 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsTopicController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsTopicController.java index b2eb12c054..e76badc8a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsTopicController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsTopicController.java @@ -1,15 +1,14 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsTopicService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; - /** * @Description * @ClassName StatsTopicController @@ -24,8 +23,8 @@ public class StatsTopicController { private StatsTopicService statsTopicService; @PostMapping("execute") - public Result execute(@RequestParam(value = "date",required = false) Date date){ - statsTopicService.partition(date); + public Result execute(@RequestBody StatsFormDTO formDTO) { + statsTopicService.partition(formDTO); return new Result(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java index dd4a29fb9d..bc3ed0d09b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java @@ -1,15 +1,13 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsUserService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; - /** * @Description 用户统计 * @ClassName StatsUserController @@ -24,8 +22,8 @@ public class StatsUserController { private StatsUserService statsUserService; @RequestMapping("execute") - public Result execute(@RequestParam(value = "date",required = false) Date date){ - statsUserService.partition(date); + public Result execute(@RequestBody StatsFormDTO formDTO) { + statsUserService.partition(formDTO); return new Result(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java index faf90b5926..f5184b653a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java @@ -37,31 +37,33 @@ import java.util.List; public interface FactGroupAgencyDailyDao extends BaseDao { /** - * @Description 插入网格小组数据 【机关-日】 * @param agencyList + * @Description 插入网格小组数据 【机关-日】 * @author zxc */ void insertGroupAgencyDaily(@Param("agencyList") List agencyList); /** - * @Description 获取 网格小组【机关-日统计】的最后一天数据 * @param + * @param customerId + * @Description 获取 网格小组【机关-日统计】的最后一天数据 * @author zxc */ - List getLastDayAgency(@Param("dateId") String dateId); + List getLastDayAgency(@Param("customerId") String customerId, @Param("dateId") String dateId); /** - * @Description 查询 月的小组增量 + * @param customerId * @param monthId + * @Description 查询 月的小组增量 * @author zxc */ - List getMonthGroupIncr(@Param("monthId")String monthId); + List getMonthGroupIncr(@Param("customerId") String customerId, @Param("monthId") String monthId); /** - * @Description 删除当天已存在数据 * @param dateId + * @Description 删除当天已存在数据 * @author zxc */ - void deleteInsertAgencyDailyByDateId(@Param("dateId")String dateId,@Param("customerId")String customerId); - + void deleteInsertAgencyDailyByDateId(@Param("dateId") String dateId, @Param("customerId") String customerId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java index 7faf406333..5c76c715ee 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java @@ -1,5 +1,7 @@ package com.epmet.service; +import com.epmet.dto.StatsFormDTO; + import java.util.Date; /** @@ -10,21 +12,14 @@ import java.util.Date; public interface StatsIssueService { /** * 机关和网格议题统计 - * @author zhaoqifeng - * @date 2020/6/22 10:58 + * * @param + * @param formDTO * @return void - */ - void agencyGridIssueStats(); - - /** - * 指定日期议题统计 * @author zhaoqifeng - * @date 2020/6/28 11:01 - * @param date - * @return void + * @date 2020/6/22 10:58 */ - void agencyGridIssueStatsOfDate(Date date); + void agencyGridIssueStats(StatsFormDTO formDTO); /** * 机关下议题日统计 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsTopicService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsTopicService.java index 9e653812d3..0c17e21420 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsTopicService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsTopicService.java @@ -1,6 +1,6 @@ package com.epmet.service; -import java.util.Date; +import com.epmet.dto.StatsFormDTO; /** * @Description 话题统计Service接口 @@ -11,11 +11,11 @@ import java.util.Date; public interface StatsTopicService { /** - * @Description 分区统计,按照客户Id划分 - * @param date 如果目标日期为空,则自动计算为T-1天 + * @param formDTO 如果目标日期为空,则自动计算为T-1天 * @return + * @Description 分区统计,按照客户Id划分 * @author wangc * @date 2020.06.28 14:38 **/ - void partition(Date date); + void partition(StatsFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java index 6bf55f86ec..db22288094 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java @@ -1,6 +1,6 @@ package com.epmet.service; -import java.util.Date; +import com.epmet.dto.StatsFormDTO; /** * @author wangc @@ -10,11 +10,11 @@ import java.util.Date; public interface StatsUserService { /** - * @Description 分区统计,按照客户Id划分 - * @param date 如果目标日期为空,则自动计算为T-1天 + * @param formDTO 如果目标日期为空,则自动计算为T-1天 * @return + * @Description 分区统计,按照客户Id划分 * @author wangc * @date 2020.06.28 14:38 - **/ - void partition(Date date); + **/ + void partition(StatsFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java index bdbb60d9d7..3c58609ada 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java @@ -117,6 +117,10 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { ScreenUserJoinEntity entity = insertMap.get(gridId); entity.setJoinTotal(issue.getIssueIncr()); GridUserCountResultDTO user = userCountMap.get(gridId); + if (user == null) { + log.warn("gridId:{} is not exist in issue,customerId:{},monthId:{},gridId:{}", JSON.toJSONString(issue), formDTO.getCustomerId(), formDTO.getMonthId(), gridId); + return; + } //百人人均议题:统计周期内总的议题数/(注册用户数/100) log.debug("issue:{}", JSON.toJSONString(issue)); log.debug("user:{}", JSON.toJSONString(user)); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index 750f3f0255..5e4fde3280 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -52,61 +52,73 @@ public class StatsGroupServiceImpl implements StatsGroupService { private CustomerGridService customerGridService; /** - * @Description 统计【网格-日】 * @param + * @Description 统计【网格-日】 * @author zxc */ @Override public void groupGridDaily(GroupStatsFormDTO formDTO) { Integer pageNo = NumConstant.ONE; Integer pageSize = NumConstant.ONE_HUNDRED; - List customerIds; + List customerIds = new ArrayList<>(); + + if (StringUtils.isNotBlank(formDTO.getCustomerId())) { + customerIds.add(formDTO.getCustomerId()); + } else { + customerIds = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + } do { - customerIds = dimCustomerService.selectCustomerIdPage(pageNo++,pageSize); + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(formDTO); - if (customerIds.size() != NumConstant.ZERO){ + if (customerIds.size() != NumConstant.ZERO) { customerIds.forEach(customerId -> { try { List gridsInfo = customerGridService.getCustomerGridIdList(customerId, dimIdBean.getDateId()); - List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); - factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId); + List resultDTOS = groupDataService.groupGridDaily(customerId, dimIdBean, gridsInfo); + factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS, customerId); } catch (Exception e) { - log.error(String.format(GroupConstant.STATS_FAILED_GRID_DAILY,customerId,LocalDate.now(),e)); + log.error(String.format(GroupConstant.STATS_FAILED_GRID_DAILY, customerId, LocalDate.now(), e)); } }); } - }while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); + } while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); + } /** - * @Description 统计 “小组” 有关数据, dim:【机关-日】 + * @Description 统计 “小组” 有关数据, dim:【机关-日】 * @author zxc */ @Override public void groupAgencyDaily(GroupStatsFormDTO formDTO) { Integer pageNo = NumConstant.ONE; Integer pageSize = NumConstant.ONE_HUNDRED; - List customerIds; + List customerIds = new ArrayList<>(); + + if (StringUtils.isNotBlank(formDTO.getCustomerId())) { + customerIds.add(formDTO.getCustomerId()); + } else { + customerIds = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + } do { - customerIds = dimCustomerService.selectCustomerIdPage(pageNo++,pageSize); - if (customerIds.size() != NumConstant.ZERO){ + if (customerIds.size() != NumConstant.ZERO) { DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(formDTO); customerIds.forEach(customerId -> { try { List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); - factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId); + factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily, customerId); } catch (Exception e) { - log.error(String.format(GroupConstant.STATS_FAILED_AGENCY_DAILY,customerId,LocalDate.now(),e)); + log.error(String.format(GroupConstant.STATS_FAILED_AGENCY_DAILY, customerId, LocalDate.now(), e)); } }); } - }while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); + } while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); } /** - * @Description 统计 “小组” 有关数据, dim:【机关-月】 + * @Description 统计 “小组” 有关数据, dim:【机关-月】 * @author zxc String customerId */ @Override @@ -114,16 +126,16 @@ public class StatsGroupServiceImpl implements StatsGroupService { DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(formDTO); String monthId = dimIdBean.getMonthId(); String dateId = dimIdBean.getDateId(); - List lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(dateId); - List monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(monthId); - if (monthGroupIncr.size() == NumConstant.ZERO){ + List lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(formDTO.getCustomerId(), dateId); + List monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(formDTO.getCustomerId(), monthId); + if (monthGroupIncr.size() == NumConstant.ZERO) { lastDayAgency.forEach(agency -> { agency.setGroupIncr(NumConstant.ZERO); }); - }else { + } else { lastDayAgency.forEach(agency -> { monthGroupIncr.forEach(monthIncr -> { - if (agency.getAgencyId().equals(monthIncr.getAgencyId())){ + if (agency.getAgencyId().equals(monthIncr.getAgencyId())) { agency.setGroupIncr(monthIncr.getMonthGroupIncr()); } }); @@ -133,14 +145,14 @@ public class StatsGroupServiceImpl implements StatsGroupService { } /** - * @Description 网格小组 【机关-日】 数据统计处理 * @param customerAgencyInfos * @param timeDim * @param customerId + * @Description 网格小组 【机关-日】 数据统计处理 * @author zxc */ - public List getAgencyGroupDaily(List customerAgencyInfos, DimIdGenerator.DimIdBean timeDim,String customerId){ - if (customerAgencyInfos.size() == NumConstant.ZERO){ + public List getAgencyGroupDaily(List customerAgencyInfos, DimIdGenerator.DimIdBean timeDim, String customerId) { + if (customerAgencyInfos.size() == NumConstant.ZERO) { return new ArrayList<>(); } List result = new ArrayList<>(); @@ -152,9 +164,9 @@ public class StatsGroupServiceImpl implements StatsGroupService { agencyResult.setAgencyId(agencyId); agencyResult.setCustomerId(customerId); agencyResult.setPid(agency.getPid()); - BeanUtils.copyProperties(timeDim,agencyResult); + BeanUtils.copyProperties(timeDim, agencyResult); //机关下的所有网格(包括直属网格) - List allGrid = this.getAllGrid(agencyId,customerId); + List allGrid = this.getAllGrid(agencyId, customerId); if (allGrid.size() != NumConstant.ZERO) { // 1. 机关下有多少网格 (this.getAllGrid拿的是当前机关下所有网格,以下方法是根据“dateId”来拿的,两者过滤) List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); @@ -246,23 +258,23 @@ public class StatsGroupServiceImpl implements StatsGroupService { } /** - * @Description 根据当前机关ID,查询出直属网格和所有下级机关的网格 * @param agencyId + * @Description 根据当前机关ID,查询出直属网格和所有下级机关的网格 * @author zxc */ - public List getAllGrid(String agencyId,String customerId){ + public List getAllGrid(String agencyId, String customerId) { List result = new ArrayList<>(); List allAgency = dimAgencyService.getAllAgency(customerId); - Map> subGridOfAgency = new HashMap<>(); + Map> subGridOfAgency = new HashMap<>(); allAgency.forEach(agency -> { - this.initAgencyGridMap(agency.getAgencyId(),agency,subGridOfAgency); + this.initAgencyGridMap(agency.getAgencyId(), agency, subGridOfAgency); }); Set>> entries = subGridOfAgency.entrySet(); entries.forEach(entry -> { String key = entry.getKey(); Set value = entry.getValue(); - if (key.equals(agencyId)){ + if (key.equals(agencyId)) { result.addAll(value); } }); @@ -270,49 +282,49 @@ public class StatsGroupServiceImpl implements StatsGroupService { } /** - * @Description 递归获取机关下的网格id【包括直属机关】 * @param pid * @param agency * @param subGridOfAgency + * @Description 递归获取机关下的网格id【包括直属机关】 * @author zxc */ - void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map> subGridOfAgency){ + void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map> subGridOfAgency) { //向map中放入数据 - if(subGridOfAgency.containsKey(pid)){ + if (subGridOfAgency.containsKey(pid)) { //包含key Set grids = subGridOfAgency.get(pid); - if(null == grids){ + if (null == grids) { grids = new HashSet<>(); - subGridOfAgency.put(pid,grids); + subGridOfAgency.put(pid, grids); } - if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ + if (null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO) { grids.addAll(agency.getGridIds()); } - }else{ + } else { //不包含key Set grids = new HashSet<>(agency.getGridIds()); - subGridOfAgency.put(pid,grids); + subGridOfAgency.put(pid, grids); } //定义递归出口 - if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){ - return ; + if (StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY, agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO) { + return; } //定义递归入口 agency.getSubAgencies().forEach(obj -> { - initAgencyGridMap(pid,obj,subGridOfAgency); + initAgencyGridMap(pid, obj, subGridOfAgency); }); } /** - * @Description 获取时间维度 dateId--weekId--monthId--quarterId--yearId + * @param + * @Description 获取时间维度 dateId--weekId--monthId--quarterId--yearId * 如果有自定义时间,根据自定义时间获取时间维度 * 没有自定义时间,默认获取前一天的时间维度 - * @param * @author zxc */ - public DimIdGenerator.DimIdBean getDimIdBean(GroupStatsFormDTO formDTO){ - if (StringUtils.isNotBlank(formDTO.getDate())){ - return DimIdGenerator.getDimIdBean(DateUtils.parse(formDTO.getDate(),DateUtils.DATE_PATTERN)); + public DimIdGenerator.DimIdBean getDimIdBean(GroupStatsFormDTO formDTO) { + if (StringUtils.isNotBlank(formDTO.getDate())) { + return DimIdGenerator.getDimIdBean(DateUtils.parse(formDTO.getDate(), DateUtils.DATE_PATTERN)); } ZoneId zoneId = ZoneId.systemDefault(); LocalDate localDate = LocalDate.now().minusDays(NumConstant.ONE); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java index cd65b93af3..7c0a98776f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.IssueConstant; import com.epmet.constant.ProjectConstant; +import com.epmet.dto.StatsFormDTO; import com.epmet.dto.issue.IssueAgencyDTO; import com.epmet.dto.issue.IssueGridDTO; import com.epmet.dto.issue.IssueProjectDTO; @@ -23,6 +24,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.math.RoundingMode; @@ -57,20 +59,30 @@ public class StatsIssueServiceImpl implements StatsIssueService { private FactIssueGridMonthlyService factIssueGridMonthlyService; @Override - public void agencyGridIssueStats() { + public void agencyGridIssueStats(StatsFormDTO formDTO) { int pageNo = 1; int pageSize = 100; List customerIdList = null; do { - //获取当前日期前一天 - Date date = DateUtils.getBeforeDay(new Date()); - customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + //如果不是空则,获取当前日期前一天 + Date date = null; + if (!StringUtils.isEmpty(formDTO.getDate())) { + date = DateUtils.stringToDate(formDTO.getDate(), DateUtils.DATE_PATTERN); + } else { + date = DateUtils.getBeforeDay(new Date()); + } + if (StringUtils.isEmpty(formDTO.getCustomerId())) { + customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + } else { + customerIdList = new ArrayList<>(); + customerIdList.add(formDTO.getCustomerId()); + } if (!CollectionUtils.isEmpty(customerIdList)) { for (String customerId : customerIdList) { //遍历统计每一个客户数据 try { customerStats(customerId, date); - } catch(Exception e) { + } catch (Exception e) { log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", customerId, DateUtils.format(date)), e); } @@ -79,27 +91,6 @@ public class StatsIssueServiceImpl implements StatsIssueService { } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); } - @Override - public void agencyGridIssueStatsOfDate(Date date) { - int pageNo = 1; - int pageSize = 100; - List customerIdList = null; - do { - //获取当前日期前一天 - customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); - if (!CollectionUtils.isEmpty(customerIdList)) { - for (String customerId : customerIdList) { - //遍历统计每一个客户数据 - try { - customerStats(customerId, date); - } catch(Exception e) { - log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", DateUtils.format(date)), e); - } - } - } - } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); - } - /** * 一个客户一个线程, 分别统计机关日/月数据和网格日/月数据 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java index c5263c243b..af00a87d3b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java @@ -434,14 +434,12 @@ public class StatsProjectServiceImpl implements StatsProjectService { } //5.2:执行网格月数据统计 - //if (Calendar.getInstance().get(Calendar.DATE) == 1) { try { 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); } - //} } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java index e507b0e8ec..397fcefa7a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsPublicityServiceImpl.java @@ -198,7 +198,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { if (null != formDTO && StringUtils.isNotBlank(formDTO.getCustomerId())) { try { - log.info("tagUsedMonthlyStatsjob execute by customerId:{},dateId:{}", formDTO.getCustomerId(), dimIdBean.getDateId()); + log.info("tagUsedMonthlyStatsjob execute by customerId:{},monthId:{}", formDTO.getCustomerId(), dimIdBean.getMonthId()); statsTagUsedMonthly(dimIdBean.getMonthId(), formDTO.getCustomerId()); } catch (Exception e) { log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "tagUsedMonthlyStatsjob", formDTO.getCustomerId(), dimIdBean.getMonthId()), e); @@ -207,7 +207,7 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { int pageNo = NumConstant.ONE; int pageSize = NumConstant.ONE_HUNDRED; List customerIdList = null; - log.info("tagUsedMonthlyStatsjob execute all customerId,dateId:{}", dimIdBean.getDateId()); + log.info("tagUsedMonthlyStatsjob execute all customerId,monthId:{}", dimIdBean.getMonthId()); do { customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); if (!CollectionUtils.isEmpty(customerIdList)) { 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 911281919b..423c47174e 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,8 +2,10 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.ProjectConstant; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.StatsFormDTO; import com.epmet.dto.stats.DimTopicStatusDTO; import com.epmet.dto.stats.topic.result.TopicStatisticalData; import com.epmet.service.StatsTopicService; @@ -14,6 +16,7 @@ import com.epmet.service.stats.topic.TopicStatisticalService; import com.epmet.service.topic.TopicService; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,27 +52,35 @@ public class StatsTopicServiceImpl implements StatsTopicService { private TopicStatisticalService topicStatisticalService; /** - * @Description 分区统计,按照客户Id划分 - * @param date 如果目标日期为空,则自动计算为T-1天 + * @param formDTO 如果目标日期为空,则自动计算为T-1天 * @return + * @Description 分区统计,按照客户Id划分 * @author wangc * @date 2020.06.28 14:38 **/ @Override - public void partition(Date date) { + public void partition(StatsFormDTO formDTO) { int pageNo = NumConstant.ONE; int pageSize = NumConstant.ONE_HUNDRED; List customerIdList = null; - do { - customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); - if (!CollectionUtils.isEmpty(customerIdList)) { - for (String customerId : customerIdList) { - //遍历统计每一个客户数据 - generate(customerId,date); + Date date = null; + if (StringUtils.isNotBlank(formDTO.getDate())) { + date = DateUtils.stringToDate(formDTO.getDate(), DateUtils.DATE_PATTERN); + } + if (StringUtils.isNotBlank(formDTO.getCustomerId())) { + generate(formDTO.getCustomerId(), date); + } else { + do { + customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + if (!CollectionUtils.isEmpty(customerIdList)) { + for (String customerId : customerIdList) { + //遍历统计每一个客户数据 + generate(customerId, date); + } } - } - } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); + } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); + } } 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 17fd8ccfc6..35568a1e2f 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,8 +2,10 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.ProjectConstant; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.StatsFormDTO; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.service.StatsUserService; import com.epmet.service.stats.DimAgencyService; @@ -12,6 +14,7 @@ import com.epmet.service.stats.user.UserStatisticalService; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,26 +50,34 @@ public class StatsUserServiceImpl implements StatsUserService { private UserStatisticalService userStatisticalService; /** - * @Description 分区统计,按照客户Id划分 - * @param date 如果目标日期为空,则自动计算为T-1天 + * @param formDTO 如果目标日期为空,则自动计算为T-1天 * @return + * @Description 分区统计,按照客户Id划分 * @author wangc * @date 2020.06.28 14:38 **/ @Override - public void partition(Date date) { + public void partition(StatsFormDTO formDTO) { int pageNo = NumConstant.ONE; int pageSize = NumConstant.ONE_HUNDRED; List customerIdList = null; - do { - customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); - if (!CollectionUtils.isEmpty(customerIdList)) { - for (String customerId : customerIdList) { - //遍历统计每一个客户数据 - generate(customerId,date); + Date date = null; + if (StringUtils.isNotBlank(formDTO.getDate())) { + date = DateUtils.stringToDate(formDTO.getDate(), DateUtils.DATE_PATTERN); + } + if (StringUtils.isNotBlank(formDTO.getCustomerId())) { + generate(formDTO.getCustomerId(), date); + } else { + do { + customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + if (!CollectionUtils.isEmpty(customerIdList)) { + for (String customerId : customerIdList) { + //遍历统计每一个客户数据 + generate(customerId, date); + } } - } - } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); + } while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java index a52009fb46..812c2c73da 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java @@ -104,16 +104,18 @@ public interface FactGroupAgencyDailyService extends BaseService agencyList,String customerId); /** - * @Description 获取 网格小组【机关-日统计】的最后一天数据 * @param + * @param customerId + * @Description 获取 网格小组【机关-日统计】的最后一天数据 * @author zxc */ - List getLastDayAgency(String dateId); + List getLastDayAgency(String customerId, String dateId); /** - * @Description 查询 月的小组增量 + * @Description 查询 月的小组增量 + * @param customerId * @param monthId * @author zxc */ - List getMonthGroupIncr(String monthId); + List getMonthGroupIncr(String customerId, String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java index 21df7a0da4..d5030d68de 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java @@ -120,25 +120,28 @@ public class FactGroupAgencyDailyServiceImpl extends BaseServiceImpl getLastDayAgency(String dateId){ - return baseDao.getLastDayAgency(dateId); + @Override + public List getLastDayAgency(String customerId, String dateId) { + return baseDao.getLastDayAgency(customerId, dateId); } /** - * @Description 查询 月的小组增量 + * @Description 查询 月的小组增量 + * @param customerId * @param monthId * @author zxc */ @Override - public List getMonthGroupIncr(String monthId) { - if (StringUtils.isBlank(monthId)){ + public List getMonthGroupIncr(String customerId, String monthId) { + if (StringUtils.isBlank(monthId)) { return new ArrayList<>(); } - return baseDao.getMonthGroupIncr(monthId); + return baseDao.getMonthGroupIncr(customerId, monthId); } } \ No newline at end of file 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 faf43458cd..bc0a9e83d2 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 @@ -518,7 +518,6 @@ public class UserServiceImpl implements UserService { regGridD.setCustomerId(customerId); regGridD.setGridId(gridId); - regGridD.setCustomerId(customerId); regGridD.setAgencyId(agencyId);//网格直属得机关 regGridD.setDateId(timeDimension.getDateId()); regGridD.setWeekId(timeDimension.getWeekId()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml index 07f7b5a739..fbdcbe322e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml @@ -91,6 +91,9 @@ fact_group_agency_daily WHERE del_flag = '0' + + AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + AND date_id = #{dateId} @@ -103,6 +106,9 @@ fact_group_agency_daily WHERE del_flag = '0' + + AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + AND month_id = #{monthId} GROUP BY agency_id diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsIssueService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsIssueService.java index 0d2f89583c..3a7106ce2a 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsIssueService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsIssueService.java @@ -1,6 +1,7 @@ package com.epmet.service; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; /** * @author zhaoqifeng @@ -10,10 +11,11 @@ import com.epmet.commons.tools.utils.Result; public interface StatsIssueService { /** * 议题统计 - * @author zhaoqifeng - * @date 2020/6/23 14:39 + * * @param * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/6/23 14:39 */ - Result agencyGridIssueStats(String params); + Result agencyGridIssueStats(StatsFormDTO formDTO); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsTopicService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsTopicService.java index 1c8c8e07f1..a7cb94d8df 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsTopicService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsTopicService.java @@ -1,15 +1,16 @@ package com.epmet.service; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; public interface StatsTopicService { /** - * @Description 调用统计服务执行统计 - 话题 * @param * @return + * @Description 调用统计服务执行统计 - 话题 * @author wangc * @date 2020.06.29 09:40 - **/ - Result execTopicStatistical(String date); + **/ + Result execTopicStatistical(StatsFormDTO formDTO); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsUserService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsUserService.java index 334f39f7ef..3d3556d3d4 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsUserService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsUserService.java @@ -1,15 +1,16 @@ package com.epmet.service; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; public interface StatsUserService { /** - * @Description 调用统计服务-用户 * @param * @return + * @Description 调用统计服务-用户 * @author wangc * @date 2020.06.29 09:39 - **/ - Result execUserStatistical(String date); + **/ + Result execUserStatistical(StatsFormDTO formDTO); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java index 6612488799..9017f014d6 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java @@ -1,10 +1,9 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.issue.form.IssueJobFromDTO; -import com.epmet.service.StatsIssueService; +import com.epmet.dto.StatsFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; -import org.apache.commons.lang3.StringUtils; +import com.epmet.service.StatsIssueService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,12 +18,7 @@ public class StatsIssueServiceImpl implements StatsIssueService { private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; @Override - public Result agencyGridIssueStats(String params) { - if (StringUtils.isNotBlank(params)) { - IssueJobFromDTO dto = new IssueJobFromDTO(); - dto.setDate(params); - return dataStatisticalOpenFeignClient.agencyGridIssueStatsOfDate(dto); - } - return dataStatisticalOpenFeignClient.agencyGridIssueStats(); + public Result agencyGridIssueStats(StatsFormDTO formDTO) { + return dataStatisticalOpenFeignClient.agencyGridIssueStats(formDTO); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java index cefabfbdc7..ab62cf84f2 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsTopicServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; import com.epmet.service.StatsTopicService; import org.slf4j.Logger; @@ -9,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - /** * @Description * @ClassName StatsTopicServiceImpl @@ -25,8 +25,7 @@ public class StatsTopicServiceImpl implements StatsTopicService { private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; @Override - public Result execTopicStatistical(String date) { - - return dataStatisticalOpenFeignClient.execTopicStatistical(date); + public Result execTopicStatistical(StatsFormDTO formDTO) { + return dataStatisticalOpenFeignClient.execTopicStatistical(formDTO); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java index 3082f91779..b866699850 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; import com.epmet.service.StatsUserService; import org.slf4j.Logger; @@ -25,7 +26,7 @@ public class StatsUserServiceImpl implements StatsUserService { private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; @Override - public Result execUserStatistical(String date) { - return dataStatisticalOpenFeignClient.execUserStatistical(date); + public Result execUserStatistical(StatsFormDTO formDTO) { + return dataStatisticalOpenFeignClient.execUserStatistical(formDTO); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsIssueTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsIssueTask.java index a69eebd61a..61983218d3 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsIssueTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsIssueTask.java @@ -1,8 +1,11 @@ package com.epmet.task; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsIssueService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,10 +23,14 @@ public class StatsIssueTask implements ITask { @Override public void run(String params) { log.info("StatsGroupGridDailyTask定时任务正在执行,参数为:{}", params); - Result result = statsIssueService.agencyGridIssueStats(params); - if (result.success()){ + StatsFormDTO formDTO = new StatsFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, StatsFormDTO.class); + } + Result result = statsIssueService.agencyGridIssueStats(formDTO); + if (result.success()) { log.info("StatsGroupGridDailyTask定时任务执行成功"); - }else { + } else { log.error("StatsGroupGridDailyTask定时任务执行失败:" + result.getMsg()); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsTopicTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsTopicTask.java index 1f454d0f79..ae3fa73c76 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsTopicTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsTopicTask.java @@ -1,7 +1,10 @@ package com.epmet.task; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsTopicService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,10 +27,14 @@ public class StatsTopicTask implements ITask { @Override public void run(String params) { logger.info("StatsTopicTask定时任务正在执行,参数为:{}", params); - Result result = statsTopicService.execTopicStatistical(params); - if (result.success()){ + StatsFormDTO statsFormDTO = new StatsFormDTO(); + if (StringUtils.isNotBlank(params)) { + statsFormDTO = JSON.parseObject(params, StatsFormDTO.class); + } + Result result = statsTopicService.execTopicStatistical(statsFormDTO); + if (result.success()) { logger.info("StatsTopicTask定时任务执行成功"); - }else { + } else { logger.error("StatsTopicTask定时任务执行失败:" + result.getMsg()); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsUserTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsUserTask.java index d8d5fffe80..a1414d6d54 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsUserTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/StatsUserTask.java @@ -1,7 +1,10 @@ package com.epmet.task; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StatsFormDTO; import com.epmet.service.StatsUserService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,10 +27,14 @@ public class StatsUserTask implements ITask { @Override public void run(String params) { logger.info("StatsUserTask定时任务正在执行,参数为:{}", params); - Result result = statsUserService.execUserStatistical(params); - if (result.success()){ + StatsFormDTO formDTO = new StatsFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, StatsFormDTO.class); + } + Result result = statsUserService.execUserStatistical(formDTO); + if (result.success()) { logger.info("StatsUserTask定时任务执行成功"); - }else { + } else { logger.error("StatsUserTask定时任务执行失败:" + result.getMsg()); } }