|
@ -176,54 +176,27 @@ public class NoticeJob implements Job {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
private JSONObject findDoctorAllMessage(String doctor) {
|
|
|
private int findDoctorAllMessage(String doctor) {
|
|
|
// 签约未读消息总数
|
|
|
int sign = messageDao.amountUnreadByReceiver(doctor);
|
|
|
org.json.JSONObject signJson = new org.json.JSONObject();
|
|
|
signJson.put("amount", sign);
|
|
|
if (sign > 0) {
|
|
|
PageRequest pageRequest = new PageRequest(0, 1);
|
|
|
Page<Message> msgs = messageDao.amountUnreadLastByReceiver(doctor, pageRequest);
|
|
|
|
|
|
if (msgs != null && msgs.getSize() > 0) {
|
|
|
for (Message msg : msgs) {
|
|
|
org.json.JSONObject msgJson = new org.json.JSONObject();
|
|
|
if (msg.getSignStatus().equals("4")) {
|
|
|
msgJson.put("msg", msg.getSenderName() + "申请与您解除家庭签约");
|
|
|
} else {
|
|
|
msgJson.put("msg", msg.getSenderName() + "申请与您签约家庭医生");
|
|
|
}
|
|
|
msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
|
|
|
signJson.put("lastMessage", msgJson);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 体征指标未读消息总数
|
|
|
int healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
|
|
|
org.json.JSONObject indexJson = new org.json.JSONObject();
|
|
|
indexJson.put("amount", healthIndex);
|
|
|
if (sign > 0) {
|
|
|
PageRequest pageRequest = new PageRequest(0, 1);
|
|
|
Page<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
|
|
|
|
|
|
if (msgs != null && msgs.getSize() > 0) {
|
|
|
for (Message msg : msgs) {
|
|
|
org.json.JSONObject msgJson = new org.json.JSONObject();
|
|
|
msgJson.put("msg", msg.getContent());
|
|
|
msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
|
|
|
indexJson.put("lastMessage", msgJson);
|
|
|
}
|
|
|
Integer doctorCount = 0;
|
|
|
Integer patientCount = 0;
|
|
|
JSONObject json = new JSONObject();
|
|
|
getImMsgAmount(json, doctor);
|
|
|
if (json.containsKey("imMsgCount")) {
|
|
|
JSONObject jsonC=json.getJSONObject("imMsgCount");
|
|
|
if (jsonC.containsKey("doctor")) {
|
|
|
doctorCount = jsonC.getInt("doctor");
|
|
|
}
|
|
|
if (jsonC.containsKey("patient")) {
|
|
|
patientCount = jsonC.getInt("patient");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
getImMsgAmount(json, doctor);
|
|
|
//json.put("consult", consultJson);
|
|
|
//json.put("famousConsult", famousJson);
|
|
|
json.put("sign", signJson);
|
|
|
json.put("healthIndex", indexJson);
|
|
|
return json;
|
|
|
return sign + healthIndex + doctorCount + patientCount;
|
|
|
}
|
|
|
|
|
|
private void getImMsgAmount(JSONObject obj, String doctor) {
|
|
@ -236,40 +209,6 @@ public class NoticeJob implements Job {
|
|
|
/**
|
|
|
* {"msg":"获取消息总数成功!","data":{"imMsgCount":"{\"doctor\":0,\"patient\":0}","healthIndex":{"amount":0},"sign":{"amount":0}},"status":200}
|
|
|
*/
|
|
|
JSONObject jo = findDoctorAllMessage(doctor);
|
|
|
Integer countAll = 0;
|
|
|
Integer doctorCount = 0;
|
|
|
Integer patientCount = 0;
|
|
|
Integer healthIndexAmountCount = 0;
|
|
|
Integer signAmountCount = 0;
|
|
|
if (jo.has("imMsgCount")) {
|
|
|
JSONObject imMsgCounnt = jo.getJSONObject("imMsgCount");
|
|
|
if (imMsgCounnt.has("doctor")) {
|
|
|
doctorCount = imMsgCounnt.getInt("doctor");
|
|
|
}
|
|
|
if (imMsgCounnt.has("patient")) {
|
|
|
patientCount = imMsgCounnt.getInt("patient");
|
|
|
}
|
|
|
}
|
|
|
if (jo.has("healthIndex")) {
|
|
|
JSONObject healthIndexCount = jo.getJSONObject("healthIndex");
|
|
|
if (healthIndexCount.has("amount")) {
|
|
|
healthIndexAmountCount = healthIndexCount.getInt("amount");
|
|
|
}
|
|
|
}
|
|
|
if (jo.has("sign")) {
|
|
|
JSONObject signAmountCountJO = jo.getJSONObject("sign");
|
|
|
if (signAmountCountJO.has("amount")) {
|
|
|
signAmountCount = signAmountCountJO.getInt("amount");
|
|
|
}
|
|
|
}
|
|
|
if (jo.has("system")) {
|
|
|
JSONObject signAmountCountJO = jo.getJSONObject("system");
|
|
|
if (signAmountCountJO.has("amount")) {
|
|
|
signAmountCount = signAmountCountJO.getInt("amount");
|
|
|
}
|
|
|
}
|
|
|
countAll = doctorCount + patientCount + healthIndexAmountCount + signAmountCount;
|
|
|
return countAll;
|
|
|
return findDoctorAllMessage(doctor);
|
|
|
}
|
|
|
}
|