From b0f912f089e3e52310f47ab4f6fbeb88161be913 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Sun, 28 Jun 2020 14:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=9D=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/topic/impl/TopicServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java index f63d887dd9..3b81c15cfa 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.DecimalFormat; import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -182,8 +183,9 @@ public class TopicServiceImpl implements TopicService { TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); if (topicSummaryInfo.size() != NumConstant.ZERO && shiftedCount != null) { Integer collect = topicSummaryInfo.stream().collect(Collectors.summingInt(TopicSummaryInfoResultDTO::getValue)); + DecimalFormat decimalFormat = new DecimalFormat(".00"); String ratio; - ratio = collect == NumConstant.ZERO ? NumConstant.ZERO + TopicConstant.RATIO : ((float) shiftedCount.getShiftedIssueCount() / (float) collect) * NumConstant.ONE_HUNDRED + TopicConstant.RATIO; + ratio = collect == NumConstant.ZERO ? NumConstant.ZERO + TopicConstant.RATIO : decimalFormat.format(((float) shiftedCount.getShiftedIssueCount() / (float) collect) * NumConstant.ONE_HUNDRED) + TopicConstant.RATIO; TopicSummaryInfoResultDTO result = new TopicSummaryInfoResultDTO(); result.setName(TopicConstant.SHIFTED); result.setRatio(ratio);