|
@ -1,8 +1,12 @@
|
|
|
package com.yihu.jw.care.service.third;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
|
|
|
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
|
|
|
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
|
|
|
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
|
|
|
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
|
|
|
import com.yihu.jw.care.service.course.CourseService;
|
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
|
import com.yihu.jw.care.service.device.PatientHealthIndexService;
|
|
@ -12,12 +16,16 @@ import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
|
|
|
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.BaseSleepPlan;
|
|
|
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
|
|
|
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
|
|
|
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
|
|
|
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
|
|
|
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -25,6 +33,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@ -59,6 +68,12 @@ public class PatientInfoPlatFormService {
|
|
|
private CapacityAssessmentRecordService capacityAssessmentRecordService;
|
|
|
@Autowired
|
|
|
private BaseCapacityLabelDao capacityLabelDao;
|
|
|
@Autowired
|
|
|
private BaseEmergencyWarnLogDao logDao;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringOrderDao securityMonitoringOrderDao;
|
|
|
@Autowired
|
|
|
private BaseSleepPlanDao sleepPlanDao;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -253,22 +268,139 @@ public class PatientInfoPlatFormService {
|
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize){
|
|
|
public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient){
|
|
|
page = page>0?page-1:0;
|
|
|
String sql = " select '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status` \n" +
|
|
|
"from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id order by create_time desc ";
|
|
|
String sql = " select '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time," +
|
|
|
"ord.`status`,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
|
|
|
"from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql +=" and ord.patient='"+patient+"' ";
|
|
|
}
|
|
|
sql+= " order by create_time desc ";
|
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
|
long count = jdbcTemplate.queryForObject(countSql,long.class);
|
|
|
sql +=" limit "+page*pageSize+","+pageSize;
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:list){
|
|
|
//添加工单响应时间、动态
|
|
|
String orderId = map.get("id").toString();
|
|
|
String orderType = map.get("OrderType").toString();
|
|
|
List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(orderId);
|
|
|
for (BaseEmergencyWarnLogDO tmp:logDOS){
|
|
|
tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime(),0));
|
|
|
}
|
|
|
map.put("orderLog",logDOS);
|
|
|
// (起床预警时长3 午睡预警时长5 起夜预警时长2 详情见设备项目睡眠带发起时定义) (离开安全区域超出距离km) (燃气烟雾 报警时浓度)
|
|
|
if ("22".equals(orderType)){
|
|
|
org.json.JSONObject info = new org.json.JSONObject();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
|
|
|
if ("疑似离开安全区域".equals(orderDO.getServeDesc())){
|
|
|
//超出距离
|
|
|
info.put("info1","超出距离: 1km");//todo
|
|
|
}
|
|
|
if ("超时未起床".equals(orderDO.getServeDesc())){
|
|
|
List<BaseSleepPlan> sleepPlan = sleepPlanDao.findByPatient(orderDO.getPatient());
|
|
|
if (sleepPlan.size()>0){
|
|
|
info.put("info1","预设起床时间: "+sleepPlan.get(0).getGetUpTime());
|
|
|
}
|
|
|
info.put("info2","超时时长: 3小时");
|
|
|
}
|
|
|
if ("午睡超时未起床".equals(orderDO.getServeDesc())){
|
|
|
if (null!=orderDO.getServeDesc()) {
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(orderDO.getWarnInfo());
|
|
|
if (jsonObject.containsKey("siestaTimeBegin") && null != jsonObject.get("siestaTimeBegin")) {
|
|
|
String siestaTimeBegin = jsonObject.getString("siestaTimeBegin");
|
|
|
info.put("info1", "预计午休起床时间: " +DateUtil.getPreTime(siestaTimeBegin,60*5+""));
|
|
|
}
|
|
|
}
|
|
|
info.put("info2","超时时长: 5小时");
|
|
|
}
|
|
|
if ("起夜超时未回床".equals(orderDO.getServeDesc())){
|
|
|
if (null!=orderDO.getServeDesc()){
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(orderDO.getWarnInfo());
|
|
|
if (jsonObject.containsKey("sleepNightRecordList")&&null!=jsonObject.get("sleepNightRecordList")){
|
|
|
com.alibaba.fastjson.JSONArray nightArr = jsonObject.getJSONArray("sleepNightRecordList");
|
|
|
if (nightArr.size()>0){
|
|
|
com.alibaba.fastjson.JSONObject tmp = nightArr.getJSONObject(0);
|
|
|
String time = tmp.getString("createTime");
|
|
|
info.put("info1","离床时间: "+time);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
info.put("info2","离床时长: 2小时");
|
|
|
}
|
|
|
if ("超时未上床晚休".equals(orderDO.getServeDesc())){
|
|
|
List<BaseSleepPlan> sleepPlan = sleepPlanDao.findByPatient(orderDO.getPatient());
|
|
|
if (sleepPlan.size()>0){
|
|
|
info.put("info1","预设晚休时间: "+sleepPlan.get(0).getNightRestTime());
|
|
|
}
|
|
|
info.put("info2","超时时长: 2小时");
|
|
|
}
|
|
|
if ("超时未午睡".equals(orderDO.getServeDesc())){
|
|
|
List<BaseSleepPlan> sleepPlan = sleepPlanDao.findByPatient(orderDO.getPatient());
|
|
|
if (sleepPlan.size()>0){
|
|
|
info.put("info1","预设午休时间: "+sleepPlan.get(0).getNapTime());
|
|
|
}
|
|
|
info.put("info2","5小时");
|
|
|
}
|
|
|
if ("疑似发生火灾".equals(orderDO.getServeDesc())){
|
|
|
//烟雾浓度
|
|
|
if (null!=orderDO.getServeDesc()){
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(orderDO.getWarnInfo());
|
|
|
String value = jsonObject.getString("smoke");
|
|
|
if (!value.contains("%")){
|
|
|
value+="%";
|
|
|
}
|
|
|
info.put("info1","烟雾浓度: "+value);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if ("疑似燃气泄漏".equals(orderDO.getServeDesc())){
|
|
|
//燃气浓度
|
|
|
if (null!=orderDO.getServeDesc()) {
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(orderDO.getWarnInfo());
|
|
|
String value = jsonObject.getString("gas");
|
|
|
if (!value.contains("%")) {
|
|
|
value += "%";
|
|
|
}
|
|
|
info.put("info1", "燃气浓度: "+value);
|
|
|
}
|
|
|
}
|
|
|
if("心率和呼吸频率异常".equals(orderDO.getServeDesc())){
|
|
|
if (null!=orderDO.getServeDesc()){
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(orderDO.getWarnInfo());
|
|
|
if(null!=jsonObject.get("breath")){
|
|
|
String breath = jsonObject.getString("breath");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(breath)){
|
|
|
info.put("info1", "预警频率 "+breath+"次/分钟");
|
|
|
}
|
|
|
}
|
|
|
if(null!=jsonObject.get("heartRate")){
|
|
|
String heartRate = jsonObject.getString("heartRate");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(heartRate)){
|
|
|
info.put("info1", "预警心率: "+heartRate+"次/分钟");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
map.put("infos",info);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize){
|
|
|
public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient){
|
|
|
page = page>0?page-1:0;
|
|
|
String sql = " select '20' as OrderType,p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient, " +
|
|
|
"p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status` \n" +
|
|
|
"from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id order by create_time desc ";
|
|
|
"p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`," +
|
|
|
" case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
|
|
|
"from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql +=" and ord.patient='"+patient+"' ";
|
|
|
}
|
|
|
sql+= " order by create_time desc ";
|
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
|
long count = jdbcTemplate.queryForObject(countSql,long.class);
|
|
|
sql +=" limit "+page*pageSize+","+pageSize;
|