瀏覽代碼

历史消息接口增加参数,用于筛选领导批示留言

wanyuan 9 月之前
父節點
當前提交
a13359c77b

+ 12 - 11
tip-api/src/main/java/com/minto/app/message/manager/MessageService.java

@@ -225,17 +225,18 @@ public interface MessageService {
 	 */
 	List<MessageBean> findMessagesList(Long pid, Integer[] resourceType,Integer messageState,Integer start,Integer range) throws BusinessException;
     /**
-     * @param curUserId 当前人员ID
-     * @param resTypes TODO
-     * @param start 开始索引
-     * @param count 结束索引
-     * @param type 消息资源类型
-     * @return 当前人员的系统消息
-     * @throws BusinessException
-     */
-    ListObject<MessageBean> getMsgsWithSystem(Long curUserId, Integer[] types,Integer[] states, Integer[] resTypes, Integer start, Integer count) throws BusinessException;
-
-
+	 * @param type 消息资源类型
+	 * @param curUserId 当前人员ID
+	 * @param resTypes TODO
+	 * @param start 开始索引
+	 * @param count 结束索引
+	 * @param filterLeaderComment 只保留领导评论
+	 * @param leaderPersonIds 领导人员id集合
+	 * @return 当前人员的系统消息
+	 * @throws BusinessException
+	 */
+    ListObject<MessageBean> getMsgsWithSystem(Long curUserId, Integer[] types,Integer[] states, Integer[] resTypes, Integer start, Integer count,
+			boolean filterLeaderComment, List<Long> leaderPersonIds) throws BusinessException;
 
 
 	/**

+ 17 - 2
tip-front/src/main/java/com/minto/web/tc/MessageController.java

@@ -12,8 +12,10 @@ import com.minto.app.message.enums.MessageEnum.MessageStateEnum;
 import com.minto.app.message.enums.MessageEnum.MessageTypeEnum;
 import com.minto.app.message.enums.MessageResourceTypeEnum;
 import com.minto.app.message.manager.MessageService;
+import com.minto.app.organization.OrgEnum;
 import com.minto.app.organization.beans.OrgLevelBean;
 import com.minto.app.organization.beans.OrgPersonBean;
+import com.minto.app.organization.beans.OrgRelationBean;
 import com.minto.app.organization.bo.OrgTeamBO;
 import com.minto.app.organization.manager.IOrgManager;
 import com.minto.app.resource.bo.CommonResourceRelationBO;
@@ -28,6 +30,7 @@ import com.minto.core.base.BaseResultCode;
 import com.minto.core.base.ListObject;
 import com.minto.core.base.R;
 import com.minto.core.common.AppContext;
+import com.minto.core.po.BasePO;
 import com.minto.core.util.*;
 import org.apache.ibatis.plugin.Intercepts;
 import org.slf4j.Logger;
@@ -47,6 +50,7 @@ import java.util.*;
 import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 @Controller
 @RequestMapping
@@ -201,7 +205,7 @@ public class MessageController {
     public ModelAndView getSystemMsg(HttpServletRequest req, HttpServletResponse res) throws Exception {
         Map<String, Object> result = new HashMap<String, Object>();
         try {
-        	//0,1用于手机端 by chenx 2018年9月18日 17:24:22
+            //0,1用于手机端 by chenx 2018年9月18日 17:24:22
             Integer[] types = new Integer[] {0,1,MessageTypeEnum.System.getKey(), MessageTypeEnum.System4News.getKey(),
                     MessageTypeEnum.System4Notice.getKey(),MessageTypeEnum.System4Share.getKey()};
             Integer[] states = new Integer[] { MessageStateEnum.Readed.getKey(), MessageStateEnum.Unread.getKey() };
@@ -230,9 +234,20 @@ public class MessageController {
             int count = PageUtil.getRangSize(req);
             int page = ReqUtil.getInt(req, "page",1);
             int start = (page-1)*count;
+
+            List<Long> leaderPersonIds = null;
+            boolean filterLeaderComment = ReqUtil.getBoolean(req, "filterLeaderComment", false);
+            if(filterLeaderComment){
+                IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
+                List<OrgPersonBean> leaderPersonBeans = orgManager.findPersonsByRoleCode(
+                        OrgEnum.OrgRoleEnum.AccountLeader.name(), AppContext.getCurrentUser().getAccountId());
+                leaderPersonIds = leaderPersonBeans.stream().map(BasePO::getId).collect(Collectors.toList());
+            }
+
             MessageService msgMmanager = AppContext.getBean(MessageService.class);
             // 暂时取消resTypes屏蔽 V6.0 看一下怎么解决
-            ListObject<MessageBean> msgs = msgMmanager.getMsgsWithSystem(userId, types, states, null, start, count);
+            ListObject<MessageBean> msgs = msgMmanager.getMsgsWithSystem(userId, types, states, null, start, count,
+                    filterLeaderComment, leaderPersonIds);
             if((page-1)*count>msgs.getCount()){
                 page = 0;
             }

+ 5 - 1
tip-service/tip-common/src/main/java/com/minto/app/message/dao/IMessageDao.java

@@ -86,10 +86,14 @@ public interface IMessageDao extends BaseDao {
      * @param resTypes TODO
      * @param start
      * @param count
+     * @param filterLeaderComment
+     * @param leaderPersonIds
      * @return
      * @throws SQLException
      */
-    public ListObject<MessageBean> findMessagesByUserAndType(Long userId, Integer[] type,Integer[] state, Integer[] resTypes, Integer start, Integer count) throws SQLException;
+    public ListObject<MessageBean> findMessagesByUserAndType(Long userId, Integer[] type, Integer[] state,
+            Integer[] resTypes, Integer start, Integer count, boolean filterLeaderComment, List<Long> leaderPersonIds)
+            throws SQLException;
     /**
      * 删除消息记录
      * @param curUserId 当前人员id

+ 15 - 7
tip-service/tip-common/src/main/java/com/minto/app/message/dao/MessageDaoImpl.java

@@ -1,9 +1,16 @@
 package com.minto.app.message.dao;
 
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import com.google.common.collect.Maps;
 import com.minto.app.message.beans.MessageBean;
 import com.minto.app.message.beans.MessageConfigBean;
 import com.minto.app.message.enums.MessageEnum;
+import com.minto.app.message.enums.MessageResourceTypeEnum;
 import com.minto.app.message.manager.MessageState;
 import com.minto.core.base.ListObject;
 import com.minto.core.dao.BaseDaoImpl;
@@ -13,12 +20,6 @@ import com.minto.core.util.DateUtil;
 import org.hibernate.criterion.*;
 import org.springframework.stereotype.Repository;
 
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * 消息操作dao
  * @author Yang.Cheng
@@ -110,7 +111,9 @@ public class MessageDaoImpl extends BaseDaoImpl implements IMessageDao {
     }
     
     @Override
-    public ListObject<MessageBean> findMessagesByUserAndType(Long userId, Integer[] type, Integer[] state,Integer[] resTypes, Integer start, Integer count) throws SQLException {
+    public ListObject<MessageBean> findMessagesByUserAndType(Long userId, Integer[] type, Integer[] state,
+            Integer[] resTypes, Integer start, Integer count, boolean filterLeaderComment, List<Long> leaderPersonIds)
+            throws SQLException{
         ListObject<MessageBean> result = new ListObject<MessageBean>();
         Criterion criterion = Restrictions.sqlRestriction("1=1");
         criterion = Restrictions.and(criterion, Restrictions.eq("receiverId", userId));
@@ -119,6 +122,11 @@ public class MessageDaoImpl extends BaseDaoImpl implements IMessageDao {
         if(ArrayUtil.isNotEmpty(resTypes)){
             criterion = Restrictions.and(criterion, Restrictions.in("resourceType", resTypes));
         }
+        if(filterLeaderComment && CollectionUtil.isNotEmpty(leaderPersonIds)){
+            criterion = Restrictions.and(criterion, Restrictions.in("senderId", leaderPersonIds));
+            criterion = Restrictions.and(criterion,
+                    Restrictions.in("resourceType", MessageResourceTypeEnum.Comment.getKey()));
+        }
         Order order = Order.desc("sendTime");
         Integer startInt = 0;
         Integer range = Integer.MAX_VALUE;

+ 4 - 2
tip-service/tip-common/src/main/java/com/minto/app/message/manager/MessageServiceImpl.java

@@ -271,9 +271,11 @@ public class MessageServiceImpl implements MessageService, SmartInitializingSing
 		return messageDao.findMessagesList(pid, resourceType, messageState, start, range);
 	}
 	@Override
-	public ListObject<MessageBean> getMsgsWithSystem(Long curUserId, Integer[] types, Integer[] states, Integer[] resTypes, Integer start, Integer count) throws BusinessException {
+	public ListObject<MessageBean> getMsgsWithSystem(Long curUserId, Integer[] types, Integer[] states, Integer[] resTypes, Integer start, Integer count,
+			boolean filterLeaderComment, List<Long> leaderPersonIds) throws BusinessException {
 		try {
-			return messageDao.findMessagesByUserAndType(curUserId, types, states, resTypes, start, count);
+			return messageDao.findMessagesByUserAndType(curUserId, types, states, resTypes, start, count,
+					filterLeaderComment, leaderPersonIds);
 		} catch (Exception e) {
 			throw new BusinessException(e);
 		}