Browse Source

暂存

dev_shibei_match
yinzuomei 4 years ago
parent
commit
f54b83d033
  1. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 20
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  3. 4
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/GroupActInfoDTO.java
  4. 5
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java
  5. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java
  6. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/GroupActInfoEntity.java
  7. 1
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java
  8. 130
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java
  9. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java
  10. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java
  11. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java

30
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -8,7 +8,9 @@
package com.epmet.commons.tools.redis;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
/**
@ -429,4 +431,32 @@ public class RedisKeys {
public static String getThirdPlatformAccessTokenKey(String platformId) {
return rootPrefix.concat("thirdplatform:accesstoken:").concat(platformId);
}
/**
* @return 设置组员已读未读标识
* @param source :act notice
* @param groupId 小组id
* @param sourceId 活动id或者通知id
* @author yinzuomei
* @description groupread:202104:act:groupId:actId
* @Date 2021/4/22 16:38
**/
public static String getGroupMsgReadKey(String source, String groupId, String sourceId) {
String currentMonth= DateUtils.getBeforeNMonth(NumConstant.ZERO);
return "groupread:".concat(currentMonth).concat(":").concat(source).concat(":").concat(groupId).concat(":").concat(sourceId);
}
/**
* @return 设置应读人员标识 默认全部赋值1
* @param source :act notice
* @param groupId 小组id
* @param sourceId 活动id或者通知id
* @author yinzuomei
* @description groupread:user:202104:act:groupId:actId
* @Date 2021/4/22 16:38
**/
public static String getGroupMsgShouldReadUser(String source, String groupId, String sourceId) {
String currentMonth= DateUtils.getBeforeNMonth(NumConstant.ZERO);
return "groupread:user:".concat(currentMonth).concat(":").concat(source).concat(":").concat(groupId).concat(":").concat(sourceId);
}
}

20
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -13,10 +13,7 @@ import com.epmet.commons.tools.exception.RenException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -422,4 +419,19 @@ public class RedisUtils {
return redisTemplate.hasKey(key);
}
public Boolean setBit(String key, long offset, boolean value) {
return redisTemplate.opsForValue().setBit(key, offset, value);
}
public Boolean getBit(String key, long offset) {
return redisTemplate.opsForValue().getBit(key, offset);
}
public Long bitCount(String key) {
return redisTemplate.execute((RedisCallback<Long>) con -> con.bitCount(key.getBytes()));
}
public Long bitCount(String key, int start, int end) {
return redisTemplate.execute((RedisCallback<Long>) con -> con.bitCount(key.getBytes(), start, end));
}
}

4
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/GroupActInfoDTO.java

@ -184,4 +184,8 @@ public class GroupActInfoDTO implements Serializable {
*/
private Date updatedTime;
/**
* 应读人数
*/
private Integer shouldRead;
}

5
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java

@ -17,9 +17,10 @@
package com.epmet.resi.group.dto.member;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -102,4 +103,6 @@ public class ResiGroupMemberDTO implements Serializable {
* 客户Id
* */
private String customerId;
private Integer tempNum;
}

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java

@ -90,7 +90,7 @@ public class GroupActInfoController {
public Result<NoticeReadListResultDTO> queryReadList(@RequestBody @LoginUser TokenDto tokenDto, @RequestBody ActReadViewFormDTO actReadViewFormDTO){
actReadViewFormDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(actReadViewFormDTO,ActReadViewFormDTO.AddUserInternalGroup.class);
return new Result<NoticeReadListResultDTO>().ok(groupActInfoService.queryReadList(actReadViewFormDTO));
return new Result<NoticeReadListResultDTO>().ok(groupActInfoService.queryReadListV2(actReadViewFormDTO));
}
/**

6
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/GroupActInfoEntity.java

@ -153,4 +153,10 @@ public class GroupActInfoEntity extends BaseEpmetEntity {
*/
private String publishUserId;
/**
* 应读人数
*/
private Integer shouldRead;
}

1
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java

@ -58,6 +58,7 @@ public interface GroupActInfoService extends BaseService<GroupActInfoEntity> {
*/
NoticeReadListResultDTO queryReadList(ActReadViewFormDTO actReadViewFormDTO);
NoticeReadListResultDTO queryReadListV2(ActReadViewFormDTO actReadViewFormDTO);
/**
* 011取消活动
*

130
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java

@ -25,6 +25,8 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.scan.param.ImgScanParamDTO;
import com.epmet.commons.tools.scan.param.ImgTaskDTO;
import com.epmet.commons.tools.scan.param.TextScanParamDTO;
@ -122,6 +124,8 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
private ActSummaryService actSummaryService;
@Autowired
private GroupMessageService groupMessageService;
@Autowired
private RedisUtils redisUtils;
/**
* 003发布编辑组织活动
@ -160,13 +164,11 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
//构造活动内容表
List<GroupActContentEntity> contentList = constructText(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getTextList());
List<GroupActContentEntity> imgList = constructImg(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getImgList());
//包含组长
List<ResiGroupMemberDTO> memberDTOList=resiGroupMemberService.getMemberList(formDTO.getGroupId());
List<ActReadRecordEntity> readRecordEntityList=constructReadRec(groupActInfoEntity.getId(),
formDTO.getCustomerId(),
formDTO.getGroupId(),
formDTO.getPublishUserId(),
groupDTO.getGridId(),
memberDTOList);
//应读数减-1,去掉组长
groupActInfoEntity.setShouldRead(memberDTOList.size()-NumConstant.ONE);
//2、插入活动内容
contentList.forEach(textContentEntity->{
groupActContentDao.insert(textContentEntity);
@ -176,10 +178,9 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
});
//3、插入操作日志
actOperationRecordDao.insert(operRecEntity);
//4、插入应读记录表
readRecordEntityList.forEach(readRecordEntity->{
actReadRecordDao.insert(readRecordEntity);
});
//4、插入应读记录表!!!!!
saveActReadRecord(groupActInfoEntity,memberDTOList);
//5、发送站内信
sendMessage(memberDTOList,formDTO,groupActInfoEntity,groupDTO);
@ -190,6 +191,32 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
return result;
}
private void saveActReadRecord(GroupActInfoEntity groupActInfoEntity,List<ResiGroupMemberDTO> memberDTOList) {
String actReadKey= RedisKeys.getGroupMsgReadKey(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId());
String actShoudReadUserKey=RedisKeys.getGroupMsgShouldReadUser(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId());
List<ActReadRecordEntity> readRecordEntityList=new ArrayList<>();
memberDTOList.forEach(memberDTO->{
ActReadRecordEntity actReadRecordEntity=new ActReadRecordEntity();
actReadRecordEntity.setCustomerId(groupActInfoEntity.getCustomerId());
actReadRecordEntity.setGroupActId(groupActInfoEntity.getId());
actReadRecordEntity.setReadFlag(GroupActConstant.UN_READ);
actReadRecordEntity.setUserId(memberDTO.getCustomerUserId());
actReadRecordEntity.setShouldBeRead(Constant.YES);
actReadRecordEntity.setGroupId(groupActInfoEntity.getGroupId());
actReadRecordEntity.setGridId(groupActInfoEntity.getGridId());
if(!groupActInfoEntity.getPublishUserId().equals(memberDTO.getCustomerUserId())){
readRecordEntityList.add(actReadRecordEntity);
//默认是未读
redisUtils.setBit(actReadKey,memberDTO.getTempNum(),false);
//当前所有成员默认应读
redisUtils.setBit(actShoudReadUserKey,memberDTO.getTempNum(),true);
}
});
/*readRecordEntityList.forEach(readRecordEntity->{
actReadRecordDao.insert(readRecordEntity);
});*/
}
private void saveGroupMessage(GroupActInfoEntity groupActInfoEntity) {
GroupMessageDTO groupMessageDTO=groupMessageService.getByMessageId(groupActInfoEntity.getId());
if(null==groupMessageDTO){
@ -479,8 +506,9 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum()>NumConstant.ZERO?false:true);
//返回详情,并且已读状态
ActReadRecordEntity actReadRecordEntity=actReadRecordDao.selectUserRec(formDTO.getGroupActId(),formDTO.getUserId());
String actReadKey= RedisKeys.getGroupMsgReadKey(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId());
if(null== actReadRecordEntity){
//插入
//todo 插入不在应读列表里的是否还记录呢????
ActReadRecordEntity insertEntity=new ActReadRecordEntity();
insertEntity.setCustomerId(groupActInfoEntity.getCustomerId());
insertEntity.setGroupActId(formDTO.getGroupActId());
@ -489,13 +517,19 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
insertEntity.setUserId(formDTO.getUserId());
insertEntity.setGridId(groupActInfoEntity.getGridId());
insertEntity.setGroupId(groupActInfoEntity.getGroupId());
actReadRecordDao.insert(insertEntity);
// todo
// actReadRecordDao.insert(insertEntity);
}else{
if(GroupActConstant.UN_READ.equals(actReadRecordEntity.getReadFlag())){
//未读->已读
actReadRecordEntity.setReadFlag(GroupActConstant.READ);
actReadRecordEntity.setUpdatedTime(new Date());
actReadRecordDao.updateById(actReadRecordEntity);
// todo
// actReadRecordDao.updateById(actReadRecordEntity);
//状态改为已读
redisUtils.setBit(actReadKey,resiGroupMemberDTO.getTempNum(),true);
}
}
return resultDTO;
@ -625,6 +659,76 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
return resultDTO;
}
@Override
public NoticeReadListResultDTO queryReadListV2(ActReadViewFormDTO actReadViewFormDTO) {
NoticeReadListResultDTO resultDTO = new NoticeReadListResultDTO();
List<NoticeReadListResultDTO.NoticeReafdRecord> readList = new ArrayList<>();
List<NoticeReadListResultDTO.NoticeReafdRecord> unReadList = new ArrayList<>();
//1.根据活动id,查询应读人员列表
GroupActInfoEntity groupActInfoEntity=baseDao.selectById(actReadViewFormDTO.getGroupActId());
List<ResiGroupMemberDTO> memembersList=resiGroupMemberService.getMemberList(groupActInfoEntity.getGroupId());
//2.调用user服务,查询人员基础数据
List<String> userIdList = memembersList.stream().map(ResiGroupMemberDTO::getCustomerUserId).collect(Collectors.toList());
Result<List<UserBaseInfoResultDTO>> result = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList);
if (!result.success()) {
throw new RenException("调用user服务,获取用户基础数据失败");
}
List<UserBaseInfoResultDTO> resultDTOList = result.getData();
if (!CollectionUtils.isEmpty(resultDTOList)) {
//3.遍历封装数据并返回
for (ResiGroupMemberDTO memberDTO : memembersList) {
//todo
//1)怎么判断当前组员属于应读人员?
//2)应读人员,是否已读??
String userActKey = RedisKeys.getGroupMsgReadKey(GroupActConstant.ACT_STR, groupActInfoEntity.getGroupId(), groupActInfoEntity.getId());
Boolean readFlag = redisUtils.getBit(userActKey, memberDTO.getTempNum());
if (readFlag) {
//已读
StringBuffer name = new StringBuffer();
StringBuffer url = new StringBuffer();
resultDTOList.forEach(user -> {
if (memberDTO.getCustomerUserId().equals(user.getUserId())) {
name.append(user.getSurname()).append(user.getName());
url.append(user.getHeadImgUrl());
}
});
NoticeReadListResultDTO.NoticeReafdRecord read = new NoticeReadListResultDTO.NoticeReafdRecord();
read.setUserId(memberDTO.getCustomerUserId());
read.setUserName(name.toString());
read.setUserHeadPhoto(url.toString());
readList.add(read);
} else {
//todo
// 未读人员 ??????
StringBuffer name = new StringBuffer();
StringBuffer url = new StringBuffer();
resultDTOList.forEach(user -> {
if (memberDTO.getCustomerUserId().equals(user.getUserId())) {
name.append(user.getSurname()).append(user.getName());
url.append(user.getHeadImgUrl());
}
});
NoticeReadListResultDTO.NoticeReafdRecord unRead = new NoticeReadListResultDTO.NoticeReafdRecord();
unRead.setUserId(memberDTO.getCustomerUserId());
unRead.setUserName(name.toString());
unRead.setUserHeadPhoto(url.toString());
unReadList.add(unRead);
}
}
}
//已读人数
String actReadKey= RedisKeys.getGroupMsgReadKey(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId());
long readNum=redisUtils.bitCount(actReadKey);
resultDTO.setReadCount((int) readNum);
//未读人数
resultDTO.setUnReadCount(groupActInfoEntity.getShouldRead()-resultDTO.getReadCount());
//已读列表
resultDTO.setReadList(readList);
//未读列表
resultDTO.setUnReadList(unReadList);
return resultDTO;
}
/**
* 011取消活动
*

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java

@ -37,4 +37,6 @@ public interface GroupActConstant {
// blank: 不显示; display:显示
String BLANK="blank";
String DISPLAY="display";
String ACT_STR="act";
}

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java

@ -20,13 +20,10 @@ package com.epmet.modules.member.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 群组成员关系表
*
@ -76,4 +73,6 @@ public class ResiGroupMemberEntity extends BaseEpmetEntity {
@TableField(fill = FieldFill.INSERT)
private String customerId;
private Integer tempNum;
}

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java

@ -372,7 +372,7 @@ public interface ModuleConstant extends Constant {
/**
* 活动扫码签到对应的跳转到 活动详情页面
*/
String GROUP_ACT_DETAIL_PAGE = "XXXXXXXXXXXXXXXXXXXXX找莹姐要路径";
String GROUP_ACT_DETAIL_PAGE = "pages/group/activity/detail";
String TOPIC_CONTENT_AND_VOICE_IS_NULL = "请输入话题内容或语音";

Loading…
Cancel
Save