|
|
@ -21,21 +21,31 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.modules.notice.dao.NoticeReafdRecordDao; |
|
|
|
import com.epmet.modules.notice.entity.NoticeReafdRecordEntity; |
|
|
|
import com.epmet.modules.notice.redis.NoticeReafdRecordRedis; |
|
|
|
import com.epmet.modules.notice.service.NoticeReafdRecordService; |
|
|
|
import com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.NoticeReadListFormDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 小组通知组成员阅读记录表 |
|
|
@ -48,6 +58,8 @@ public class NoticeReafdRecordServiceImpl extends BaseServiceImpl<NoticeReafdRec |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private NoticeReafdRecordRedis noticeReafdRecordRedis; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<NoticeReafdRecordDTO> page(Map<String, Object> params) { |
|
|
@ -101,4 +113,58 @@ public class NoticeReafdRecordServiceImpl extends BaseServiceImpl<NoticeReafdRec |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 通知已读未读列表查询 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public NoticeReadListResultDTO noticeReadList(TokenDto tokenDto, NoticeReadListFormDTO formDTO) { |
|
|
|
NoticeReadListResultDTO resultDTO = new NoticeReadListResultDTO(); |
|
|
|
List<NoticeReadListResultDTO.NoticeReafdRecord> readList = new ArrayList<>(); |
|
|
|
List<NoticeReadListResultDTO.NoticeReafdRecord> unReadList = new ArrayList<>(); |
|
|
|
//1.根据通知Id查询组成员已读未读数据
|
|
|
|
List<NoticeReafdRecordDTO> list = baseDao.getByNoticeId(formDTO.getNoticeId()); |
|
|
|
|
|
|
|
//2.调用user服务,查询人员基础数据
|
|
|
|
List<String> userIdList = list.stream().map(NoticeReafdRecordDTO::getUserId).collect(Collectors.toList()); |
|
|
|
Result<List<UserBaseInfoResultDTO>> result = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList); |
|
|
|
if (!result.success()){ |
|
|
|
throw new RenException("调用user服务,获取用户基础数据失败"); |
|
|
|
} |
|
|
|
List<UserBaseInfoResultDTO> resultDTOList = result.getData(); |
|
|
|
|
|
|
|
//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("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); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultDTO.setReadCount(readList.size()); |
|
|
|
resultDTO.setUnReadCount(unReadList.size()); |
|
|
|
resultDTO.setReadList(readList); |
|
|
|
resultDTO.setUnReadList(unReadList); |
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
} |