From f249e12963f9512a5d665eb57a1e5440c156bd85 Mon Sep 17 00:00:00 2001 From: 张天森 <1292933220@qq.com> Date: 星期五, 08 七月 2022 17:17:56 +0800 Subject: [PATCH] update --- springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java index 9e94005..c1a6e1e 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java @@ -3349,7 +3349,12 @@ vo.setRealUsersMonth(realUsersMonth); vo.setRealUser(getStreetRealUser(realUsersTotal)); vo.setRealUserRate(getRate(vo.getAllUser(),vo.getRealUser())); - vo.setUserActivityXAll(getTwentyDays()); + List<Date> twentyDays = getTwentyDays(); + SimpleDateFormat sdf1=new SimpleDateFormat("MM"); + for (Date twentyDay : twentyDays) { + sdf1.format(twentyDay); + } + vo.setUserActivityXAll(getTwentyDays()); vo.setUserActivityXMonth(getMonthTwentyDays()); List<String> addUserYAll=new ArrayList<>(); List<String> addUserYMonth=new ArrayList<>(); @@ -3374,8 +3379,8 @@ vo.setActiveUserYMonth(activeUserYMonth); if (type.equals(BYSTREET) || type.equals(ALLCOMMUNITY) || type.equals(ALLSTREET)){ //获取其他用户 - vo.setOtherUser(indexDataKanbanVO.getAllUser()-vo.getAllUser()); - vo.setOtherUserRate(getRate(indexDataKanbanVO.getAllUser(),vo.getAllUser())); + vo.setOtherUser(indexDataKanbanVO.getAllUser()-countUser(vo.getUserProportionTotal())); + vo.setOtherUserRate(getRate(indexDataKanbanVO.getAllUser(),vo.getOtherUser())); } return R.ok(vo); } @@ -3426,7 +3431,7 @@ private Double getRate(Integer total,Integer count){ if (0 != total && null != total){ if (0 != count && null != count){ - BigDecimal div = NumberUtil.div(count.toString(), total.toString(),1); + BigDecimal div = NumberUtil.div(count.toString(), total.toString(),2); return div.doubleValue(); } } @@ -3451,4 +3456,21 @@ return count; } + /** + * 计算当前统计范围内的所有用户数 + * */ + public Integer countUser(List<UserProportion> list){ + Integer count=0; + if (list.size()>0){ + for (UserProportion proportion : list) { + if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(proportion)){ + if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(proportion.getUser())){ + count+=proportion.getUser(); + } + } + } + } + return count; + } + } -- Gitblit v1.7.1