| 
					
				 | 
			
			
				@ -41,7 +41,6 @@ import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.ResponseContant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.emergency.EmergencyOrderVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.GpsUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.LatitudeUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -244,7 +243,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setServiceStatus("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.save(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //创建im会话  安防警报咨询的sessionid  为居民code+(wlyy_consult_team表consult)+20 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject IMObj = consultTeamService.addSecurityMoConsult(orderDO.getId(),orderDO.getPatient(),null,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject IMObj = consultTeamService.addSecurityMoConsult(orderDO.getId(),orderDO.getPatient(),null,null,orderDO.getServeDesc()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sessionId=orderDO.getPatient()+"_"+ IMObj.getJSONObject("resultMsg").getString("consult") + "_22"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setSessionId(sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(orderDO.getServeDesc())){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -456,7 +455,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    monitorInfo.put("sleepPlan",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                emergencyOrderVO.setInformation(monitorInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -465,7 +464,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (6==orderDO.getOrderSource()){//气感工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                emergencyOrderVO.setInformation(monitorInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -474,7 +473,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (7==orderDO.getOrderSource()){//烟感工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                emergencyOrderVO.setInformation(monitorInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -525,7 +524,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(BaseDoctorDO doc:doctorDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> noticeObj = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("type","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("typeName","助老员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("typeName","社工"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("id",doc.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("name",doc.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("photo",doc.getPhoto()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -663,7 +662,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            String svrDesc,String topicItem, Integer page, Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            String svrDesc,String topicItem, Integer page, Integer pageSize,Integer dailyMonitor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray result = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //服务权限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(doctorServicePermissionsService.isPermission(doctor,10)==0){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -676,12 +675,53 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ord.doctor_name,ord.update_user,ord.update_user_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (1==dailyMonitor){//医生日常监护居民安防工单列表查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isBlank(topicItem)||StringUtils.isBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return new PageEnvelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String categoryCode =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventLost": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'4'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventFall": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'12'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventFire": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'15'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventGasLeakage": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'14'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventOutOfBed": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'13'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(doctor)){//日常监护医生必传 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter += " and EXISTS( SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " p.openid,p.sex,p.pad_imei padImei " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " and m.doctor_code = '"+doctor+"' and m.del = '1' ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter +=" and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " where  pd.user = p.id and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItem+"',dd.service_topic)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("preventLost".equals(topicItem)){//有绑定围栏的居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(serverDoctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter +=" and ord.doctor = '"+serverDoctor+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -756,7 +796,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getSecurityTab(String patient,String doctor,String status,String svrDesc,String topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getSecurityTab(String patient,String doctor,String status,String svrDesc,String topicItem,Integer dailyMonitor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("status_-2",0);//误报警 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -777,11 +817,49 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = "select ord.status,ord.serve_desc,count(ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fliter = "  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (1==dailyMonitor){//医生日常监护居民安防工单列表查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isBlank(topicItem)||StringUtils.isBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String categoryCode =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventLost": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'4'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventFall": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'12'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventFire": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'15'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventGasLeakage": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'14'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "preventOutOfBed": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    categoryCode="'13'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(doctor)) {//日常监护医生必传 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter += " and EXISTS( SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " p.openid,p.sex,p.pad_imei padImei " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " and m.doctor_code = '" + doctor + "' and m.del = '1' ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter += " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " where  pd.user = p.id and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("preventLost".equals(topicItem)) {//有绑定围栏的居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and ord.patient='"+patient+"' "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1389,7 +1467,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (String team:teams){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = "select DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile from base_team_member mem " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(社工)' END) as name,doc.photo,doc.mobile from base_team_member mem " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "INNER JOIN base_doctor doc on mem.doctor_code = doc.id and mem.del=1 and mem.team_code='"+team+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String,Object>>tmp = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.addAll(tmp); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1398,7 +1476,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject patientMonitoringInfo(String patient,String topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject patientMonitoringInfo(String patient,String topicItem,boolean video){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("location",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("fences",null); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1406,6 +1484,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("fire",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("fall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("sleep",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("sleepOrderInfo",null);//最近工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("deviceSn",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("emeAssistance",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("monitorInfo",null); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1443,6 +1522,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    count = Integer.parseInt(tmp.get("total").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (count>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.put("sleep",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql = " select serve_desc from base_security_monitoring_order where topic_item='preventOutOfBed' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                "and patient='"+patient+"' and `status`=1 order by create_time desc limit 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<String> serveDesces = jdbcTemplate.queryForList(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (serveDesces.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.put("sleepOrderInfo",serveDesces.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.put("sleep",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1454,7 +1539,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (counnt>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("emeAssistance",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = patientSignTopicInfo(result,patient,topicItem,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = patientSignTopicInfo(result,patient,topicItem,null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1472,6 +1557,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("fire",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("fall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("sleep",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("sleepOrderInfo",null);//最近工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("deviceSn",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("emeAssistance",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("monitorInfo",null); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1509,6 +1595,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    count = Integer.parseInt(tmp.get("total").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (count>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.put("sleep",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql = " select serve_desc from base_security_monitoring_order where topic_item='preventOutOfBed' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                "and patient='"+patient+"' and `status`=1 order by create_time desc limit 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<String> serveDesces = jdbcTemplate.queryForList(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (serveDesces.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.put("sleepOrderInfo",serveDesces.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.put("sleep",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1522,9 +1614,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (devices4.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result =  patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result =  patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn(),true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientSignTopicInfo(result,patient,"preventFall",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientSignTopicInfo(result,patient,"preventFall",null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1561,6 +1653,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject locationTmp = response.getJSONObject("last_location"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Double lon = locationTmp.getJSONArray("coordinates").getDouble(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Double lat = locationTmp.getJSONArray("coordinates").getDouble(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!response.getBoolean("online")){//设备离线 取居民表定位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.put("X1online",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.put("X1online",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("city",response.getString("last_city")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("province",response.getString("last_province")); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1851,7 +1948,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem,String deviceSn){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem,String deviceSn,boolean video){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null==result){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1865,14 +1962,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            preventOutOfBed(result, patient,true,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            preventFire(result, patient,null,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            preventFire(result, patient,null,video); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("preventGasLeakage".equals(topicItem)||StringUtils.isBlank(topicItem)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            preventGasLeakage(result, patient,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            preventGasLeakage(result, patient,video); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1944,7 +2042,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDO.setOrderId(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDO.setUserType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDO.setContent("助老员"+doctorDO.getName()+"前往定位"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDO.setContent("社工"+doctorDO.getName()+"前往定位"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logDao.save(logDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2044,4 +2142,126 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject findMonitorPatientsByDoctor(String doctor,String topicItem,String day,Integer page,Integer pageSize,Integer detail){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.openid,p.sex,p.pad_imei padImei " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " and m.doctor_code = '"+doctor+"' and m.del = '1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fliter = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String categoryCode =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String topicItemTmp = topicItem; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        switch (topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "actionTrack": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'4'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                topicItemTmp="preventLost"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "preventLost": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'4'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "preventFall": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'12'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "preventFire": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'15'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "preventGasLeakage": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'14'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "preventOutOfBed": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode="'13'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        fliter =" and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " where  pd.user = sr.patient and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItemTmp+"',dd.service_topic)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("preventLost".equals(topicItem)){//有绑定围栏的居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list =  jdbcTemplate.queryForList(sql+fliter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("total",list.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (1 == detail){//获取详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray monitorInfos = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer totalPage = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(list.size()%pageSize==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalPage =list.size()/pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalPage = list.size()/pageSize+1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer currentIndexFrom = page*pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer currentIndexEnd = page*pageSize+pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("totalPage",totalPage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("currentPage",page+1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=currentIndexFrom;i<list.size()&&i<currentIndexEnd;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> patientTmp = list.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String deviceSn =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " on pd.device_id = dd.id where  pd.user = '"+patientTmp.get("id").toString()+"' and pd.del=0  and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItemTmp+"',dd.service_topic)",String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceSns.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn = deviceSns.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceSns.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn = deviceSns.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("deviceCode",deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                switch (topicItem){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case "actionTrack": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONArray locations = JSON.parseArray(JSON.toJSONString(patientDeviceService.getX1Locations(deviceSn, day), SerializerFeature.WriteMapNullValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        object.put("routes", locations); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //获取手表定位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject response= patientDeviceService.getAqgDeviceInfo2(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (response!=null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            //定位信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (response.containsKey("last_location") && response.get("last_location") != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONObject locationTmp = response.getJSONObject("last_location"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                Double lon = locationTmp.getJSONArray("coordinates").getDouble(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                Double lat = locationTmp.getJSONArray("coordinates").getDouble(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (!response.getBoolean("online")) {//设备离线 取居民表定位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    object.put("X1online", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    object.put("X1online", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat, lon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("city", response.getString("last_city")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("province", response.getString("last_province")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("address", response.getString("last_address")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                object.put("location", tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        object = patientMonitoringInfo(patientTmp.get("id").toString(),topicItem,false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("patientInfo",patientTmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfos.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("topicInfo",monitorInfos); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray monitorInfos = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=0;i<list.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> patientTmp = list.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String deviceSn =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " on pd.device_id = dd.id where  pd.user = '"+patientTmp.get("id").toString()+"' and pd.del=0  and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItem+"',dd.service_topic)",String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceSns.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn = deviceSns.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject object  = patientMonitoringInfo(patientTmp.get("id").toString(),"null",false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("deviceSn",deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("patientInfo",patientTmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                monitorInfos.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("topicInfo",monitorInfos); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |