|
@ -101,49 +101,43 @@ public class MessageService extends BaseService {
|
|
* 查询医生未读消息和最后消息
|
|
* 查询医生未读消息和最后消息
|
|
*/
|
|
*/
|
|
public JSONObject findDoctorAllMessage(String doctor) throws Exception {
|
|
public JSONObject findDoctorAllMessage(String doctor) throws Exception {
|
|
// 签约未读消息总数
|
|
|
|
int sign = messageDao.amountUnreadByReceiver(doctor);
|
|
|
|
JSONObject signJson = new JSONObject();
|
|
|
|
signJson.put("amount", sign);
|
|
|
|
if (sign > 0) {
|
|
|
|
|
|
// 关注未读消息总数
|
|
|
|
int concern = messageDao.amountUnreadConcernByReceiver(doctor);
|
|
|
|
JSONObject concernJson = new JSONObject();
|
|
|
|
concernJson.put("amount", concern);
|
|
|
|
if (concern > 0) {
|
|
PageRequest pageRequest = new PageRequest(0, 1);
|
|
PageRequest pageRequest = new PageRequest(0, 1);
|
|
Page<Message> msgs = messageDao.amountUnreadLastByReceiver(doctor, pageRequest);
|
|
|
|
|
|
Page<Message> msgs = messageDao.amountUnreadConcernLastByReceiver(doctor, pageRequest);
|
|
|
|
|
|
if (msgs != null && msgs.getSize() > 0) {
|
|
if (msgs != null && msgs.getSize() > 0) {
|
|
for (Message msg : msgs) {
|
|
for (Message msg : msgs) {
|
|
JSONObject msgJson = new JSONObject();
|
|
JSONObject msgJson = new JSONObject();
|
|
msgJson.put("title", msg.getTitle());
|
|
msgJson.put("title", msg.getTitle());
|
|
msgJson.put("type", msg.getType());
|
|
msgJson.put("type", msg.getType());
|
|
if (msg.getSignStatus().equals("4")) {
|
|
|
|
msgJson.put("msg", msg.getSenderName() + "申请与您解除家庭签约");
|
|
|
|
} else if(msg.getSignStatus().equals("8")){
|
|
|
|
msgJson.put("msg", msg.getSenderName() + "申请与您续签家庭医生");
|
|
|
|
}else{
|
|
|
|
msgJson.put("msg", msg.getSenderName() + "申请与您签约家庭医生");
|
|
|
|
}
|
|
|
|
msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCzrq()));
|
|
|
|
signJson.put("lastMessage", msgJson);
|
|
|
|
|
|
msgJson.put("msg",msg.getContent());
|
|
|
|
msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCreateTime()));
|
|
|
|
concernJson.put("lastMessage", msgJson);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 体征指标未读消息总数
|
|
// 体征指标未读消息总数
|
|
Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
|
|
|
|
JSONObject indexJson = new JSONObject();
|
|
|
|
indexJson.put("amount", healthIndex);
|
|
|
|
if (healthIndex > 0) {
|
|
|
|
PageRequest pageRequest = new PageRequest(0, 1);
|
|
|
|
List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
|
|
|
|
|
|
|
|
if (msgs != null && msgs.size() > 0) {
|
|
|
|
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()));
|
|
|
|
indexJson.put("lastMessage", msgJson);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
|
|
|
|
// JSONObject indexJson = new JSONObject();
|
|
|
|
// indexJson.put("amount", healthIndex);
|
|
|
|
// if (healthIndex > 0) {
|
|
|
|
// PageRequest pageRequest = new PageRequest(0, 1);
|
|
|
|
// List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
|
|
|
|
//
|
|
|
|
// if (msgs != null && msgs.size() > 0) {
|
|
|
|
// 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()));
|
|
|
|
// indexJson.put("lastMessage", msgJson);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
//获取未读系统消息
|
|
//获取未读系统消息
|
|
List<Message> systemMessage = messageDao.getSystemMessageUnread(doctor);
|
|
List<Message> systemMessage = messageDao.getSystemMessageUnread(doctor);
|
|
@ -161,42 +155,27 @@ public class MessageService extends BaseService {
|
|
}
|
|
}
|
|
|
|
|
|
//获取续方消息
|
|
//获取续方消息
|
|
List<Message> prescriptionMessage = messageDao.getSysTemMessageByPrescription(doctor,"0");
|
|
|
|
JSONObject prescriptionJson = new JSONObject();
|
|
|
|
if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
|
|
|
|
prescriptionJson.put("amount", prescriptionMessage.size());
|
|
|
|
JSONObject msgJson = new JSONObject();
|
|
|
|
msgJson.put("title", prescriptionMessage.get(0).getTitle());
|
|
|
|
msgJson.put("type", prescriptionMessage.get(0).getType());
|
|
|
|
msgJson.put("msg", prescriptionMessage.get(0).getContent());
|
|
|
|
msgJson.put("msgTime", DateUtil.dateToStrLong(prescriptionMessage.get(0).getCreateTime()));
|
|
|
|
prescriptionJson.put("lastMessage", msgJson);
|
|
|
|
} else {
|
|
|
|
prescriptionJson.put("amount", 0);
|
|
|
|
}
|
|
|
|
|
|
// List<Message> prescriptionMessage = messageDao.getSysTemMessageByPrescription(doctor,"0");
|
|
|
|
// JSONObject prescriptionJson = new JSONObject();
|
|
|
|
// if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
|
|
|
|
// prescriptionJson.put("amount", prescriptionMessage.size());
|
|
|
|
// JSONObject msgJson = new JSONObject();
|
|
|
|
// msgJson.put("title", prescriptionMessage.get(0).getTitle());
|
|
|
|
// msgJson.put("type", prescriptionMessage.get(0).getType());
|
|
|
|
// msgJson.put("msg", prescriptionMessage.get(0).getContent());
|
|
|
|
// msgJson.put("msgTime", DateUtil.dateToStrLong(prescriptionMessage.get(0).getCreateTime()));
|
|
|
|
// prescriptionJson.put("lastMessage", msgJson);
|
|
|
|
// } else {
|
|
|
|
// prescriptionJson.put("amount", 0);
|
|
|
|
// }
|
|
|
|
|
|
//协同服务
|
|
|
|
List<Message> callServiceMes = messageDao.findByReceiverCallService(doctor);
|
|
|
|
JSONObject callServiceMesJson = new JSONObject();
|
|
|
|
if (callServiceMes != null && callServiceMes.size() > 0) {
|
|
|
|
callServiceMesJson.put("amount", callServiceMes.size());
|
|
|
|
JSONObject callJson = new JSONObject();
|
|
|
|
callJson.put("title", callServiceMes.get(0).getTitle());
|
|
|
|
callJson.put("type", callServiceMes.get(0).getType());
|
|
|
|
callJson.put("msg", callServiceMes.get(0).getContent());
|
|
|
|
callJson.put("msgTime", DateUtil.dateToStrLong(callServiceMes.get(0).getCreateTime()));
|
|
|
|
callServiceMesJson.put("lastMessage", callJson);
|
|
|
|
} else {
|
|
|
|
callServiceMesJson.put("amount", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
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("concern", concernJson);//关注数
|
|
|
|
// json.put("healthIndex", indexJson);//健康指标
|
|
json.put("system", systemJson);//系统消息
|
|
json.put("system", systemJson);//系统消息
|
|
json.put("prescription", prescriptionJson);//续方消息
|
|
|
|
json.put("callService", callServiceMesJson);//协同服务消息
|
|
|
|
|
|
// json.put("prescription", prescriptionJson);//续方消息
|
|
|
|
|
|
return json;
|
|
return json;
|
|
}
|
|
}
|