|  | @ -1230,18 +1230,51 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         result.put("location",null);
 | 
	
		
			
				|  |  |         result.put("fences",null);
 | 
	
		
			
				|  |  |         result.put("smoke",null);
 | 
	
		
			
				|  |  |         result.put("gasLeakage",null);
 | 
	
		
			
				|  |  |         result.put("fire",null);
 | 
	
		
			
				|  |  |         result.put("fall",null);
 | 
	
		
			
				|  |  |         result.put("sleep",null);
 | 
	
		
			
				|  |  |         result.put("deviceSn",null);
 | 
	
		
			
				|  |  |         result.put("monitorInfo",null);
 | 
	
		
			
				|  |  |         String sql = " select count(id) from base_security_monitoring_order where patient='"+patient+"' and topic_item='preventFall' and status="+SecurityMonitoringOrderDO.Status.apply.getType();
 | 
	
		
			
				|  |  |         Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
 | 
	
		
			
				|  |  |         if (count>0){
 | 
	
		
			
				|  |  |             result.put("fall",true);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             result.put("fall",false);
 | 
	
		
			
				|  |  |         String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
 | 
	
		
			
				|  |  |                 " on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
 | 
	
		
			
				|  |  |                 "and dict.remark='security'  GROUP BY dict.code ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object>tmp:sqlResult){
 | 
	
		
			
				|  |  |             switch (tmp.get("code").toString()){
 | 
	
		
			
				|  |  |                 case "preventGasLeakage":
 | 
	
		
			
				|  |  |                    Integer count = Integer.parseInt(tmp.get("total").toString());
 | 
	
		
			
				|  |  |                     if (count>0){
 | 
	
		
			
				|  |  |                         result.put("gasLeakage",true);
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         result.put("gasLeakage",false);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 case "preventFire":
 | 
	
		
			
				|  |  |                     count = Integer.parseInt(tmp.get("total").toString());
 | 
	
		
			
				|  |  |                     if (count>0){
 | 
	
		
			
				|  |  |                         result.put("fire",true);
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         result.put("fire",false);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 case "preventFall":
 | 
	
		
			
				|  |  |                     count = Integer.parseInt(tmp.get("total").toString());
 | 
	
		
			
				|  |  |                     if (count>0){
 | 
	
		
			
				|  |  |                         result.put("fall",true);
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         result.put("fall",false);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 case "preventOutOfBed":
 | 
	
		
			
				|  |  |                     count = Integer.parseInt(tmp.get("total").toString());
 | 
	
		
			
				|  |  |                     if (count>0){
 | 
	
		
			
				|  |  |                         result.put("sleep",true);
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         result.put("sleep",false);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         result = patientSignTopicInfo(result,patient,topicItem);
 | 
	
		
			
				|  |  |         return result;
 | 
	
	
		
			
				|  | @ -1545,17 +1578,39 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *获取居民睡眠监护列表
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Page<BaseSleepPlanDetail> getPatientSleepDetainList(String patient,String begin,String end,Integer page,Integer pageSize){
 | 
	
		
			
				|  |  |     public JSONObject getPatientSleepDetainList(String patient,String begin,String end,Integer page,Integer pageSize){
 | 
	
		
			
				|  |  |         page=page>0?page-1:0;
 | 
	
		
			
				|  |  |         PageRequest pageRequest = new PageRequest(page, pageSize);
 | 
	
		
			
				|  |  |         begin = begin.substring(0,begin.indexOf(" "));
 | 
	
		
			
				|  |  |         end = end.substring(0,end.indexOf(" "));
 | 
	
		
			
				|  |  |         if (StringUtils.isBlank(end)){
 | 
	
		
			
				|  |  |             end = begin;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         Page<BaseSleepPlanDetail> list = sleepPlanDetailDao.findByListByPage(patient,begin,end,pageRequest);
 | 
	
		
			
				|  |  |         List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         BaseSleepPlan sleepPlan=null;
 | 
	
		
			
				|  |  |         if (sleepPlans.size()>0){
 | 
	
		
			
				|  |  |             sleepPlan = sleepPlans.get(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (BaseSleepPlanDetail tmp:list){
 | 
	
		
			
				|  |  |             List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,tmp.getDay());
 | 
	
		
			
				|  |  |             tmp.setSleepNightRecordList(records);
 | 
	
		
			
				|  |  |             String str = JSON.toJSONStringWithDateFormat(tmp, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
 | 
	
		
			
				|  |  |             JSONObject jsonObject = JSONObject.parseObject(str);
 | 
	
		
			
				|  |  |             if (null==sleepPlan){
 | 
	
		
			
				|  |  |                 jsonObject.put("sleepPlan",false);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 jsonObject.put("sleepPlan",true);
 | 
	
		
			
				|  |  |                 String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
 | 
	
		
			
				|  |  |                 jsonObject.put("getUpTime",sleepPlan.getGetUpTime());
 | 
	
		
			
				|  |  |                 jsonObject.put("siestaTime",sleepPlan.getNapTime());
 | 
	
		
			
				|  |  |                 jsonObject.put("nightRestTime",sleepPlan.getNightRestTime());
 | 
	
		
			
				|  |  |                 jsonObject.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
 | 
	
		
			
				|  |  |                 array.add(jsonObject);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |         JSONObject result = (JSONObject) JSONObject.toJSON(list);
 | 
	
		
			
				|  |  |         result.put("content",array);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1585,6 +1640,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
 | 
	
		
			
				|  |  |     private String getSleepMonitoringDay(Date date,String patient){
 | 
	
		
			
				|  |  |         List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         if (sleepPlans.size()>0){
 | 
	
		
			
				|  |  |             BaseSleepPlan sleepPlan = sleepPlans.get(0);
 | 
	
		
			
				|  |  |             String bedUpStr = sleepPlans.get(0).getGetUpTime();
 | 
	
		
			
				|  |  |             Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+bedUpStr+":00");// 起床时间 起床前一小时内算为起床
 | 
	
		
			
				|  |  |             if (date.before(bedUp)&&bedUp.getTime()-date.getTime()>1000*1*3600){
 |