|
@ -1,23 +1,18 @@
|
|
|
package com.yihu.wlyy.service.app.message;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
|
|
|
import com.yihu.wlyy.entity.consult.ConsultTeam;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
|
|
|
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.wlyy.repository.deviece.DeviceDao;
|
|
|
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import io.swagger.models.auth.In;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@ -33,9 +28,11 @@ import org.springside.modules.persistence.DynamicSpecifications;
|
|
|
import org.springside.modules.persistence.SearchFilter;
|
|
|
import org.springside.modules.persistence.SearchFilter.Operator;
|
|
|
|
|
|
import com.yihu.wlyy.entity.consult.ConsultTeam;
|
|
|
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 消息业务处理类
|
|
@ -279,37 +276,77 @@ public class MessageService extends BaseService {
|
|
|
*/
|
|
|
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";
|
|
|
String sql = "select a.sender,a.tz_type,count(1) count,max(date_format(a.czrq,'%Y-%c-%d %H:%i:%s')) last_time,a.has_read from wlyy_Message a where a.receiver='" + doctor + "' and a.type='2' group by a.sender,a.tz_type,a.has_read order by last_time desc";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
Map<String,Map<String, Object>> map = new HashMap<>();
|
|
|
for (Map<String, Object> item : list) {
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
Map<String, Object> obj = null;
|
|
|
String patientCode = String.valueOf(item.get("sender"));
|
|
|
//获取患者信息
|
|
|
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 {
|
|
|
break;
|
|
|
String read = String.valueOf(item.get("has_read")); //0已读,1未读
|
|
|
String patientType = patientCode + type;
|
|
|
if(map.containsKey(patientType)){
|
|
|
obj = map.get(patientType);
|
|
|
if(obj.get("time").toString().compareTo(item.get("last_time").toString())<0){
|
|
|
obj.put("time", item.get("last_time"));
|
|
|
}
|
|
|
}else{
|
|
|
obj = new HashMap<>();
|
|
|
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("photo", patient.getPhoto());
|
|
|
}
|
|
|
if("1".equals(read)){
|
|
|
obj.put("count1", item.get("count"));
|
|
|
}else{
|
|
|
obj.put("count0", item.get("count"));
|
|
|
}
|
|
|
|
|
|
re.add(obj);
|
|
|
map.put(patientType,obj);
|
|
|
// 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (Map<String, Object> item : map.values()) {
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
String type = String.valueOf(item.get("type")); //1血糖,2血压,3体重,4腰
|
|
|
String count1 = item.get("count1")==null?"0":item.get("count1").toString();
|
|
|
String count0 = item.get("count0")==null?"0":item.get("count0").toString();
|
|
|
|
|
|
obj.put("patient", item.get("patient"));
|
|
|
obj.put("type", type);
|
|
|
obj.put("time", item.get("time"));
|
|
|
obj.put("name", item.get("name"));
|
|
|
obj.put("sex", item.get("sex"));
|
|
|
obj.put("birthday", item.get("birthday"));
|
|
|
obj.put("photo", item.get("photo"));
|
|
|
if ("1".equals(type)) {
|
|
|
obj.put("message", "有血糖异常未读消息"+count1+"条,已读消息"+count0+"条");
|
|
|
} else if ("2".equals(type)) {
|
|
|
obj.put("message", "有血压异常未读消息"+count1+"条,已读消息"+count0+"条");
|
|
|
} else {
|
|
|
break;
|
|
|
}
|
|
|
re.add(obj);
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|