|  |  | @ -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、取消活动 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  | 
 |