|  | @ -608,8 +608,8 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                         Long timeDiffer = timeDate.getTime() - bedUp.getTime();
 | 
	
		
			
				|  |  |                         if(DateUtil.isInArea(timeDate,bedUpBegin,bedUpEnd)){//起床时间内
 | 
	
		
			
				|  |  |                             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);
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
	
		
			
				|  | @ -617,7 +617,7 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                         else if (3600*upLongWarn*1000<timeDiffer){//距离起床超过三个小时还在床
 | 
	
		
			
				|  |  |                             if ("1".equals(bed_status)){//还在床
 | 
	
		
			
				|  |  |                                 if (null==planDetail.getUpStatus()) {
 | 
	
		
			
				|  |  |                                     planDetail.setUpStatus(0);
 | 
	
		
			
				|  |  |                                     planDetail.setUpStatus(1);
 | 
	
		
			
				|  |  |                                     planDetail.setBedStatus(1);
 | 
	
		
			
				|  |  |                                     planDetail.setBreath(breath);
 | 
	
		
			
				|  |  |                                     planDetail.setHeartRate(heartrate);
 | 
	
	
		
			
				|  | @ -629,7 +629,7 @@ 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);
 | 
	
	
		
			
				|  | @ -646,7 +646,7 @@ 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);
 | 
	
		
			
				|  |  |                                 }
 | 
	
	
		
			
				|  | @ -669,13 +669,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,bedBegin,dayTime);
 | 
	
		
			
				|  |  |                                     if (records.size()>0){//
 | 
	
		
			
				|  |  |                                     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);
 | 
	
	
		
			
				|  | @ -709,7 +712,7 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                                     }else {//是否触发工单
 | 
	
		
			
				|  |  |                                         record = records.get(0);
 | 
	
		
			
				|  |  |                                         timeDiffer = timeDate.getTime()-record.getCreateTime().getTime();
 | 
	
		
			
				|  |  |                                         if (timeDiffer>3600*nightLongWarn*1000){//超过2未回床小时 触发工单
 | 
	
		
			
				|  |  |                                         if (timeDiffer>3600*nightLongWarn*1000&&0==records.get(0).getStatus()){//超过2未回床小时 触发工单
 | 
	
		
			
				|  |  |                                             planDetail.setSleepNightRecordList(records);
 | 
	
		
			
				|  |  |                                             planDetail.setBedStatus(0);
 | 
	
		
			
				|  |  |                                             outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
 | 
	
	
		
			
				|  | @ -812,9 +815,6 @@ public class DeviceService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (null!=record){
 | 
	
		
			
				|  |  |                 record.setStatus(-1);
 | 
	
		
			
				|  |  |                 record.setUpdateTime(time_date);
 | 
	
		
			
				|  |  |                 Long timeDiffer = (time_date.getTime() - record.getCreateTime().getTime())/1000;
 | 
	
		
			
				|  |  |                 record.setOutTime(timeDiffer+"");
 | 
	
		
			
				|  |  |                 nightRecord.save(record);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |     }
 |