| 
					
				 | 
			
			
				@ -2,13 +2,16 @@ package com.yihu.jw.message.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.message.BaseMessageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.message.dao.MessageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Pageable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Sort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.LinkedList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -58,12 +61,16 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("name","应用消息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("count",applyReadCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("message",applyList.size()>0?applyList.get(0).getMsgContent():null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("createTime", applyList.size()>0?DateUtil.dateToStr(applyList.get(0).getCreateTime(),"yyyy-MM-dd HH:mm:ss"):null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("type","01"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultList.add(applyMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> systemMap = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMap.put("name","系统消息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMap.put("count",systemReadCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMap.put("message",systemList.size()>0?systemList.get(0).getMsgContent():null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMap.put("createTime", systemList.size()>0?DateUtil.dateToStr(systemList.get(0).getCreateTime(),"yyyy-MM-dd HH:mm:ss"):null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        applyMap.put("type","02"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultList.add(systemMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer unReadPageSize = pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(page==0){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -77,7 +84,11 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("patientCode",one.get("sender")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("name",one.get("sender_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("count",one.get("num")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("message",one.get("msg_content")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("message",one.get("msg_content"));//create_time 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("createTime", DateUtil.dateToStr((Date)one.get("create_time"),"yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("senderPhoto", one.get("sender_photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            unReadMap.put("senderSex", one.get("sex")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            applyMap.put("type","03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(unReadMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(unReadResult.size()<unReadPageSize){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -90,6 +101,10 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("name",one.get("sender_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("count",one.get("num")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("message",one.get("msg_content")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("createTime", DateUtil.dateToStr((Date)one.get("create_time"),"yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("senderPhoto", one.get("sender_photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                readMap.put("senderSex", one.get("sex")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                applyMap.put("type","03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultList.add(readMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -115,7 +130,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private List<Map<String, Object>> messageListSql(Integer platform,String code,Integer readState,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql =" SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.*, b.msg_content " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.*, b.msg_content ,b.sender_photo ,p.sex " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  SELECT " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -130,6 +145,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.receiver = '"+code+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.del = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.read_state = "+readState+" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.msg_type_code like '03%'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   m.sender, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   m.sender_name " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -142,7 +158,8 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND b.receiver = '"+code+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND b.del = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND b.read_state = "+readState+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND b.msg_type_code like '%03%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND b.msg_type_code like '03%'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON a.sender = p.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -155,6 +172,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.receiver = '"+code+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.del = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.read_state = "+readState+" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND m.msg_type_code like '03%'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   m.sender, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   m.sender_name " ; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -185,4 +203,14 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<BaseMessageDO> getAllByPatient(String receiver,String sender,String msgTypeCode,Integer platform,Pageable pageRequest){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return messageDao.getAllByPatient(receiver,sender,msgTypeCode,platform,pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<BaseMessageDO> getAllByPatient(String receiver,String msgTypeCode,Integer platform,Pageable pageRequest){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return messageDao.getAllByPatient(receiver,msgTypeCode,platform,pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |