From a293b504e5c572abe01d471c991badc61bbcf69b Mon Sep 17 00:00:00 2001 From: Caps <452713115@qq.com> Date: Sun, 26 Apr 2020 15:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E7=AE=A1=E7=90=86=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E5=85=AC=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/RetailCompanyService.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java b/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java index e0b6740..57135dc 100644 --- a/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java +++ b/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java @@ -377,12 +377,12 @@ public class RetailCompanyService { //计算两个时间间隔用于计算平均值 LocalDate start = LocalDate.parse(startTime); LocalDate end = LocalDate.parse(endTime); - long days = end.until(start, ChronoUnit.DAYS); + long days = end.until(start, ChronoUnit.DAYS) + 1; organizationalVO.setNewCustomer((int) (countEnd - count)); organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2)); - organizationalVO.setAvgNewCustomer(check(countEnd - count, days)); - organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2, days)); + organizationalVO.setAvgNewCustomer(check1(countEnd - count, days)); + organizationalVO.setAvgNewEffectiveCustomer(check1(countEnd2 - count2, days)); } private void newCustomerStore(String startTime, String endTime, DataVO organizationalVO, List storeIds) { @@ -436,6 +436,20 @@ public class RetailCompanyService { return Math.round((l1 / l2) * 100); } } + /** + * 除法计算 + * + * @param l1 被除数 + * @param l2 除数 + * @return 值 + */ + public Integer check1(Long l1, Long l2) { + if (l2 == null || l1 == null || l2 == 0) { + return 0; + } else { + return Math.round((l1 / l2)); + } + } /** * 查询门店推广数据