From 696be1898b573015ea649471c44f3331f9117c42 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 21 Sep 2020 14:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3-=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E8=83=BD=E5=8A=9BV0.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/heart/ActInfoDao.java | 9 ++ .../epmet/dao/partymember/PartyMemberDao.java | 8 ++ .../main/java/com/epmet/dao/user/UserDao.java | 10 ++ .../extract/impl/CalCpcIndexServiceImpl.java | 2 +- .../extract/impl/CalGridIndexServiceImpl.java | 95 ++++++++++++++++++- .../resources/mapper/heart/ActInfoDao.xml | 14 +++ .../mapper/partymember/PartyMemberDao.xml | 15 +++ .../main/resources/mapper/user/UserDao.xml | 13 +++ 8 files changed, 160 insertions(+), 6 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java index 5c3dfddd3d..1381898f01 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java @@ -41,4 +41,13 @@ public interface ActInfoDao{ * @Date 2020/9/21 10:41 **/ List> selectActGroupByGridId(@Param("customerId") String customerId, @Param("monthId") String monthId); + + /** + * @return java.util.List + * @param regUserIds + * @author yinzuomei + * @description 根据userId,查询用户是否是志愿者,返回是志愿者的用户集合 + * @Date 2020/9/21 13:55 + **/ + List selectGridRegUserVolunteer(@Param("list") List regUserIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java index 7927e8bee1..18b44ea8e0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java @@ -36,4 +36,12 @@ public interface PartyMemberDao{ */ List selectPartyMemberByCustomer(@Param("customerId") String customerId); + /** + * @return java.util.List + * @param volunteerUserIds + * @author yinzuomei + * @description 志愿者中,同时是党员的人数 + * @Date 2020/9/21 14:13 + **/ + List selectVolunteerPartyUserIds(@Param("list") List volunteerUserIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index 22372cbed4..28c0a2c389 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java @@ -111,4 +111,14 @@ public interface UserDao { List selectPartymembersByCustomerId(@Param("customerId")String customerId); List selectWarmHeartedByCustomerId(@Param("customerId")String customerId); + + /** + * @param customerId + * @param gridId + * @return java.util.List + * @author yinzuomei + * @description 查询当前网格下,首次注册的用户ids + * @Date 2020/9/21 13:46 + **/ + List selectGridRegUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java index 0b64d285fa..4296506ab8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java @@ -396,7 +396,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { continue; } NumberFormat numberFormat = NumberFormat.getInstance(); - numberFormat.setMaximumFractionDigits(6); + numberFormat.setMaximumFractionDigits(NumConstant.SIX); String topicToIssueRatioStr = numberFormat.format((float) projectTotal / issueTotal); BigDecimal topicToIssueRatio = new BigDecimal(topicToIssueRatioStr); map.put(partyMember.getUserId(), topicToIssueRatio); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java index 082fc28114..86eff5d1ca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java @@ -11,6 +11,8 @@ import com.epmet.constant.ProjectEvaluateConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; import com.epmet.dao.heart.ActInfoDao; +import com.epmet.dao.partymember.PartyMemberDao; +import com.epmet.dao.user.UserDao; import com.epmet.dto.extract.form.GovernAbilityGridMonthlyFormDTO; import com.epmet.dto.extract.form.GridIssueCountResultDTO; import com.epmet.dto.extract.form.PartyAbilityGridMonthlyFormDTO; @@ -27,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.text.NumberFormat; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -70,6 +74,11 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao; @Autowired private ActInfoDao actInfoDao; + @Autowired + private UserDao userDao; + @Autowired + private PartyMemberDao partyMemberDao; + /** * @Description 计算网格指标党建能力 * @param customerId @@ -391,14 +400,52 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { entity.setMonthId(monthId); entity.setQuarterId(quarterId); entity.setYearId(yearId); - //网格活动组织次数 爱心活动 + //网格活动组织次数 爱心活动 : 活动状态已结束并且实际结束时间在评价周期内的 if(activityCountMap.containsKey(entity.getGridId())){ entity.setActivityCount(activityCountMap.get(entity.getGridId())); } - //网格志愿者占比 todo -// entity.setVolunteerRatio(); - //网格党员志愿者率 todo -// entity.setPartyVolunteerRatio(); + + List volunteerUserIds=new ArrayList<>(); + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.SIX); + //网格志愿者占比 : 所有注册用户中,注册了志愿者的用户占比 + //(1)网格内的注册用户有哪些? + List regUserIds=this.getGridRegUserIds(customerId,entity.getGridId()); + if(CollectionUtils.isEmpty(regUserIds)){ + log.info(String.format("当前网格%s下没有注册用户,所以网格志愿者占比volunteerRatio赋值0",entity.getGridId())); + entity.setVolunteerRatio(BigDecimal.ZERO); + }else{ + //(2)网格内注册用户中,那些人注册了志愿者? + volunteerUserIds=this.getGridRegUserVolunteer(regUserIds); + if(CollectionUtils.isEmpty(volunteerUserIds)){ + log.info(String.format("当前网格%s下注册用户%s个,其中志愿者为0个,所以网格志愿者占比volunteerRatio赋值0",entity.getGridId(),regUserIds.size())); + entity.setVolunteerRatio(BigDecimal.ZERO); + }else{ + int volunteerTotal=volunteerUserIds.size(); + int regUserTotal=regUserIds.size(); + String volunteerRatioStr = numberFormat.format((float) volunteerTotal / regUserTotal); + BigDecimal volunteerRatio = new BigDecimal(volunteerRatioStr); + entity.setVolunteerRatio(volunteerRatio); + } + } + //网格党员志愿者率 : 所有志愿者中,同时是党员的占比 + if(CollectionUtils.isEmpty(volunteerUserIds)){ + log.info(String.format("当前网格%s下志愿者人数0个,所以网格党员志愿者率partyVolunteerRatio赋值为0",entity.getGridId())); + entity.setPartyVolunteerRatio(BigDecimal.ZERO); + }else{ + List paryUserIds=this.getVolunteerPartyUserIds(volunteerUserIds); + if(CollectionUtils.isEmpty(paryUserIds)){ + log.info(String.format("当前网格%s下志愿者%s个,同时是党员的0个,所以网格党员志愿者率partyVolunteerRatio赋值为0",entity.getGridId(),volunteerUserIds.size())); + entity.setPartyVolunteerRatio(BigDecimal.ZERO); + }else{ + int volunteerCount=volunteerUserIds.size(); + int partyUserCount=paryUserIds.size(); + String partyVolunteerRatioStr = numberFormat.format((float) partyUserCount / volunteerCount); + BigDecimal partyVolunteerRatio = new BigDecimal(partyVolunteerRatioStr); + entity.setPartyVolunteerRatio(partyVolunteerRatio); + } + } + } //3、批量删 deleteBatchIndexServiceAblityGridMonthly(customerId,monthId); @@ -410,6 +457,44 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { return true; } + + /** + * @return java.util.List + * @param customerId + * @param gridId + * @author yinzuomei + * @description 查询当前网格下,首次注册的用户ids + * @Date 2020/9/21 13:44 + **/ + @DataSource(DataSourceConstant.EPMET_USER) + private List getGridRegUserIds(String customerId, String gridId) { + return userDao.selectGridRegUserIds(customerId,gridId); + } + + /** + * @return java.util.List + * @param regUserIds + * @author yinzuomei + * @description 根据userId,查询用户是否是志愿者,返回是志愿者的用户集合 + * @Date 2020/9/21 13:50 + **/ + @DataSource(DataSourceConstant.EPMET_HEART) + private List getGridRegUserVolunteer(List regUserIds) { + return actInfoDao.selectGridRegUserVolunteer(regUserIds); + } + + /** + * @return java.util.List + * @param volunteerUserIds + * @author yinzuomei + * @description 志愿者中,同时是党员的人数 + * @Date 2020/9/21 14:10 + **/ + @DataSource(DataSourceConstant.PARTY_MEMBER) + private List getVolunteerPartyUserIds(List volunteerUserIds) { + return partyMemberDao.selectVolunteerPartyUserIds(volunteerUserIds); + } + /** * @return java.util.Map * @param customerId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml index fafa780590..ea26569ba8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml @@ -18,4 +18,18 @@ GROUP BY ai.SPONSOR_ID + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml index b5e77a8699..1a6a74ddd4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml @@ -29,4 +29,19 @@ CUSTOMER_ID = #{customerId} AND (FIRST_REGISTER = 1 OR REGISTER = 1) + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml index 22061e3e70..03f525d12d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -457,4 +457,17 @@ AND rolename.ROLE_KEY = 'warmhearted' + + +