Browse Source

群组统计表字段增加默认值,新增议题时更新缓存,受邀入群时更新缓存

dev_shibei_match
wangchao 5 years ago
parent
commit
be78c58310
  1. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupStatisticalDao.java
  2. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java
  3. 21
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/impl/GroupInvitationServiceImpl.java
  4. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java
  5. 11
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java
  6. 10
      epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/db.sql
  7. 9
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupStatisticalDao.xml

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupStatisticalDao.java

@ -38,4 +38,13 @@ public interface ResiGroupStatisticalDao extends BaseDao<ResiGroupStatisticalEnt
* @author sun
*/
ResiGroupStatisticalEntity selectByResiGroupId(@Param("resiGroupId") String resiGroupId);
/**
* @Description 总议题数+1
* @param groupId
* @return
* @author wangc
* @date 2020.05.24 00:03
**/
void incryTotalIssues(@Param("groupId") String groupId);
}

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java

@ -84,7 +84,7 @@ public class ResiGroupRedis {
if(StringUtils.isNotBlank(groupId)){
ResiGroupInfoRedisDTO groupCache = (ResiGroupInfoRedisDTO)
redisUtils.get(ResiGroupRedisKeys.getResiGroupInfoKey(groupId));
if(null == groupCache || StringUtils.isBlank(groupCache.getGroupId())){
if(null == groupCache || StringUtils.isBlank(groupCache.getGroupId()) || null == groupCache.getGroupStatisticalInfo()){
//如果缓存中没有该组信息,从数据库中查询并放入缓存
ResiGroupDTO groupMySql = groupService.get(groupId);
if(null != groupMySql && StringUtils.isNotBlank(groupMySql.getId())){
@ -134,6 +134,9 @@ public class ResiGroupRedis {
statisticalRedis.setTotalEarnestMembers(statistical.getTotalEarnestMemebers());
statisticalRedis.setTotalNormalMembers(statistical.getTotalNormalMemebers());
groupRedis.setGroupStatisticalInfo(statisticalRedis);
}else{
//数据库中没有该组的统计数据
logger.warn(String.format("数据库中没有组统计信息,组Id:【%s】",groupId));
}
//将从数据库中查询出的数据放入缓存
set(groupRedis);

21
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/impl/GroupInvitationServiceImpl.java

@ -40,6 +40,7 @@ import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.ResiGuideFeignClient;
import com.epmet.modules.group.dao.ResiGroupDao;
import com.epmet.modules.group.entity.ResiGroupEntity;
import com.epmet.modules.group.redis.ResiGroupRedis;
import com.epmet.modules.group.service.ResiGroupService;
import com.epmet.modules.invitation.dao.GroupInvitationDao;
import com.epmet.modules.invitation.entity.GroupInvitationEntity;
@ -54,6 +55,7 @@ import com.epmet.resi.group.constant.LeaderFlagConstant;
import com.epmet.resi.group.constant.MemberStateConstant;
import com.epmet.resi.group.dto.UserRoleDTO;
import com.epmet.resi.group.dto.group.ResiGroupDTO;
import com.epmet.resi.group.dto.group.ResiGroupInfoRedisDTO;
import com.epmet.resi.group.dto.invitation.GroupInvitationDTO;
import com.epmet.resi.group.dto.invitation.form.AccetInvitationFormDTO;
import com.epmet.resi.group.dto.invitation.form.CreateGroupInvitationFormDTO;
@ -102,6 +104,8 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private ResiGuideFeignClient resiGuideFeignClient;
@Autowired
private ResiGroupRedis resiGroupRedis;
@Override
public PageData<GroupInvitationDTO> page(Map<String, Object> params) {
@ -366,6 +370,23 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD
resiGroupMemberService.saveOrUpdate(resiGroupMemberDTO);
//5、修改群统计值
resiGroupMemberDao.updateResiGroupStatistical(groupMemeberOperation.getGroupId(), userRoleDTO);
ResiGroupInfoRedisDTO groupCache =
resiGroupRedis.get(groupInvitationDTO.getResiGroupId());
if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){
groupCache.getGroupStatisticalInfo().setTotalMembers(
null == groupCache.getGroupStatisticalInfo().getTotalMembers() ? NumConstant.TWO : groupCache.getGroupStatisticalInfo().getTotalMembers() +NumConstant.ONE
);
if(StringUtils.equals(userRoleDTO.getPartymemberFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalPartyMembers(
null == groupCache.getGroupStatisticalInfo().getTotalPartyMembers() ? NumConstant.ONE : groupCache.getGroupStatisticalInfo().getTotalPartyMembers()+NumConstant.ONE
);
if(StringUtils.equals(userRoleDTO.getRegisteredResiFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalNormalMembers(
null == groupCache.getGroupStatisticalInfo().getTotalNormalMembers() ? NumConstant.TWO : groupCache.getGroupStatisticalInfo().getTotalNormalMembers()+NumConstant.ONE
);
if(StringUtils.equals(userRoleDTO.getWarmHeartedFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalEarnestMembers(
null == groupCache.getGroupStatisticalInfo().getTotalEarnestMembers() ? NumConstant.ONE : groupCache.getGroupStatisticalInfo().getTotalEarnestMembers()+NumConstant.ONE
);
resiGroupRedis.set(groupCache);
}
//6、发送消息
this.sendMessageToLeader(formDTO, resiGroupDTO,groupInvitationDTO);
}

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java

@ -140,7 +140,7 @@ public class ResiGroupMemberRedis {
.concat(userId));
}
}
memberCache.setGroupId(groupId);
return memberCache;
}

11
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java

@ -132,6 +132,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
@Autowired
private GovIssueFeignClient govIssueFeignClient;
private final Log logger = LogFactory.getLog(getClass());
@Override
@ -1068,7 +1069,15 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
if(operationResult != NumConstant.ONE){
logger.warn(ModuleConstant.FAILURE_TO_ADD_TOPIC_OPERATION);
}
return;
}
//7.更新组统计信息 议题数量+1
resiGroupStatisticalDao.incryTotalIssues(group.getGroupId());
if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){
groupCache.getGroupStatisticalInfo().setTotalIssues(
null == groupCache.getGroupStatisticalInfo().getTotalIssues() ? NumConstant.ONE
: groupCache.getGroupStatisticalInfo().getTotalIssues() + NumConstant.ONE
);
resiGroupRedis.set(groupCache);
}
logger.warn(ModuleConstant.FAILURE_TO_UPDATE_TOPIC);

10
epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/db.sql

@ -30,4 +30,14 @@ ALTER TABLE RESI_TOPIC ADD (
ISSUE_ID VARCHAR (64) DEFAULT NULL COMMENT '议题ID,可为空'
);
-- @Date 2020-05-23 23:56
-- @Author wangc
-- @Description 数据库epmet_resi_group中的resi_group_statistica(组统计表)字段增加默认值
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_TOPICS` `TOTAL_TOPICS` INT(255) NULL DEFAULT '0' COMMENT '话题总数';
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_MEMBERS` `TOTAL_MEMBERS` INT(255) NOT NULL DEFAULT '1' COMMENT '成员总数';
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_NORMAL_MEMEBERS` `TOTAL_NORMAL_MEMEBERS` INT(11) NULL DEFAULT '1' COMMENT '普通居民总数=群人数';
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_EARNEST_MEMEBERS` `TOTAL_EARNEST_MEMEBERS` INT(255) NULL DEFAULT '0' COMMENT '热心居民总数';
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_PARTY_MEMBERS` `TOTAL_PARTY_MEMBERS` INT(255) NULL DEFAULT '0' COMMENT '党员总数';
ALTER TABLE `resi_group_statistical` CHANGE `TOTAL_ISSUES` `TOTAL_ISSUES` INT(255) NULL DEFAULT '0' COMMENT '已转议题总数';

9
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupStatisticalDao.xml

@ -28,4 +28,13 @@
AND rgs.resi_group_id = #{resiGroupId}
</select>
<!-- 总议题数+1 -->
<update id="incryTotalIssues" parameterType="string">
UPDATE resi_group_statistical
SET TOTAL_ISSUES = TOTAL_ISSUES + 1
WHERE
RESI_GROUP_ID = #{groupId}
AND DEL_FLAG = '0'
</update>
</mapper>

Loading…
Cancel
Save