|  | @ -403,33 +403,24 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                 String patientCode = result.getUser();
 | 
	
		
			
				|  |  |                 //患者信息
 | 
	
		
			
				|  |  |                 Patient patient = patientDao.findByCode(patientCode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 int bloodPressureBbnormalCount = 0;//血压异常次数
 | 
	
		
			
				|  |  |                 int bloodSuggurBbnormalCount = 0;//血糖异常次数
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 排序
 | 
	
		
			
				|  |  |                 Sort sort = new Sort(Sort.Direction.DESC, "recordDate");
 | 
	
		
			
				|  |  |                 // 分页信息
 | 
	
		
			
				|  |  |                 Pageable pageRequest = new PageRequest(0, 5, sort);
 | 
	
		
			
				|  |  |                 Pageable pageable = new PageRequest(1, 5);
 | 
	
		
			
				|  |  |                 List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
 | 
	
		
			
				|  |  |                 List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
 | 
	
		
			
				|  |  |                 if( 1 == patient.getDisease()){
 | 
	
		
			
				|  |  |                     bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,2,pageable);
 | 
	
		
			
				|  |  |                 } else if( 2 == patient.getDisease()){
 | 
	
		
			
				|  |  |                     bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,1,pageable);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,2,pageable);
 | 
	
		
			
				|  |  |                     bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,1,pageable);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 for (PatientHealthIndex patientHealthIndex : bloodPressurepatientHealthIndices) {
 | 
	
		
			
				|  |  |                     if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
 | 
	
		
			
				|  |  |                 bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
 | 
	
		
			
				|  |  |                 bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 for (PatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
 | 
	
		
			
				|  |  |                     if(index1.getStatus() != null && 1 == index1.getStatus()){
 | 
	
		
			
				|  |  |                         bloodPressureBbnormalCount++;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 for (PatientHealthIndex patientHealthIndex : bloodSuggurpatientHealthIndices) {
 | 
	
		
			
				|  |  |                     if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
 | 
	
		
			
				|  |  |                 for (PatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
 | 
	
		
			
				|  |  |                     if(index2.getStatus() != null && 1 == index2.getStatus()){
 | 
	
		
			
				|  |  |                         bloodSuggurBbnormalCount++;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
	
		
			
				|  | @ -442,14 +433,28 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                     Date end = new Date();
 | 
	
		
			
				|  |  |                     Date start = DateUtil.setDateTime(end,-7);
 | 
	
		
			
				|  |  |                     //计算血糖或者血压一周内的异常记录数量
 | 
	
		
			
				|  |  |                     int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1);
 | 
	
		
			
				|  |  |                     int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
 | 
	
		
			
				|  |  |                     if(errorCount >= 5){//超过5次,记为预警状态
 | 
	
		
			
				|  |  |                         patient.setStandardStatus(1);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //连续5次正常,修改用户为非预警状态
 | 
	
		
			
				|  |  |                 if((0 == bloodPressureBbnormalCount && 0 == bloodSuggurBbnormalCount) && 1 == patient.getStandardStatus()){
 | 
	
		
			
				|  |  |                 if(patient.getDisease() != null){
 | 
	
		
			
				|  |  |                     if( 1 == patient.getDisease()){
 | 
	
		
			
				|  |  |                         if(0 == bloodPressureBbnormalCount && 1 == patient.getStandardStatus()){
 | 
	
		
			
				|  |  |                             patient.setStandardStatus(0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }else if(2 == patient.getDisease()){
 | 
	
		
			
				|  |  |                         if(0 == bloodSuggurBbnormalCount && 1 == patient.getStandardStatus()){
 | 
	
		
			
				|  |  |                             patient.setStandardStatus(0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }else if( 3 == patient.getDisease()){
 | 
	
		
			
				|  |  |                         if( (0 == bloodSuggurBbnormalCount|| 0 == bloodPressureBbnormalCount)&& 1 == patient.getStandardStatus()){
 | 
	
		
			
				|  |  |                             patient.setStandardStatus(0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     patient.setStandardStatus(0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 |