From 83c1a766957e4c74ea6e81c6e9b18f1b692b1b7b Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期六, 26 八月 2023 17:50:40 +0800
Subject: [PATCH] bug

---
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java |   92 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 85 insertions(+), 7 deletions(-)

diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
index 807442b..1c29ef1 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
@@ -1242,6 +1242,9 @@
         BigDecimal bigTen = new BigDecimal("100.00");
         BigDecimal menPercent = new BigDecimal("100.00");
         BigDecimal womenPercent = new BigDecimal("100.00");
+        if(personTotal==0){
+            personTotalBig = bigTen;
+        }
         if(manTotal==0&&womenTotal==0){
             menPercent = new BigDecimal("50.00");
             womenPercent = new BigDecimal("50.00");
@@ -1252,7 +1255,7 @@
             menPercent = new BigDecimal("100.00");
             womenPercent = new BigDecimal("0.00");
         }else{
-            menPercent = manTotalBig.divide(personTotalBig).setScale(0,BigDecimal.ROUND_HALF_UP);
+            menPercent = manTotalBig.divide(personTotalBig,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
             womenPercent = bigTen.subtract(menPercent);
         }
         mgtTotalMemberTotalVo.setManPercent(menPercent);
@@ -1261,6 +1264,18 @@
         String[] ageKey = {"<20", "21-30", "31-40", "41-50", ">50"};
         // 不同年龄段的会员数数组
         Integer[] ageValue = {mgtAgeTotalVo.getTenAge(), mgtAgeTotalVo.getTwentyAge(), mgtAgeTotalVo.getThirtyAge(), mgtAgeTotalVo.getFortyAge(), mgtAgeTotalVo.getFiftyAge()};
+        BigDecimal[] agePercentValue = new BigDecimal[5];
+        Integer totalPerson = mgtAgeTotalVo.getTenAge()+mgtAgeTotalVo.getTwentyAge()+ mgtAgeTotalVo.getThirtyAge()+mgtAgeTotalVo.getFortyAge()+mgtAgeTotalVo.getFiftyAge();
+        BigDecimal totalPersonBig = new BigDecimal(totalPerson.toString());
+        BigDecimal hundredBig = new BigDecimal("100");
+        if(totalPerson==0){
+            totalPersonBig = hundredBig;
+        }
+        agePercentValue[0] = new BigDecimal(mgtAgeTotalVo.getTenAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[1] = new BigDecimal(mgtAgeTotalVo.getTwentyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[2] = new BigDecimal(mgtAgeTotalVo.getThirtyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[3] = new BigDecimal(mgtAgeTotalVo.getFortyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[4] = new BigDecimal(mgtAgeTotalVo.getFiftyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
         // 设置年龄段数组和不同年龄段的会员数数组
         mgtTotalMemberTotalVo.setAgeKey(ageKey);
         mgtTotalMemberTotalVo.setAgeValue(ageValue);
@@ -1362,20 +1377,55 @@
         MgtPlTotalMemberTotalVo plTotalMemberTotalVo = memberMapper.getPlTotalMemberTotal(mgtBasePlatformDto);
         MgtAgeTotalVo mgtAgeTotalVo = memberMapper.getPlTotalMemberTotalAge(mgtBasePlatformDto);
         if (mgtAgeTotalVo != null) {
-            plTotalMemberTotalVo.setManTotal(mgtAgeTotalVo.getManTotal());
-            plTotalMemberTotalVo.setWomenTotal(mgtAgeTotalVo.getWomenTotal());
-        } else {
-            plTotalMemberTotalVo.setManTotal(0);
-            plTotalMemberTotalVo.setWomenTotal(0);
+            Integer manTotal = mgtAgeTotalVo.getManTotal();
+            Integer womenTotal = mgtAgeTotalVo.getWomenTotal();
+            Integer personTotal = manTotal + womenTotal;
+            BigDecimal manTotalBig = new BigDecimal(manTotal);
+            BigDecimal personTotalBig = new BigDecimal(personTotal);
+            BigDecimal bigTen = new BigDecimal("100.00");
+            BigDecimal menPercent = new BigDecimal("100.00");
+            BigDecimal womenPercent = new BigDecimal("100.00");
+            if(personTotal==0){
+                personTotalBig = bigTen;
+            }
+            if(manTotal==0&&womenTotal==0){
+                menPercent = new BigDecimal("50.00");
+                womenPercent = new BigDecimal("50.00");
+            }else if(manTotal==0&&womenTotal>0){
+                menPercent = new BigDecimal("0.00");
+                womenPercent = new BigDecimal("100.00");
+            }else if(manTotal>0&&womenTotal==0){
+                menPercent = new BigDecimal("100.00");
+                womenPercent = new BigDecimal("0.00");
+            }else{
+                menPercent = manTotalBig.divide(personTotalBig,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+                womenPercent = bigTen.subtract(menPercent);
+            }
+            plTotalMemberTotalVo.setManTotal(manTotal);
+            plTotalMemberTotalVo.setWomenTotal(womenTotal);
+            plTotalMemberTotalVo.setManPercent(menPercent);
+            plTotalMemberTotalVo.setWomenPercent(womenPercent);
         }
-
         // 年龄段数组
         String[] ageKey = {"<20", "21-30", "31-40", "41-50", ">50"};
         // 不同年龄段的会员数数组
         Integer[] ageValue = {mgtAgeTotalVo.getTenAge(), mgtAgeTotalVo.getTwentyAge(), mgtAgeTotalVo.getThirtyAge(), mgtAgeTotalVo.getFortyAge(), mgtAgeTotalVo.getFiftyAge()};
+        BigDecimal[] agePercentValue = new BigDecimal[5];
+        Integer totalPerson = mgtAgeTotalVo.getTenAge()+mgtAgeTotalVo.getTwentyAge()+ mgtAgeTotalVo.getThirtyAge()+mgtAgeTotalVo.getFortyAge()+mgtAgeTotalVo.getFiftyAge();
+        BigDecimal totalPersonBig = new BigDecimal(totalPerson.toString());
+        BigDecimal hundredBig = new BigDecimal("100");
+        if(totalPerson==0){
+            totalPersonBig = hundredBig;
+        }
+        agePercentValue[0] = new BigDecimal(mgtAgeTotalVo.getTenAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[1] = new BigDecimal(mgtAgeTotalVo.getTwentyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[2] = new BigDecimal(mgtAgeTotalVo.getThirtyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[3] = new BigDecimal(mgtAgeTotalVo.getFortyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[4] = new BigDecimal(mgtAgeTotalVo.getFiftyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
         // 设置年龄段数组和不同年龄段的会员数数组
         plTotalMemberTotalVo.setAgeKey(ageKey);
         plTotalMemberTotalVo.setAgeValue(ageValue);
+        plTotalMemberTotalVo.setAgePercent(agePercentValue);
         // 获取不同调理类型的会员数
         List<MgtMapIntTotalVo> nurseTotalVos = memberMapper.getPlTotalMemberTotalNurse(mgtBasePlatformDto);
         if (nurseTotalVos != null && nurseTotalVos.size() > 0) {
@@ -1492,6 +1542,18 @@
         String[] ageKey = {"<20", "21-30", "31-40", "41-50", ">50"};
         // 不同年龄段的会员数数组
         Integer[] ageValue = {mgtAgeTotalVo.getTenAge(), mgtAgeTotalVo.getTwentyAge(), mgtAgeTotalVo.getThirtyAge(), mgtAgeTotalVo.getFortyAge(), mgtAgeTotalVo.getFiftyAge()};
+        BigDecimal[] agePercentValue = new BigDecimal[5];
+        Integer totalPerson = mgtAgeTotalVo.getTenAge()+mgtAgeTotalVo.getTwentyAge()+ mgtAgeTotalVo.getThirtyAge()+mgtAgeTotalVo.getFortyAge()+mgtAgeTotalVo.getFiftyAge();
+        BigDecimal totalPersonBig = new BigDecimal(totalPerson.toString());
+        BigDecimal hundredBig = new BigDecimal("100");
+        if(totalPerson==0){
+            totalPersonBig = hundredBig;
+        }
+        agePercentValue[0] = new BigDecimal(mgtAgeTotalVo.getTenAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[1] = new BigDecimal(mgtAgeTotalVo.getTwentyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[2] = new BigDecimal(mgtAgeTotalVo.getThirtyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[3] = new BigDecimal(mgtAgeTotalVo.getFortyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[4] = new BigDecimal(mgtAgeTotalVo.getFiftyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
         // 设置年龄段数组和不同年龄段的会员数数组
         mgtShopTotalMemberVo.setAgeKey(ageKey);
         mgtShopTotalMemberVo.setAgeValue(ageValue);
@@ -1629,6 +1691,9 @@
         BigDecimal bigTen = new BigDecimal("100.00");
         BigDecimal menPercent = new BigDecimal("100.00");
         BigDecimal womenPercent = new BigDecimal("100.00");
+        if(personTotal==0){
+            personTotalBig = bigTen;
+        }
         if(manTotal==0&&womenTotal==0){
             menPercent = new BigDecimal("50.00");
             womenPercent = new BigDecimal("50.00");
@@ -1648,9 +1713,22 @@
         String[] ageKey = {"<20", "21-30", "31-40", "41-50", ">50"};
         // 不同年龄段的会员数数组
         Integer[] ageValue = {mgtAgeTotalVo.getTenAge(), mgtAgeTotalVo.getTwentyAge(), mgtAgeTotalVo.getThirtyAge(), mgtAgeTotalVo.getFortyAge(), mgtAgeTotalVo.getFiftyAge()};
+        BigDecimal[] agePercentValue = new BigDecimal[5];
+        Integer totalPerson = mgtAgeTotalVo.getTenAge()+mgtAgeTotalVo.getTwentyAge()+ mgtAgeTotalVo.getThirtyAge()+mgtAgeTotalVo.getFortyAge()+mgtAgeTotalVo.getFiftyAge();
+        BigDecimal totalPersonBig = new BigDecimal(totalPerson.toString());
+        BigDecimal hundredBig = new BigDecimal("100");
+        if(totalPerson==0){
+            totalPersonBig = hundredBig;
+        }
+        agePercentValue[0] = new BigDecimal(mgtAgeTotalVo.getTenAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[1] = new BigDecimal(mgtAgeTotalVo.getTwentyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[2] = new BigDecimal(mgtAgeTotalVo.getThirtyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[3] = new BigDecimal(mgtAgeTotalVo.getFortyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
+        agePercentValue[4] = new BigDecimal(mgtAgeTotalVo.getFiftyAge().toString()).divide(totalPersonBig,2,BigDecimal.ROUND_HALF_UP).multiply(hundredBig);
         // 设置年龄段数组和不同年龄段的会员数数组
         memberFixedTotalVo.setAgeKey(ageKey);
         memberFixedTotalVo.setAgeValue(ageValue);
+        memberFixedTotalVo.setAgePercentValue(agePercentValue);
         // 获取不同护理类型的会员数
         List<MgtMapIntTotalVo> nurseTotalVos = memberMapper.getMerMemberTotalNurse(merTotalDto);
         if (nurseTotalVos != null && nurseTotalVos.size() > 0) {

--
Gitblit v1.7.1