diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java index 3f2e21e297..aecf370b48 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java +++ b/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 memberDTOList) { - /*String actReadKey= RedisKeys.getGroupMsgReadKey(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId()); - String actShoudReadUserKey=RedisKeys.getGroupMsgShouldReadUser(GroupActConstant.ACT_STR,groupActInfoEntity.getGroupId(),groupActInfoEntity.getId());*/ List 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 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 { - 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); } }); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java index 0736625518..fd4328ddaa 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java +++ b/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(); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReadRecordServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReadRecordServiceImpl.java index 93b728bcfb..6d135a0b8c 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReadRecordServiceImpl.java +++ b/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 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 wordList = new ArrayList<>(); wordList.add(formDTO.getTitle());