Browse Source

网格相关-服务能力V0.3

dev_shibei_match
yinzuomei 5 years ago
parent
commit
696be1898b
  1. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java
  2. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java
  5. 95
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java
  6. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml
  7. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml
  8. 13
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

9
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<Map<String, Integer>> selectActGroupByGridId(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @return java.util.List<java.lang.String>
* @param regUserIds
* @author yinzuomei
* @description 根据userId,查询用户是否是志愿者返回是志愿者的用户集合
* @Date 2020/9/21 13:55
**/
List<String> selectGridRegUserVolunteer(@Param("list") List<String> regUserIds);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/partymember/PartyMemberDao.java

@ -36,4 +36,12 @@ public interface PartyMemberDao{
*/
List<PartyMemberDTO> selectPartyMemberByCustomer(@Param("customerId") String customerId);
/**
* @return java.util.List<java.lang.String>
* @param volunteerUserIds
* @author yinzuomei
* @description 志愿者中同时是党员的人数
* @Date 2020/9/21 14:13
**/
List<String> selectVolunteerPartyUserIds(@Param("list") List<String> volunteerUserIds);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java

@ -111,4 +111,14 @@ public interface UserDao {
List<String> selectPartymembersByCustomerId(@Param("customerId")String customerId);
List<GridHeartedFormDTO> selectWarmHeartedByCustomerId(@Param("customerId")String customerId);
/**
* @param customerId
* @param gridId
* @return java.util.List<java.lang.String>
* @author yinzuomei
* @description 查询当前网格下首次注册的用户ids
* @Date 2020/9/21 13:46
**/
List<String> selectGridRegUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId);
}

2
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);

95
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<String> volunteerUserIds=new ArrayList<>();
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(NumConstant.SIX);
//网格志愿者占比 : 所有注册用户中,注册了志愿者的用户占比
//(1)网格内的注册用户有哪些?
List<String> 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<String> 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<java.lang.String>
* @param customerId
* @param gridId
* @author yinzuomei
* @description 查询当前网格下首次注册的用户ids
* @Date 2020/9/21 13:44
**/
@DataSource(DataSourceConstant.EPMET_USER)
private List<String> getGridRegUserIds(String customerId, String gridId) {
return userDao.selectGridRegUserIds(customerId,gridId);
}
/**
* @return java.util.List<java.lang.String>
* @param regUserIds
* @author yinzuomei
* @description 根据userId,查询用户是否是志愿者返回是志愿者的用户集合
* @Date 2020/9/21 13:50
**/
@DataSource(DataSourceConstant.EPMET_HEART)
private List<String> getGridRegUserVolunteer(List<String> regUserIds) {
return actInfoDao.selectGridRegUserVolunteer(regUserIds);
}
/**
* @return java.util.List<java.lang.String>
* @param volunteerUserIds
* @author yinzuomei
* @description 志愿者中同时是党员的人数
* @Date 2020/9/21 14:10
**/
@DataSource(DataSourceConstant.PARTY_MEMBER)
private List<String> getVolunteerPartyUserIds(List<String> volunteerUserIds) {
return partyMemberDao.selectVolunteerPartyUserIds(volunteerUserIds);
}
/**
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @param customerId

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml

@ -18,4 +18,18 @@
GROUP BY
ai.SPONSOR_ID
</select>
<!-- 根据userId,查询用户是否是志愿者,返回是志愿者的用户集合 -->
<select id="selectGridRegUserVolunteer" parameterType="map" resultType="java.lang.String">
SELECT
DISTINCT vi.USER_ID
FROM
volunteer_info vi
WHERE
vi.DEL_FLAG = '0'
AND
<foreach collection="list" item="userId" separator="or" open="(" close=")">
vi.USER_ID =#{userId}
</foreach>
</select>
</mapper>

15
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)
</select>
<!-- 志愿者中,同时是党员的人数 -->
<select id="selectVolunteerPartyUserIds" parameterType="map" resultType="java.lang.String">
SELECT DISTINCT
pi.USER_ID
FROM
partymember_info pi
WHERE
pi.DEL_FLAG = '0'
AND ( pi.CONFIRM_RESULT = 'auto_confirm_success' OR pi.CONFIRM_RESULT = 'approved' )
AND
<foreach collection="list" item="userId" separator="or" open="(" close=")">
pi.USER_ID =#{userId}
</foreach>
</select>
</mapper>

13
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

@ -457,4 +457,17 @@
AND
rolename.ROLE_KEY = 'warmhearted'
</select>
<!-- 查询当前网格下,首次注册的用户ids -->
<select id="selectGridRegUserIds" parameterType="map" resultType="java.lang.String">
SELECT DISTINCT
USER_ID
FROM
register_relation rr
WHERE
rr.DEL_FLAG = '0'
AND rr.CUSTOMER_ID =#{customerId}
and rr.GRID_ID=#{gridId}
AND rr.FIRST_REGISTER = '1'
</select>
</mapper>

Loading…
Cancel
Save