|
@ -26,6 +26,7 @@ import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
|
|
|
import com.yihu.wlyy.service.third.iot.IotDeviceService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.*;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
@ -228,7 +229,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
" ORDER BY " +
|
|
|
" a.record_date DESC " +
|
|
|
"LIMIT 0,1 ";
|
|
|
List<Map<String, Object>> devicePatient = jdbcTemplate.queryForList(sql, patient, type);
|
|
|
// List<Map<String, Object>> devicePatient = jdbcTemplate.queryForList(sql, patient, type);
|
|
|
List<Map<String, Object>> devicePatient = findDataByPatient(sql, patient, type);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
for (Map<String, Object> device : devicePatient) {
|
|
|
String time = device.get("record_date") == null ? null : device.get("record_date").toString();
|
|
@ -429,7 +431,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
" and del = '1' " +
|
|
|
" GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
|
|
|
" order by record_date,id desc ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> list = getPatientXT_JsonIot(sql,patient,dateString);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
obj.put("type", 1);
|
|
|
obj.put("czrq", date);
|
|
@ -639,6 +642,171 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询最近的一条体征数据
|
|
|
* @param sql
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> findDataByPatient(String sql,String patient,Integer type){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
List<Map<String, Object>> re = new ArrayList<>();
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndType(patient,type,1);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
re.add(indexToMap(list.get(0)));
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
return jdbcTemplate.queryForList(sql, patient, type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 患者最近填写的健康指标
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DevicePatientHealthIndex> findRecentByPatientIterable(String patient){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
return iotDeviceService.findByPatientAndType(patient,null,1000);
|
|
|
}else {
|
|
|
return patientHealthIndexDao.findRecentByPatient(patient);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据患者标志获取健康指标
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public DevicePatientHealthIndex findLastByPatienIot(String patient,Integer type){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
DevicePatientHealthIndex index = null;
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndType(patient,type,1);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
index = list.get(0);
|
|
|
}
|
|
|
return index;
|
|
|
}else {
|
|
|
return findLastByPatien(patient,type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询指标记录
|
|
|
* @param patient
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public List<String> findDateListIot(String patient,Date startDate,Date endDate, Integer page, Integer size,String start, String end){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
List<String> re = new ArrayList<>();
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndTime(patient, null,page, size, null, start, end);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
list.forEach(one->{
|
|
|
re.add(DateUtil.dateToStrShort(one.getRecordDate()));
|
|
|
});
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
return patientHealthIndexDao.findDateList(patient,startDate,endDate,page,size);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间查找
|
|
|
* @param sql
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @param size
|
|
|
* @param gi_type
|
|
|
* @param begin
|
|
|
* @param end
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> findByPatientAndTime(String sql,String patient,Integer type,Integer size,Integer gi_type, String begin, String end){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
List<Map<String, Object>> re = new ArrayList<>();
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndTime(patient, type,1, size, gi_type, begin, end);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
list.forEach(one->{
|
|
|
re.add(indexToMap(one));
|
|
|
});
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间查找
|
|
|
* @param sql
|
|
|
* @param patient
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getPatientXT_JsonIot(String sql,String patient, String date){
|
|
|
String begin = date +" 00:00:00";
|
|
|
String end= date +" 23:59:59";
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
List<Map<String, Object>> re = new ArrayList<>();
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndTime(patient, 1,1, 100, null, begin, end);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
list.forEach(one->{
|
|
|
re.add(indexToMap(one));
|
|
|
});
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间查找
|
|
|
* @param sql
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getPatientXT_JsonIot(String sql,String patient,Integer type,Integer page,Integer size, String begin,String end){
|
|
|
if(iotDeviceService.isUploadIot()){
|
|
|
List<Map<String, Object>> re = new ArrayList<>();
|
|
|
List<DevicePatientHealthIndex> list = iotDeviceService.findByPatientAndTime(patient, type,page, size, null, begin, end);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
list.forEach(one->{
|
|
|
re.add(indexToMap(one));
|
|
|
});
|
|
|
}
|
|
|
return re;
|
|
|
}else {
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转map
|
|
|
* @param index
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<String, Object> indexToMap(DevicePatientHealthIndex index){
|
|
|
Map<String, Object> map = new HashedMap();
|
|
|
map.put("value1",index.getValue1());
|
|
|
map.put("value2",index.getValue2());
|
|
|
map.put("value3",index.getValue3());
|
|
|
map.put("value4",index.getValue4());
|
|
|
map.put("value5",index.getValue5());
|
|
|
map.put("value6",index.getValue6());
|
|
|
map.put("value7",index.getValue7());
|
|
|
map.put("device_sn",index.getDeviceSn());
|
|
|
map.put("record_date",index.getRecordDate());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/********************************************物联网 end***********************************************************/
|
|
|
|
|
@ -1177,7 +1345,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
sql = sql + conditionApp +
|
|
|
" GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
|
|
|
" order by record_date desc ,sort_date desc limit " + 0 + " ," + 1000 + " ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> list = findByPatientAndTime(sql,patient,type,1000,gi_type,begin,end);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", map.get("id"));
|
|
@ -1464,7 +1633,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
" and del = '1' " +
|
|
|
" GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
|
|
|
" order by record_date desc ,sort_date desc limit " + pageRequest.getOffset() + " ," + pageRequest.getPageSize() + " ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> list = getPatientXT_JsonIot(sql,patient,type,pageRequest.getOffset(),pageRequest.getPageSize(),start,end);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", map.get("id"));
|
|
@ -1519,7 +1689,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
{
|
|
|
PageRequest pageRequest = new PageRequest(page, pageSize);
|
|
|
//根据时间过滤排序
|
|
|
List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
// List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
List<String> dateList = findDateListIot(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize(), start, end);
|
|
|
if (dateList != null && dateList.size() > 0) {
|
|
|
for (String dateString : dateList) {
|
|
|
com.alibaba.fastjson.JSONObject obj = getPatientXT_Json(patient, dateString);
|
|
@ -1564,7 +1735,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
*/
|
|
|
public JSONArray findRecentByPatient(String patient) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
Iterable<DevicePatientHealthIndex> iterable = patientHealthIndexDao.findRecentByPatient(patient);
|
|
|
// List<DevicePatientHealthIndex> iterable = patientHealthIndexDao.findRecentByPatient(patient);
|
|
|
List<DevicePatientHealthIndex> iterable = findRecentByPatientIterable(patient);
|
|
|
if (iterable != null) {
|
|
|
Iterator<DevicePatientHealthIndex> iterator = iterable.iterator();
|
|
|
while (iterator != null && iterator.hasNext()) {
|