|
@ -464,18 +464,42 @@ public class PatientHealthIndexService extends BaseService {
|
|
Date date = DateUtil.strToDateShort(dateString);
|
|
Date date = DateUtil.strToDateShort(dateString);
|
|
/***************** 按时间排序 ***************************/
|
|
/***************** 按时间排序 ***************************/
|
|
|
|
|
|
List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
"MIN(id) id" +
|
|
|
|
", user" +
|
|
|
|
",value1" +
|
|
|
|
",value2" +
|
|
|
|
",value3" +
|
|
|
|
",value4" +
|
|
|
|
",value5" +
|
|
|
|
",value6" +
|
|
|
|
",value7" +
|
|
|
|
",device_sn" +
|
|
|
|
",type" +
|
|
|
|
",record_date" +
|
|
|
|
",sort_date" +
|
|
|
|
",min(czrq) czrq " +
|
|
|
|
" from device.wlyy_patient_health_index " +
|
|
|
|
" WHERE `user` = '"+patient+"' " +
|
|
|
|
" and type = 1" +
|
|
|
|
" and DATE_FORMAT(record_date,'%Y-%m-%d') = '"+dateString+"'" +
|
|
|
|
" 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<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
|
|
if (list != null && list.size() > 0) {
|
|
if (list != null && list.size() > 0) {
|
|
obj.put("type", 1);
|
|
obj.put("type", 1);
|
|
obj.put("czrq", date);
|
|
obj.put("czrq", date);
|
|
obj.put("recordDate", date);
|
|
obj.put("recordDate", date);
|
|
obj.put("sortDate", date);
|
|
obj.put("sortDate", date);
|
|
for (DevicePatientHealthIndex item : list) {
|
|
|
|
String data = item.getValue1();
|
|
|
|
String dataType = item.getValue2();
|
|
|
|
String deviceSn = item.getDeviceSn()==null?"":item.getDeviceSn();
|
|
|
|
String recordDate = DateUtil.dateToStr(item.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
|
Long id = item.getId();
|
|
|
|
|
|
for (Map<String,Object> item : list) {
|
|
|
|
String data = item.get("value1").toString();
|
|
|
|
String dataType = item.get("value2").toString();
|
|
|
|
String deviceSn = item.get("device_sn")==null?"":item.get("device_sn").toString();
|
|
|
|
String recordDate = item.get("record_date").toString();
|
|
|
|
Long id = Long.parseLong(item.get("id")+"");
|
|
if (data != null && dataType != null) {
|
|
if (data != null && dataType != null) {
|
|
if (dataType.equals("1")) {
|
|
if (dataType.equals("1")) {
|
|
obj.put("value1", data);
|
|
obj.put("value1", data);
|
|
@ -776,23 +800,78 @@ public class PatientHealthIndexService extends BaseService {
|
|
* @param end 结束时间
|
|
* @param end 结束时间
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<DevicePatientHealthIndex> findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
|
|
|
|
List<DevicePatientHealthIndex> re = new ArrayList<>();
|
|
|
|
|
|
public JSONArray findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
|
|
|
|
JSONArray re = new JSONArray();
|
|
|
|
|
|
Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
if (gi_type != 0) {
|
|
|
|
Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
|
PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
|
re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
"MIN(id) id" +
|
|
|
|
", user" +
|
|
|
|
",value1" +
|
|
|
|
",value2" +
|
|
|
|
",value3" +
|
|
|
|
",value4" +
|
|
|
|
",value5" +
|
|
|
|
",value6" +
|
|
|
|
",value7" +
|
|
|
|
",device_sn" +
|
|
|
|
",type" +
|
|
|
|
",record_date" +
|
|
|
|
",sort_date" +
|
|
|
|
",min(czrq) czrq " +
|
|
|
|
" from device.wlyy_patient_health_index " +
|
|
|
|
" WHERE `user` = '"+patient+"' " +
|
|
|
|
" and type =" +type+
|
|
|
|
" and record_date >= '"+begin+"'" +
|
|
|
|
" and record_date <= '"+end+"' " +
|
|
|
|
" and del = '1' " ;
|
|
|
|
String conditionApp = "";
|
|
|
|
if(gi_type != 0){
|
|
|
|
conditionApp = " and value2 = '"+gi_type+"' ";
|
|
|
|
}
|
|
|
|
sql = sql +conditionApp +
|
|
|
|
" GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
|
|
|
|
" order by sort_date desc ,record_date desc limit "+0+" ,"+1000+" ";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
for (Map<String,Object> map:list){
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("id",map.get("id"));
|
|
|
|
json.put("patient",map.get("user"));
|
|
|
|
json.put("value1",map.get("value1"));
|
|
|
|
json.put("value2",map.get("value2"));
|
|
|
|
json.put("value3",map.get("value3"));
|
|
|
|
json.put("value4",map.get("value4"));
|
|
|
|
json.put("value5",map.get("value5"));
|
|
|
|
json.put("value6",map.get("value6"));
|
|
|
|
json.put("value7",map.get("value7"));
|
|
|
|
json.put("deviceSn",map.get("device_sn")==null?"":map.get("device_sn"));
|
|
|
|
json.put("type",map.get("type"));
|
|
|
|
|
|
|
|
Date date = (Date) map.get("record_date");
|
|
|
|
if (type == 2) {
|
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
|
} else {
|
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
|
|
|
|
}
|
|
|
|
json.put("sortDate",map.get("sort_date"));
|
|
|
|
json.put("czrq",map.get("czrq"));
|
|
|
|
|
|
} else {
|
|
|
|
// 排序
|
|
|
|
Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
|
PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
|
re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
|
|
re.put(json);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// if (gi_type != 0) {
|
|
|
|
// Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
|
// PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
|
// re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
//
|
|
|
|
// } else {
|
|
|
|
// // 排序
|
|
|
|
// Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
|
// PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
|
// re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
// }
|
|
|
|
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|
|
|
|
|
|
@ -807,8 +886,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
* @param pageSize
|
|
* @param pageSize
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, String start, String end, int page, int pageSize) {
|
|
|
|
List<DevicePatientHealthIndex> re = new ArrayList<>();
|
|
|
|
|
|
public JSONArray findIndexByPatient(String patient, int type, String start, String end, int page, int pageSize) {
|
|
|
|
JSONArray re = new JSONArray();
|
|
if (page > 0) {
|
|
if (page > 0) {
|
|
page = page - 1;
|
|
page = page - 1;
|
|
}
|
|
}
|
|
@ -817,23 +896,74 @@ public class PatientHealthIndexService extends BaseService {
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
if (type == 1) //血糖特殊处理
|
|
if (type == 1) //血糖特殊处理
|
|
{
|
|
{
|
|
PageRequest pageRequest = new PageRequest(page, pageSize);
|
|
|
|
//根据时间过滤排序
|
|
|
|
List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
if (dateList != null && dateList.size() > 0) {
|
|
|
|
for (String dateString : dateList) {
|
|
|
|
DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
|
|
|
|
if (obj != null) {
|
|
|
|
re.add(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// PageRequest pageRequest = new PageRequest(page, pageSize);
|
|
|
|
// //根据时间过滤排序
|
|
|
|
// List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
// if (dateList != null && dateList.size() > 0) {
|
|
|
|
// for (String dateString : dateList) {
|
|
|
|
// DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
|
|
|
|
// if (obj != null) {
|
|
|
|
// re.add(obj);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
} else {
|
|
} else {
|
|
// 排序
|
|
// 排序
|
|
Sort sort = new Sort(Direction.DESC, "recordDate");
|
|
Sort sort = new Sort(Direction.DESC, "recordDate");
|
|
PageRequest pageRequest = new PageRequest(page, pageSize, sort);
|
|
PageRequest pageRequest = new PageRequest(page, pageSize, sort);
|
|
List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
re = list;
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
"MIN(id) id" +
|
|
|
|
", user" +
|
|
|
|
",value1" +
|
|
|
|
",value2" +
|
|
|
|
",value3" +
|
|
|
|
",value4" +
|
|
|
|
",value5" +
|
|
|
|
",value6" +
|
|
|
|
",value7" +
|
|
|
|
",device_sn" +
|
|
|
|
",type" +
|
|
|
|
",record_date" +
|
|
|
|
",sort_date" +
|
|
|
|
",min(czrq) czrq " +
|
|
|
|
" from device.wlyy_patient_health_index " +
|
|
|
|
" WHERE `user` = '"+patient+"' " +
|
|
|
|
" and type =" +type+
|
|
|
|
" and record_date >= '"+start+"'" +
|
|
|
|
" and record_date <= '"+end+"' " +
|
|
|
|
" and del = '1' " +
|
|
|
|
" GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
|
|
|
|
" order by sort_date desc ,record_date desc limit "+pageRequest.getOffset()+" ,"+pageRequest.getPageSize()+" ";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
for (Map<String,Object> map:list){
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("id",map.get("id"));
|
|
|
|
json.put("patient",map.get("user"));
|
|
|
|
json.put("value1",map.get("value1"));
|
|
|
|
json.put("value2",map.get("value2"));
|
|
|
|
json.put("value3",map.get("value3"));
|
|
|
|
json.put("value4",map.get("value4"));
|
|
|
|
json.put("value5",map.get("value5"));
|
|
|
|
json.put("value6",map.get("value6"));
|
|
|
|
json.put("value7",map.get("value7"));
|
|
|
|
json.put("deviceSn",map.get("device_sn")==null?"":map.get("device_sn"));
|
|
|
|
json.put("type",map.get("type"));
|
|
|
|
|
|
|
|
Date date = (Date) map.get("record_date");
|
|
|
|
if (type == 2) {
|
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
|
} else {
|
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
|
|
|
|
}
|
|
|
|
json.put("sortDate",map.get("sort_date"));
|
|
|
|
json.put("czrq",map.get("czrq"));
|
|
|
|
|
|
|
|
re.put(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
|
|
|
|
// re = list;
|
|
}
|
|
}
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|