From 98d1a6d49c66e235cab973cbc836cdc82fa6deba Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 27 Sep 2020 17:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=82=E4=B8=8E=E8=81=94?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/extract/form/ExtractScreenFormDTO.java | 4 ++++ .../controller/ScreenExtractDailyController.java | 7 ++++--- .../extract/toscreen/ScreenExtractService.java | 5 +++-- .../impl/PublicPartExtractServiceImpl.java | 10 +++++++--- .../toscreen/impl/ScreenExtractServiceImpl.java | 14 +++++++------- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractScreenFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractScreenFormDTO.java index 4bcd4fce65..c4cff4cf5b 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractScreenFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractScreenFormDTO.java @@ -17,5 +17,9 @@ public class ExtractScreenFormDTO implements Serializable { private String customerId; private String monthId; private String dateId; + private String startMonth; + private String endMonth; + private String startDate; + private String endDate; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index 4d05009ec8..c83a07427d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -2,6 +2,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -33,14 +34,14 @@ public class ScreenExtractDailyController { } /** - * @param extractOriginFormDTO + * @param formDTO * @Description 抽取数据到大屏【月】 * @author zxc * @date 2020/9/24 10:15 上午 */ @PostMapping("extractmonthlyyall") - public Result screenExtractMonthly(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - screenExtractService.extractDailyAll(extractOriginFormDTO); + public Result screenExtractMonthly(@RequestBody ExtractScreenFormDTO formDTO) { + screenExtractService.extractMonthlyAll(formDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java index 7b5ee20155..eefe383408 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/ScreenExtractService.java @@ -1,6 +1,7 @@ package com.epmet.service.evaluationindex.extract.toscreen; import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.extract.form.ExtractScreenFormDTO; /** * @Author zxc @@ -17,11 +18,11 @@ public interface ScreenExtractService { void extractDailyAll(ExtractOriginFormDTO extractOriginFormDTO); /** - * @param extractOriginFormDTO + * @param formDTO * @Description 抽取数据到大屏【月】 * @author zxc * @date 2020/9/24 10:15 上午 */ - void extractMonthlyAll(ExtractOriginFormDTO extractOriginFormDTO); + void extractMonthlyAll(ExtractScreenFormDTO 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 68f4886f8f..3146e15a43 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 @@ -119,8 +119,12 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { entity.setJoinTotal(issue.getIssueIncr()); GridUserCountResultDTO user = userCountMap.get(gridId); //百人人均议题:统计周期内总的议题数/(注册用户数/100) - BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()).divide(new BigDecimal(NumConstant.ONE_HUNDRED))); - entity.setAvgIssue(avgIssueCount); + log.debug("issue:{}", JSON.toJSONString(issue)); + log.debug("user:{}", JSON.toJSONString(user)); + if (!user.getRegTotal().equals(0)) { + BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()).divide(new BigDecimal(NumConstant.ONE_HUNDRED))); + entity.setAvgIssue(avgIssueCount); + } }); @@ -227,7 +231,7 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { } private void buildUserJoinEntity(ExtractScreenFormDTO formDTO, Object org, Map result) { - DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(DateUtils.stringToDate(formDTO.getMonthId(), DateUtils.DATE_PATTERN_YYYYMMDD)); + DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(DateUtils.stringToDate(formDTO.getMonthId(), DateUtils.DATE_PATTERN_YYYYMM)); ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(dimIdBean, ScreenUserJoinEntity.class); if (org instanceof DimGridEntity) { DimGridEntity grid = (DimGridEntity) org; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index 7853b0c69b..acbb43dcbf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -71,7 +71,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } @Override - public void extractMonthlyAll(ExtractOriginFormDTO formDTO) { + public void extractMonthlyAll(ExtractScreenFormDTO formDTO) { List customerIds = new ArrayList<>(); if (StringUtils.isNotBlank(formDTO.getCustomerId())) { @@ -83,13 +83,13 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } if (!CollectionUtils.isEmpty(customerIds)) { customerIds.forEach(customerId -> { - if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { - List daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); - daysBetween.forEach(dateId -> { - extractMonthly(customerId, dateId); + if (StringUtils.isNotBlank(formDTO.getStartMonth()) && StringUtils.isNotBlank(formDTO.getEndMonth())) { + List daysBetween = DateUtils.getMonthBetween(formDTO.getStartDate(), formDTO.getEndDate()); + daysBetween.forEach(monthId -> { + extractMonthly(customerId, monthId); }); - } else if (StringUtils.isNotBlank(formDTO.getDateId())) { - extractMonthly(customerId, formDTO.getDateId()); + } else if (StringUtils.isNotBlank(formDTO.getMonthId())) { + extractMonthly(customerId, formDTO.getMonthId()); } else { String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""); extractMonthly(customerId, dateId);