| 
					
				 | 
			
			
				@ -2321,12 +2321,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode = "'13'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "emergencyAssistance": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode = "'7'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCode = "'7','4'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("emergencyAssistance".equals(topicItem)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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 ('7')) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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)) "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2361,10 +2360,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceSns.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn = deviceSns.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceSns.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn = deviceSns.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("deviceCode", deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("deviceSn", deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                switch (topicItem) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case "actionTrack": 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2397,23 +2393,23 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String SoSDeviceSql = "SELECT id  FROM base_emergency_assistance_order WHERE `status` = '1' AND patient = '" + id + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<Map<String, Object>> listMapsOrder = jdbcTemplate.queryForList(SoSDeviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject tmp = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (listMapsOrder.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (listMapsOrder.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            for (Map<String, Object> stringObjectMap : listMapsOrder) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("orderId",stringObjectMap.get("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("orderId", stringObjectMap.get("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            tmp.put("eCall", 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            tmp.put("eCall", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            tmp.put("orderId", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        BasePatientDO patientDO = basePatientDao.findById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (null != patientDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (StringUtils.isNotBlank(patientDO.getHomeLatLon())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                String homeLatLon = patientDO.getHomeLatLon(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                double homeLat = Double.parseDouble(homeLatLon.split(",")[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                double homeLon = Double.parseDouble(homeLatLon.split(",")[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (StringUtils.isNotBlank(patientDO.getLatLon())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    String[] latLon = patientDO.getLatLon().toString().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (StringUtils.isNotBlank(patientDO.getLatLon())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                String[] latLon = patientDO.getLatLon().toString().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (StringUtils.isNotBlank(patientDO.getHomeLatLon())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    String homeLatLon = patientDO.getHomeLatLon(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    double homeLat = Double.parseDouble(homeLatLon.split(",")[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    double homeLon = Double.parseDouble(homeLatLon.split(",")[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    double homeDistance = countDistance.getDistance(Double.parseDouble(latLon[0]), Double.parseDouble(latLon[1]), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            homeLat, homeLon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if (homeDistance > 50 * 1000) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2421,12 +2417,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        tmp.put("atHome", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    String locationAddress = LatitudeUtils.getLocationAddress(latLon[0], latLon[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    tmp.put("address", locationAddress); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    tmp.put("atHome", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    tmp.put("address", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                String locationAddress = LatitudeUtils.getLocationAddress(latLon[0], latLon[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("address", locationAddress); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("atHome", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                tmp.put("address", ""); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2462,3 +2457,4 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |