|
@ -19,6 +19,8 @@ import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -137,73 +139,65 @@ public class DeviceService {
|
|
|
Double lat= Double.parseDouble(request.getParameter("lat"));
|
|
|
Double lon= Double.parseDouble(request.getParameter("lon"));
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
|
|
|
DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
|
|
|
BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
|
|
|
DeviceSosLogDO logDO = new DeviceSosLogDO();
|
|
|
logDO.setPatient(patientDO.getId());
|
|
|
logDO.setPatientName(patientDO.getName());
|
|
|
logDO.setIdcard(patientDO.getIdcard());
|
|
|
logDO.setCategoryCode(deviceDO.getCategoryCode());
|
|
|
logDO.setDeviceSn(deviceDO.getDeviceSn());
|
|
|
logDO.setCreateTime(new Date());
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
logDO.setSosAddress(address);
|
|
|
logDO.setSosLat(position.getDouble("lat")+"");
|
|
|
logDO.setSosLon(position.getDouble("lon")+"");
|
|
|
}
|
|
|
if (deviceDO.getCategoryCode().equals("7")) {
|
|
|
logDO.setSosAddress(deviceDO.getSosAddress());
|
|
|
Map<String, String> json = null;
|
|
|
if (StringUtils.isNotBlank(deviceDO.getSosAddress())) {
|
|
|
json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
}
|
|
|
if (json != null) {
|
|
|
logDO.setSosLat(json.get("lat").toString());
|
|
|
logDO.setSosLon(json.get("lng").toString());
|
|
|
}
|
|
|
}
|
|
|
//发送紧急救助
|
|
|
String sql =" select Distinct pack.org_code,pack.org_name\n" +
|
|
|
"from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
|
|
|
"on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
|
|
|
"INNER JOIN base_service_package pack pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
if (sqlResult.size()>0){
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("serveAddress",logDO.getSosAddress());
|
|
|
jsonObject.put("serveLon",logDO.getSosLon());
|
|
|
jsonObject.put("serveLat",logDO.getSosLat());
|
|
|
jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
|
|
|
jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
|
|
|
jsonObject.put("patient",logDO.getPatient());
|
|
|
jsonObject.put("patientName",logDO.getPatientName());
|
|
|
jsonObject.put("deviceSn",logDO.getDeviceSn());
|
|
|
String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
|
|
|
Map map = new HashMap<String, String>();
|
|
|
map.put("patientId", logDO.getPatient());
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
|
|
|
BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
|
|
|
DeviceSosLogDO logDO = new DeviceSosLogDO();
|
|
|
logDO.setPatient(patientDO.getId());
|
|
|
logDO.setPatientName(patientDO.getName());
|
|
|
logDO.setIdcard(patientDO.getIdcard());
|
|
|
logDO.setCategoryCode(deviceDO.getCategoryCode());
|
|
|
logDO.setDeviceSn(deviceDO.getDeviceSn());
|
|
|
logDO.setCreateTime(new Date());
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
map.put("orderSource", 2); //工单来源工单发起来源状态 1APP 2手环 3居家报警
|
|
|
JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
logDO.setSosAddress(address);
|
|
|
logDO.setSosLat(position.getDouble("lat")+"");
|
|
|
logDO.setSosLon(position.getDouble("lon")+"");
|
|
|
}
|
|
|
if (deviceDO.getCategoryCode().equals("7")) {
|
|
|
map.put("orderSource", 3);
|
|
|
}
|
|
|
map.put("jsonData", jsonObject.toJSONString());
|
|
|
String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
|
|
|
String postParams = AesEncryptUtils.agEncrypt(content);
|
|
|
String response = httpClientUtil.postBodyRawForm(url,postParams);
|
|
|
JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
|
|
|
logDO.setSosSendStatus(jsonObjectData.getInteger("status").toString());
|
|
|
if (jsonObjectData.containsKey("message")){
|
|
|
logDO.setSosSendMessage(jsonObjectData.getString("message"));
|
|
|
}
|
|
|
if (jsonObjectData.containsKey("msg")){
|
|
|
logDO.setSosSendMessage(jsonObjectData.getString("msg"));
|
|
|
logDO.setSosAddress(deviceDO.getSosAddress());
|
|
|
Map<String, String> json = null;
|
|
|
if (StringUtils.isNotBlank(deviceDO.getSosAddress())) {
|
|
|
json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
}
|
|
|
if (json != null) {
|
|
|
logDO.setSosLat(json.get("lat").toString());
|
|
|
logDO.setSosLon(json.get("lng").toString());
|
|
|
}
|
|
|
}
|
|
|
//发送紧急救助
|
|
|
String sql =" select Distinct pack.org_code,pack.org_name\n" +
|
|
|
"from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
|
|
|
"on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
|
|
|
"INNER JOIN base_service_package pack pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
if (sqlResult.size()>0){
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("serveAddress",logDO.getSosAddress());
|
|
|
jsonObject.put("serveLon",logDO.getSosLon());
|
|
|
jsonObject.put("serveLat",logDO.getSosLat());
|
|
|
jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
|
|
|
jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
|
|
|
jsonObject.put("patient",logDO.getPatient());
|
|
|
jsonObject.put("patientName",logDO.getPatientName());
|
|
|
jsonObject.put("deviceSn",logDO.getDeviceSn());
|
|
|
String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("jsonData", jsonObject.toJSONString()));
|
|
|
params.add(new BasicNameValuePair("patientId", logDO.getPatient()));
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
params.add(new BasicNameValuePair("orderSource", "2"));//工单来源工单发起来源状态 1APP 2手环 3居家报警
|
|
|
}
|
|
|
if (deviceDO.getCategoryCode().equals("7")) {
|
|
|
params.add(new BasicNameValuePair("orderSource", "3"));
|
|
|
}
|
|
|
String response = httpClientUtil.post(url, params,"UTF-8");
|
|
|
System.out.println(response);
|
|
|
|
|
|
}
|
|
|
sosLogDao.save(logDO);
|
|
|
}
|
|
|
sosLogDao.save(logDO);
|
|
|
}catch(Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -259,11 +253,9 @@ public class DeviceService {
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
//获取手环最新定位信息
|
|
|
String url = cloudCareUrl+"/cloudCare/noLogin/device/getDeviceLastLocation";
|
|
|
Map map = new HashMap<String, String>();
|
|
|
map.put("deviceSn",deviceDO.getDeviceSn());
|
|
|
String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
|
|
|
String postParams = AesEncryptUtils.agEncrypt(content);
|
|
|
String response = httpClientUtil.getBodyRawForm(url,postParams);
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("deviceSn", deviceDO.getDeviceSn()));
|
|
|
String response = httpClientUtil.post(url, params,"UTF-8");
|
|
|
JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
|
|
|
Double lat = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lat");
|
|
@ -276,7 +268,6 @@ public class DeviceService {
|
|
|
" and pack.del=1";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
if (sqlResult.size()>0){
|
|
|
map = new HashMap();
|
|
|
url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("patient",patientDO.getId());
|
|
@ -291,16 +282,16 @@ public class DeviceService {
|
|
|
jsonObject.put("deviceSn",deviceid);
|
|
|
JSONObject jsonObjectParam = new JSONObject();
|
|
|
jsonObjectParam.put("order", jsonObject);
|
|
|
map.put("jsonData", jsonObjectParam.toJSONString());
|
|
|
map.put("orderSource", 2);
|
|
|
map.put("warnStr", "疑似离开安全区域");
|
|
|
|
|
|
content = com.alibaba.fastjson.JSONObject.toJSONString(map);
|
|
|
postParams = AesEncryptUtils.agEncrypt(content);
|
|
|
response = httpClientUtil.postBodyRawForm(url,postParams);
|
|
|
result = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
|
|
|
System.out.println(jsonObjectData.toJSONString());
|
|
|
|
|
|
params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
|
|
|
params.add(new BasicNameValuePair("orderSource", "2"));
|
|
|
params.add(new BasicNameValuePair("warnStr", "疑似离开安全区域"));
|
|
|
|
|
|
response = httpClientUtil.post(url, params,"UTF-8");
|
|
|
System.out.println(response);
|
|
|
System.out.println(response);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -562,6 +553,8 @@ public class DeviceService {
|
|
|
Integer nightLongWarn=2;//起夜预警时长
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
Date timeDate = DateUtil.strToDate(time_begin);//当前时间
|
|
|
String dayTime = null;//检测日期
|
|
|
String patient = devicePatientDeviceDos.get(0).getUser();
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatientAndDeviceSn(patient,device);
|
|
|
BaseSleepPlanDetail planDetail = new BaseSleepPlanDetail();
|
|
@ -570,9 +563,8 @@ public class DeviceService {
|
|
|
sleepPlan = sleepPlans.get(0);
|
|
|
}
|
|
|
if (null!=sleepPlan){
|
|
|
Date timeDate = DateUtil.strToDate(time_begin);//当前时间
|
|
|
Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getGetUpTime()+":00");// 起床时间 起床前一小时内算为起床
|
|
|
if (timeDate.before(bedUp)){
|
|
|
Date bedUp = DateUtil.strToDate(DateUtil.dateToStrShort(timeDate)+" "+sleepPlan.getGetUpTime()+":00");// 起床时间 起床前一小时内算为起床
|
|
|
if (timeDate.before(bedUp)&&bedUp.getTime()-timeDate.getTime()>1000*1*3600){
|
|
|
bedUp = DateUtil.getNextDay1(bedUp,-1);
|
|
|
}
|
|
|
Date bedUpBegin = DateUtil.getNextMin(bedUp,-60);//起床时间 起床前一小时内算为起床
|
|
@ -582,21 +574,22 @@ public class DeviceService {
|
|
|
Date SiestaBegin = null;// 午睡开始时间
|
|
|
if (StringUtils.isNotBlank(sleepPlan.getNapTime())){
|
|
|
needSiesta=true;
|
|
|
SiestaTime = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getNapTime()+":00");
|
|
|
SiestaTime = DateUtil.strToDate(DateUtil.dateToStrShort(timeDate)+" "+sleepPlan.getNapTime()+":00");
|
|
|
SiestaBegin = DateUtil.getNextMin(SiestaTime,-60);// 午睡开始时间
|
|
|
}
|
|
|
String inTime = sleepPlan.getNightRestTime();
|
|
|
Date bedIn = null;// 入睡时间
|
|
|
Date bedBegin = null;// 入睡开始时间
|
|
|
String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
|
|
|
if (inTime.charAt(0)=='0') {
|
|
|
dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
|
|
|
if (inTime.charAt(0)=='0'&&inTime.charAt(1)!='0') {//0点后为睡觉日期
|
|
|
bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime()+":00");
|
|
|
bedIn = DateUtil.getNextDay1(bedIn,1);
|
|
|
}else {
|
|
|
bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime()+":00");
|
|
|
|
|
|
}
|
|
|
bedBegin = DateUtil.getNextMin(bedIn,-60*2);
|
|
|
List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByDay(dayTime);
|
|
|
List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient,dayTime);
|
|
|
if (planDetails.size()>0){
|
|
|
planDetail = planDetails.get(0);
|
|
|
}
|
|
@ -605,25 +598,22 @@ public class DeviceService {
|
|
|
planDetail.setDeviceSn(device);
|
|
|
/***起床***/
|
|
|
Long timeDiffer = timeDate.getTime() - bedUp.getTime();
|
|
|
if(DateUtil.isInArea(timeDate,bedUpBegin,bedUpEnd)){//起床时间内
|
|
|
if(DateUtil.isInArea(timeDate,bedUpBegin,SiestaBegin)){//起床时间内
|
|
|
if ("0".equals(bed_status)){//起床
|
|
|
if (null==planDetail.getUpStatus()){
|
|
|
planDetail.setUpStatus(1);
|
|
|
if (null==planDetail.getUpStatus()||1==planDetail.getUpStatus()){
|
|
|
planDetail.setUpStatus(0);
|
|
|
planDetail.setUpTime(timeDate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (3600*upLongWarn*1000<timeDiffer&&timeDiffer<(3600*upLongWarn+600)*1000){//距离起床超过三个小时还在床
|
|
|
if ("1".equals(bed_status)){//还在床
|
|
|
if (1==planDetail.getUpStatus()){}//起床后再次入睡超时未起床不触发
|
|
|
else {
|
|
|
if (null==planDetail.getUpStatus()){
|
|
|
planDetail.setUpStatus(0);
|
|
|
planDetail.setBedStatus(0);
|
|
|
if (3600*upLongWarn*1000<timeDiffer){//距离起床超过三个小时还在床
|
|
|
if (null==planDetail.getUpStatus()) {
|
|
|
planDetail.setUpStatus(1);
|
|
|
planDetail.setBedStatus(1);
|
|
|
planDetail.setBreath(breath);
|
|
|
planDetail.setHeartRate(heartrate);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
outBedOrder(null, timeDate,devicePatientDeviceDos.get(0), patient, device, "超时未起床", JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -631,16 +621,16 @@ public class DeviceService {
|
|
|
/***午睡***/
|
|
|
if(needSiesta&&DateUtil.isInArea(timeDate,SiestaBegin,bedIn)){//午睡时段
|
|
|
if ("0".equals(bed_status)){
|
|
|
if (null==planDetail.getSiestaStatus()){//超时未午睡午睡
|
|
|
if (null==planDetail.getSiestaStatus()){//超时未午睡
|
|
|
timeDiffer = timeDate.getTime() - SiestaTime.getTime();
|
|
|
if (timeDiffer>3600*siestaLongWarn*1000){
|
|
|
planDetail.setSiestaStatus(0);
|
|
|
planDetail.setBedStatus(0);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
}
|
|
|
}
|
|
|
else if(1 == planDetail.getSiestaStatus()&&null==planDetail.getSiestaTimeEnd()){//午睡起床
|
|
|
else if(1 == planDetail.getSiestaStatus()&&null==planDetail.getSiestaLong()){//午睡起床
|
|
|
planDetail.setSiestaTimeEnd(timeDate);
|
|
|
timeDiffer = (planDetail.getSiestaTimeEnd().getTime()-planDetail.getSiestaTimeBegin().getTime())/1000;
|
|
|
planDetail.setSiestaLong(timeDiffer+"");
|
|
@ -648,18 +638,21 @@ public class DeviceService {
|
|
|
|
|
|
}
|
|
|
if ("1".equals(bed_status)){
|
|
|
if (null==planDetail.getSiestaStatus()){
|
|
|
if (null==planDetail.getSiestaStatus()||0==planDetail.getSiestaStatus()){
|
|
|
planDetail.setSiestaStatus(1);
|
|
|
planDetail.setSiestaTimeBegin(timeDate);
|
|
|
}
|
|
|
else if(1==planDetail.getSiestaStatus()&&null==planDetail.getSiestaTimeEnd()){
|
|
|
timeDiffer = timeDate.getTime() - planDetail.getSiestaTimeBegin().getTime();
|
|
|
if(3600*siestaLongWarn*1000<timeDiffer&&timeDiffer<(3600*siestaLongWarn+600)*1000){//午睡超时未起床
|
|
|
planDetail.setBedStatus(0);
|
|
|
planDetail.setBreath(breath);
|
|
|
planDetail.setHeartRate(heartrate);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
if(3600*siestaLongWarn*1000<timeDiffer){//午睡超时未起床
|
|
|
if (planDetail.getSiestaStatus()==1){
|
|
|
planDetail.setBedStatus(1);
|
|
|
planDetail.setSiestaTimeEnd(timeDate);//设置临时结束时间但不计算时长 避免重复发起工单
|
|
|
planDetail.setBreath(breath);
|
|
|
planDetail.setHeartRate(heartrate);
|
|
|
outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -669,13 +662,16 @@ public class DeviceService {
|
|
|
if (timeDiffer>0&&timeDate.after(bedBegin)){ //起夜记录
|
|
|
BaseSleepNightRecord record = new BaseSleepNightRecord();
|
|
|
if ("1".equals(bed_status)){
|
|
|
if (null==planDetail.getInStatus()){
|
|
|
if (null==planDetail.getInStatus()||0==planDetail.getInStatus()){
|
|
|
planDetail.setInStatus(1);
|
|
|
planDetail.setInTimeBegin(timeDate);
|
|
|
}
|
|
|
else if (1==planDetail.getInStatus()){//在床记录起夜时长
|
|
|
List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedIn);
|
|
|
if (records.size()>0){//
|
|
|
List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedBegin,dayTime);
|
|
|
if (records.size()==0){
|
|
|
records = nightRecord.findBySnStaPaTime(device,patient,-1,bedBegin,dayTime);//超时未归的起夜记录
|
|
|
}
|
|
|
if (records.size()>0){//已经晚休了 但是存在起夜未归
|
|
|
record = records.get(0);
|
|
|
record.setStatus(1);
|
|
|
record.setUpdateTime(timeDate);
|
|
@ -687,14 +683,14 @@ public class DeviceService {
|
|
|
}
|
|
|
}
|
|
|
if ("0".equals(bed_status)){//离床
|
|
|
List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedIn);
|
|
|
List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedBegin,dayTime);
|
|
|
if(null==planDetail.getInStatus()){
|
|
|
timeDiffer = timeDate.getTime() - bedIn.getTime();
|
|
|
if (timeDiffer>3600*nightLongWarn*1000){
|
|
|
planDetail.setInStatus(0);
|
|
|
planDetail.setBedStatus(1);
|
|
|
planDetail.setSleepNightRecordList(records);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
|
|
|
outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
}
|
|
|
}
|
|
@ -709,10 +705,10 @@ public class DeviceService {
|
|
|
}else {//是否触发工单
|
|
|
record = records.get(0);
|
|
|
timeDiffer = timeDate.getTime()-record.getCreateTime().getTime();
|
|
|
if (timeDiffer>3600*nightLongWarn*1000){//超过2未回床小时 触发工单
|
|
|
planDetail.setSleepNightRecordList(records);
|
|
|
if (timeDiffer>3600*nightLongWarn*1000&&0==records.get(0).getStatus()){//超过2未回床小时 触发工单
|
|
|
planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
|
|
|
planDetail.setBedStatus(0);
|
|
|
outBedOrder(records.get(0),devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
orderCreate=true;
|
|
|
}
|
|
|
}
|
|
@ -735,7 +731,8 @@ public class DeviceService {
|
|
|
planDetail.setBreath(breath);
|
|
|
planDetail.setHeartRate(heartrate);
|
|
|
planDetail.setBedStatus(1);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
|
|
|
outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@ -745,14 +742,14 @@ public class DeviceService {
|
|
|
planDetail.setBreath(breath);
|
|
|
planDetail.setHeartRate(heartrate);
|
|
|
planDetail.setBedStatus(1);
|
|
|
outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
|
|
|
outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@ -761,7 +758,7 @@ public class DeviceService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public void outBedOrder(BaseSleepNightRecord record,DevicePatientDevice patientDevice,String patient ,String device,String serverName,String warnInfo)throws Exception{
|
|
|
public void outBedOrder(BaseSleepNightRecord record,Date time_date,DevicePatientDevice patientDevice,String patient ,String device,String serverName,String warnInfo)throws Exception{
|
|
|
// //夜间十二点 起床半小时后未回床 触发安防工单
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
if(null!=patientDO){
|
|
@ -798,16 +795,14 @@ public class DeviceService {
|
|
|
jsonObject.put("warnInfo",warnInfo);
|
|
|
JSONObject jsonObjectParam = new JSONObject();
|
|
|
jsonObjectParam.put("order", jsonObject);
|
|
|
map.put("jsonData", jsonObjectParam.toJSONString());
|
|
|
map.put("orderSource", 5);
|
|
|
map.put("warnStr", serverName);
|
|
|
|
|
|
String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
|
|
|
String postParams = AesEncryptUtils.agEncrypt(content);
|
|
|
String response = httpClientUtil.postBodyRawForm(url,postParams);
|
|
|
JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
|
|
|
System.out.println(jsonObjectData.toJSONString());
|
|
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
|
|
|
params.add(new BasicNameValuePair("warnStr", serverName));
|
|
|
params.add(new BasicNameValuePair("orderSource", "5"));
|
|
|
String response = httpClientUtil.post(url, params,"UTF-8");
|
|
|
System.out.println(response);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (null!=record){
|