| 
					
				 | 
			
			
				@ -19,6 +19,7 @@ import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.sign.ServicePackageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.CountDistance; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.Point; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.dict.BaseYujingDict; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.BaseSleepPlan; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.PatientSafeAreaDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -39,6 +40,7 @@ import com.yihu.jw.util.healthIndex.HealthIndexUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.util.ObjectUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -734,6 +736,13 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String dict(List<BaseYujingDict> dictList,String code){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (BaseYujingDict yujingDict : dictList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (code.equals(yujingDict.getDictCode())) return yujingDict.getDictValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取设备关联数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 手表4:电量、佩戴状态、是否预警、在线状态 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -747,6 +756,11 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 血糖1:最近一次血糖、在线状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getDeviceIndexAndOrder(String category_code,String deviceSn,String patient,String filterTime){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String dictSql = "SELECT * from base_yujing_dict where del =1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseYujingDict> dictList = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper<>(BaseYujingDict.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zwsj = dict(dictList, "ty2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String dictCode = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String beforeTime = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String afterTime = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean bl = false;//是否进行时间范围查询 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -860,9 +874,19 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                pageSql =bl?" and record_date >= '"+beforeTime+"' and record_date <= '"+afterTime+"'  ORDER BY sort_date DESC limit 1 ": " ORDER BY sort_date DESC LIMIT 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlResult = jdbcTemplate.queryForList(sql+pageSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (sqlResult.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer xl = Integer.parseInt(sqlResult.get(0).get("value1").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (xl>=50&&xl<=100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictCode= "xl1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else if (xl<50){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictCode="xl2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else if (xl>100){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictCode="xl3"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sqlResult.get(0).put("value1_status",dict(dictList,dictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("heartRate",sqlResult.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("heartRate","无心率数据"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("heartRate",zwsj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //获取手表定位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject dw = patientDeviceService.getAqgDeviceInfo2(deviceSn); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -887,12 +911,12 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            double homeLon = Double.parseDouble(homeLatLon.split(",")[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            double homeDistance = countDistance.getDistance(homeLat,homeLon,lat,lon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (homeDistance * 1000 > 50) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("isAtHome","离家"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("isAtHome",dict(dictList,"ty1")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("isAtHome","居家"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("isAtHome",dict(dictList,"ty4")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            detailInfo.put("isAtHome",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            detailInfo.put("isAtHome",zwsj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        detailInfo.put("location", tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -991,12 +1015,32 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (response.getBooleanValue("onbed")) {//当前在床状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("bedStatus", 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("heartRate", response.getString("heartrate")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("breath", response.getString("breathrate")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                Integer heartRate = response.getInteger("heartrate"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                Integer breath = response.getInteger("breathrate"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                dictCode = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (heartRate > 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl3"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else if (heartRate < 50) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else if (heartRate >= 50 && heartRate <= 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("heartRate", heartRate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("breath", breath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("heartRate_status",dict(dictList,dictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (breath > 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl3"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else if (breath < 50) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else if (breath >= 50 && breath <= 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    dictCode = "xl1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("breath_status",dict(dictList,dictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("bedStatus", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("heartRate", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("breath", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("heartRate", zwsj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                detailInfo.put("breath", zwsj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1035,10 +1079,11 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc  limit 1  ": " ORDER BY create_time desc limit 1  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlResult = jdbcTemplate.queryForList(sql+pageSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (sqlResult.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("warnStatus",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //烟雾浓度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("value1_Status",dict(dictList,"yg1")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("orderInfo",sqlResult.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("warnStatus",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("value1_Status",dict(dictList,"yg2")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //获取最新一次烟雾浓度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(bl){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1060,11 +1105,18 @@ public class PatientInfoPlatFormService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = " select temperature_value ,record_time as temperature_value_record_time  from base_device_health_index where device_sn='"+deviceSn+"' and temperature_value is not null  ORDER BY record_time desc limit 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlResult = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dictCode =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (sqlResult.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (Integer.parseInt(sqlResult.get(0).get("temperature_value").toString())<50) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictCode = "yg4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictCode = "yg3"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.putAll(sqlResult.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("temperature_status",dict(dictList,dictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("temperature_value",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("temperature_status",zwsj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    detailInfo.put("temperature_value_record_time",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |