|
@ -7,9 +7,11 @@ import javax.transaction.Transactional;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
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;
|
|
@ -17,6 +19,7 @@ import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
@ -46,6 +49,8 @@ public class MessageService extends BaseService {
|
|
|
private MessageDao messageDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
/**
|
|
|
* 汇总查询医生的消息总数
|
|
@ -252,8 +257,81 @@ public class MessageService extends BaseService {
|
|
|
return jo;
|
|
|
}
|
|
|
|
|
|
public void changeMessageToRead(Long id) {
|
|
|
Message message= messageDao.findOne(id);
|
|
|
message.setRead(1);
|
|
|
/**
|
|
|
* 获取超标指标消息--根据患者分组
|
|
|
*/
|
|
|
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)
|
|
|
{
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
re.add(obj);
|
|
|
}
|
|
|
else{
|
|
|
System.out.print("not exit patient!code:"+patientCode);
|
|
|
}
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取患者超标指标消息
|
|
|
*/
|
|
|
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<>();
|
|
|
// 排序
|
|
|
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()));
|
|
|
re.add(map);
|
|
|
}
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
}
|