|
|
@@ -1,14 +1,11 @@
|
|
|
package com.xunmei.core.information.service.impl;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.message.vo.MessageAppPageVo;
|
|
|
-import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
@@ -17,19 +14,17 @@ import com.xunmei.core.information.dto.CoreMessageCenterDTO;
|
|
|
import com.xunmei.core.information.mapper.CoreMessageCenterMapper;
|
|
|
import com.xunmei.core.information.service.ICoreMessageCenterService;
|
|
|
import com.xunmei.core.information.vo.CoreMessageCenterVO;
|
|
|
+import com.xunmei.core.information.vo.CoreMessageUnReadVO;
|
|
|
import com.xunmei.core.message.mapper.CoreAnnouncementNotificationMapper;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.RemoteRoleService;
|
|
|
import com.xunmei.system.api.RemoteUserService;
|
|
|
-import com.xunmei.system.api.domain.SysOrg;
|
|
|
-import com.xunmei.system.api.domain.SysRole;
|
|
|
import com.xunmei.system.api.model.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -93,33 +88,41 @@ public class CoreMessageCenterServiceImpl extends ServiceImpl<CoreMessageCenterM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer isRead() {
|
|
|
+ public CoreMessageUnReadVO isRead() {
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
- Integer integer1 = baseMapper.selectNoRead(userId);
|
|
|
- //通知
|
|
|
+ // 业务提醒数量
|
|
|
+ Integer businessUnReadCount = baseMapper.selectNoRead(userId,2);
|
|
|
+ // 消息未读数量
|
|
|
+ Integer messageUnReadCount = baseMapper.selectNoRead(userId,3);
|
|
|
+ //获取通知公共未读数量
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
- List<SysRole> roleByUserId = remoteRoleService.getRoleByUserId(loginUser.getUserid(), SecurityConstants.INNER);
|
|
|
- List<Long> collect = roleByUserId.stream().map(SysRole::getId).collect(Collectors.toList());
|
|
|
- Long[] roles;
|
|
|
- if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
- roles = collect.toArray(new Long[collect.size()]);
|
|
|
- } else {
|
|
|
- roles = null;
|
|
|
- }
|
|
|
+// List<SysRole> roleByUserId = remoteRoleService.getRoleByUserId(loginUser.getUserid(), SecurityConstants.INNER);
|
|
|
+// List<Long> collect = roleByUserId.stream().map(SysRole::getId).collect(Collectors.toList());
|
|
|
+// Long[] roles;
|
|
|
+// if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+// roles = collect.toArray(new Long[collect.size()]);
|
|
|
+// } else {
|
|
|
+// roles = null;
|
|
|
+// }
|
|
|
//通知
|
|
|
- Integer i = 0;
|
|
|
- if (null!=roles){
|
|
|
- List<MessageAppPageVo> messageAppPageVos = coreAnnouncementNotificationMapper.selectAll(loginUser.getOrgId(), roles);
|
|
|
- List<Long> longs = coreAnnouncementNotificationMapper.selectReadByUser(loginUser.getUserid());
|
|
|
- List<Long> collect1 = messageAppPageVos.stream().map(MessageAppPageVo::getId).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(collect1) && null != longs && longs.size() != collect1.size()) {
|
|
|
- i = collect1.size() - longs.size();
|
|
|
- }
|
|
|
+ Integer noticeUnReadCount = 0;
|
|
|
+// if (null!=roles){
|
|
|
+ List<MessageAppPageVo> messageAppPageVos = coreAnnouncementNotificationMapper.selectAll(loginUser.getOrgId(), null);
|
|
|
+ List<Long> longs = coreAnnouncementNotificationMapper.selectReadByUser(loginUser.getUserid());
|
|
|
+ List<Long> collect1 = messageAppPageVos.stream().map(MessageAppPageVo::getId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect1) && null != longs && longs.size() != collect1.size()) {
|
|
|
+ noticeUnReadCount = collect1.size() - longs.size();
|
|
|
}
|
|
|
- Integer result = 0;
|
|
|
- if (i + integer1 > 0) {
|
|
|
- result = i + integer1;
|
|
|
+// }
|
|
|
+ Integer totalUnReadCount = 0;
|
|
|
+ if (noticeUnReadCount + businessUnReadCount+messageUnReadCount > 0) {
|
|
|
+ totalUnReadCount = noticeUnReadCount + businessUnReadCount+messageUnReadCount;
|
|
|
}
|
|
|
+ CoreMessageUnReadVO result=new CoreMessageUnReadVO();
|
|
|
+ result.setTotalCount(totalUnReadCount);
|
|
|
+ result.setMessageUnReadCount(messageUnReadCount);
|
|
|
+ result.setBusinessUnReadCount(businessUnReadCount);
|
|
|
+ result.setNoticeUnReadCount(noticeUnReadCount);
|
|
|
return result;
|
|
|
}
|
|
|
|