| 
															
																@ -2,6 +2,7 @@ package com.yihu.jw.message.service; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.entity.base.message.BaseMessageDO; 
															 | 
															
															 | 
															
																import com.yihu.jw.entity.base.message.BaseMessageDO; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.message.dao.MessageDao; 
															 | 
															
															 | 
															
																import com.yihu.jw.message.dao.MessageDao; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.yihu.jw.util.date.DateUtil; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.mysql.query.BaseJpaService; 
															 | 
															
															 | 
															
																import com.yihu.mysql.query.BaseJpaService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.apache.commons.collections.map.HashedMap; 
															 | 
															
															 | 
															
																import org.apache.commons.collections.map.HashedMap; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.beans.factory.annotation.Autowired; 
															 | 
															
															 | 
															
																import org.springframework.beans.factory.annotation.Autowired; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -30,12 +31,11 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * 消息列表 
															 | 
															
															 | 
															
																     * 消息列表 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @param platform 
															 | 
															
															 | 
															
																     * @param platform 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @param code 
															 | 
															
															 | 
															
																     * @param code 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @param saasId 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @param page 
															 | 
															
															 | 
															
																     * @param page 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @param pageSize 
															 | 
															
															 | 
															
																     * @param pageSize 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @return 
															 | 
															
															 | 
															
																     * @return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public List<Map<String,Object>> messageList(Integer platform,String code,String saasId,Integer page,Integer pageSize){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public List<Map<String,Object>> messageList(Integer platform,String code,Integer page,Integer pageSize){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if(page==null){ 
															 | 
															
															 | 
															
																        if(page==null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            page = 0; 
															 | 
															
															 | 
															
																            page = 0; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -50,10 +50,10 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        // 排序 
															 | 
															
															 | 
															
																        // 排序 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Sort sort = new Sort(Sort.Direction.DESC, "createTime"); 
															 | 
															
															 | 
															
																        Sort sort = new Sort(Sort.Direction.DESC, "createTime"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        // 分页信息 
															 | 
															
															 | 
															
																        // 分页信息 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<BaseMessageDO> applyList = messageDao.messageList(platform,code,saasId,"00%"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Integer applyReadCount = messageDao.countMessage(platform,code,saasId,"00%"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<BaseMessageDO> systemList = messageDao.messageList(platform,code,saasId,"01%"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Integer systemReadCount = messageDao.countMessage(platform,code,saasId,"01%"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<BaseMessageDO> applyList = messageDao.messageList(platform,code,"00%"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        Integer applyReadCount = messageDao.countMessage(platform,code,"00%"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<BaseMessageDO> systemList = messageDao.messageList(platform,code,"01%"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        Integer systemReadCount = messageDao.countMessage(platform,code,"01%"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Map<String,Object>> resultList = new LinkedList<>(); 
															 | 
															
															 | 
															
																        List<Map<String,Object>> resultList = new LinkedList<>(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Map<String,Object> applyMap = new HashedMap(); 
															 | 
															
															 | 
															
																        Map<String,Object> applyMap = new HashedMap(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -73,7 +73,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        //1、未读消息(置顶) 
															 | 
															
															 | 
															
																        //1、未读消息(置顶) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Map<String, Object>> unReadResult = messageListSql(platform,code,saasId,0,page,unReadPageSize); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<Map<String, Object>> unReadResult = messageListSql(platform,code,0,page,unReadPageSize); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        for(Map<String, Object> one:unReadResult){ 
															 | 
															
															 | 
															
																        for(Map<String, Object> one:unReadResult){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            Map<String,Object> unReadMap = new HashedMap(); 
															 | 
															
															 | 
															
																            Map<String,Object> unReadMap = new HashedMap(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            unReadMap.put("name",one.get("sender_name")); 
															 | 
															
															 | 
															
																            unReadMap.put("name",one.get("sender_name")); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -82,9 +82,9 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            resultList.add(unReadMap); 
															 | 
															
															 | 
															
																            resultList.add(unReadMap); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if(unReadResult.size()<unReadPageSize){ 
															 | 
															
															 | 
															
																        if(unReadResult.size()<unReadPageSize){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            page = messageCountSql(platform,code,saasId,1,page,pageSize); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            page = messageCountSql(platform,code,1,page,pageSize); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //2、已读消息 
															 | 
															
															 | 
															
																            //2、已读消息 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            List<Map<String, Object>> readResult = messageListSql(platform,code,saasId,1,page,unReadPageSize); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            List<Map<String, Object>> readResult = messageListSql(platform,code,1,page,unReadPageSize); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            for(Map<String, Object> one:readResult){ 
															 | 
															
															 | 
															
																            for(Map<String, Object> one:readResult){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                Map<String,Object> readMap = new HashedMap(); 
															 | 
															
															 | 
															
																                Map<String,Object> readMap = new HashedMap(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                readMap.put("name",one.get("sender_name")); 
															 | 
															
															 | 
															
																                readMap.put("name",one.get("sender_name")); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -104,14 +104,17 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public List<BaseMessageDO> applyMessageList(String patient, Date failureTime, String msgTypeCode){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return messageDao.applyMessageList(patient,failureTime,msgTypeCode); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public List<Map<String, Object>> applyMessageList(String patient, Date failureTime, String msgTypeCode){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        String failureTimeStr = DateUtil.dateToStr(failureTime,"yyyy-MM-dd HH:mm:ss"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        String sql = "select m.* from base_message m join patient_apply_for_log l on m.relation_data=l.id where m.failure_Time>='"+failureTimeStr+"' and m.msgTypeCode='"+msgTypeCode+"'"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return jdbcTemplate.queryForList(sql); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																//        return messageDao.applyMessageList(patient,failureTime,msgTypeCode); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private List<Map<String, Object>> messageListSql(Integer platform,String code,String saasId,Integer readState,Integer page,Integer pageSize){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private List<Map<String, Object>> messageListSql(Integer platform,String code,Integer readState,Integer page,Integer pageSize){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        String sql =" SELECT " + 
															 | 
															
															 | 
															
																        String sql =" SELECT " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " a.*, b.msg_content " + 
															 | 
															
															 | 
															
																                " a.*, b.msg_content " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " FROM " + 
															 | 
															
															 | 
															
																                " FROM " + 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -126,7 +129,6 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  WHERE " + 
															 | 
															
															 | 
															
																                "  WHERE " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "   m.platform = '"+platform+"' " + 
															 | 
															
															 | 
															
																                "   m.platform = '"+platform+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.receiver = '"+code+"' " + 
															 | 
															
															 | 
															
																                "  AND m.receiver = '"+code+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.saas_id = '"+saasId+"' " + 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.del = 1 " + 
															 | 
															
															 | 
															
																                "  AND m.del = 1 " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.read_state = "+readState+" " + 
															 | 
															
															 | 
															
																                "  AND m.read_state = "+readState+" " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  GROUP BY " + 
															 | 
															
															 | 
															
																                "  GROUP BY " + 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -139,20 +141,18 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND a.create_time = b.create_time " + 
															 | 
															
															 | 
															
																                " AND a.create_time = b.create_time " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND b.platform = '"+platform+"' " + 
															 | 
															
															 | 
															
																                " AND b.platform = '"+platform+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND b.receiver = '"+code+"' " + 
															 | 
															
															 | 
															
																                " AND b.receiver = '"+code+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND b.saas_id = '"+saasId+"' " + 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND b.del = 1 " + 
															 | 
															
															 | 
															
																                " AND b.del = 1 " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                " AND m.read_state = "+readState; 
															 | 
															
															 | 
															
																                " AND m.read_state = "+readState; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return jdbcTemplate.queryForList(sql); 
															 | 
															
															 | 
															
																        return jdbcTemplate.queryForList(sql); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private Integer messageCountSql(Integer platform,String code,String saasId,Integer readState,Integer page,Integer originalPageSize){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private Integer messageCountSql(Integer platform,String code,Integer readState,Integer page,Integer originalPageSize){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        String sql ="  SELECT count(*) as num " + 
															 | 
															
															 | 
															
																        String sql ="  SELECT count(*) as num " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  FROM " + 
															 | 
															
															 | 
															
																                "  FROM " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "   base_message m " + 
															 | 
															
															 | 
															
																                "   base_message m " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  WHERE " + 
															 | 
															
															 | 
															
																                "  WHERE " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "   m.platform = '"+platform+"' " + 
															 | 
															
															 | 
															
																                "   m.platform = '"+platform+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.receiver = '"+code+"' " + 
															 | 
															
															 | 
															
																                "  AND m.receiver = '"+code+"' " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.saas_id = '"+saasId+"' " + 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.del = 1 " + 
															 | 
															
															 | 
															
																                "  AND m.del = 1 " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  AND m.read_state = "+readState+" " + 
															 | 
															
															 | 
															
																                "  AND m.read_state = "+readState+" " + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                "  GROUP BY " + 
															 | 
															
															 | 
															
																                "  GROUP BY " + 
															 |