From fca8867d69670b3723cf9e77945e54d6a9cb6703 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 2 Mar 2021 10:48:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8D=E5=8F=82=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GrassrootsPartyDevServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassrootsPartyDevServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassrootsPartyDevServiceImpl.java index 6285e007f4..6c94e983ec 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassrootsPartyDevServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassrootsPartyDevServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.evaluationindex.screen.GrassrootsPartyDevService; import com.epmet.datareport.utils.DateUtils; import com.epmet.datareport.utils.ModuleConstant; +import com.epmet.evaluationindex.screen.constant.ScreenConstant; import com.epmet.evaluationindex.screen.dto.form.BranchBuildRankFormDTO; import com.epmet.evaluationindex.screen.dto.form.BranchBuildTrendFormDTO; import com.epmet.evaluationindex.screen.dto.form.ParymemberFormDTO; @@ -78,7 +79,7 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService if(null == result.getPlatFormTotal() || NumConstant.ZERO == result.getPlatFormTotal()){ result.setPercentInPlatForm(convertPercentStr(BigDecimal.ZERO)); }else{ - result.setPercentInPlatForm(convertPercentStr(new BigDecimal((result.getPartyMemberTotal().doubleValue()/result.getPlatFormTotal().doubleValue())))); + result.setPercentInPlatForm(getRatio(result.getPartyMemberTotal(),result.getPlatFormTotal())); } return result; } @@ -96,11 +97,21 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService if(null == result.getPlatFormTotal() || NumConstant.ZERO == result.getPlatFormTotal()){ result.setPercentInPlatForm(convertPercentStr(BigDecimal.ZERO)); }else{ - result.setPercentInPlatForm(convertPercentStr(new BigDecimal((result.getPartyMemberTotal().doubleValue()/result.getPlatFormTotal().doubleValue())))); + result.setPercentInPlatForm(getRatio(result.getPartyMemberTotal(),result.getPlatFormTotal())); } return result; } + public String getRatio(Integer partyMemberTotal, Integer platFormTotal){ + if (null == partyMemberTotal || null == platFormTotal || partyMemberTotal == NumConstant.ZERO || platFormTotal == NumConstant.ZERO){ + return "0.00%"; + } + BigDecimal aDecimal = new BigDecimal(partyMemberTotal); + BigDecimal bDecimal = new BigDecimal(platFormTotal); + BigDecimal result = aDecimal.divide(bDecimal, NumConstant.FOUR, BigDecimal.ROUND_HALF_UP); + return result.multiply(NumConstant.ONE_HUNDRED_DECIMAL).setScale(NumConstant.TWO,BigDecimal.ROUND_HALF_UP).toPlainString().concat(ScreenConstant.RATIO); + } + /** * @Description 2、党员基本情况-年龄分布 * @NEI https://nei.netease.com/interface/detail/req/?pid=57068&id=321980