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) { 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<>(); List<ActReadRecordEntity> readRecordEntityList=new ArrayList<>();
memberDTOList.forEach(memberDTO->{ memberDTOList.forEach(memberDTO->{
ActReadRecordEntity actReadRecordEntity=new ActReadRecordEntity(); ActReadRecordEntity actReadRecordEntity=new ActReadRecordEntity();
actReadRecordEntity.setCustomerId(groupActInfoEntity.getCustomerId()); actReadRecordEntity.setCustomerId(groupActInfoEntity.getCustomerId());
actReadRecordEntity.setGroupActId(groupActInfoEntity.getId()); actReadRecordEntity.setGroupActId(groupActInfoEntity.getId());
actReadRecordEntity.setReadFlag(GroupActConstant.UN_READ);
actReadRecordEntity.setUserId(memberDTO.getCustomerUserId()); actReadRecordEntity.setUserId(memberDTO.getCustomerUserId());
actReadRecordEntity.setShouldBeRead(Constant.YES); actReadRecordEntity.setShouldBeRead(Constant.YES);
actReadRecordEntity.setGroupId(groupActInfoEntity.getGroupId()); actReadRecordEntity.setGroupId(groupActInfoEntity.getGroupId());
actReadRecordEntity.setGridId(groupActInfoEntity.getGridId()); actReadRecordEntity.setGridId(groupActInfoEntity.getGridId());
//组长默认已读,组员默认未读
if(!groupActInfoEntity.getPublishUserId().equals(memberDTO.getCustomerUserId())){ if(!groupActInfoEntity.getPublishUserId().equals(memberDTO.getCustomerUserId())){
readRecordEntityList.add(actReadRecordEntity); actReadRecordEntity.setReadFlag(GroupActConstant.UN_READ);
/* //默认是未读 }else{
redisUtils.setBit(actReadKey,memberDTO.getTempNum(),false); actReadRecordEntity.setReadFlag(GroupActConstant.READ);
//当前所有成员默认应读
redisUtils.setBit(actShoudReadUserKey,memberDTO.getTempNum(),true);*/
} }
readRecordEntityList.add(actReadRecordEntity);
}); });
readRecordEntityList.forEach(readRecordEntity->{ readRecordEntityList.forEach(readRecordEntity->{
actReadRecordDao.insert(readRecordEntity); actReadRecordDao.insert(readRecordEntity);
@ -505,27 +502,30 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setUserRole(resiGroupMemberDTO.getGroupLeaderFlag()); resultDTO.setUserRole(resiGroupMemberDTO.getGroupLeaderFlag());
// 有签到后不可以修改活动时间:true可以修改,false不可以, // 有签到后不可以修改活动时间:true可以修改,false不可以,
resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum() > NumConstant.ZERO ? false : true); resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum() > NumConstant.ZERO ? false : true);
//返回详情,并且已读状态 if (!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())) {
ActReadRecordEntity actReadRecordEntity=actReadRecordDao.selectUserRec(formDTO.getGroupActId(),formDTO.getUserId()); //如果活动关闭,则不更新已读记录
if(null== actReadRecordEntity){ //非关闭状态下,返回详情,并且已读状态
if(!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())){ ActReadRecordEntity actReadRecordEntity = actReadRecordDao.selectUserRec(formDTO.getGroupActId(), formDTO.getUserId());
//插入已读记录,默认不属于应读人。 if (null == actReadRecordEntity) {
ActReadRecordEntity insertEntity=new ActReadRecordEntity(); if (!GroupActConstant.CLOSED.equals(groupActInfoEntity.getStatus())) {
insertEntity.setCustomerId(groupActInfoEntity.getCustomerId()); //插入已读记录,默认不属于应读人。
insertEntity.setGroupActId(formDTO.getGroupActId()); ActReadRecordEntity insertEntity = new ActReadRecordEntity();
insertEntity.setReadFlag(GroupActConstant.READ); insertEntity.setCustomerId(groupActInfoEntity.getCustomerId());
insertEntity.setShouldBeRead(Constant.NO); insertEntity.setGroupActId(formDTO.getGroupActId());
insertEntity.setUserId(formDTO.getUserId()); insertEntity.setReadFlag(GroupActConstant.READ);
insertEntity.setGridId(groupActInfoEntity.getGridId()); insertEntity.setShouldBeRead(Constant.NO);
insertEntity.setGroupId(groupActInfoEntity.getGroupId()); insertEntity.setUserId(formDTO.getUserId());
actReadRecordDao.insert(insertEntity); insertEntity.setGridId(groupActInfoEntity.getGridId());
} insertEntity.setGroupId(groupActInfoEntity.getGroupId());
}else{ actReadRecordDao.insert(insertEntity);
if(GroupActConstant.UN_READ.equals(actReadRecordEntity.getReadFlag())){ }
//未读->已读 } else {
actReadRecordEntity.setReadFlag(GroupActConstant.READ); if (GroupActConstant.UN_READ.equals(actReadRecordEntity.getReadFlag())) {
actReadRecordEntity.setUpdatedTime(new Date()); //未读->已读
actReadRecordDao.updateById(actReadRecordEntity); actReadRecordEntity.setReadFlag(GroupActConstant.READ);
actReadRecordEntity.setUpdatedTime(new Date());
actReadRecordDao.updateById(actReadRecordEntity);
}
} }
} }
return resultDTO; return resultDTO;
@ -618,28 +618,31 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
if (!CollectionUtils.isEmpty(resultDTOList)) { if (!CollectionUtils.isEmpty(resultDTOList)) {
//3.遍历封装数据并返回 //3.遍历封装数据并返回
list.forEach(l -> { list.forEach(l -> {
StringBuffer name = new StringBuffer(); //不展示组长的记录
StringBuffer url = new StringBuffer(); if (!l.getUserId().equals(actReadViewFormDTO.getUserId())) {
resultDTOList.forEach(user -> { StringBuffer name = new StringBuffer();
if (l.getUserId().equals(user.getUserId())) { StringBuffer url = new StringBuffer();
name.append(user.getSurname()).append(user.getName()); resultDTOList.forEach(user -> {
url.append(user.getHeadImgUrl()); 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") @PostMapping(value = "edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditNoticeFormDTO formDTO){ public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditNoticeFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, EditNoticeFormDTO.Edit.class, EditNoticeFormDTO.EditUserShow.class); ValidatorUtils.validateEntity(formDTO, EditNoticeFormDTO.Edit.class, EditNoticeFormDTO.EditUserShow.class);
if(formDTO.getExpirationTime().before(new Date())){
throw new RenException("通知过期时间不能早于当前时间");
}
formDTO.setUserId(tokenDto.getUserId()); formDTO.setUserId(tokenDto.getUserId());
noticeService.edit(formDTO); noticeService.edit(formDTO);
return new Result(); 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 org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -138,13 +139,18 @@ public class NoticeReadRecordServiceImpl extends BaseServiceImpl<NoticeReadRecor
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void readType(ReadTypeFormDTO formDTO) { 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()); NoticeReadRecordEntity entity = baseDao.selectByNoticeId(formDTO.getNoticeId(), formDTO.getUserId());
//2.不存在记录时新增已读记录 //3.不存在记录时新增已读记录
if (null == entity || StringUtils.isEmpty(entity.getId())) { if (null == entity || StringUtils.isEmpty(entity.getId())) {
//查询通知详情
NoticeEntity notice = noticeDao.selectById(formDTO.getNoticeId());
//新增当前人员已读数据 //新增当前人员已读数据
NoticeReadRecordEntity reafdRecord = new NoticeReadRecordEntity(); NoticeReadRecordEntity reafdRecord = new NoticeReadRecordEntity();
reafdRecord.setCustomerId(notice.getCustomerId()); reafdRecord.setCustomerId(notice.getCustomerId());
@ -155,7 +161,7 @@ public class NoticeReadRecordServiceImpl extends BaseServiceImpl<NoticeReadRecor
reafdRecord.setReadFlag(ReadFlagConstant.READ); reafdRecord.setReadFlag(ReadFlagConstant.READ);
insert(reafdRecord); insert(reafdRecord);
} else { } else {
//3.已存在记录且是已读状态不在修改 //4.已存在记录且是已读状态不在修改
if (ReadFlagConstant.UN_READ.equals(entity.getReadFlag())) { if (ReadFlagConstant.UN_READ.equals(entity.getReadFlag())) {
entity.setReadFlag(ReadFlagConstant.READ); entity.setReadFlag(ReadFlagConstant.READ);
baseDao.updateById(entity); 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) { if (null == entity) {
throw new RenException(String.format("小组通知变更,获取通知数据失败,通知Id->", formDTO.getNoticeId())); 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.文字、图片安全校验 //2.文字、图片安全校验
List<String> wordList = new ArrayList<>(); List<String> wordList = new ArrayList<>();
wordList.add(formDTO.getTitle()); wordList.add(formDTO.getTitle());

Loading…
Cancel
Save