Browse Source

Merge remote-tracking branch 'origin/dev_group_act_notice' into dev_temp

master
yinzuomei 4 years ago
parent
commit
c8f53f45bd
  1. 103
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java
  2. 3
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java
  3. 16
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReadRecordServiceImpl.java
  4. 8
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java

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

@ -193,25 +193,22 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
}
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);*/
actReadRecordEntity.setReadFlag(GroupActConstant.UN_READ);
}else{
actReadRecordEntity.setReadFlag(GroupActConstant.READ);
}
readRecordEntityList.add(actReadRecordEntity);
});
readRecordEntityList.forEach(readRecordEntity->{
actReadRecordDao.insert(readRecordEntity);
@ -505,27 +502,30 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setUserRole(resiGroupMemberDTO.getGroupLeaderFlag());
// 有签到后不可以修改活动时间:true可以修改,false不可以,
resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum() > NumConstant.ZERO ? false : true);
//返回详情,并且已读状态
ActReadRecordEntity actReadRecordEntity=actReadRecordDao.selectUserRec(formDTO.getGroupActId(),formDTO.getUserId());
if(null== actReadRecordEntity){
if(!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())){
//插入已读记录,默认不属于应读人。
ActReadRecordEntity insertEntity=new ActReadRecordEntity();
insertEntity.setCustomerId(groupActInfoEntity.getCustomerId());
insertEntity.setGroupActId(formDTO.getGroupActId());
insertEntity.setReadFlag(GroupActConstant.READ);
insertEntity.setShouldBeRead(Constant.NO);
insertEntity.setUserId(formDTO.getUserId());
insertEntity.setGridId(groupActInfoEntity.getGridId());
insertEntity.setGroupId(groupActInfoEntity.getGroupId());
actReadRecordDao.insert(insertEntity);
}
}else{
if(GroupActConstant.UN_READ.equals(actReadRecordEntity.getReadFlag())){
//未读->已读
actReadRecordEntity.setReadFlag(GroupActConstant.READ);
actReadRecordEntity.setUpdatedTime(new Date());
actReadRecordDao.updateById(actReadRecordEntity);
if (!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())) {
//如果活动关闭,则不更新已读记录
//非关闭状态下,返回详情,并且已读状态
ActReadRecordEntity actReadRecordEntity = actReadRecordDao.selectUserRec(formDTO.getGroupActId(), formDTO.getUserId());
if (null == actReadRecordEntity) {
if (!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())) {
//插入已读记录,默认不属于应读人。
ActReadRecordEntity insertEntity = new ActReadRecordEntity();
insertEntity.setCustomerId(groupActInfoEntity.getCustomerId());
insertEntity.setGroupActId(formDTO.getGroupActId());
insertEntity.setReadFlag(GroupActConstant.READ);
insertEntity.setShouldBeRead(Constant.NO);
insertEntity.setUserId(formDTO.getUserId());
insertEntity.setGridId(groupActInfoEntity.getGridId());
insertEntity.setGroupId(groupActInfoEntity.getGroupId());
actReadRecordDao.insert(insertEntity);
}
} else {
if (GroupActConstant.UN_READ.equals(actReadRecordEntity.getReadFlag())) {
//未读->已读
actReadRecordEntity.setReadFlag(GroupActConstant.READ);
actReadRecordEntity.setUpdatedTime(new Date());
actReadRecordDao.updateById(actReadRecordEntity);
}
}
}
return resultDTO;
@ -618,28 +618,31 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
if (!CollectionUtils.isEmpty(resultDTOList)) {
//3.遍历封装数据并返回
list.forEach(l -> {
StringBuffer name = new StringBuffer();
StringBuffer url = new StringBuffer();
resultDTOList.forEach(user -> {
if (l.getUserId().equals(user.getUserId())) {
name.append(user.getSurname()).append(user.getName());
url.append(user.getHeadImgUrl());
//不展示组长的记录
if (!l.getUserId().equals(actReadViewFormDTO.getUserId())) {
StringBuffer name = new StringBuffer();
StringBuffer url = new StringBuffer();
resultDTOList.forEach(user -> {
if (l.getUserId().equals(user.getUserId())) {
name.append(user.getSurname()).append(user.getName());
url.append(user.getHeadImgUrl());
}
});
if (GroupActConstant.READ.equals(l.getReadFlag())) {
//已读
NoticeReadListResultDTO.NoticeReafdRecord read = new NoticeReadListResultDTO.NoticeReafdRecord();
read.setUserId(l.getUserId());
read.setUserName(name.toString());
read.setUserHeadPhoto(url.toString());
readList.add(read);
} else {
//未读
NoticeReadListResultDTO.NoticeReafdRecord unRead = new NoticeReadListResultDTO.NoticeReafdRecord();
unRead.setUserId(l.getUserId());
unRead.setUserName(name.toString());
unRead.setUserHeadPhoto(url.toString());
unReadList.add(unRead);
}
});
if (GroupActConstant.READ.equals(l.getReadFlag())) {
//已读
NoticeReadListResultDTO.NoticeReafdRecord read = new NoticeReadListResultDTO.NoticeReafdRecord();
read.setUserId(l.getUserId());
read.setUserName(name.toString());
read.setUserHeadPhoto(url.toString());
readList.add(read);
} else {
//未读
NoticeReadListResultDTO.NoticeReafdRecord unRead = new NoticeReadListResultDTO.NoticeReafdRecord();
unRead.setUserId(l.getUserId());
unRead.setUserName(name.toString());
unRead.setUserHeadPhoto(url.toString());
unReadList.add(unRead);
}
});

3
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java

@ -79,9 +79,6 @@ public class NoticeController {
@PostMapping(value = "edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditNoticeFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, EditNoticeFormDTO.Edit.class, EditNoticeFormDTO.EditUserShow.class);
if(formDTO.getExpirationTime().before(new Date())){
throw new RenException("通知过期时间不能早于当前时间");
}
formDTO.setUserId(tokenDto.getUserId());
noticeService.edit(formDTO);
return new Result();

16
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReadRecordServiceImpl.java

@ -48,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -138,13 +139,18 @@ public class NoticeReadRecordServiceImpl extends BaseServiceImpl<NoticeReadRecor
@Override
@Transactional(rollbackFor = Exception.class)
public void readType(ReadTypeFormDTO formDTO) {
//1.根据通知Id和当前用户查询是否存在通知阅读记录
//1.查询通知详情,判断有没有过期
NoticeEntity notice = noticeDao.selectById(formDTO.getNoticeId());
//已经过期的通知,新用户阅读不算阅读,在通知有效期内没有阅读的就不算已读
if(notice.getChangeTime().before(new Date())){
return;
}
//2.根据通知Id和当前用户查询是否存在通知阅读记录
NoticeReadRecordEntity entity = baseDao.selectByNoticeId(formDTO.getNoticeId(), formDTO.getUserId());
//2.不存在记录时新增已读记录
//3.不存在记录时新增已读记录
if (null == entity || StringUtils.isEmpty(entity.getId())) {
//查询通知详情
NoticeEntity notice = noticeDao.selectById(formDTO.getNoticeId());
//新增当前人员已读数据
NoticeReadRecordEntity reafdRecord = new NoticeReadRecordEntity();
reafdRecord.setCustomerId(notice.getCustomerId());
@ -155,7 +161,7 @@ public class NoticeReadRecordServiceImpl extends BaseServiceImpl<NoticeReadRecor
reafdRecord.setReadFlag(ReadFlagConstant.READ);
insert(reafdRecord);
} else {
//3.已存在记录且是已读状态不在修改
//4.已存在记录且是已读状态不在修改
if (ReadFlagConstant.UN_READ.equals(entity.getReadFlag())) {
entity.setReadFlag(ReadFlagConstant.READ);
baseDao.updateById(entity);

8
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java

@ -293,6 +293,14 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity>
if (null == entity) {
throw new RenException(String.format("小组通知变更,获取通知数据失败,通知Id->", formDTO.getNoticeId()));
}
//通知已过期时不允许再次变更
if(entity.getChangeTime().before(new Date())){
throw new RenException("通知已过期不允许再次变更");
}
if(formDTO.getExpirationTime().before(new Date())){
throw new RenException("通知过期时间不能早于当前时间");
}
//2.文字、图片安全校验
List<String> wordList = new ArrayList<>();
wordList.add(formDTO.getTitle());

Loading…
Cancel
Save