Parcourir la source

医生端--系统消息修改

hzp il y a 8 ans
Parent
commit
07720e30d0

+ 3 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -44,9 +44,10 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2) order by a.czrq desc")
    List<Message> getSystemMessage(String doctor);
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2)")
    List<Message> getSystemMessage(String doctor,Pageable pageRequest);

+ 76 - 77
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -55,9 +55,9 @@ public class MessageService extends BaseService {
    /**
     * IM消息数量
     */
    private String getImMsgAmount(String doctor){
    private String getImMsgAmount(String doctor) {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id="+doctor;
                + "/api/v1/chats/msg/amount?user_id=" + doctor;
        return HttpClientUtil.get(url, "UTF-8");
    }
@ -126,17 +126,16 @@ public class MessageService extends BaseService {
                JSONObject msgJson = new JSONObject();
                msgJson.put("title", msgs.get(0).getTitle());
                msgJson.put("type", msgs.get(0).getType());
                msgJson.put("msg",  msgs.get(0).getContent());
                msgJson.put("msgTime",  DateUtil.dateToStrLong(msgs.get(0).getCzrq()));
                msgJson.put("msg", msgs.get(0).getContent());
                msgJson.put("msgTime", DateUtil.dateToStrLong(msgs.get(0).getCzrq()));
                indexJson.put("lastMessage", msgJson);
            }
        }
        //获取系统消息
        List<Message> systemMessage = messageDao.getSystemMessage(doctor);
        //获取未读系统消息
        List<Message> systemMessage = messageDao.getSystemMessageUnread(doctor);
        JSONObject systemJson = new JSONObject();
        if(systemMessage!=null && systemMessage.size()>0)
        {
        if (systemMessage != null && systemMessage.size() > 0) {
            systemJson.put("amount", systemMessage.size());
            JSONObject msgJson = new JSONObject();
            msgJson.put("title", systemMessage.get(0).getTitle());
@ -144,13 +143,12 @@ public class MessageService extends BaseService {
            msgJson.put("msg", systemMessage.get(0).getContent());
            msgJson.put("msgTime", DateUtil.dateToStrLong(systemMessage.get(0).getCzrq()));
            systemJson.put("lastMessage", msgJson);
        }
        else{
        } else {
            systemJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount",getImMsgAmount(doctor));//IM消息数量
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
        json.put("sign", signJson);//签约数
        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
@ -159,8 +157,6 @@ public class MessageService extends BaseService {
    }
    /**
     * 查询健康咨询列表
     *
@ -253,66 +249,59 @@ public class MessageService extends BaseService {
    }
    public JSONObject findMessageNum(String doctor, Integer type) {
        JSONObject jo=new JSONObject();
        JSONObject jo = new JSONObject();
        //得到消息总数
        int count= messageDao.findMessageNum(doctor,type);
        String DateString="";
        String message="";
        String sql="select w.* from wlyy_message w where w.type='"+type+"' and w.receiver='"+doctor+"' order by w.czrq desc limit 0,1";
        List<Message> returnList= jdbcTemplate.query(sql,new BeanPropertyRowMapper(Message.class));
        if(returnList!=null&&returnList.size()>0){
            Message m=returnList.get(0);
            DateString=DateUtil.dateToStrShort(m.getCzrq());
            message=m.getContent();
        int count = messageDao.findMessageNum(doctor, type);
        String DateString = "";
        String message = "";
        String sql = "select w.* from wlyy_message w where w.type='" + type + "' and w.receiver='" + doctor + "' order by w.czrq desc limit 0,1";
        List<Message> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(Message.class));
        if (returnList != null && returnList.size() > 0) {
            Message m = returnList.get(0);
            DateString = DateUtil.dateToStrShort(m.getCzrq());
            message = m.getContent();
        }
        jo.put("count",count);
        jo.put("message",message);
        jo.put("date",DateString);
        jo.put("count", count);
        jo.put("message", message);
        jo.put("date", DateString);
        return jo;
    }
    /**
     * 获取超标指标消息--根据患者分组
     */
    public List<Map<String,Object>> getHealthIndexMessage(String doctor)throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
        String sql = "select a.sender,a.tz_type,count(1) count,max(date_format(a.czrq,'%Y-%c-%d %h:%i:%s')) last_time from wlyy_Message a where a.receiver='"+doctor+"' and a.has_read='1' and a.type='2' group by a.sender,a.tz_type order by last_time desc";
        List<Map<String,Object>> list =jdbcTemplate.queryForList(sql);
        for(Map<String,Object> item:list)
        {
            Map<String,Object> obj = new HashMap<>();
    public List<Map<String, Object>> getHealthIndexMessage(String doctor) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        String sql = "select a.sender,a.tz_type,count(1) count,max(date_format(a.czrq,'%Y-%c-%d %h:%i:%s')) last_time from wlyy_Message a where a.receiver='" + doctor + "' and a.has_read='1' and a.type='2' group by a.sender,a.tz_type order by last_time desc";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> item : list) {
            Map<String, Object> obj = new HashMap<>();
            String patientCode = String.valueOf(item.get("sender"));
            //获取患者信息
            Patient patient =patientDao.findByCode(patientCode);
            if(patient!=null)
            {
            Patient patient = patientDao.findByCode(patientCode);
            if (patient != null) {
                String type = String.valueOf(item.get("tz_type")); //1血糖,2血压,3体重,4腰
                obj.put("patient",patientCode);
                obj.put("type",type);
                obj.put("time",item.get("last_time"));
                obj.put("name",patient.getName());
                obj.put("sex",patient.getSex());
                obj.put("birthday",DateUtil.dateToStrShort(patient.getBirthday()));
                obj.put("sex",patient.getSex());
                obj.put("photo",patient.getPhoto());
                if("1".equals(type))
                {
                    obj.put("message","有"+item.get("count")+"条血糖异常未读消息") ;
                }
                else if("2".equals(type))
                {
                    obj.put("message","有"+item.get("count")+"条血压异常未读消息") ;
                }
                else{
                obj.put("patient", patientCode);
                obj.put("type", type);
                obj.put("time", item.get("last_time"));
                obj.put("name", patient.getName());
                obj.put("sex", patient.getSex());
                obj.put("birthday", DateUtil.dateToStrShort(patient.getBirthday()));
                obj.put("sex", patient.getSex());
                obj.put("photo", patient.getPhoto());
                if ("1".equals(type)) {
                    obj.put("message", "有" + item.get("count") + "条血糖异常未读消息");
                } else if ("2".equals(type)) {
                    obj.put("message", "有" + item.get("count") + "条血压异常未读消息");
                } else {
                    break;
                }
                re.add(obj);
            }
            else{
                System.out.print("not exit patient!code:"+patientCode);
            } else {
                System.out.print("not exit patient!code:" + patientCode);
            }
        }
        return re;
@ -321,32 +310,42 @@ public class MessageService extends BaseService {
    /**
     * 获取患者超标指标消息
     */
    public List<Map<String,String>> getHealthIndexMessageByPatient(String doctor, String patient, String type, Integer page, Integer pagesize)throws Exception{
    public List<Map<String, String>> getHealthIndexMessageByPatient(String doctor, String patient, String type, Integer page, Integer pagesize) throws Exception {
        List<Map<String,String>> re = new ArrayList<>();
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        Pageable pageRequest = new PageRequest(page-1, pagesize, sort);
        List<Message> list= messageDao.getHealthIndexMessageByPatient(doctor,patient,type,pageRequest);
        if(list!=null && list.size()>0)
        {
            for(Message item:list)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",String.valueOf(item.getId()));
                map.put("sender",item.getSender());
                map.put("senderName",item.getSenderName());
                map.put("senderPhoto",item.getSenderPhoto());
                map.put("type",type);
                map.put("read",String.valueOf(item.getRead()));
                map.put("sex",String.valueOf(item.getSex()));
                map.put("value1",String.valueOf(item.getValue1()));
                map.put("value2",String.valueOf(item.getValue2()));
                map.put("czrq",DateUtil.dateToStrLong(item.getCzrq()));
        Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
        List<Message> list = messageDao.getHealthIndexMessageByPatient(doctor, patient, type, pageRequest);
        if (list != null && list.size() > 0) {
            for (Message item : list) {
                Map<String, String> map = new HashMap<>();
                map.put("id", String.valueOf(item.getId()));
                map.put("sender", item.getSender());
                map.put("senderName", item.getSenderName());
                map.put("senderPhoto", item.getSenderPhoto());
                map.put("type", type);
                map.put("read", String.valueOf(item.getRead()));
                map.put("sex", String.valueOf(item.getSex()));
                map.put("value1", String.valueOf(item.getValue1()));
                map.put("value2", String.valueOf(item.getValue2()));
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 获取系统消息
     */
    public List<Message> getSystemMessage(String doctor,Integer page,Integer pagesize) throws Exception
    {
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, pagesize,sort);
        return messageDao.getSystemMessage(doctor,pageRequest);
    }
}

+ 53 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -155,49 +155,27 @@ public class DoctorMessageController extends BaseController {
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 * 系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "findMessage")
	@RequestMapping(value = "getSystemMessage",method = RequestMethod.GET)
	@ResponseBody
	public String findMessage(String type,
							   long id,
							   int pagesize) {
	@ApiOperation("获取系统消息")
	public String getSystemMessage(@ApiParam(value="第几页",defaultValue = "1")
							  @RequestParam Integer page,
							  @ApiParam(value="每页几行",defaultValue = "10")
							  @RequestParam Integer pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
			List<Message> list = messageService.getSystemMessage(getUID(),page,pagesize);
			return write(200, "获取消息成功!", "list", list);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	@RequestMapping(value = "getHealthIndexMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取超标指标消息--根据患者分组")
@ -301,4 +279,46 @@ public class DoctorMessageController extends BaseController {
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "findMessage")
	@ResponseBody
	@ApiOperation("获取某类消息(1.2.8版本作废)")
	public String findMessage(String type,
							  long id,
							  int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
}