|
@ -17,9 +17,11 @@ import com.yihu.wlyy.util.SystemConf;
|
|
import com.yihu.wlyy.util.query.BaseDeviceJpaService;
|
|
import com.yihu.wlyy.util.query.BaseDeviceJpaService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.*;
|
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@ -27,7 +29,6 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -139,7 +140,146 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
|
|
// }
|
|
// }
|
|
String f = filter.toString();
|
|
String f = filter.toString();
|
|
// System.out.println("sql:"+sql+f+" order by i.czrq desc "+" limit "+(page-1)+","+pageSize);
|
|
// System.out.println("sql:"+sql+f+" order by i.czrq desc "+" limit "+(page-1)+","+pageSize);
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc "+" limit "+(page-1)+","+pageSize);
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc "+" limit "+(page-1)*pageSize+","+pageSize);
|
|
|
|
if(resultList.size()<=0){
|
|
|
|
return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
long count = 0;
|
|
|
|
String regex = "(\\w{3})(\\w+)(\\w{3})";
|
|
|
|
List<DeviceHealthIndexVO> listTemp = new ArrayList<>();
|
|
|
|
if(resultList !=null && resultList.size()>0){
|
|
|
|
// count = getCount(filter.toString());
|
|
|
|
count = jdbcTemplate.queryForObject(countSql+filter.toString(),Long.class);
|
|
|
|
for (Map<String, Object> info : resultList){
|
|
|
|
DeviceHealthIndexVO bean = new DeviceHealthIndexVO();
|
|
|
|
bean.setId(Long.getLong(info.get("id")+""));
|
|
|
|
bean.setCzrq(info.get("czrq")!=null?(Date)info.get("czrq"):null);
|
|
|
|
bean.setDel(info.get("del")!=null?info.get("del")+"":null);
|
|
|
|
bean.setDeviceSn(info.get("device_sn")!=null?info.get("device_sn")+"":null);
|
|
|
|
bean.setIdcard(info.get("idcard")!=null?info.get("idcard")+"":null);
|
|
|
|
bean.setIntervene(info.get("intervene")!=null?info.get("intervene")+"":null);
|
|
|
|
bean.setRecordDate(info.get("record_date")!=null?(Date)info.get("record_date"):null);
|
|
|
|
bean.setSortDate(info.get("sort_date")!=null?(Date)info.get("sort_date"):null);
|
|
|
|
bean.setStatus(info.get("status")!=null?(Integer)info.get("status"):null);
|
|
|
|
bean.setType(info.get("type")!=null?(Integer)info.get("type"):0);
|
|
|
|
bean.setUser(info.get("user")!=null?info.get("user")+"":null);
|
|
|
|
bean.setUserName(info.get("userName")!=null?info.get("userName")+"":null);
|
|
|
|
bean.setValue1(info.get("value1")!=null?info.get("value1")+"":null);
|
|
|
|
bean.setValue2(info.get("value2")!=null?info.get("value2")+"":null);
|
|
|
|
bean.setValue3(info.get("value3")!=null?info.get("value3")+"":null);
|
|
|
|
bean.setValue4(info.get("value4")!=null?info.get("value4")+"":null);
|
|
|
|
bean.setValue5(info.get("value5")!=null?info.get("value5")+"":null);
|
|
|
|
bean.setValue6(info.get("value6")!=null?info.get("value6")+"":null);
|
|
|
|
bean.setValue7(info.get("value7")!=null?info.get("value7")+"":null);
|
|
|
|
// BeanUtils.copyProperties(info, bean);
|
|
|
|
// Patient patient = findPatient(bean.getUser());
|
|
|
|
// bean.setUserName(patient== null?"":patient.getName());
|
|
|
|
if(StringUtils.isNotBlank(bean.getIdcard())){
|
|
|
|
bean.setIdcard(bean.getIdcard().replaceAll(regex, "$1****$3"));
|
|
|
|
}
|
|
|
|
bean.setHealthStandard(gethealthStandard(bean.getType(),bean.getUser()).toString());
|
|
|
|
listTemp.add(bean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new PageImpl<DeviceHealthIndexVO>(listTemp,pageRequest,count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 无需登录
|
|
|
|
* @param deviceSn
|
|
|
|
* @param date
|
|
|
|
* @param idcard
|
|
|
|
* @param userName
|
|
|
|
* @param indexType
|
|
|
|
* @param page
|
|
|
|
* @param pageSize
|
|
|
|
* @param indexTypeMin1
|
|
|
|
* @param indexTypeMax1
|
|
|
|
* @param indexTypeMin2
|
|
|
|
* @param indexTypeMax2
|
|
|
|
* @param doctorName
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Page<DeviceHealthIndexVO> searchList2(String deviceSn,String date,String idcard,String userName,String indexType,Integer page,Integer pageSize,
|
|
|
|
Double indexTypeMin1,Double indexTypeMax1,Double indexTypeMin2,Double indexTypeMax2,String doctorName)throws Exception{
|
|
|
|
if (page == null){
|
|
|
|
page = 1;
|
|
|
|
}
|
|
|
|
if(pageSize == null){
|
|
|
|
pageSize = 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
Pageable pageRequest = new PageRequest(page-1,pageSize);
|
|
|
|
|
|
|
|
StringBuilder filter = new StringBuilder();
|
|
|
|
|
|
|
|
String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_sign_family s WHERE s. STATUS > 0 and i.user=s.patient ";
|
|
|
|
String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_sign_family s WHERE s. STATUS > 0 and i.user=s.patient ";
|
|
|
|
|
|
|
|
//根据患者名称过滤
|
|
|
|
if(!StringUtils.isEmpty(userName)){
|
|
|
|
filter.append(" AND s.NAME LIKE '%"+userName+"%' ");
|
|
|
|
}
|
|
|
|
//根据健管师或医生名称过滤
|
|
|
|
if(!StringUtils.isEmpty(doctorName)){
|
|
|
|
filter.append(" and (s.doctor_name like '%"+doctorName+"%' or s.doctor_health_name like '%"+doctorName+"%') ");
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(deviceSn)){
|
|
|
|
filter.append(" and i.device_sn='"+deviceSn+"' ");
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(idcard)){
|
|
|
|
filter.append(" and i.idcard='"+idcard+"' ");
|
|
|
|
}
|
|
|
|
//体征数据创建时间
|
|
|
|
if(!StringUtils.isEmpty(date)){
|
|
|
|
Date startTimeTemp = DateTimeUtil.simpleDateParse(date);
|
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
|
calendar.setTime(startTimeTemp);
|
|
|
|
calendar.set(Calendar.HOUR,23);
|
|
|
|
calendar.set(Calendar.MINUTE,59);
|
|
|
|
calendar.set(Calendar.SECOND,59);
|
|
|
|
calendar.set(Calendar.MILLISECOND,999);
|
|
|
|
Date endTimeTemp = calendar.getTime();
|
|
|
|
filter.append(" and i.czrq>='" + DateTimeUtil.simpleDateTimeFormat(startTimeTemp)+"'");
|
|
|
|
filter.append(" and i.czrq<='" + DateTimeUtil.simpleDateTimeFormat(endTimeTemp)+"'");
|
|
|
|
}
|
|
|
|
//指标类型
|
|
|
|
if(!StringUtils.isEmpty(indexType)){
|
|
|
|
filter.append(" and i.type="+indexType);
|
|
|
|
}
|
|
|
|
//体征数据
|
|
|
|
// if("1".equals(indexType)||"2".equals(indexType)||"4".equals(indexType)){
|
|
|
|
if(indexTypeMin1!=null){
|
|
|
|
filter.append(" and value1>="+indexTypeMin1);
|
|
|
|
}
|
|
|
|
if(indexTypeMax1!=null){
|
|
|
|
filter.append(" and value1<="+indexTypeMax1);
|
|
|
|
}
|
|
|
|
if(indexTypeMin2!=null){
|
|
|
|
filter.append(" and value2>="+indexTypeMin2);
|
|
|
|
}
|
|
|
|
if(indexTypeMax2!=null){
|
|
|
|
filter.append(" and value2<="+indexTypeMax2);
|
|
|
|
}
|
|
|
|
// }else{
|
|
|
|
// if(indexTypeMin1!=null){
|
|
|
|
// filter.append(" and value3>="+indexTypeMin1);
|
|
|
|
// }
|
|
|
|
// if(indexTypeMax1!=null){
|
|
|
|
// filter.append(" and value3<="+indexTypeMax1);
|
|
|
|
// }
|
|
|
|
// if(indexTypeMin2!=null){
|
|
|
|
// filter.append(" and value4>="+indexTypeMin2);
|
|
|
|
// }
|
|
|
|
// if(indexTypeMax2!=null){
|
|
|
|
// filter.append(" and value4<="+indexTypeMax2);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
String f = filter.toString();
|
|
|
|
// System.out.println("sql:"+sql+f+" order by i.czrq desc "+" limit "+(page-1)+","+pageSize);
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc "+" limit "+(page-1)*pageSize+","+pageSize);
|
|
if(resultList.size()<=0){
|
|
if(resultList.size()<=0){
|
|
return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
|
|
return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
|
|
}
|
|
}
|
|
@ -291,7 +431,7 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
|
|
return patientDao.findByCode(patientCode);
|
|
return patientDao.findByCode(patientCode);
|
|
}
|
|
}
|
|
|
|
|
|
public List<DeviceHealthIndexExportVO> exportDeviceHealthIndexList(String town, String hospital) {
|
|
|
|
|
|
/*public List<DeviceHealthIndexExportVO> exportDeviceHealthIndexList(String town, String hospital) {
|
|
List<DeviceHealthIndexExportVO> list = new ArrayList<>();
|
|
List<DeviceHealthIndexExportVO> list = new ArrayList<>();
|
|
String sql = "SELECT " +
|
|
String sql = "SELECT " +
|
|
"s.patient," +
|
|
"s.patient," +
|
|
@ -306,6 +446,35 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
|
|
"SELECT `user`,device_sn,type,max(record_date) record_date FROM device.wlyy_patient_health_index WHERE device_sn IS NOT NULL AND del=1 GROUP BY `user`,device_sn,type) d WHERE s.patient=d.`user` AND s.hospital='"+hospital+"' AND s.`status`> 0) ORDER BY patient";
|
|
"SELECT `user`,device_sn,type,max(record_date) record_date FROM device.wlyy_patient_health_index WHERE device_sn IS NOT NULL AND del=1 GROUP BY `user`,device_sn,type) d WHERE s.patient=d.`user` AND s.hospital='"+hospital+"' AND s.`status`> 0) ORDER BY patient";
|
|
list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DeviceHealthIndexExportVO.class));
|
|
list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DeviceHealthIndexExportVO.class));
|
|
return list ;
|
|
return list ;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出体征上传明细
|
|
|
|
* @param town
|
|
|
|
* @param hospital
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<DeviceHealthIndexExportVO> exportDeviceHealthIndexList(String town, String hospital) {
|
|
|
|
List<DeviceHealthIndexExportVO> list = new ArrayList<>();
|
|
|
|
String sql = "SELECT " +
|
|
|
|
"s.patient," +
|
|
|
|
"s.`name`," +
|
|
|
|
"s.mobile," +
|
|
|
|
"s.idcard," +
|
|
|
|
"d.device_sn," +
|
|
|
|
"d.device_name," +
|
|
|
|
"d.record_date," +
|
|
|
|
"d.amount,"+
|
|
|
|
"CASE d.type WHEN 1 THEN '血糖' WHEN 2 THEN '血压' WHEN 3 THEN '体重' WHEN 4 THEN '腰围' END statusName,"+
|
|
|
|
"s.doctor_name," +
|
|
|
|
"p.address FROM wlyy_sign_family s,wlyy_patient p,(" +
|
|
|
|
"SELECT i.`user`,i.device_sn, i.type, max(i.record_date) record_date, count(i.id) amount, w.device_name " +
|
|
|
|
"FROM device.wlyy_patient_health_index i,wlyy_patient_device w "+
|
|
|
|
"WHERE i.device_sn = w.device_sn AND i.del=1 GROUP BY i.`user`,i.device_sn,i.type) d "+
|
|
|
|
"WHERE s.patient = d.`user` AND s.hospital='"+hospital+"' AND s.`status`> 0 AND s.patient=p.code AND d.`type` in (1,2) ORDER BY d.record_date desc ";
|
|
|
|
|
|
|
|
list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DeviceHealthIndexExportVO.class));
|
|
|
|
return list ;
|
|
}
|
|
}
|
|
|
|
|
|
public JSONObject gethealthStandard(Integer type, String patientCode) {
|
|
public JSONObject gethealthStandard(Integer type, String patientCode) {
|