|
@ -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);
|
|
|
}
|
|
|
}
|